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 intSpecial 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 intUpper limit of the number of values that might be decoded in a single call toreadBlock(IndexInput, byte[], int[]).(package private) static final intUpper limit of the number of bytes that might be required to storedBLOCK_SIZEencoded values. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intbitsRequired(int[] data) Compute the number of bits required to serialize any of the longs indata.private static intcomputeIterations(PackedInts.Decoder decoder) Compute the number of iterations required to decodeBLOCK_SIZEvalues with the providedPackedInts.Decoder.private static intencodedSize(PackedInts.Format format, int packedIntsVersion, int bitsPerValue) Compute the number of bytes required to encode a block of values that requirebitsPerValuebits per value with formatformat.private static booleanisAllEqual(int[] data) (package private) voidreadBlock(IndexInput in, byte[] encoded, int[] decoded) Read the next block of data (Forformat).(package private) voidskipBlock(IndexInput in) Skip the next block of data.(package private) voidwriteBlock(int[] data, byte[] encoded, IndexOutput out) Write a block of data (Forformat).
-
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_SIZEencoded 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_SIZEare garbage, it is necessary to allocate value buffers whose size is>= MAX_DATA_SIZEto avoidArrayIndexOutOfBoundsExceptions. -
encodedSizes
private final int[] encodedSizes -
encoders
-
decoders
-
iterations
private final int[] iterations
-
-
Constructor Details
-
ForUtil
ForUtil(float acceptableOverheadRatio, DataOutput out) throws IOException Create a newForUtilinstance 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_SIZEvalues with the providedPackedInts.Decoder. -
encodedSize
Compute the number of bytes required to encode a block of values that requirebitsPerValuebits per value with formatformat. -
writeBlock
Write a block of data (Forformat).- 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 (Forformat).- 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.
-