public final class DirectWriter extends Object
DirectReader.
Unlike PackedInts, it optimizes for read i/o operations and supports > 2B values. Example usage:
int bitsPerValue = DirectWriter.bitsRequired(100); // values up to and including 100
IndexOutput output = dir.createOutput("packed", IOContext.DEFAULT);
DirectWriter writer = DirectWriter.getInstance(output, numberOfValues, bitsPerValue);
for (int i = 0; i < numberOfValues; i++) {
writer.add(value);
}
writer.finish();
output.close();
DirectReader| Modifier and Type | Method and Description |
|---|---|
void |
add(long l)
Adds a value to this writer
|
static int |
bitsRequired(long maxValue)
Returns how many bits are required to hold values up
to and including maxValue
|
void |
finish()
finishes writing
|
static DirectWriter |
getInstance(IndexOutput output,
long numValues,
int bitsPerValue)
Returns an instance suitable for encoding
numValues using bitsPerValue |
static int |
unsignedBitsRequired(long maxValue)
Returns how many bits are required to hold values up
to and including maxValue, interpreted as an unsigned value.
|
public void add(long l)
throws IOException
IOExceptionpublic void finish()
throws IOException
IOExceptionpublic static DirectWriter getInstance(IndexOutput output, long numValues, int bitsPerValue)
numValues using bitsPerValuepublic static int bitsRequired(long maxValue)
maxValue - the maximum value that should be representable.PackedInts.bitsRequired(long)public static int unsignedBitsRequired(long maxValue)
maxValue - the maximum value that should be representable.PackedInts.unsignedBitsRequired(long)Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.