Class NodeReferenceWithVector

java.lang.Object
com.apple.foundationdb.async.hnsw.NodeReference
com.apple.foundationdb.async.hnsw.NodeReferenceWithVector
Direct Known Subclasses:
NodeReferenceWithDistance

public class NodeReferenceWithVector extends NodeReference
Represents a reference to a node that includes an associated vector.

This class extends NodeReference by adding a RealVector field. It encapsulates both the primary key of a node and its corresponding vector data, which is particularly useful in vector-based search and indexing scenarios. Primarily, node references are used to refer to Nodes in a storage-independent way, i.e. a node reference always contains the vector of a node while the node itself (depending on the storage adapter) may not.

  • Constructor Details

    • NodeReferenceWithVector

      public NodeReferenceWithVector(@Nonnull Tuple primaryKey, @Nonnull Transformed<RealVector> vector)
      Constructs a new NodeReferenceWithVector with a specified primary key and vector.

      The primary key is used to initialize the parent class via a call to super(), while the vector is stored as a field in this instance. Both parameters are expected to be non-null.

      Parameters:
      primaryKey - the primary key of the node, must not be null
      vector - the vector associated with the node, must not be null
  • Method Details

    • getVector

      @Nonnull public Transformed<RealVector> getVector()
      Gets the vector of Half objects.

      This method provides access to the internal vector. The returned vector is guaranteed not to be null, as indicated by the @Nonnull annotation.

      Returns:
      the vector of Half objects; will never be null.
    • asNodeReferenceWithVector

      @Nonnull public NodeReferenceWithVector asNodeReferenceWithVector()
      Returns this instance cast as a NodeReferenceWithVector.
      Overrides:
      asNodeReferenceWithVector in class NodeReference
      Returns:
      this instance as a NodeReferenceWithVector, which is never null.
    • equals

      public boolean equals(Object o)
      Description copied from class: NodeReference
      Compares this NodeReference to the specified object for equality.

      The result is true if and only if the argument is not null and is a NodeReference object that has the same primaryKey as this object.

      Overrides:
      equals in class NodeReference
      Parameters:
      o - the object to compare with this NodeReference for equality.
      Returns:
      true if the given object is equal to this one; false otherwise.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class NodeReference
    • toString

      public String toString()
      Overrides:
      toString in class NodeReference