final class ForUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static int |
ALL_VALUES_EQUAL
Special number of bits per value used whenever all values to encode are equal.
|
private PackedInts.Decoder[] |
decoders |
private int[] |
encodedSizes |
private PackedInts.Encoder[] |
encoders |
private int[] |
iterations |
(package private) static int |
MAX_DATA_SIZE
Upper limit of the number of values that might be decoded in a single call to
readBlock(IndexInput, byte[], int[]) . |
(package private) static int |
MAX_ENCODED_SIZE
Upper limit of the number of bytes that might be required to stored
BLOCK_SIZE encoded values. |
Constructor and Description |
---|
ForUtil(DataInput in)
|
ForUtil(float acceptableOverheadRatio,
DataOutput out)
Create a new
ForUtil instance and save state into out . |
Modifier and Type | Method and Description |
---|---|
private static int |
bitsRequired(int[] data)
Compute the number of bits required to serialize any of the longs in
data . |
private static int |
computeIterations(PackedInts.Decoder decoder)
Compute the number of iterations required to decode
BLOCK_SIZE
values with the provided PackedInts.Decoder . |
private static int |
encodedSize(PackedInts.Format format,
int packedIntsVersion,
int bitsPerValue)
Compute the number of bytes required to encode a block of values that require
bitsPerValue bits per value with format format . |
private static boolean |
isAllEqual(int[] data) |
(package private) void |
readBlock(IndexInput in,
byte[] encoded,
int[] decoded)
Read the next block of data (
For format). |
(package private) void |
skipBlock(IndexInput in)
Skip the next block of data.
|
(package private) void |
writeBlock(int[] data,
byte[] encoded,
IndexOutput out)
Write a block of data (
For format). |
private static final int ALL_VALUES_EQUAL
static final int MAX_ENCODED_SIZE
BLOCK_SIZE
encoded values.static final int MAX_DATA_SIZE
readBlock(IndexInput, byte[], int[])
. Although values after
BLOCK_SIZE
are garbage, it is necessary to allocate value buffers
whose size is >= MAX_DATA_SIZE
to avoid ArrayIndexOutOfBoundsException
s.private final int[] encodedSizes
private final PackedInts.Encoder[] encoders
private final PackedInts.Decoder[] decoders
private final int[] iterations
ForUtil(float acceptableOverheadRatio, DataOutput out) throws java.io.IOException
ForUtil
instance and save state into out
.java.io.IOException
ForUtil(DataInput in) throws java.io.IOException
java.io.IOException
private static int computeIterations(PackedInts.Decoder decoder)
BLOCK_SIZE
values with the provided PackedInts.Decoder
.private static int encodedSize(PackedInts.Format format, int packedIntsVersion, int bitsPerValue)
bitsPerValue
bits per value with format format
.void writeBlock(int[] data, byte[] encoded, IndexOutput out) throws java.io.IOException
For
format).data
- the data to writeencoded
- a buffer to use to encode dataout
- the destination outputjava.io.IOException
- If there is a low-level I/O errorvoid readBlock(IndexInput in, byte[] encoded, int[] decoded) throws java.io.IOException
For
format).in
- the input to use to read dataencoded
- a buffer that can be used to store encoded datadecoded
- where to write decoded datajava.io.IOException
- If there is a low-level I/O errorvoid skipBlock(IndexInput in) throws java.io.IOException
in
- the input where to read datajava.io.IOException
- If there is a low-level I/O errorprivate static boolean isAllEqual(int[] data)
private static int bitsRequired(int[] data)
data
.