Package org.terrier.compression.bit
Class DebuggingBitIn
- java.lang.Object
-
- org.terrier.compression.bit.DebuggingBitIn
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,BitIn
public class DebuggingBitIn extends java.lang.Object implements BitIn, java.io.Closeable
This class provides debugging at the bit stream level. All read*() and skip*() methods log verbosely for each request.- Since:
- 3.5
- Author:
- Craig Macdonald
- See Also:
BitIn
-
-
Field Summary
-
Fields inherited from interface org.terrier.compression.bit.BitIn
USUAL_EXTENSION
-
-
Constructor Summary
Constructors Constructor Description DebuggingBitIn(BitIn _in)Wraps a BitIn implementation with logging calls
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidalign()Aligns the stream to the next bytevoidclose()bytegetBitOffset()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.
-
-
-
Constructor Detail
-
DebuggingBitIn
public DebuggingBitIn(BitIn _in)
Wraps a BitIn implementation with logging calls
-
-
Method Detail
-
align
public void align() throws java.io.IOExceptionDescription copied from interface:BitInAligns the stream to the next byte
-
getBitOffset
public byte getBitOffset()
Description copied from interface:BitInReturns the bit offset in the last byte. It corresponds to the position in which the next bit will be written. Use only when writting.- Specified by:
getBitOffsetin interfaceBitIn- Returns:
- the bit offset in the stream.
-
getByteOffset
public long getByteOffset()
Description copied from interface:BitInReturns 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- Specified by:
getByteOffsetin interfaceBitIn- Returns:
- the byte offset in the stream.
-
readBinary
public int readBinary(int len) throws java.io.IOExceptionDescription copied from interface:BitInReads a binary integer from the already read buffer.- Specified by:
readBinaryin interfaceBitIn- Parameters:
len- the number of binary bits to read- Returns:
- the decoded integer
- Throws:
java.io.IOException- if an I/O error occurs
-
readDelta
public int readDelta() throws java.io.IOExceptionDescription copied from interface:BitInReads a delta encoded integer from the underlying stream
-
readGamma
public int readGamma() throws java.io.IOExceptionDescription copied from interface:BitInReads a gamma encoded integer from the underlying stream
-
readGolomb
public int readGolomb(int b) throws java.io.IOExceptionDescription copied from interface:BitInReads a Golomb encoded integer- Specified by:
readGolombin interfaceBitIn- Parameters:
b- the golomb modulus- Returns:
- the int read
- Throws:
java.io.IOException- if and I/O error occurs
-
readInterpolativeCoding
public void readInterpolativeCoding(int[] data, int offset, int len, int lo, int hi) throws java.io.IOExceptionDescription copied from interface:BitInReads a sequence of numbers from the stream interpolative coded.- Specified by:
readInterpolativeCodingin interfaceBitIn- 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
-
readMinimalBinary
public int readMinimalBinary(int b) throws java.io.IOExceptionDescription copied from interface:BitInReads a binary encoded integer, given an upper bound- Specified by:
readMinimalBinaryin interfaceBitIn- Parameters:
b- the upper bound- Returns:
- the int read
- Throws:
java.io.IOException- if an I/O error occurs
-
readMinimalBinaryZero
public int readMinimalBinaryZero(int b) throws java.io.IOExceptionDescription copied from interface:BitInReads a minimal binary encoded number, when the upper bound can b zero. Used to interpolative code- Specified by:
readMinimalBinaryZeroin interfaceBitIn- Parameters:
b- the upper bound- Returns:
- the int read
- Throws:
java.io.IOException- if an I/O error occurs
-
readSkewedGolomb
public int readSkewedGolomb(int b) throws java.io.IOExceptionDescription copied from interface:BitInReads 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- Specified by:
readSkewedGolombin interfaceBitIn- Returns:
- the number read
- Throws:
java.io.IOException- if an I/O error occurs
-
readUnary
public int readUnary() throws java.io.IOExceptionDescription copied from interface:BitInReads a unary encoded integer from the underlying stream
-
skipBits
public void skipBits(int len) throws java.io.IOExceptionDescription copied from interface:BitInSkip a number of bits while reading the bit file.
-
skipBytes
public void skipBytes(long len) throws java.io.IOExceptionDescription copied from interface:BitInSkip a number of bytes while reading the bit file. After this opteration, getBitOffset() == 0, so use skipBits(int) to get getBitOffset() to desired value.
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-