Enum Class Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding
java.lang.Object
java.lang.Enum<Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding>
org.apache.lucene.codecs.lucene104.Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding
- All Implemented Interfaces:
Serializable,Comparable<Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding>,Constable
- Enclosing class:
Lucene104ScalarQuantizedVectorsFormat
public static enum Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding
extends Enum<Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding>
Allowed encodings for scalar quantization.
This specifies how many bits are used per dimension and also dictates packing of dimensions into a byte stream.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionEach dimension is quantized to 2 bits (dibit) and packed into bytes.Each dimension is quantized to 4 bits two values are packed into each output byte.Each dimension is quantized to 7 bits and treated as a signed value.Each dimension is quantized to a single bit and packed into bytes.Each dimension is quantized to 8 bits and treated as an unsigned value. -
Method Summary
Modifier and TypeMethodDescriptionfromNumBits(int bits) fromWireNumber(int wireNumber) Returns the encoding for the given wire number, or empty if unknown.bytegetBits()Return the number of bits used per dimension.intgetDiscreteDimensions(int dimensions) Return the number of dimensions rounded up to fit into whole bytes.intReturn the number of dimensions that can be packed into a single byte.intgetDocPackedLength(int dimensions) Return the number of bytes required to store a packed vector of the given dimensions.byteintintgetQueryPackedLength(int dimensions) booleanReturns the enum constant of this class with the specified name.values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
UNSIGNED_BYTE
Each dimension is quantized to 8 bits and treated as an unsigned value. -
PACKED_NIBBLE
Each dimension is quantized to 4 bits two values are packed into each output byte. -
SEVEN_BIT
Each dimension is quantized to 7 bits and treated as a signed value.This is intended for backwards compatibility with older iterations of scalar quantization. This setting will produce an index the same size as
UNSIGNED_BYTEbut will produce less accurate vector comparisons. -
SINGLE_BIT_QUERY_NIBBLE
Each dimension is quantized to a single bit and packed into bytes. During query time, the query vector is quantized to 4 bits per dimension.This is the most space efficient encoding, and will produce an index 8x smaller than
UNSIGNED_BYTE. However, this comes at the cost of accuracy. -
DIBIT_QUERY_NIBBLE
Each dimension is quantized to 2 bits (dibit) and packed into bytes. During query time, the query vector is quantized to 4 bits per dimension.This encoding produces an index 4x smaller than
UNSIGNED_BYTE, offering a balance between the compression ofSINGLE_BIT_QUERY_NIBBLEand the accuracy ofPACKED_NIBBLE.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
fromNumBits
-
isAsymmetric
public boolean isAsymmetric() -
getBits
public byte getBits()Return the number of bits used per dimension. -
getQueryBits
public byte getQueryBits() -
getDiscreteDimensions
public int getDiscreteDimensions(int dimensions) Return the number of dimensions rounded up to fit into whole bytes. -
getDocBitsPerDim
public int getDocBitsPerDim()Return the number of dimensions that can be packed into a single byte. -
getQueryBitsPerDim
public int getQueryBitsPerDim() -
getDocPackedLength
public int getDocPackedLength(int dimensions) Return the number of bytes required to store a packed vector of the given dimensions. -
getQueryPackedLength
public int getQueryPackedLength(int dimensions) -
fromWireNumber
public static Optional<Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding> fromWireNumber(int wireNumber) Returns the encoding for the given wire number, or empty if unknown.
-