Class Lucene90OnHeapHnswGraph
- java.lang.Object
-
- org.apache.lucene.util.hnsw.HnswGraph
-
- org.apache.lucene.backward_codecs.lucene90.Lucene90OnHeapHnswGraph
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.util.hnsw.HnswGraph
HnswGraph.NodesIterator
-
-
Field Summary
Fields Modifier and Type Field Description private Lucene90NeighborArraycurprivate java.util.List<Lucene90NeighborArray>graphprivate intmaxConnprivate intupto
-
Constructor Summary
Constructors Constructor Description Lucene90OnHeapHnswGraph(int maxConn)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) intaddNode()intentryNode()Returns graph's entry point on the top level *Lucene90NeighborArraygetNeighbors(int node)Returns theNeighborQueueconnected to the given node.HnswGraph.NodesIteratorgetNodesOnLevel(int level)Get all nodes on a given level as node 0th ordinalsintnextNeighbor()Iterates over the neighbor list.intnumLevels()Returns the number of levels of the graphstatic NeighborQueuesearch(float[] query, int topK, int numSeed, RandomAccessVectorValues vectors, VectorSimilarityFunction similarityFunction, HnswGraph graphValues, Bits acceptOrds, int visitedLimit, java.util.SplittableRandom random)Searches for the nearest neighbors of a query vector.voidseek(int level, int targetNode)Move the pointer to exactly the givenlevel'starget.intsize()Returns the number of nodes in the graph
-
-
-
Field Detail
-
maxConn
private final int maxConn
-
graph
private final java.util.List<Lucene90NeighborArray> graph
-
upto
private int upto
-
cur
private Lucene90NeighborArray cur
-
-
Method Detail
-
search
public static NeighborQueue search(float[] query, int topK, int numSeed, RandomAccessVectorValues vectors, VectorSimilarityFunction similarityFunction, HnswGraph graphValues, Bits acceptOrds, int visitedLimit, java.util.SplittableRandom random) throws java.io.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:
java.io.IOException
-
getNeighbors
public Lucene90NeighborArray getNeighbors(int node)
Returns theNeighborQueueconnected to the given node.- Parameters:
node- the node whose neighbors are returned
-
size
public int size()
Description copied from class:HnswGraphReturns the number of nodes in the graph
-
addNode
int addNode()
-
seek
public void seek(int level, int targetNode)Description copied from class:HnswGraphMove the pointer to exactly the givenlevel'starget. After this method returns, callHnswGraph.nextNeighbor()to return successive (ordered) connected node ordinals.- Specified by:
seekin classHnswGraph- Parameters:
level- level of the graphtargetNode- ordinal of a node in the graph, must be ≥ 0 and <VectorValues.size().
-
nextNeighbor
public int nextNeighbor()
Description copied from class:HnswGraphIterates over the neighbor list. It is illegal to call this method after it returns NO_MORE_DOCS without callingHnswGraph.seek(int, int), which resets the iterator.- Specified by:
nextNeighborin classHnswGraph- Returns:
- a node ordinal in the graph, or NO_MORE_DOCS if the iteration is complete.
-
numLevels
public int numLevels()
Description copied from class:HnswGraphReturns the number of levels of the graph
-
entryNode
public int entryNode()
Description copied from class:HnswGraphReturns graph's entry point on the top level *
-
getNodesOnLevel
public HnswGraph.NodesIterator getNodesOnLevel(int level)
Description copied from class:HnswGraphGet all nodes on a given level as node 0th ordinals- Specified by:
getNodesOnLevelin classHnswGraph- Parameters:
level- level for which to get all nodes- Returns:
- an iterator over nodes where
nextIntreturns a next node on the level
-
-