java.lang.Object
org.elasticsearch.index.codec.vectors.BQSpaceUtils
Utility class for quantization calculations
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidtransposeHalfByte(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.static voidtransposeHalfByte(int[] q, byte[] quantQueryByte) Same astransposeHalfByte(byte[], byte[])but the input vector is provided as an array of integers.static voidtransposeHalfByteLegacy(byte[] q, byte[] quantQueryByte) Same astransposeHalfByte(byte[], byte[])but with more readable but slower code.static voidtransposeHalfByteLegacy(int[] q, byte[] quantQueryByte) Same astransposeHalfByte(int[], byte[])but with more readable but slower code.
-
Field Details
-
B_QUERY
public static final short B_QUERY- See Also:
-
-
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 15quantQueryByte- the byte array to store the transposed query vector
-
transposeHalfByteLegacy
public static void transposeHalfByteLegacy(byte[] q, byte[] quantQueryByte) Same astransposeHalfByte(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 15quantQueryByte- the byte array to store the transposed query vector
-
transposeHalfByte
public static void transposeHalfByte(int[] q, byte[] quantQueryByte) Same astransposeHalfByte(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 15quantQueryByte- the byte array to store the transposed query vector
-
transposeHalfByteLegacy
public static void transposeHalfByteLegacy(int[] q, byte[] quantQueryByte) Same astransposeHalfByte(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 15quantQueryByte- the byte array to store the transposed query vector
-