Package org.apache.lucene.util.hnsw
Class NeighborArray
- java.lang.Object
-
- org.apache.lucene.util.hnsw.NeighborArray
-
public class NeighborArray extends Object
NeighborArray encodes the neighbors of a node and their mutual scores in the HNSW graph as a pair of growable arrays. Nodes are arranged in the sorted order of their scores in descending order (if scoresDescOrder is true), or in the ascending order of their scores (if scoresDescOrder is false)- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Constructor Description NeighborArray(int maxSize, boolean descOrder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int newNode, float newScore)
Add a new node to the NeighborArray.void
clear()
void
insertSorted(int newNode, float newScore)
Add a new node to the NeighborArray into a correct sort position according to its score.int[]
node()
Direct access to the internal list of node ids; provided for efficient writing of the graphvoid
removeIndex(int idx)
void
removeLast()
float[]
score()
int
size()
String
toString()
-
-
-
Method Detail
-
add
public void add(int newNode, float newScore)
Add a new node to the NeighborArray. The new node must be worse than all previously stored nodes.
-
insertSorted
public void insertSorted(int newNode, float newScore)
Add a new node to the NeighborArray into a correct sort position according to its score.
-
size
public int size()
-
node
public int[] node()
Direct access to the internal list of node ids; provided for efficient writing of the graph- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
score
public float[] score()
-
clear
public void clear()
-
removeLast
public void removeLast()
-
removeIndex
public void removeIndex(int idx)
-
-