Package htsjdk.samtools.cram.encoding.core

# Class BetaIntegerCodec

java.lang.Object
htsjdk.samtools.cram.encoding.core.CoreCodec<Integer>
htsjdk.samtools.cram.encoding.core.BetaIntegerCodec

All Implemented Interfaces:
  `CRAMCodec<Integer>`

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

Modifier and Type
Method
Description
`final Integer`
`read()`
Read a single object from the stream
`Integer`
`read(int length)`
Read a array of specified length from the stream
`final void`
`write(Integer value)`
Write an object to the stream

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### 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 Details

### 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

### write

public final void write(Integer value)
Description copied from interface: `CRAMCodec`
Write an object to the stream

Parameters:
  `value` - the object to write