HnswConcurrentMergeBuilder (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.util.hnsw, class: HnswConcurrentMergeBuilder

Package org.apache.lucene.util.hnsw

# Class HnswConcurrentMergeBuilder

java.lang.Object
org.apache.lucene.util.hnsw.HnswConcurrentMergeBuilder

All Implemented Interfaces:
  `HnswBuilder`

public class HnswConcurrentMergeBuilder extends Object implements HnswBuilder
A graph builder that manages multiple workers, it only supports adding the whole graph all at once. It will spawn a thread for each worker and the workers will pick the work in batches.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `HnswConcurrentMergeBuilder(TaskExecutor taskExecutor, int numWorker, RandomVectorScorerSupplier scorerSupplier, int M, int beamWidth, OnHeapHnswGraph hnsw, BitSet initializedNodes)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addGraphNode(int node)`
  Inserts a doc with a vector value to the graph
  `void`
  `addGraphNode(int node, IntHashSet eps)`
  Inserts a doc with a vector value to the graph, searching on level 0 with provided entry points
  `OnHeapHnswGraph`
  `build(int maxOrd)`
  Adds all nodes to the graph up to the provided `maxOrd`.
  `OnHeapHnswGraph`
  `getCompletedGraph()`
  Once this method is called, no further updates to the graph are accepted (addGraphNode will throw IllegalStateException).
  `OnHeapHnswGraph`
  `getGraph()`
  `void`
  `setAbortCheck(IORunnable abortCheck)`
  Sets a check that is invoked before every node insertion during graph construction.
  `void`
  `setInfoStream(InfoStream infoStream)`
  Set info-stream to output debugging information

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

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

- ## Constructor Details

  - ### HnswConcurrentMergeBuilder

    public HnswConcurrentMergeBuilder(TaskExecutor taskExecutor, int numWorker, RandomVectorScorerSupplier scorerSupplier, int M, int beamWidth, OnHeapHnswGraph hnsw, BitSet initializedNodes) throws IOException
    Throws:
      `IOException`

- ## Method Details

  - ### build

    public OnHeapHnswGraph build(int maxOrd) throws IOException
    Description copied from interface: `HnswBuilder`
    Adds all nodes to the graph up to the provided `maxOrd`.
    Specified by:
      `build` in interface `HnswBuilder`
    Parameters:
      `maxOrd` - The maximum ordinal (excluded) of the nodes to be added.
    Throws:
      `IOException`

  - ### addGraphNode

    public void addGraphNode(int node) throws IOException
    Description copied from interface: `HnswBuilder`
    Inserts a doc with a vector value to the graph
    Specified by:
      `addGraphNode` in interface `HnswBuilder`
    Throws:
      `IOException`

  - ### addGraphNode

    public void addGraphNode(int node, IntHashSet eps) throws IOException
    Description copied from interface: `HnswBuilder`
    Inserts a doc with a vector value to the graph, searching on level 0 with provided entry points
    Specified by:
      `addGraphNode` in interface `HnswBuilder`
    Throws:
      `IOException`

  - ### setInfoStream

    public void setInfoStream(InfoStream infoStream)
    Description copied from interface: `HnswBuilder`
    Set info-stream to output debugging information
    Specified by:
      `setInfoStream` in interface `HnswBuilder`

  - ### setAbortCheck

    public void setAbortCheck(IORunnable abortCheck)
    Description copied from interface: `HnswBuilder`
    Sets a check that is invoked before every node insertion during graph construction. The check may throw an exception to abort the build promptly, e.g. `MergePolicy.MergeAbortedException` when the merge that triggered the build has been aborted.

    The check must be non-null and can be set at most once.

    Specified by:
      `setAbortCheck` in interface `HnswBuilder`

  - ### getCompletedGraph

    public OnHeapHnswGraph getCompletedGraph() throws IOException
    Description copied from interface: `HnswBuilder`
    Once this method is called, no further updates to the graph are accepted (addGraphNode will throw IllegalStateException). Final modifications to the graph (eg patching up disconnected components, re-ordering node ids for better delta compression) may be triggered, so callers should expect this call to take some time.
    Specified by:
      `getCompletedGraph` in interface `HnswBuilder`
    Throws:
      `IOException`

  - ### getGraph

    public OnHeapHnswGraph getGraph()
    Specified by:
      `getGraph` in interface `HnswBuilder`