Class NodeReferenceWithDistance
java.lang.Object
com.apple.foundationdb.async.hnsw.NodeReference
com.apple.foundationdb.async.hnsw.NodeReferenceWithVector
com.apple.foundationdb.async.hnsw.NodeReferenceWithDistance
Represents a reference to a node that includes its vector and its distance from a query vector.
This class extends NodeReferenceWithVector by additionally associating a distance value, typically the result
of a distance calculation in a nearest neighbor search. Objects of this class are immutable.
-
Constructor Summary
ConstructorsConstructorDescriptionNodeReferenceWithDistance(Tuple primaryKey, Transformed<RealVector> vector, double distance) Constructs a new instance ofNodeReferenceWithDistance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares this object against the specified object for equality.doubleGets the distance.inthashCode()Generates a hash code for this object.Methods inherited from class com.apple.foundationdb.async.hnsw.NodeReferenceWithVector
asNodeReferenceWithVector, getVector, toStringMethods inherited from class com.apple.foundationdb.async.hnsw.NodeReference
getPrimaryKey, primaryKeys
-
Constructor Details
-
NodeReferenceWithDistance
public NodeReferenceWithDistance(@Nonnull Tuple primaryKey, @Nonnull Transformed<RealVector> vector, double distance) Constructs a new instance ofNodeReferenceWithDistance.This constructor initializes the reference with the node's primary key, its vector, and the calculated distance from some origin vector (e.g., a query vector). It calls the superclass constructor to set the
primaryKeyandvector.- Parameters:
primaryKey- the primary key of the referenced node, represented as aTuple. Must not be null.vector- the vector associated with the referenced node. Must not be null.distance- the calculated distance of this node reference to some query vector or similar.
-
-
Method Details
-
getDistance
public double getDistance()Gets the distance.- Returns:
- the current distance value
-
equals
Compares this object against the specified object for equality.The result is
trueif and only if the argument is notnull, is aNodeReferenceWithDistanceobject, has the same properties as determined by the superclass'sequals(Object)method, and has the samedistancevalue.- Overrides:
equalsin classNodeReferenceWithVector- Parameters:
o- the object to compare with this instance for equality.- Returns:
trueif the specified object is equal to thisNodeReferenceWithDistance;falseotherwise.
-
hashCode
public int hashCode()Generates a hash code for this object.- Overrides:
hashCodein classNodeReferenceWithVector- Returns:
- a hash code value for this object.
-