Package org.apache.lucene.util.hnsw
Class HnswGraphBuilder<T>
- java.lang.Object
-
- org.apache.lucene.util.hnsw.HnswGraphBuilder<T>
-
-
Field Summary
Fields Modifier and Type Field Description static String
HNSW_COMPONENT
A name for the HNSW component for the info-stream *static long
randSeed
Random seed for level generation; public to expose for testing *
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGraphNode(int node, RandomAccessVectorValues<T> values)
void
addGraphNode(int node, T value)
Inserts a doc with vector value to the graphOnHeapHnswGraph
build(RandomAccessVectorValues<T> vectorsToAdd)
Reads all the vectors from two copies of aRandomAccessVectorValues
.static <T> HnswGraphBuilder<T>
create(RandomAccessVectorValues<T> vectors, VectorEncoding vectorEncoding, VectorSimilarityFunction similarityFunction, int M, int beamWidth, long seed)
static <T> HnswGraphBuilder<T>
create(RandomAccessVectorValues<T> vectors, VectorEncoding vectorEncoding, VectorSimilarityFunction similarityFunction, int M, int beamWidth, long seed, HnswGraph initializerGraph, Map<Integer,Integer> oldToNewOrdinalMap)
OnHeapHnswGraph
getGraph()
void
setInfoStream(InfoStream infoStream)
Set info-stream to output debugging information *
-
-
-
Field Detail
-
HNSW_COMPONENT
public static final String HNSW_COMPONENT
A name for the HNSW component for the info-stream *- See Also:
- Constant Field Values
-
randSeed
public static long randSeed
Random seed for level generation; public to expose for testing *
-
-
Method Detail
-
create
public static <T> HnswGraphBuilder<T> create(RandomAccessVectorValues<T> vectors, VectorEncoding vectorEncoding, VectorSimilarityFunction similarityFunction, int M, int beamWidth, long seed) throws IOException
- Throws:
IOException
-
create
public static <T> HnswGraphBuilder<T> create(RandomAccessVectorValues<T> vectors, VectorEncoding vectorEncoding, VectorSimilarityFunction similarityFunction, int M, int beamWidth, long seed, HnswGraph initializerGraph, Map<Integer,Integer> oldToNewOrdinalMap) throws IOException
- Throws:
IOException
-
build
public OnHeapHnswGraph build(RandomAccessVectorValues<T> vectorsToAdd) throws IOException
Reads all the vectors from two copies of aRandomAccessVectorValues
. Providing two copies enables efficient retrieval without extra data copying, while avoiding collision of the returned values.- Parameters:
vectorsToAdd
- the vectors for which to build a nearest neighbors graph. Must be an independent accessor for the vectors- Throws:
IOException
-
setInfoStream
public void setInfoStream(InfoStream infoStream)
Set info-stream to output debugging information *
-
getGraph
public OnHeapHnswGraph getGraph()
-
addGraphNode
public void addGraphNode(int node, T value) throws IOException
Inserts a doc with vector value to the graph- Throws:
IOException
-
addGraphNode
public void addGraphNode(int node, RandomAccessVectorValues<T> values) throws IOException
- Throws:
IOException
-
-