NeighborArray

class NeighborArray(maxSize: Int, scoresDescOrder: Boolean)

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)

Constructors

Link copied to clipboard
constructor(maxSize: Int, scoresDescOrder: Boolean)

Functions

Link copied to clipboard
fun addAndEnsureDiversity(newNode: Int, newScore: Float, nodeId: Int, scorer: UpdateableRandomVectorScorer)

In addition to .addOutOfOrder, this function will also remove the least-diverse node if the node array is full after insertion

Link copied to clipboard
fun addInOrder(newNode: Int, newScore: Float)

Add a new node to the NeighborArray. The new node must be worse than all previously stored nodes. This cannot be called after .addOutOfOrder

Link copied to clipboard
fun addOutOfOrder(newNode: Int, newScore: Float)

Add node and newScore but do not insert as sorted

Link copied to clipboard
fun clear()
Link copied to clipboard
fun insertSorted(newNode: Int, newScore: Float)

This method is for test only.

Link copied to clipboard

Direct access to the internal list of node ids; provided for efficient writing of the graph

Link copied to clipboard
fun removeIndex(idx: Int)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun size(): Int
Link copied to clipboard

Sort the array according to scores, and return the sorted indexes of previous unsorted nodes (unchecked nodes)

Link copied to clipboard
open override fun toString(): String