Package io.github.jbellis.jvector.graph
Class NodeQueue
java.lang.Object
io.github.jbellis.jvector.graph.NodeQueue
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.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()int[]Returns a copy of the internal nodes array.nodesCopy(NodeSimilarity.ExactScoreFunction sf, float rerankFloor) intpop()Removes the top element and returns its node id.booleanpush(int newNode, float newScore) Adds a new graph node to the heap.intsize()inttopNode()Returns the top element's node id.floattopScore()Returns the top element's node score.toString()
-
Constructor Details
-
NodeQueue
-
-
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 idnewScore- 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
-
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() -
toString
-