|
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.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.Closeable
close
in class BitFile
public byte getBitOffset()
getBitOffset
in interface BitIn
getBitOffset
in interface BitOut
getBitOffset
in class BitFile
public long getByteOffset()
getByteOffset
in interface BitIn
getByteOffset
in interface BitOut
getByteOffset
in class BitFile
public int readGamma()
readGamma
in interface BitIn
readGamma
in class BitFile
public void align()
align
in interface BitIn
align
in class BitFile
java.io.IOException
- if an I/O error occurspublic BitIn readReset(long startByteOffset, byte startBitOffset, long endByteOffset, byte endBitOffset)
readReset
in interface BitInSeekable
readReset
in class BitFile
startByteOffset
- 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 BitIn
readUnary
in class BitFile
public byte[] getInBuffer()
public void writeFlush()
writeFlush
in class BitFile
public int readBinary(int noBits)
readBinary
in interface BitIn
readBinary
in class BitFile
noBits
- the number of binary bits to read
public void skipBits(int noBits)
skipBits
in interface BitIn
skipBits
in class BitFile
noBits
- The number of bits to skippublic int writeBinary(int bitsToWrite, int n)
writeBinary
in interface BitOut
writeBinary
in class BitFile
bitsToWrite
- the number of bits to writen
- the integer to write
public int writeGamma(int n)
writeGamma
in interface BitOut
writeGamma
in class BitFile
n
- The integer to be encoded and saved in the buffer.
public void writeReset() throws java.io.IOException
writeReset
in class BitFile
java.io.IOException
public int writeUnary(int n)
writeUnary
in interface BitOut
writeUnary
in class BitFile
n
- 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 |