Package org.apache.lucene.util.packed
Class MonotonicBlockPackedWriter
- java.lang.Object
 - 
- org.apache.lucene.util.packed.MonotonicBlockPackedWriter
 
 
- 
public final class MonotonicBlockPackedWriter extends java.lang.ObjectA writer for large monotonically increasing sequences of positive longs.The sequence is divided into fixed-size blocks and for each block, values are modeled after a linear function f: x → A × x + B. The block encodes deltas from the expected values computed from this function using as few bits as possible. Each block has an overhead between 6 and 14 bytes.
Format:
- <BLock>BlockCount
 - BlockCount: ⌈ ValueCount / BlockSize ⌉
 - Block: <Header, (Ints)>
 - Header: <B, A, BitsPerValue>
 - B: the B from f: x → A × x + B using a
     
variable-length long - A: the A from f: x → A × x + B encoded using
     
Float.floatToIntBits(float)on4 bytes - BitsPerValue: a 
variable-length int - Ints: if BitsPerValue is 0, then there is nothing to read and
     all values perfectly match the result of the function. Otherwise, these
     are the
     zigzag-encoded
     
packeddeltas from the expected value (computed from the function) using exaclty BitsPerValue bits per value 
- See Also:
 MonotonicBlockPackedReader
 
- 
- 
Constructor Summary
Constructors Constructor Description MonotonicBlockPackedWriter(DataOutput out, int blockSize)Sole constructor. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(long l)Append a new long.voidfinish()Flush all buffered data to disk.longord()Return the number of values which have been added.voidreset(DataOutput out)Reset this writer to wrapout. 
 - 
 
- 
- 
Constructor Detail
- 
MonotonicBlockPackedWriter
public MonotonicBlockPackedWriter(DataOutput out, int blockSize)
Sole constructor.- Parameters:
 blockSize- the number of values of a single block, must be a power of 2
 
 - 
 
- 
Method Detail
- 
add
public void add(long l) throws java.io.IOExceptionAppend a new long.- Throws:
 java.io.IOException
 
- 
reset
public void reset(DataOutput out)
Reset this writer to wrapout. The block size remains unchanged. 
- 
finish
public void finish() throws java.io.IOExceptionFlush all buffered data to disk. This instance is not usable anymore after this method has been called untilreset(DataOutput)has been called.- Throws:
 java.io.IOException
 
- 
ord
public long ord()
Return the number of values which have been added. 
 - 
 
 -