Class ForUtil
- java.lang.Object
-
- org.apache.lucene.codecs.lucene50.ForUtil
-
final class ForUtil extends java.lang.ObjectEncode 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 intALL_VALUES_EQUALSpecial number of bits per value used whenever all values to encode are equal.private PackedInts.Decoder[]decodersprivate int[]encodedSizesprivate PackedInts.Encoder[]encodersprivate int[]iterations(package private) static intMAX_DATA_SIZEUpper limit of the number of values that might be decoded in a single call toreadBlock(IndexInput, byte[], int[]).(package private) static intMAX_ENCODED_SIZEUpper limit of the number of bytes that might be required to storedBLOCK_SIZEencoded values.
-
Constructor Summary
Constructors Constructor Description ForUtil(float acceptableOverheadRatio, DataOutput out)Create a newForUtilinstance and save state intoout.ForUtil(DataInput in)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private 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 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_SIZEencoded 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_SIZEare garbage, it is necessary to allocate value buffers whose size is>= MAX_DATA_SIZEto avoidArrayIndexOutOfBoundsExceptions.
-
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.IOExceptionCreate a newForUtilinstance 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_SIZEvalues 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 requirebitsPerValuebits per value with formatformat.
-
writeBlock
void writeBlock(int[] data, byte[] encoded, IndexOutput out) throws java.io.IOExceptionWrite a block of data (Forformat).- 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 (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:
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.
-
-