Class ForUtil
- java.lang.Object
-
- org.apache.lucene.codecs.lucene50.ForUtil
-
final class ForUtil extends java.lang.Object
Encode all values in normal area with fixed bit width, which is determined by the max value in this block.
-
-
Field Summary
Fields Modifier and Type Field 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 toreadBlock(IndexInput, byte[], int[])
.(package private) static int
MAX_ENCODED_SIZE
Upper limit of the number of bytes that might be required to storedBLOCK_SIZE
encoded values.
-
Constructor Summary
Constructors Constructor Description ForUtil(float acceptableOverheadRatio, DataOutput out)
Create a newForUtil
instance and save state intoout
.ForUtil(DataInput in)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private 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 Detail
-
ALL_VALUES_EQUAL
private static final int ALL_VALUES_EQUAL
Special number of bits per value used whenever all values to encode are equal.- See Also:
- Constant Field Values
-
MAX_ENCODED_SIZE
static final int MAX_ENCODED_SIZE
Upper limit of the number of bytes that might be required to storedBLOCK_SIZE
encoded values.- See Also:
- Constant Field Values
-
MAX_DATA_SIZE
static final int MAX_DATA_SIZE
Upper 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
private final PackedInts.Encoder[] encoders
-
decoders
private final PackedInts.Decoder[] decoders
-
iterations
private final int[] iterations
-
-
Constructor Detail
-
ForUtil
ForUtil(float acceptableOverheadRatio, DataOutput out) throws java.io.IOException
Create a newForUtil
instance and save state intoout
.- Throws:
java.io.IOException
-
ForUtil
ForUtil(DataInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
computeIterations
private static int computeIterations(PackedInts.Decoder decoder)
Compute the number of iterations required to decodeBLOCK_SIZE
values with the providedPackedInts.Decoder
.
-
encodedSize
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
.
-
writeBlock
void writeBlock(int[] data, byte[] encoded, IndexOutput out) throws java.io.IOException
Write a block of data (For
format).- Parameters:
data
- the data to writeencoded
- a buffer to use to encode dataout
- the destination output- Throws:
java.io.IOException
- If there is a low-level I/O error
-
readBlock
void readBlock(IndexInput in, byte[] encoded, int[] decoded) throws java.io.IOException
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:
java.io.IOException
- If there is a low-level I/O error
-
skipBlock
void skipBlock(IndexInput in) throws java.io.IOException
Skip the next block of data.- Parameters:
in
- the input where to read data- Throws:
java.io.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
.
-
-