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)
      Compares this NodeReferenceWithVector to the specified object for equality.
      Overrides:
      equals in class NodeReference
      Parameters:
      o - the object to compare with this NodeReferenceWithVector.
      Returns:
      true if the objects are equal; false otherwise.
    • hashCode

      public int hashCode()
      Computes the hash code for this object.
      Overrides:
      hashCode in class NodeReference
      Returns:
      a hash code value for this object.
    • toString

      public String toString()
      Returns a string representation of this object.
      Overrides:
      toString in class NodeReference
      Returns:
      a concise string representation of this object.