|
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.BitOutputStream uk.ac.gla.terrier.compression.BitByteOutputStream
public class BitByteOutputStream
This class provides methods to write compressed integers to an outputstream.
The numbers are written into a byte starting from the most significant bit (i.e, left to right).
This class does not use any buffering, it relies on the underlying OutputStream
to decide when to flush to disk.
It is used for indexing, when keeping many compressed streams in memory (MemoryOutputStream) and a two-level
buffering is unnecessary (and slower).
Constructor Summary | |
---|---|
BitByteOutputStream()
Empty constructor, used for subclassing |
|
BitByteOutputStream(java.io.File file)
Constructs an instance of the class for a given file |
|
BitByteOutputStream(java.io.OutputStream is)
Constructs an instance of the class for a given stream |
|
BitByteOutputStream(java.lang.String filename)
Constructs an instance of the class for a given filename |
Method Summary | |
---|---|
void |
close()
Closes the stream. |
byte |
getBitOffset()
Returns the bit offset in the last byte. |
long |
getByteOffset()
Returns the byte offset of the stream. |
byte |
getByteToWrite()
|
void |
pad()
Fills the remaining bits of the current byte with 0s |
int |
writeInt(int x,
int len)
Writes an integer x into the underlying OutputStream. |
int |
writeUnary(int x)
Writes an integer x using unary encoding. |
Methods inherited from class uk.ac.gla.terrier.compression.BitOutputStream |
---|
append, append, flush, padAndFlush, writeBinary, writeDelta, writeGamma, writeGolomb, writeInterpolativeCode, writeMinimalBinary, writeSkewedGolomb |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BitByteOutputStream(java.io.OutputStream is) throws java.io.IOException
is
- java.io.OutputStream the underlying input stream
java.io.IOException
- if an I/O error occurspublic BitByteOutputStream(java.lang.String filename) throws java.io.IOException
filename
- java.lang.String the name of the underlying file
java.io.IOException
- if an I/O error occurspublic BitByteOutputStream(java.io.File file) throws java.io.IOException
file
- java.io.File the underlying file
java.io.IOException
- if an I/O error occurspublic BitByteOutputStream()
Method Detail |
---|
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class BitOutputStream
java.io.IOException
- if an I/O error occurspublic long getByteOffset()
getByteOffset
in interface BitOut
getByteOffset
in class BitOutputStream
public byte getBitOffset()
getBitOffset
in interface BitOut
getBitOffset
in class BitOutputStream
public int writeUnary(int x) throws java.io.IOException
writeUnary
in interface BitOut
writeUnary
in class BitOutputStream
x
- the number to write
java.io.IOException
- if an I/O error occurs.public int writeInt(int x, int len) throws java.io.IOException
writeInt
in class BitOutputStream
x
- the int to writelen
- length of the int in bits
java.io.IOException
- if an I/O error occurs.public void pad() throws java.io.IOException
java.io.IOException
public byte getByteToWrite()
|
Terrier IR Platform 2.2.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |