java.lang.Object
org.elasticsearch.index.codec.vectors.BQSpaceUtils

public class BQSpaceUtils extends Object
Utility class for quantization calculations
  • Field Details

  • Constructor Details

    • BQSpaceUtils

      public BQSpaceUtils()
  • Method Details

    • transposeHalfByte

      public static void transposeHalfByte(byte[] q, byte[] quantQueryByte)
      Copied from Lucene, replace with Lucene's implementation sometime after Lucene 10 Transpose the query vector into a byte array allowing for efficient bitwise operations with the index bit vectors. The idea here is to organize the query vector bits such that the first bit of every dimension is in the first set dimensions bits, or (dimensions/8) bytes. The second, third, and fourth bits are in the second, third, and fourth set of dimensions bits, respectively. This allows for direct bitwise comparisons with the stored index vectors through summing the bitwise results with the relative required bit shifts.
      Parameters:
      q - the query vector, assumed to be half-byte quantized with values between 0 and 15
      quantQueryByte - the byte array to store the transposed query vector
    • transposeHalfByteLegacy

      public static void transposeHalfByteLegacy(byte[] q, byte[] quantQueryByte)
      Same as transposeHalfByte(byte[], byte[]) but with more readable but slower code.
      Parameters:
      q - the query vector, assumed to be half-byte quantized with values between 0 and 15
      quantQueryByte - the byte array to store the transposed query vector
    • transposeHalfByte

      public static void transposeHalfByte(int[] q, byte[] quantQueryByte)
      Same as transposeHalfByte(byte[], byte[]) but the input vector is provided as an array of integers.
      Parameters:
      q - the query vector, assumed to be half-byte quantized with values between 0 and 15
      quantQueryByte - the byte array to store the transposed query vector
    • transposeHalfByteLegacy

      public static void transposeHalfByteLegacy(int[] q, byte[] quantQueryByte)
      Same as transposeHalfByte(int[], byte[]) but with more readable but slower code.
      Parameters:
      q - the query vector, assumed to be half-byte quantized with values between 0 and 15
      quantQueryByte - the byte array to store the transposed query vector