Class VectorSimilarityFunctions

java.lang.Object
org.elasticsearch.nativeaccess.VectorSimilarityFunctions
All Implemented Interfaces:
NativeLibrary, VectorLibrary

public final class VectorSimilarityFunctions extends Object implements VectorLibrary
Utility class providing vector similarity functions.

MethodHandles are returned to avoid a static reference to MemorySegment, which is not in the currently lowest compile version, JDK 17. Code consuming the method handles will, by definition, require access to MemorySegment.

  • Method Details

    • dotProductHandle

      public MethodHandle dotProductHandle()
      Produces a method handle returning the dot product of byte (signed int8) vectors.

      The type of the method handle will have int as return type, The type of its first and second arguments will be MemorySegment, whose contents is the vector data bytes. The third argument is the length of the vector data.

      Specified by:
      dotProductHandle in interface VectorLibrary
    • squareDistanceHandle

      public MethodHandle squareDistanceHandle()
      Produces a method handle returning the square distance of byte (signed int8) vectors.

      The type of the method handle will have int as return type, The type of its first and second arguments will be MemorySegment, whose contents is the vector data bytes. The third argument is the length of the vector data.

      Specified by:
      squareDistanceHandle in interface VectorLibrary