Class Lucene90OnHeapHnswGraph
java.lang.Object
org.apache.lucene.util.hnsw.HnswGraph
org.apache.lucene.backward_codecs.lucene90.Lucene90OnHeapHnswGraph
An
HnswGraph where all nodes and connections are held in memory. This class is used to
construct the HNSW graph before it's written to the index.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.util.hnsw.HnswGraph
HnswGraph.ArrayNodesIterator, HnswGraph.CollectionNodesIterator, HnswGraph.NodesIterator -
Field Summary
Fields inherited from class org.apache.lucene.util.hnsw.HnswGraph
EMPTY, UNKNOWN_MAX_CONN -
Method Summary
Modifier and TypeMethodDescriptionintgetNeighbors(int node) Returns theNeighborQueueconnected to the given node.getNodesOnLevel(int level) intmaxConn()intintintstatic NeighborQueuesearch(float[] query, int topK, int numSeed, FloatVectorValues vectors, VectorSimilarityFunction similarityFunction, HnswGraph graphValues, Bits acceptOrds, long visitedLimit, SplittableRandom random) Searches for the nearest neighbors of a query vector.voidseek(int level, int targetNode) intsize()
-
Method Details
-
search
public static NeighborQueue search(float[] query, int topK, int numSeed, FloatVectorValues vectors, VectorSimilarityFunction similarityFunction, HnswGraph graphValues, Bits acceptOrds, long visitedLimit, SplittableRandom random) throws IOException Searches for the nearest neighbors of a query vector.- Parameters:
query- search query vectortopK- the number of nodes to be returnednumSeed- the size of the queue maintained while searching, and controls the number of random entry points to samplevectors- vector valuesgraphValues- the graph values. May represent the entire graph, or a level in a hierarchical graph.acceptOrds-Bitsthat represents the allowed document ordinals to match, ornullif they are all allowed to match.random- a source of randomness, used for generating entry points to the graph- Returns:
- a priority queue holding the closest neighbors found
- Throws:
IOException
-
getNeighbors
Returns theNeighborQueueconnected to the given node.- Parameters:
node- the node whose neighbors are returned
-
size
public int size() -
seek
public void seek(int level, int targetNode) -
nextNeighbor
public int nextNeighbor()- Specified by:
nextNeighborin classHnswGraph
-
neighborCount
public int neighborCount()- Specified by:
neighborCountin classHnswGraph
-
maxConn
public int maxConn() -
numLevels
public int numLevels() -
entryNode
public int entryNode() -
getNodesOnLevel
- Specified by:
getNodesOnLevelin classHnswGraph
-