QuantizedByteVectorValues.ScalarEncoding (Lucene 10.5.0 core API)
Description: declaration: package: org.apache.lucene.util.quantization, class: QuantizedByteVectorValues, enum: ScalarEncoding

Package org.apache.lucene.util.quantization

# Enum Class QuantizedByteVectorValues.ScalarEncoding

java.lang.Object
java.lang.Enum<QuantizedByteVectorValues.ScalarEncoding>
org.apache.lucene.util.quantization.QuantizedByteVectorValues.ScalarEncoding

All Implemented Interfaces:
  `Serializable`, `Comparable<QuantizedByteVectorValues.ScalarEncoding>`, `Constable`

Enclosing class:
  `QuantizedByteVectorValues`

public static enum QuantizedByteVectorValues.ScalarEncoding extends Enum<QuantizedByteVectorValues.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 Constants
  Enum Constant
  Description
  `DIBIT_QUERY_NIBBLE`
  Each dimension is quantized to 2 bits (dibit) and packed into bytes.
  `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.
  `SINGLE_BIT_QUERY_NIBBLE`
  Each dimension is quantized to a single bit and packed into bytes.
  `UNSIGNED_BYTE`
  Each dimension is quantized to 8 bits and treated as an unsigned value.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static QuantizedByteVectorValues.ScalarEncoding`
  `fromNumBits(int bits)`
  `static Optional<QuantizedByteVectorValues.ScalarEncoding>`
  `fromWireNumber(int wireNumber)`
  Returns the encoding for the given wire number, or empty if unknown.
  `byte`
  `getBits()`
  Return the number of bits used per dimension.
  `int`
  `getDiscreteDimensions(int dimensions)`
  Return the number of dimensions rounded up to fit into whole bytes.
  `int`
  `getDocBitsPerDim()`
  Return the number of dimensions that can be packed into a single byte.
  `int`
  `getDocPackedLength(int dimensions)`
  Return the number of bytes required to store a packed vector of the given dimensions.
  `byte`
  `getQueryBits()`
  `int`
  `getQueryBitsPerDim()`
  `int`
  `getQueryPackedLength(int dimensions)`
  `int`
  `getWireNumber()`
  `boolean`
  `isAsymmetric()`
  `static QuantizedByteVectorValues.ScalarEncoding`
  `valueOf(String name)`
  Returns the enum constant of this class with the specified name.
  `static QuantizedByteVectorValues.ScalarEncoding[]`
  `values()`
  Returns an array containing the constants of this enum class, in the order they are declared.

  ### Methods inherited from class java.lang.Enum

  `clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Enum Constant Details

  - ### UNSIGNED_BYTE

    public static final QuantizedByteVectorValues.ScalarEncoding UNSIGNED_BYTE
    Each dimension is quantized to 8 bits and treated as an unsigned value.

  - ### PACKED_NIBBLE

    public static final QuantizedByteVectorValues.ScalarEncoding PACKED_NIBBLE
    Each dimension is quantized to 4 bits two values are packed into each output byte.

  - ### SEVEN_BIT

    public static final QuantizedByteVectorValues.ScalarEncoding 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_BYTE` but will produce less accurate vector comparisons.

  - ### SINGLE_BIT_QUERY_NIBBLE

    public static final QuantizedByteVectorValues.ScalarEncoding 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

    public static final QuantizedByteVectorValues.ScalarEncoding 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 of `SINGLE_BIT_QUERY_NIBBLE` and the accuracy of `PACKED_NIBBLE`.

- ## Method Details

  - ### values

    public static QuantizedByteVectorValues.ScalarEncoding[] 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

    public static QuantizedByteVectorValues.ScalarEncoding valueOf(String name)
    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 name
      `NullPointerException` - if the argument is null

  - ### fromNumBits

    public static QuantizedByteVectorValues.ScalarEncoding fromNumBits(int bits)

  - ### isAsymmetric

    public boolean isAsymmetric()

  - ### getWireNumber

    public int getWireNumber()

  - ### 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<QuantizedByteVectorValues.ScalarEncoding> fromWireNumber(int wireNumber)
    Returns the encoding for the given wire number, or empty if unknown.