Package org.apache.lucene.util.packed
Class DirectMonotonicWriter
- java.lang.Object
-
- org.apache.lucene.util.packed.DirectMonotonicWriter
-
public final class DirectMonotonicWriter extends Object
Write monotonically-increasing sequences of integers. This writer splits data into blocks and then for each block, computes the average slope, the minimum value and only encode the delta from the expected value using aDirectWriter.- See Also:
DirectMonotonicReader- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_BLOCK_SHIFTstatic intMIN_BLOCK_SHIFT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(long v)Write a new value.voidfinish()This must be called exactly once after all values have beenadded.static DirectMonotonicWritergetInstance(IndexOutput metaOut, IndexOutput dataOut, long numValues, int blockShift)Returns an instance suitable for encodingnumValuesinto monotonic blocks of 2blockShiftvalues.
-
-
-
Field Detail
-
MIN_BLOCK_SHIFT
public static final int MIN_BLOCK_SHIFT
- See Also:
- Constant Field Values
-
MAX_BLOCK_SHIFT
public static final int MAX_BLOCK_SHIFT
- See Also:
- Constant Field Values
-
-
Method Detail
-
add
public void add(long v) throws IOExceptionWrite a new value. Note that data might not make it to storage untilfinish()is called.- Throws:
IllegalArgumentException- if values don't come in orderIOException
-
finish
public void finish() throws IOExceptionThis must be called exactly once after all values have beenadded.- Throws:
IOException
-
getInstance
public static DirectMonotonicWriter getInstance(IndexOutput metaOut, IndexOutput dataOut, long numValues, int blockShift)
Returns an instance suitable for encodingnumValuesinto monotonic blocks of 2blockShiftvalues. Metadata will be written tometaOutand actual data todataOut.
-
-