Class TokenStreams

java.lang.Object
htsjdk.samtools.cram.compression.nametokenisation.TokenStreams

public class TokenStreams extends Object
Token streams for the CRAM 3.1 name tokeniser. Stores decompressed byte streams indexed by (position, tokenType). Accepts an optional shared RANSNx16Decode instance to avoid allocating a fresh 1MB+ decoder per stream.
  • Field Details

  • Constructor Details

    • TokenStreams

      public TokenStreams(ByteBuffer inputByteBuffer, int useArith, int numNames)
      The outer index corresponds to the (column) position in a name (starting at index 0). The inner index corresponds to the token type. Each element in this list of lists is a ByteBuffer of tokens.
      Parameters:
      inputByteBuffer - - the input buffer of token streams
      useArith - - true to use range coding; false for rANS coding
      numNames - - the number of read names in the slice for which this token stream is being created
    • TokenStreams

      public TokenStreams(ByteBuffer inputByteBuffer, int useArith, int numNames, RANSNx16Decode sharedRansDecoder)
      Parameters:
      inputByteBuffer - the input buffer of token streams
      useArith - true to use range coding; false for rANS coding
      numNames - the number of read names in the slice
      sharedRansDecoder - optional shared rANS decoder instance (avoids per-stream allocation)
  • Method Details

    • getStreamsForPos

      public ByteBuffer[] getStreamsForPos(int pos)
      Return the array of token streams for a given column position. The returned array is indexed by token type constant (e.g., TOKEN_TYPE).
      Parameters:
      pos - the column position (0-based)
      Returns:
      array of ByteBuffers indexed by token type; entries may be null
    • getStream

      public ByteBuffer getStream(int tokenPosition, int tokenType)
      Return the token stream for a specific position and token type.
      Parameters:
      tokenPosition - the column position (0-based)
      tokenType - the token type constant (e.g., TOKEN_STRING)
      Returns:
      the ByteBuffer for that stream, or null if not present