org.terrier.compression
Class MemorySBOS

java.lang.Object
  extended by org.terrier.compression.BitOutputStream
      extended by org.terrier.compression.BitByteOutputStream
          extended by org.terrier.compression.MemorySBOS
All Implemented Interfaces:
java.io.Closeable, BitOut

public class MemorySBOS
extends BitByteOutputStream

This class extends the BitByteOutputStream, so it provides the compression writing functions, but uses a MemoryOutputStream as an underlying OutputStream, so it is needed to be flushed to disk separately. It uses BitByteOutputStream and not BitOutputStream because the MemoryOutputStream class has already its own buffer (to keep everything in memory), and extra buffering is inadequate.

Author:
Roi Blanco

Field Summary
protected  MemoryOutputStream mos
          The underlying MemoryOutputStream
 
Fields inherited from class org.terrier.compression.BitByteOutputStream
byteToWrite
 
Fields inherited from class org.terrier.compression.BitOutputStream
bitOffset, buffer, bufferPointer, bufferSize, byteOffset, DEFAULT_SIZE, dos, logger
 
Constructor Summary
MemorySBOS()
          Constructor for the class.
 
Method Summary
 MemoryOutputStream getMOS()
           
 int getSize()
          Return the amount of memory bytes consumed by the underlying buffer
 java.lang.String toString()
          Writes the underlying MemoryOutputStream in String format.
 
Methods inherited from class org.terrier.compression.BitByteOutputStream
close, getBitOffset, getByteOffset, getByteToWrite, pad, writeInt, writeUnary
 
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, wait, wait, wait
 

Field Detail

mos

protected MemoryOutputStream mos
The underlying MemoryOutputStream

Constructor Detail

MemorySBOS

public MemorySBOS()
           throws java.io.IOException
Constructor for the class. Instanciates the BitByteOutputStream and MemoryOutputStream classes.

Throws:
java.io.IOException - if an I/O error occurs.
Method Detail

toString

public java.lang.String toString()
Writes the underlying MemoryOutputStream in String format.

Overrides:
toString in class java.lang.Object

getMOS

public MemoryOutputStream getMOS()
Returns:
The underlying MemoryOutputStream.

getSize

public int getSize()
Return the amount of memory bytes consumed by the underlying buffer



Terrier 3.5. Copyright © 2004-2011 University of Glasgow