Interface VectorSimilarityFunctions
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 cosine of float32 vectors.Produces a method handle returning the dot product of byte (unsigned int7) vectors.Produces a method handle which computes the dot product of several byte (unsigned int7) vectors.Produces a method handle returning the dot product of float32 vectors.Produces a method handle returning the square distance of byte (unsigned int7) vectors.Produces a method handle returning the square distance of float32 vectors.
-
Method Details
-
dotProductHandle7u
MethodHandle dotProductHandle7u()Produces a method handle returning the dot product of byte (unsigned int7) vectors.Unsigned int7 byte vectors have values in the range of 0 to 127 (inclusive).
The type of the method handle will have
intas 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. -
dotProductHandle7uBulk
MethodHandle dotProductHandle7uBulk()Produces a method handle which computes the dot product of several byte (unsigned int7) vectors. This bulk operation can be used to compute the dot product between a single query vector and a number of other vectors.Unsigned int7 byte vectors have values in the range of 0 to 127 (inclusive).
The type of the method handle will have
voidas return type. The type of its first and second arguments will beMemorySegment, the former contains the vector data bytes for several vectors, while the latter just a single vector. The type of the third argument is an int, representing the dimensions of each vector. The type of the fourth argument is an int, representing the number of vectors in the first argument. The type of the final argument is a MemorySegment, into which the computed dot product float values will be stored. -
squareDistanceHandle7u
MethodHandle squareDistanceHandle7u()Produces a method handle returning the square distance of byte (unsigned int7) vectors.Unsigned int7 byte vectors have values in the range of 0 to 127 (inclusive).
The type of the method handle will have
intas 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. -
cosineHandleFloat32
MethodHandle cosineHandleFloat32()Produces a method handle returning the cosine of float32 vectors.The type of the method handle will have
floatas return type, The type of its first and second arguments will beMemorySegment, whose contents is the vector data floats. The third argument is the length of the vector data - number of 4-byte float32 elements. -
dotProductHandleFloat32
MethodHandle dotProductHandleFloat32()Produces a method handle returning the dot product of float32 vectors.The type of the method handle will have
floatas return type, The type of its first and second arguments will beMemorySegment, whose contents is the vector data floats. The third argument is the length of the vector data - number of 4-byte float32 elements. -
squareDistanceHandleFloat32
MethodHandle squareDistanceHandleFloat32()Produces a method handle returning the square distance of float32 vectors.The type of the method handle will have
floatas return type, The type of its first and second arguments will beMemorySegment, whose contents is the vector data floats. The third argument is the length of the vector data - number of 4-byte float32 elements.
-