Terrier IR Platform
2.2.1

uk.ac.gla.terrier.compression
Interface BitOut

All Superinterfaces:
java.io.Closeable
All Known Implementing Classes:
BitByteOutputStream, BitFile, BitOutputStream, MemorySBOS, OldBitFile, OldBitOutputStream

public interface BitOut
extends java.io.Closeable

Interface describing the writing compression methods supported by the BitFile classes.

Since:
2.0
Version:
$Revision: 1.4 $
Author:
Craig Macdonald

Method Summary
 byte getBitOffset()
          Returns the bit offset in the last byte.
 long getByteOffset()
          Returns the byte offset of the stream.
 int writeBinary(int len, int x)
          Writes an integer in binary format to the stream.
 int writeGamma(int x)
          Writes an integer x into the stream using gamma encoding.
 int writeUnary(int x)
          Writes an integer x using unary encoding.
 
Methods inherited from interface java.io.Closeable
close
 

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.

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.

Returns:
the bit offset in the stream.

writeUnary

int writeUnary(int x)
               throws java.io.IOException
Writes an integer x using unary encoding. The encoding is a sequence of x -1 zeros and 1 one: 1, 01, 001, 0001, etc .. This method is not failsafe, it doesn't check if the argument is 0 or negative.

Parameters:
x - the number to write
Returns:
the number of bits written
Throws:
java.io.IOException - if an I/O error occurs.

writeGamma

int writeGamma(int x)
               throws java.io.IOException
Writes an integer x into the stream using gamma encoding. This method is not failsafe, it doesn't check if the argument is 0 or negative.

Parameters:
x - the int number to write
Returns:
the number of bits written
Throws:
java.io.IOException - if an I/O error occurs.

writeBinary

int writeBinary(int len,
                int x)
                throws java.io.IOException
Writes an integer in binary format to the stream.

Parameters:
len - size in bits of the number.
x - the integer to write.
Returns:
the number of bits written.
Throws:
java.io.IOException - if an I/O error occurs.

Terrier IR Platform
2.2.1

Terrier Information Retrieval Platform 2.2.1. Copyright 2004-2008 University of Glasgow