Package org.terrier.compression.bit
Interface BitIn
-
- All Superinterfaces:
java.lang.AutoCloseable,java.io.Closeable
- All Known Implementing Classes:
BitFileBuffered.BitInBuffered,BitFileChannel.FileChannelBitInBuffered,BitInBase,BitInputStream,ConcurrentBitFileBuffered.ConcurrentBitInBuffered,DebuggingBitIn
public interface BitIn extends java.io.CloseableInterface describing the read compression methods supported by the BitFileBuffered and BitInputStream classes. Integers read by the BitIn interface are always greater than 0.- Since:
- 2.0
- Author:
- Craig Macdonald
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringUSUAL_EXTENSIONfile extension
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidalign()Aligns the stream to the next bytebytegetBitOffset()Returns the bit offset in the last byte.longgetByteOffset()Returns the byte offset of the stream.intreadBinary(int len)Reads a binary integer from the already read buffer.intreadDelta()Reads a delta encoded integer from the underlying streamintreadGamma()Reads a gamma encoded integer from the underlying streamintreadGolomb(int b)Reads a Golomb encoded integervoidreadInterpolativeCoding(int[] data, int offset, int len, int lo, int hi)Reads a sequence of numbers from the stream interpolative coded.intreadMinimalBinary(int b)Reads a binary encoded integer, given an upper boundintreadMinimalBinaryZero(int b)Reads a minimal binary encoded number, when the upper bound can b zero.intreadSkewedGolomb(int b)Reads a skewed-golomb encoded integer from the underlying stream Consider a bucket-vectorv = <0, 2b, 4b, ...intreadUnary()Reads a unary encoded integer from the underlying streamvoidskipBits(int len)Skip a number of bits while reading the bit file.voidskipBytes(long len)Skip a number of bytes while reading the bit file.
-
-
-
Field Detail
-
USUAL_EXTENSION
static final java.lang.String USUAL_EXTENSION
file extension- See Also:
- Constant Field Values
-
-
Method Detail
-
getByteOffset
long getByteOffset()
Returns the byte offset of the stream. It corresponds to the position of the byte in which the next bit will be written. Use only when writting- Returns:
- the byte offset in the stream.
-
getBitOffset
byte getBitOffset()
Returns the bit offset in the last byte. It corresponds to the position in which the next bit will be written. Use only when writting.- Returns:
- the bit offset in the stream.
-
readUnary
int readUnary() throws java.io.IOExceptionReads a unary encoded integer from the underlying stream- Returns:
- the number read
- Throws:
java.io.IOException- if an I/O error occurs
-
readGamma
int readGamma() throws java.io.IOExceptionReads a gamma encoded integer from the underlying stream- Returns:
- the number read
- Throws:
java.io.IOException- if an I/O error occurs
-
readBinary
int readBinary(int len) throws java.io.IOExceptionReads a binary integer from the already read buffer.- Parameters:
len- the number of binary bits to read- Returns:
- the decoded integer
- Throws:
java.io.IOException- if an I/O error occurs
-
readMinimalBinary
int readMinimalBinary(int b) throws java.io.IOExceptionReads a binary encoded integer, given an upper bound- Parameters:
b- the upper bound- Returns:
- the int read
- Throws:
java.io.IOException- if an I/O error occurs
-
readMinimalBinaryZero
int readMinimalBinaryZero(int b) throws java.io.IOExceptionReads a minimal binary encoded number, when the upper bound can b zero. Used to interpolative code- Parameters:
b- the upper bound- Returns:
- the int read
- Throws:
java.io.IOException- if an I/O error occurs
-
readGolomb
int readGolomb(int b) throws java.io.IOExceptionReads a Golomb encoded integer- Parameters:
b- the golomb modulus- Returns:
- the int read
- Throws:
java.io.IOException- if and I/O error occurs
-
readSkewedGolomb
int readSkewedGolomb(int b) throws java.io.IOExceptionReads a skewed-golomb encoded integer from the underlying stream Consider a bucket-vectorv = <0, 2b, 4b, ... , 2^i b, ...>The sum of the elements in the vector goesb, 3b, 7b, 2^(i-1)*b- Returns:
- the number read
- Throws:
java.io.IOException- if an I/O error occurs
-
readDelta
int readDelta() throws java.io.IOExceptionReads a delta encoded integer from the underlying stream- Returns:
- the number read
- Throws:
java.io.IOException- if an I/O error occurs
-
readInterpolativeCoding
void readInterpolativeCoding(int[] data, int offset, int len, int lo, int hi) throws java.io.IOExceptionReads a sequence of numbers from the stream interpolative coded.- Parameters:
data- the result vectoroffset- offset where to write in the vectorlen- the number of integers to decode.lo- a lower bound (the same one passed to writeInterpolativeCoding)hi- an upper bound (the same one passed to writeInterpolativeCoding)- Throws:
java.io.IOException- if an I/O error occurs
-
skipBits
void skipBits(int len) throws java.io.IOExceptionSkip a number of bits while reading the bit file.- Parameters:
len- The number of bits to skip- Throws:
java.io.IOException- if an I/O error occurs
-
skipBytes
void skipBytes(long len) throws java.io.IOExceptionSkip a number of bytes while reading the bit file. After this opteration, getBitOffset() == 0, so use skipBits(int) to get getBitOffset() to desired value.- Parameters:
len- The number of bytes to skip- Throws:
java.io.IOException- if an I/O error occurs
-
align
void align() throws java.io.IOExceptionAligns the stream to the next byte- Throws:
java.io.IOException- if an I/O error occurs
-
-