- java.lang.Object
-
- org.apache.lucene.util.hnsw.HnswConcurrentMergeBuilder
-
- All Implemented Interfaces:
HnswBuilder
public class HnswConcurrentMergeBuilder extends java.lang.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
HnswConcurrentMergeBuilder.ConcurrentMergeWorker
private static class
HnswConcurrentMergeBuilder.MergeSearcher
This searcher will obtain the lock and make a copy of neighborArray when seeking the graph such that concurrent modification of the graph will not impact the search
-
Field Summary
Fields Modifier and Type Field Description private static int
DEFAULT_BATCH_SIZE
private InfoStream
infoStream
private TaskExecutor
taskExecutor
private HnswConcurrentMergeBuilder.ConcurrentMergeWorker[]
workers
-
Constructor Summary
Constructors Constructor Description HnswConcurrentMergeBuilder(TaskExecutor taskExecutor, int numWorker, RandomVectorScorerSupplier scorerSupplier, int M, int beamWidth, OnHeapHnswGraph hnsw, BitSet initializedNodes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGraphNode(int node)
Inserts a doc with vector value to the graphOnHeapHnswGraph
build(int maxOrd)
Adds all nodes to the graph up to the providedmaxOrd
.OnHeapHnswGraph
getGraph()
(package private) void
setBatchSize(int newSize)
void
setInfoStream(InfoStream infoStream)
Set info-stream to output debugging information
-
-
-
Field Detail
-
DEFAULT_BATCH_SIZE
private static final int DEFAULT_BATCH_SIZE
- See Also:
- Constant Field Values
-
taskExecutor
private final TaskExecutor taskExecutor
-
workers
private final HnswConcurrentMergeBuilder.ConcurrentMergeWorker[] workers
-
infoStream
private InfoStream infoStream
-
-
Constructor Detail
-
HnswConcurrentMergeBuilder
public HnswConcurrentMergeBuilder(TaskExecutor taskExecutor, int numWorker, RandomVectorScorerSupplier scorerSupplier, int M, int beamWidth, OnHeapHnswGraph hnsw, BitSet initializedNodes) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
build
public OnHeapHnswGraph build(int maxOrd) throws java.io.IOException
Description copied from interface:HnswBuilder
Adds all nodes to the graph up to the providedmaxOrd
.- Specified by:
build
in interfaceHnswBuilder
- Parameters:
maxOrd
- The maximum ordinal (excluded) of the nodes to be added.- Throws:
java.io.IOException
-
addGraphNode
public void addGraphNode(int node) throws java.io.IOException
Description copied from interface:HnswBuilder
Inserts a doc with vector value to the graph- Specified by:
addGraphNode
in interfaceHnswBuilder
- Throws:
java.io.IOException
-
setInfoStream
public void setInfoStream(InfoStream infoStream)
Description copied from interface:HnswBuilder
Set info-stream to output debugging information- Specified by:
setInfoStream
in interfaceHnswBuilder
-
getGraph
public OnHeapHnswGraph getGraph()
- Specified by:
getGraph
in interfaceHnswBuilder
-
setBatchSize
void setBatchSize(int newSize)
-
-