Package org.apache.lucene.util.hnsw
Class InitializedHnswGraphBuilder
java.lang.Object
org.apache.lucene.util.hnsw.HnswGraphBuilder
org.apache.lucene.util.hnsw.InitializedHnswGraphBuilder
- All Implemented Interfaces:
HnswBuilder
This creates a graph builder that is initialized with the provided HnswGraph. This is useful for
merging HnswGraphs from multiple segments.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.util.hnsw.HnswGraphBuilder
HnswGraphBuilder.GraphBuilderKnnCollector -
Field Summary
Fields inherited from class org.apache.lucene.util.hnsw.HnswGraphBuilder
DEFAULT_BEAM_WIDTH, DEFAULT_MAX_CONN, frozen, hnsw, HNSW_COMPONENT, hnswLock, infoStream, randSeed, scorerSupplier -
Constructor Summary
ConstructorsConstructorDescriptionInitializedHnswGraphBuilder(RandomVectorScorerSupplier scorerSupplier, int M, int beamWidth, long seed, OnHeapHnswGraph initializedGraph, BitSet initializedNodes) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGraphNode(int node) Inserts a doc with vector value to the graphvoidaddGraphNode(int node, UpdateableRandomVectorScorer scorer) static InitializedHnswGraphBuilderfromGraph(RandomVectorScorerSupplier scorerSupplier, int M, int beamWidth, long seed, HnswGraph initializerGraph, int[] newOrdMap, BitSet initializedNodes, int totalNumberOfVectors) Create a new HnswGraphBuilder that is initialized with the provided HnswGraph.static OnHeapHnswGraphMethods inherited from class org.apache.lucene.util.hnsw.HnswGraphBuilder
addGraphNodeWithEps, addVectors, build, create, create, getCompletedGraph, getGraph, setInfoStream
-
Constructor Details
-
InitializedHnswGraphBuilder
public InitializedHnswGraphBuilder(RandomVectorScorerSupplier scorerSupplier, int M, int beamWidth, long seed, OnHeapHnswGraph initializedGraph, BitSet initializedNodes) throws IOException - Throws:
IOException
-
-
Method Details
-
fromGraph
public static InitializedHnswGraphBuilder fromGraph(RandomVectorScorerSupplier scorerSupplier, int M, int beamWidth, long seed, HnswGraph initializerGraph, int[] newOrdMap, BitSet initializedNodes, int totalNumberOfVectors) throws IOException Create a new HnswGraphBuilder that is initialized with the provided HnswGraph.- Parameters:
scorerSupplier- the scorer to use for vectorsM- the number of connections to keep per nodebeamWidth- the number of nodes to explore in the searchseed- the seed for the random number generatorinitializerGraph- the graph to initialize the new graph buildernewOrdMap- a mapping from the old node ordinal to the new node ordinalinitializedNodes- a bitset of nodes that are already initialized in the initializerGraphtotalNumberOfVectors- the total number of vectors in the new graph, this should include all vectors expected to be added to the graph in the future- Returns:
- a new HnswGraphBuilder that is initialized with the provided HnswGraph
- Throws:
IOException- when reading the graph fails
-
initGraph
public static OnHeapHnswGraph initGraph(int M, HnswGraph initializerGraph, int[] newOrdMap, int totalNumberOfVectors) throws IOException - Throws:
IOException
-
addGraphNode
- Overrides:
addGraphNodein classHnswGraphBuilder- Throws:
IOException
-
addGraphNode
Description copied from interface:HnswBuilderInserts a doc with vector value to the graph- Specified by:
addGraphNodein interfaceHnswBuilder- Overrides:
addGraphNodein classHnswGraphBuilder- Throws:
IOException
-