Lucene90OnHeapHnswGraph (Lucene 10.5.1 backward-codecs API)
Description: declaration: package: org.apache.lucene.backward_codecs.lucene90, class: Lucene90OnHeapHnswGraph

Package org.apache.lucene.backward_codecs.lucene90

# Class Lucene90OnHeapHnswGraph

java.lang.Object
org.apache.lucene.util.hnsw.HnswGraph
org.apache.lucene.backward_codecs.lucene90.Lucene90OnHeapHnswGraph

public final class Lucene90OnHeapHnswGraph extends HnswGraph
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.DenseNodesIterator, HnswGraph.NodesIterator`

- ## Field Summary

  ### Fields inherited from class org.apache.lucene.util.hnsw.HnswGraph

  `EMPTY, UNKNOWN_MAX_CONN`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `entryNode()`
  `Lucene90NeighborArray`
  `getNeighbors(int node)`
  Returns the `NeighborQueue` connected to the given node.
  `HnswGraph.NodesIterator`
  `getNodesOnLevel(int level)`
  `int`
  `maxConn()`
  `int`
  `neighborCount()`
  `int`
  `nextNeighbor()`
  `int`
  `numLevels()`
  `static NeighborQueue`
  `search(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.
  `void`
  `seek(int level, int targetNode)`
  `int`
  `size()`

  ### Methods inherited from class org.apache.lucene.util.hnsw.HnswGraph

  `getSortedNodes, maxNodeId`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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 vector
      `topK` - the number of nodes to be returned
      `numSeed` - the size of the queue maintained while searching, and controls the number of random entry points to sample
      `vectors` - vector values
      `graphValues` - the graph values. May represent the entire graph, or a level in a hierarchical graph.
      `acceptOrds` - `Bits` that represents the allowed document ordinals to match, or `null` if 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

    public Lucene90NeighborArray getNeighbors(int node)
    Returns the `NeighborQueue` connected to the given node.
    Parameters:
      `node` - the node whose neighbors are returned

  - ### size

    public int size()
    Specified by:
      `size` in class `HnswGraph`

  - ### seek

    public void seek(int level, int targetNode)
    Specified by:
      `seek` in class `HnswGraph`

  - ### nextNeighbor

    public int nextNeighbor()
    Specified by:
      `nextNeighbor` in class `HnswGraph`

  - ### neighborCount

    public int neighborCount()
    Specified by:
      `neighborCount` in class `HnswGraph`

  - ### maxConn

    public int maxConn()
    Specified by:
      `maxConn` in class `HnswGraph`

  - ### numLevels

    public int numLevels()
    Specified by:
      `numLevels` in class `HnswGraph`

  - ### entryNode

    public int entryNode()
    Specified by:
      `entryNode` in class `HnswGraph`

  - ### getNodesOnLevel

    public HnswGraph.NodesIterator getNodesOnLevel(int level)
    Specified by:
      `getNodesOnLevel` in class `HnswGraph`