Class NodeQueue

java.lang.Object
io.github.jbellis.jvector.graph.NodeQueue

public class NodeQueue extends Object
NodeQueue uses a AbstractLongHeap to store lists of nodes in a graph, represented as a node id with an associated score packed together as a sortable long, which is sorted primarily by score. The queue push(int, float) operation provides either fixed-size or unbounded operations, depending on the implementation subclasses, and either maxheap or minheap behavior.
  • Constructor Details

  • Method Details

    • size

      public int size()
      Returns:
      the number of elements in the heap
    • push

      public boolean push(int newNode, float newScore)
      Adds a new graph node to the heap. Will extend storage or replace the worst element depending on the type of heap it is.
      Parameters:
      newNode - the node id
      newScore - the relative similarity score to the node of the owner
      Returns:
      true if the new value was added.
    • pop

      public int pop()
      Removes the top element and returns its node id.
    • nodesCopy

      public int[] nodesCopy()
      Returns a copy of the internal nodes array. Not sorted by score!
    • nodesCopy

      public SearchResult.NodeScore[] nodesCopy(NodeSimilarity.ExactScoreFunction sf, float rerankFloor)
    • topNode

      public int topNode()
      Returns the top element's node id.
    • topScore

      public float topScore()
      Returns the top element's node score. For the min heap this is the minimum score. For the max heap this is the maximum score.
    • clear

      public void clear()
    • incomplete

      public boolean incomplete()
    • markIncomplete

      public void markIncomplete()
    • toString

      public String toString()
      Overrides:
      toString in class Object