Package org.apache.lucene.util.hnsw
Interface HnswBuilder
- All Known Implementing Classes:
HnswConcurrentMergeBuilder,HnswGraphBuilder,InitializedHnswGraphBuilder,MergingHnswGraphBuilder
public interface HnswBuilder
Interface for builder building the
OnHeapHnswGraph- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddGraphNode(int node) Inserts a doc with a vector value to the graphvoidaddGraphNode(int node, IntHashSet eps) Inserts a doc with a vector value to the graph, searching on level 0 with provided entry pointsbuild(int maxOrd) Adds all nodes to the graph up to the providedmaxOrd.Once this method is called, no further updates to the graph are accepted (addGraphNode will throw IllegalStateException).getGraph()voidsetAbortCheck(IORunnable abortCheck) Sets a check that is invoked before every node insertion during graph construction.voidsetInfoStream(InfoStream infoStream) Set info-stream to output debugging information
-
Method Details
-
build
Adds all nodes to the graph up to the providedmaxOrd.- Parameters:
maxOrd- The maximum ordinal (excluded) of the nodes to be added.- Throws:
IOException
-
addGraphNode
Inserts a doc with a vector value to the graph- Throws:
IOException
-
addGraphNode
Inserts a doc with a vector value to the graph, searching on level 0 with provided entry points- Throws:
IOException
-
setInfoStream
Set info-stream to output debugging information -
setAbortCheck
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.MergeAbortedExceptionwhen the merge that triggered the build has been aborted.The check must be non-null and can be set at most once.
- Throws:
IllegalStateException- if the check was already set
-
getGraph
OnHeapHnswGraph getGraph() -
getCompletedGraph
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.- Throws:
IOException
-