Interface DenseVector

All Known Implementing Classes:
BinaryDenseVector, BitBinaryDenseVector, BitKnnDenseVector, ByteBinaryDenseVector, ByteKnnDenseVector, KnnDenseVector

public interface DenseVector
DenseVector value type for the painless. dotProduct, l1Norm, l2Norm, cosineSimilarity have three flavors depending on the type of the queryVector 1) float[], this is for the ScoreScriptUtils class bindings which have converted a List based query vector into an array 2) List, A painless script will typically use Lists since they are easy to pass as params and have an easy literal syntax. Working with Lists directly, instead of converting to a float[], trades off runtime operations against memory pressure. Dense Vectors may have high dimensionality, up to 4096. Allocating a float[] per doc per script API call is prohibitively expensive. 3) Object, the whitelisted method for the painless API. Calls into the float[] or List version based on the class of the argument and checks dimensionality.
  • Field Details

  • Method Details

    • checkDimensions

      default void checkDimensions(int qvDims)
    • getVector

      float[] getVector()
    • getMagnitude

      float getMagnitude()
    • dotProduct

      int dotProduct(byte[] queryVector)
    • dotProduct

      double dotProduct(float[] queryVector)
    • dotProduct

      double dotProduct(List<Number> queryVector)
    • dotProduct

      default double dotProduct(Object queryVector)
    • l1Norm

      int l1Norm(byte[] queryVector)
    • l1Norm

      double l1Norm(float[] queryVector)
    • l1Norm

      double l1Norm(List<Number> queryVector)
    • l1Norm

      default double l1Norm(Object queryVector)
    • hamming

      int hamming(byte[] queryVector)
    • hamming

      int hamming(List<Number> queryVector)
    • hamming

      default int hamming(Object queryVector)
    • l2Norm

      double l2Norm(byte[] queryVector)
    • l2Norm

      double l2Norm(float[] queryVector)
    • l2Norm

      double l2Norm(List<Number> queryVector)
    • l2Norm

      default double l2Norm(Object queryVector)
    • cosineSimilarity

      default double cosineSimilarity(byte[] queryVector)
      Get the cosine similarity with the un-normalized query vector
    • cosineSimilarity

      double cosineSimilarity(byte[] queryVector, float qvMagnitude)
      Get the cosine similarity with the query vector
      Parameters:
      qvMagnitude - - pre-calculated magnitude of the query vector
    • cosineSimilarity

      default double cosineSimilarity(float[] queryVector)
      Get the cosine similarity with the un-normalized query vector
    • cosineSimilarity

      double cosineSimilarity(float[] queryVector, boolean normalizeQueryVector)
      Get the cosine similarity with the query vector
      Parameters:
      normalizeQueryVector - - normalize the query vector, does not change the contents of passed in query vector
    • cosineSimilarity

      double cosineSimilarity(List<Number> queryVector)
      Get the cosine similarity with the un-normalized query vector
    • cosineSimilarity

      default double cosineSimilarity(Object queryVector)
      Get the cosine similarity with the un-normalized query vector. Handles queryVectors of type float[] and List.
    • isEmpty

      boolean isEmpty()
    • getDims

      int getDims()
    • size

      int size()
    • getMagnitude

      static float getMagnitude(byte[] vector)
    • getMagnitude

      static float getMagnitude(byte[] vector, int dims)
    • getBitMagnitude

      static float getBitMagnitude(byte[] vector, int dims)
    • getMagnitude

      static float getMagnitude(float[] vector)
    • getMagnitude

      static float getMagnitude(List<Number> vector)
    • checkDimensions

      static void checkDimensions(int dvDims, int qvDims)