Package org.elasticsearch.nativeaccess
Class VectorSimilarityFunctions
java.lang.Object
org.elasticsearch.nativeaccess.VectorSimilarityFunctions
- All Implemented Interfaces:
NativeLibrary
,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 Summary
Modifier and TypeMethodDescriptionProduces a method handle returning the dot product of byte (signed int8) vectors.Produces a method handle returning the square distance of byte (signed int8) vectors.
-
Method Details
-
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 beMemorySegment
, whose contents is the vector data bytes. The third argument is the length of the vector data.- Specified by:
dotProductHandle
in interfaceVectorLibrary
-
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 beMemorySegment
, whose contents is the vector data bytes. The third argument is the length of the vector data.- Specified by:
squareDistanceHandle
in interfaceVectorLibrary
-