Package htsjdk.variant.bcf2
Class BCF2Decoder
java.lang.Object
htsjdk.variant.bcf2.BCF2Decoder
-
Constructor Summary
ModifierConstructorDescriptionprotected
BCF2Decoder
(byte[] recordBytes) Create a new decoder ready to read BCF2 data from the byte[] recordBytes, for testing purposes -
Method Summary
Modifier and TypeMethodDescriptionboolean
final int
decodeInt
(byte typeDescriptor, int missingValue) Decode an int from the stream.final int
final int[]
decodeIntArray
(byte typeDescriptor, int size) final int[]
decodeIntArray
(int size, BCF2Type type, int[] maybeDest) Low-level reader for int[] Requires a typeDescriptor so the function knows how many elements to read, and how they are encoded.final int
decodeNumberOfElements
(byte typeDescriptor) final Object
decodeSingleValue
(BCF2Type type) final Object
final Object
decodeTypedValue
(byte typeDescriptor) final Object
decodeTypedValue
(byte typeDescriptor, int size) int
The size of the current block in bytesbyte[]
Returns the byte[] for the block of data we are currently decodingfinal int
readBlockSize
(InputStream inputStream) Read the size of the next block from inputStreamvoid
readNextBlock
(int blockSizeInBytes, InputStream stream) Reads the next record from input stream and prepare this decoder to decode values from itfinal byte
void
setRecordBytes
(byte[] recordBytes) Use the recordBytes[] to read BCF2 records from now onvoid
skipNextBlock
(int blockSizeInBytes, InputStream stream) Skips the next record from input stream, invalidating current block data
-
Constructor Details
-
BCF2Decoder
public BCF2Decoder() -
BCF2Decoder
protected BCF2Decoder(byte[] recordBytes) Create a new decoder ready to read BCF2 data from the byte[] recordBytes, for testing purposes- Parameters:
recordBytes
-
-
-
Method Details
-
readNextBlock
Reads the next record from input stream and prepare this decoder to decode values from it- Parameters:
stream
-
-
skipNextBlock
Skips the next record from input stream, invalidating current block data- Parameters:
stream
-
-
getRecordBytes
public byte[] getRecordBytes()Returns the byte[] for the block of data we are currently decoding- Returns:
-
getBlockSize
public int getBlockSize()The size of the current block in bytes- Returns:
-
blockIsFullyDecoded
public boolean blockIsFullyDecoded() -
setRecordBytes
public void setRecordBytes(byte[] recordBytes) Use the recordBytes[] to read BCF2 records from now on- Parameters:
recordBytes
-
-
decodeTypedValue
- Throws:
IOException
-
decodeTypedValue
- Throws:
IOException
-
decodeTypedValue
- Throws:
IOException
-
decodeSingleValue
- Throws:
IOException
-
decodeNumberOfElements
- Throws:
IOException
-
decodeInt
Decode an int from the stream. If the value in the stream is missing, returns missingValue. Requires the typeDescriptor indicate an inline single element event- Parameters:
typeDescriptor
-- Returns:
- Throws:
IOException
-
decodeInt
- Throws:
IOException
-
decodeIntArray
Low-level reader for int[] Requires a typeDescriptor so the function knows how many elements to read, and how they are encoded. If size == 0 => result is null If size > 0 => result depends on the actual values in the stream -- If the first element read is MISSING, result is null (all values are missing) -- Else result = int[N] where N is the first N non-missing values decoded- Parameters:
maybeDest
- if not null we'll not allocate space for the vector, but instead use the externally allocated array of ints to store values. If the size of this vector is < the actual size of the elements, we'll be forced to use freshly allocated arrays. Also note that padded int elements are still forced to do a fresh allocation as well.- Returns:
- see description
- Throws:
IOException
-
decodeIntArray
- Throws:
IOException
-
readBlockSize
Read the size of the next block from inputStream- Parameters:
inputStream
-- Returns:
- Throws:
IOException
-
readTypeDescriptor
- Throws:
IOException
-