|
Terrier IR Platform 2.2.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object uk.ac.gla.terrier.compression.BitInputStream
public class BitInputStream
This class reads from a file or an InputStream integers that can be coded with different encoding algorithms. It does not use any internal buffering, and operates with bytes.
Constructor Summary | |
---|---|
BitInputStream(java.io.File file)
Constructs an instance of the class for a given file |
|
BitInputStream(java.io.InputStream is)
Constructs an instance of the class for a given stream |
|
BitInputStream(java.lang.String filename)
Constructs an instance of the class for a given filename |
Method Summary | |
---|---|
void |
align()
Aligns the stream to the next byte |
void |
close()
Closes the stream. |
byte |
getBitOffset()
Returns the bit offset in the last byte. |
long |
getByteOffset()
Returns the byte offset of the stream. |
int |
readBinary(int len)
Reads a binary integer from the already read buffer. |
int |
readDelta()
Reads a delta encoded integer from the underlying stream |
int |
readGamma()
Reads a gamma encoded integer from the underlying stream |
int |
readGolomb(int b)
Reads a Golomb encoded integer |
void |
readInterpolativeCoding(int[] data,
int offset,
int len,
int lo,
int hi)
Reads a sequence of numbers from the stream interpolative coded. |
int |
readMinimalBinary(int b)
Reads a binary encoded integer, given an upper bound |
int |
readMinimalBinaryZero(int b)
Reads a minimal binary encoded number, when the upper bound can b zero. |
int |
readSkewedGolomb(int b)
Reads a skewed-golomb encoded integer from the underlying stream Consider a bucket-vector v =
|
int |
readUnary()
Reads a unary encoded integer from the underlying stream |
void |
skipBits(int len)
Skip a number of bits in the current input stream |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BitInputStream(java.io.InputStream is) throws java.io.IOException
is
- java.io.InputStream the underlying input stream
java.io.IOException
- if an I/O error occurspublic BitInputStream(java.lang.String filename) throws java.io.IOException
filename
- java.lang.String the name of the undelying file
java.io.IOException
- if an I/O error occurspublic BitInputStream(java.io.File file) throws java.io.IOException
file
- java.io.File the underlying file
java.io.IOException
- if an I/O error occursMethod Detail |
---|
public void close() throws java.io.IOException
close
in interface java.io.Closeable
java.io.IOException
- if an I/O error occurspublic long getByteOffset()
getByteOffset
in interface BitIn
public byte getBitOffset()
getBitOffset
in interface BitIn
public int readUnary() throws java.io.IOException
readUnary
in interface BitIn
java.io.IOException
- if an I/O error occurspublic int readGamma() throws java.io.IOException
readGamma
in interface BitIn
java.io.IOException
- if an I/O error occurspublic int readBinary(int len) throws java.io.IOException
readBinary
in interface BitIn
len
- the number of binary bits to read
java.io.IOException
- if an I/O error occurspublic void skipBits(int len) throws java.io.IOException
skipBits
in interface BitIn
len
- The number of bits to skip
java.io.IOException
- if an I/O error occurspublic int readMinimalBinary(int b) throws java.io.IOException
b
- the upper bound
java.io.IOException
- if an I/O error occurspublic int readGolomb(int b) throws java.io.IOException
b
- the golomb modulus
java.io.IOException
- if and I/O error occurspublic int readDelta() throws java.io.IOException
java.io.IOException
- if an I/O error occurspublic int readSkewedGolomb(int b) throws java.io.IOException
v =
The sum of the elements in the vector goes
b, 3b, 7b, 2^(i-1)*b
java.io.IOException
- if an I/O error occurspublic void readInterpolativeCoding(int[] data, int offset, int len, int lo, int hi) throws java.io.IOException
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)
java.io.IOException
- if an I/O error occurspublic int readMinimalBinaryZero(int b) throws java.io.IOException
b
- the upper bound
java.io.IOException
- if an I/O error occurspublic void align() throws java.io.IOException
align
in interface BitIn
java.io.IOException
- if an I/O error occurs
|
Terrier IR Platform 2.2.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |