Class ForUtil
java.lang.Object
org.apache.lucene.backward_codecs.lucene50.ForUtil
Encode all values in normal area with fixed bit width, which is determined by the max value in
this block.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
Special number of bits per value used whenever all values to encode are equal.private final PackedInts.Decoder[]
private final int[]
private final PackedInts.Encoder[]
private final int[]
(package private) static final int
Upper limit of the number of values that might be decoded in a single call toreadBlock(IndexInput, byte[], int[])
.(package private) static final int
Upper limit of the number of bytes that might be required to storedBLOCK_SIZE
encoded values. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
bitsRequired
(int[] data) Compute the number of bits required to serialize any of the longs indata
.private static int
computeIterations
(PackedInts.Decoder decoder) Compute the number of iterations required to decodeBLOCK_SIZE
values with the providedPackedInts.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 requirebitsPerValue
bits per value with formatformat
.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).
-
Field Details
-
ALL_VALUES_EQUAL
private static final int ALL_VALUES_EQUALSpecial number of bits per value used whenever all values to encode are equal.- See Also:
-
MAX_ENCODED_SIZE
static final int MAX_ENCODED_SIZEUpper limit of the number of bytes that might be required to storedBLOCK_SIZE
encoded values.- See Also:
-
MAX_DATA_SIZE
static final int MAX_DATA_SIZEUpper limit of the number of values that might be decoded in a single call toreadBlock(IndexInput, byte[], int[])
. Although values afterBLOCK_SIZE
are garbage, it is necessary to allocate value buffers whose size is>= MAX_DATA_SIZE
to avoidArrayIndexOutOfBoundsException
s. -
encodedSizes
private final int[] encodedSizes -
encoders
-
decoders
-
iterations
private final int[] iterations
-
-
Constructor Details
-
ForUtil
ForUtil(float acceptableOverheadRatio, DataOutput out) throws IOException Create a newForUtil
instance and save state intoout
.- Throws:
IOException
-
ForUtil
ForUtil(DataInput in) throws IOException - Throws:
IOException
-
-
Method Details
-
computeIterations
Compute the number of iterations required to decodeBLOCK_SIZE
values with the providedPackedInts.Decoder
. -
encodedSize
Compute the number of bytes required to encode a block of values that requirebitsPerValue
bits per value with formatformat
. -
writeBlock
Write a block of data (For
format).- Parameters:
data
- the data to writeencoded
- a buffer to use to encode dataout
- the destination output- Throws:
IOException
- If there is a low-level I/O error
-
readBlock
Read the next block of data (For
format).- Parameters:
in
- the input to use to read dataencoded
- a buffer that can be used to store encoded datadecoded
- where to write decoded data- Throws:
IOException
- If there is a low-level I/O error
-
skipBlock
Skip the next block of data.- Parameters:
in
- the input where to read data- Throws:
IOException
- If there is a low-level I/O error
-
isAllEqual
private static boolean isAllEqual(int[] data) -
bitsRequired
private static int bitsRequired(int[] data) Compute the number of bits required to serialize any of the longs indata
.
-