Package htsjdk.variant.bcf2
Class BCF2Decoder
java.lang.Object
htsjdk.variant.bcf2.BCF2Decoder
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBCF2Decoder(byte[] recordBytes) Create a new decoder ready to read BCF2 data from the byte[] recordBytes, for testing purposes -
Method Summary
Modifier and TypeMethodDescriptionbooleanfinal intdecodeInt(byte typeDescriptor, int missingValue) Decode an int from the stream.final intfinal 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 intdecodeNumberOfElements(byte typeDescriptor) final ObjectdecodeSingleValue(BCF2Type type) final Objectfinal ObjectdecodeTypedValue(byte typeDescriptor) final ObjectdecodeTypedValue(byte typeDescriptor, int size) intThe size of the current block in bytesbyte[]Returns the byte[] for the block of data we are currently decodingfinal intreadBlockSize(InputStream inputStream) Read the size of the next block from inputStreamvoidreadNextBlock(int blockSizeInBytes, InputStream stream) Reads the next record from input stream and prepare this decoder to decode values from itfinal bytevoidsetRecordBytes(byte[] recordBytes) Use the recordBytes[] to read BCF2 records from now onvoidskipNextBlock(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
-