Class ES940OSQVectorsScorer

java.lang.Object
org.elasticsearch.simdvec.ES940OSQVectorsScorer
Direct Known Subclasses:
MemorySegmentES940OSQVectorsScorer

public class ES940OSQVectorsScorer extends Object
Scorer for quantized vectors stored as an IndexInput.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final float[]
     
    protected static final float[]
     
    static final int
     
    protected final int
     
    protected final int
     
    protected final org.apache.lucene.store.IndexInput
    The wrapper IndexInput.
    protected final byte
     
     
    protected final int
     
    protected final float[]
     
    protected final byte
     
    protected final int[]
     
    protected final float[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ES940OSQVectorsScorer(org.apache.lucene.store.IndexInput in, byte queryBits, byte indexBits, int dimensions, int dataLength)
     
    ES940OSQVectorsScorer(org.apache.lucene.store.IndexInput in, byte queryBits, byte indexBits, int dimensions, int dataLength, int bulkSize)
     
    ES940OSQVectorsScorer(org.apache.lucene.store.IndexInput in, byte queryBits, byte indexBits, int dimensions, int dataLength, int bulkSize, ES940OSQVectorsScorer.SymmetricInt4Encoding int4Encoding)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    applyCorrectionsIndividually(float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp, float lowerInterval, float upperInterval, int targetComponentSum, float additionalCorrection, float qcDist)
    Computes the final score by applying the necessary corrections to the provided quantized distance.
    long
    quantizeScore(byte[] q)
    compute the quantize distance between the provided quantized query and the quantized vector that is read from the wrapped IndexInput.
    void
    quantizeScoreBulk(byte[] q, int count, float[] scores)
    Compute the quantize distance between the provided quantized query and the quantized vectors that are read from the wrapped IndexInput.
    void
    quantizeScoreBulkOffsets(byte[] q, int[] offsets, int offsetsCount, float[] scores, int count)
    Compute the quantize distance between the provided quantized query and the quantized vectors that are read from the wrapped IndexInput.
    float
    scoreBulk(byte[] q, float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp, float[] scores)
    Bulk score overload; same as scoreBulk(byte[], float, float, int, float, VectorSimilarityFunction, float, float[], int) with bulkSize as the default bulkSize param value.
    float
    scoreBulk(byte[] q, float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp, float[] scores, int bulkSize)
    Compute the distance between the provided quantized query and the quantized vectors that are read from the wrapped IndexInput.
    float
    scoreBulkOffsets(byte[] q, float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp, int[] offsets, int offsetsCount, float[] scores, int count)
    Compute the distance between the provided quantized query and the quantized vectors that are read from the wrapped IndexInput.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • BULK_SIZE

      public static final int BULK_SIZE
      See Also:
    • BIT_SCALES

      protected static final float[] BIT_SCALES
    • in

      protected final org.apache.lucene.store.IndexInput in
      The wrapper IndexInput.
    • queryBits

      protected final byte queryBits
    • indexBits

      protected final byte indexBits
    • length

      protected final int length
    • dimensions

      protected final int dimensions
    • bulkSize

      protected final int bulkSize
    • int4Encoding

      protected final ES940OSQVectorsScorer.SymmetricInt4Encoding int4Encoding
    • lowerIntervals

      protected final float[] lowerIntervals
    • upperIntervals

      protected final float[] upperIntervals
    • targetComponentSums

      protected final int[] targetComponentSums
    • additionalCorrections

      protected final float[] additionalCorrections
  • Constructor Details

    • ES940OSQVectorsScorer

      public ES940OSQVectorsScorer(org.apache.lucene.store.IndexInput in, byte queryBits, byte indexBits, int dimensions, int dataLength, int bulkSize, ES940OSQVectorsScorer.SymmetricInt4Encoding int4Encoding)
    • ES940OSQVectorsScorer

      public ES940OSQVectorsScorer(org.apache.lucene.store.IndexInput in, byte queryBits, byte indexBits, int dimensions, int dataLength, int bulkSize)
    • ES940OSQVectorsScorer

      public ES940OSQVectorsScorer(org.apache.lucene.store.IndexInput in, byte queryBits, byte indexBits, int dimensions, int dataLength)
  • Method Details

    • quantizeScore

      public long quantizeScore(byte[] q) throws IOException
      compute the quantize distance between the provided quantized query and the quantized vector that is read from the wrapped IndexInput.
      Throws:
      IOException
    • quantizeScoreBulk

      public void quantizeScoreBulk(byte[] q, int count, float[] scores) throws IOException
      Compute the quantize distance between the provided quantized query and the quantized vectors that are read from the wrapped IndexInput. The number of quantized vectors to read is determined by and the results are stored in the provided array.
      Throws:
      IOException
    • quantizeScoreBulkOffsets

      public void quantizeScoreBulkOffsets(byte[] q, int[] offsets, int offsetsCount, float[] scores, int count) throws IOException
      Compute the quantize distance between the provided quantized query and the quantized vectors that are read from the wrapped IndexInput. The number of quantized vectors to read is determined by and the results are stored in the provided array. Only the vectors that are indexed in the provided are scored; the others are skipped.
      Throws:
      IOException
    • applyCorrectionsIndividually

      public float applyCorrectionsIndividually(float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp, float lowerInterval, float upperInterval, int targetComponentSum, float additionalCorrection, float qcDist)
      Computes the final score by applying the necessary corrections to the provided quantized distance.
    • scoreBulk

      public float scoreBulk(byte[] q, float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp, float[] scores) throws IOException
      Bulk score overload; same as scoreBulk(byte[], float, float, int, float, VectorSimilarityFunction, float, float[], int) with bulkSize as the default bulkSize param value.
      Throws:
      IOException
    • scoreBulk

      public float scoreBulk(byte[] q, float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp, float[] scores, int bulkSize) throws IOException
      Compute the distance between the provided quantized query and the quantized vectors that are read from the wrapped IndexInput.

      The number of vectors to score is defined by . The expected format of the input is as follows: First the quantized vectors are read from the input,then all the lower intervals as floats, then all the upper intervals as floats, then all the target component sums as shorts, and finally all the additional corrections as floats.

      The results are stored in the provided array.

      Throws:
      IOException
    • scoreBulkOffsets

      public float scoreBulkOffsets(byte[] q, float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp, int[] offsets, int offsetsCount, float[] scores, int count) throws IOException
      Compute the distance between the provided quantized query and the quantized vectors that are read from the wrapped IndexInput.

      Similar to scoreBulk(byte[], float, float, int, float, org.apache.lucene.index.VectorSimilarityFunction, float, float[]), but only the vectors indexed by the provided are scored; the others are skipped.

      The results are stored in the provided array.

      Throws:
      IOException