|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.terrier.compression.BitOutputStream org.terrier.compression.BitByteOutputStream
public class BitByteOutputStream
An implementation of BitOutputStream that does no buffering. 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).
Field Summary | |
---|---|
protected byte |
byteToWrite
A byte to write to the stream. |
Fields inherited from class org.terrier.compression.BitOutputStream |
---|
bitOffset, buffer, bufferPointer, bufferSize, byteOffset, DEFAULT_SIZE, dos, logger |
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 org.terrier.compression.BitOutputStream |
---|
append, append, flush, padAndFlush, writeBinary, writeDelta, writeGamma, writeGolomb, writeInterpolativeCode, writeMinimalBinary, writeSkewedGolomb |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected byte byteToWrite
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 interface BitOut
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()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |