public final class MonotonicBlockPackedWriter extends 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.
- BlockCount: ⌈ ValueCount / BlockSize ⌉
- Block: <Header, (Ints)>
- Header: <B, A, BitsPerValue>
- B: the B from f: x → A × x + B using a
- A: the A from f: x → A × x + B encoded using
- BitsPerValue: a
- 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
packeddeltas from the expected value (computed from the function) using exactly BitsPerValue bits per value.
- See Also:
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
All Methods Instance Methods Concrete Methods Modifier and Type Method Description
add(long l)Append a new long.
finish()Flush all buffered data to disk.
ord()Return the number of values which have been added.
reset(DataOutput out)Reset this writer to wrap
protected DataOutput out
protected final long values
protected byte blocks
protected int off
protected long ord
protected boolean finished
public MonotonicBlockPackedWriter(DataOutput out, int blockSize)Sole constructor.
blockSize- the number of values of a single block, must be a power of 2
public void reset(DataOutput out)Reset this writer to wrap
out. The block size remains unchanged.
public void finish() throws IOExceptionFlush all buffered data to disk. This instance is not usable anymore after this method has been called until
reset(DataOutput)has been called.
public long ord()Return the number of values which have been added.