Module org.apache.lucene.core
Package org.apache.lucene.util.packed
Class MonotonicBlockPackedWriter
- java.lang.Object
-
- org.apache.lucene.util.packed.AbstractBlockPackedWriter
-
- org.apache.lucene.util.packed.MonotonicBlockPackedWriter
-
public final class MonotonicBlockPackedWriter extends AbstractBlockPackedWriter
A 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.
Format:
- <BLock>BlockCount
- BlockCount: ⌈ ValueCount / BlockSize ⌉
- Block: <Header, (Ints)>
- Header: <B, A, BitsPerValue>
- B: the B from f: x → A × x + B using a
zig-zag encoded
vLong
- 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 thepacked
deltas from the expected value (computed from the function) using exactly BitsPerValue bits per value.
- See Also:
MonotonicBlockPackedReader
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.util.packed.AbstractBlockPackedWriter
blocks, BPV_SHIFT, finished, MAX_BLOCK_SIZE, MIN_BLOCK_SIZE, MIN_VALUE_EQUALS_0, off, ord, out, values
-
-
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 void
add(long l)
Append a new long.protected void
flush()
-
Methods inherited from class org.apache.lucene.util.packed.AbstractBlockPackedWriter
addBlockOfZeros, finish, ord, reset, writeValues, writeVLong
-
-
-
-
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.IOException
Description copied from class:AbstractBlockPackedWriter
Append a new long.- Overrides:
add
in classAbstractBlockPackedWriter
- Throws:
java.io.IOException
-
flush
protected void flush() throws java.io.IOException
- Specified by:
flush
in classAbstractBlockPackedWriter
- Throws:
java.io.IOException
-
-