Class BetaIntegerCodec
- java.lang.Object
-
- htsjdk.samtools.cram.encoding.core.CoreCodec<Integer>
-
- htsjdk.samtools.cram.encoding.core.BetaIntegerCodec
-
public final class BetaIntegerCodec extends CoreCodec<Integer>
Encodes integers by adding a constant offset value to a range of values in order to reduce the necessary number of bits needed to store each value. As a simple example, consider a data series with values all in the range 10,000 - 10,100. Choosing the offset -10,000 means every encoded value will be stored as 0 - 100, requiring only ceil(log2(100)) = 7 bits per value.
-
-
Field Summary
-
Fields inherited from class htsjdk.samtools.cram.encoding.core.CoreCodec
coreBlockInputStream, coreBlockOutputStream
-
-
Constructor Summary
Constructors Constructor Description BetaIntegerCodec(BitInputStream coreBlockInputStream, BitOutputStream coreBlockOutputStream, int offset, int bitsPerValue)
Given integers to encode in the range MIN to MAX:
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Integer
read()
Read a single object from the streamInteger
read(int length)
Read a array of specified length from the streamvoid
write(Integer value)
Write an object to the stream
-
-
-
Constructor Detail
-
BetaIntegerCodec
public BetaIntegerCodec(BitInputStream coreBlockInputStream, BitOutputStream coreBlockOutputStream, int offset, int bitsPerValue)
Given integers to encode in the range MIN to MAX:- Parameters:
offset
- the common value to be added to all values before storage. Setting this to (-MIN) will ensure all stored values will be in the range (0 .. MAX - MIN)bitsPerValue
- the smallest value which will allow the largest stored value (MAX - MIN)
-
-
Method Detail
-
read
public final Integer read()
Description copied from interface:CRAMCodec
Read a single object from the stream- Returns:
- an object from the stream
-
read
public Integer read(int length)
Description copied from interface:CRAMCodec
Read a array of specified length from the stream- Parameters:
length
- the number of elements to read- Returns:
- an object from the stream
-
-