|
Terrier IR Platform 2.2.1 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.ac.gla.terrier.compression.BitFile
uk.ac.gla.terrier.compression.OldBitFile
public class OldBitFile
This class encapsulates a random access file and provides
the functionalities to write highly compressed data structures, eg binary encoded, unary encoded and gamma encoded
integers greater than zero, as well as specifying their offset in the file. It
is employed by the DirectIndex and the InvertedIndex classes.
The sequence of method calls to write a sequence of gamma encoded
and unary encoded numbers is:
file.writeReset();
while for reading a sequence of numbers the sequence of calls is:
long startByte1 = file.getByteOffset();
byte startBit1 = file.getBitOffset();
file.writeGamma(20000);
file.writeUnary(2);
file.writeGamma(35000);
file.writeUnary(1);
file.writeGamma(3);
file.writeUnary(2);
file.writeFlush();
long endByte1 = file.getByteOffset();
byte endBit1 = file.getBitOffset();
if (endBit1 == 0 && endByte1 > 0) {
endBit1 = 7;
endByte1--;
}
file.readReset((long) startByte1, (byte) startBit1, (long) endByte1, (byte) endBit1);
int gamma = file.readGamma();
int unary = file.readUnary();
| Constructor Summary | |
|---|---|
OldBitFile(java.io.File file)
A constuctor for an instance of this class, given an abstract file. |
|
OldBitFile(java.io.File file,
java.lang.String access)
A constuctor for an instance of this class, given an abstract file. |
|
OldBitFile(java.lang.String filename)
A constuctor for an instance of this class. |
|
OldBitFile(java.lang.String filename,
java.lang.String access)
A constuctor for an instance of this class. |
|
| Method Summary | |
|---|---|
void |
align()
Aligns the stream to the next byte |
void |
close()
Closes the random access file. |
byte |
getBitOffset()
Returns the bit offset of the last current byte in the buffer. |
long |
getByteOffset()
Returns the byte offset in the buffer. |
byte[] |
getInBuffer()
Returns the current buffer being processed |
int |
readBinary(int noBits)
Reads a binary integer from the already read buffer. |
int |
readGamma()
Reads and decodes a gamma encoded integer from the already read buffer. |
BitIn |
readReset(long startByteOffset,
byte startBitOffset,
long endByteOffset,
byte endBitOffset)
Reads from the file a specific number of bytes and after this call, a sequence of read calls may follow. |
int |
readUnary()
Reads a unary integer from the already read buffer. |
void |
skipBits(int noBits)
Skip a number of bits in the current input stream |
int |
writeBinary(int bitsToWrite,
int n)
Deprecated. |
void |
writeFlush()
Deprecated. |
int |
writeGamma(int n)
Deprecated. |
void |
writeReset()
Deprecated. |
int |
writeUnary(int n)
Deprecated. |
| Methods inherited from class uk.ac.gla.terrier.compression.BitFile |
|---|
readGolomb, readInterpolativeCoding, readMinimalBinary, readMinimalBinaryZero, readSkewedGolomb, writeGolomb, writeInt, writeInterpolativeCode, writeMinimalBinary, writeSkewedGolomb |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public OldBitFile(java.io.File file)
public OldBitFile(java.io.File file,
java.lang.String access)
public OldBitFile(java.lang.String filename)
public OldBitFile(java.lang.String filename,
java.lang.String access)
| Method Detail |
|---|
public void close()
close in interface java.io.Closeableclose in class BitFilepublic byte getBitOffset()
getBitOffset in interface BitIngetBitOffset in interface BitOutgetBitOffset in class BitFilepublic long getByteOffset()
getByteOffset in interface BitIngetByteOffset in interface BitOutgetByteOffset in class BitFilepublic int readGamma()
readGamma in interface BitInreadGamma in class BitFilepublic void align()
align in interface BitInalign in class BitFilejava.io.IOException - if an I/O error occurs
public BitIn readReset(long startByteOffset,
byte startBitOffset,
long endByteOffset,
byte endBitOffset)
readReset in interface BitInSeekablereadReset in class BitFilestartByteOffset - the starting byte to read fromstartBitOffset - the bit offset in the starting byteendByteOffset - the ending byteendBitOffset - the bit offset in the ending byte.
This bit is the last bit of this entry.
public int readUnary()
readUnary in interface BitInreadUnary in class BitFilepublic byte[] getInBuffer()
public void writeFlush()
writeFlush in class BitFilepublic int readBinary(int noBits)
readBinary in interface BitInreadBinary in class BitFilenoBits - the number of binary bits to read
public void skipBits(int noBits)
skipBits in interface BitInskipBits in class BitFilenoBits - The number of bits to skip
public int writeBinary(int bitsToWrite,
int n)
writeBinary in interface BitOutwriteBinary in class BitFilebitsToWrite - the number of bits to writen - the integer to write
public int writeGamma(int n)
writeGamma in interface BitOutwriteGamma in class BitFilen - The integer to be encoded and saved in the buffer.
public void writeReset()
throws java.io.IOException
writeReset in class BitFilejava.io.IOExceptionpublic int writeUnary(int n)
writeUnary in interface BitOutwriteUnary in class BitFilen - The integer to be encoded and writen in the buffer.
|
Terrier IR Platform 2.2.1 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||