Package it.unimi.di.big.mg4j.index
Class CachingOutputBitStream
- java.lang.Object
-
- it.unimi.dsi.io.OutputBitStream
-
- it.unimi.di.big.mg4j.index.CachingOutputBitStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public final class CachingOutputBitStream extends OutputBitStream
A special output bit stream with an additional methodbuffer()
that returns the internal buffer if the internal buffer contains all that has been written since the last call toposition(0)
.This bit stream is used every time that it is necessary to cache quickly a bit stream. By sizing the buffer size appropriately, most of the times data written to the stream will be readable directly from the buffer. Remember to call
OutputBitStream.align()
before retrieving the buffer, or some bits might be still floating in the bit buffer.
-
-
Field Summary
-
Fields inherited from class it.unimi.dsi.io.OutputBitStream
avail, buffer, DEFAULT_BUFFER_SIZE, DELTA, fileChannel, free, GAMMA, MAX_PRECOMPUTED, os, pos, position, repositionableStream, SHIFTED_GAMMA, wrapping, ZETA_3
-
-
Constructor Summary
Constructors Constructor Description CachingOutputBitStream(File file, int bufferSize)
CachingOutputBitStream(String filename, int bufferSize)
-
Method Summary
Modifier and Type Method Description byte[]
buffer()
Return the internal buffer, if it contains all data.-
Methods inherited from class it.unimi.dsi.io.OutputBitStream
align, close, copyFrom, flush, position, write, write, write, writeBit, writeBit, writeByteOffset, writeDelta, writeDeltas, writeGamma, writeGammas, writeGolomb, writeGolomb, writeInt, writeLong, writeLongDelta, writeLongGamma, writeLongGolomb, writeLongGolomb, writeLongMinimalBinary, writeLongMinimalBinary, writeLongNibble, writeLongShiftedGamma, writeLongSkewedGolomb, writeLongUnary, writeLongZeta, writeMinimalBinary, writeMinimalBinary, writeNibble, writeShiftedGamma, writeShiftedGammas, writeSkewedGolomb, writeUnary, writeZeta, writtenBits, writtenBits
-
-
-
-
Constructor Detail
-
CachingOutputBitStream
public CachingOutputBitStream(File file, int bufferSize) throws FileNotFoundException
- Throws:
FileNotFoundException
-
CachingOutputBitStream
public CachingOutputBitStream(String filename, int bufferSize) throws FileNotFoundException
- Throws:
FileNotFoundException
-
-
Method Detail
-
buffer
public byte[] buffer()
Return the internal buffer, if it contains all data.Note that this method should always be called after an
OutputBitStream.align()
, or some bits might be still floating in the bit buffer.- Returns:
- the internal buffer, if it contains the cached content written since the last call to
position(0)
, ornull
.
-
-