public final class DirectWriter
extends java.lang.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 | Field and Description |
---|---|
(package private) int |
bitsPerValue |
(package private) long |
count |
(package private) BulkOperation |
encoder |
(package private) boolean |
finished |
(package private) int |
iterations |
(package private) byte[] |
nextBlocks |
(package private) long[] |
nextValues |
(package private) long |
numValues |
(package private) int |
off |
(package private) DataOutput |
output |
(package private) static int[] |
SUPPORTED_BITS_PER_VALUE |
Constructor and Description |
---|
DirectWriter(DataOutput output,
long numValues,
int bitsPerValue) |
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
|
private void |
flush() |
static DirectWriter |
getInstance(DataOutput output,
long numValues,
int bitsPerValue)
Returns an instance suitable for encoding
numValues using bitsPerValue |
private static int |
roundBits(int bitsRequired)
Round a number of bits per value to the next amount of bits per value that
is supported by this writer.
|
static int |
unsignedBitsRequired(long maxValue)
Returns how many bits are required to hold values up
to and including maxValue, interpreted as an unsigned value.
|
final int bitsPerValue
final long numValues
final DataOutput output
long count
boolean finished
int off
final byte[] nextBlocks
final long[] nextValues
final BulkOperation encoder
final int iterations
static final int[] SUPPORTED_BITS_PER_VALUE
DirectWriter(DataOutput output, long numValues, int bitsPerValue)
public void add(long l) throws java.io.IOException
java.io.IOException
private void flush() throws java.io.IOException
java.io.IOException
public void finish() throws java.io.IOException
java.io.IOException
public static DirectWriter getInstance(DataOutput output, long numValues, int bitsPerValue)
numValues
using bitsPerValue
private static int roundBits(int bitsRequired)
bitsRequired
- the amount of bits requiredpublic 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)