Package org.apache.lucene.codecs.hnsw
Class PrefetchableFlatVectorScorer
java.lang.Object
org.apache.lucene.codecs.hnsw.PrefetchableFlatVectorScorer
- All Implemented Interfaces:
FlatVectorsScorer
A
FlatVectorsScorer wrapper that enables prefetching of vector data before scoring.
This implementation demonstrates how to use prefetch operations with KNN search to preload vectors into memory before distance computations, potentially improving performance by reducing memory access latency during bulk scoring operations.
The prefetching occurs in RandomVectorScorer.bulkScore(int[], float[], int) before delegating
to the underlying scorer.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Constructor Summary
ConstructorsConstructorDescriptionPrefetchableFlatVectorScorer(FlatVectorsScorer flatVectorsScorer) Constructs a new prefetchable scorer wrapper. -
Method Summary
Modifier and TypeMethodDescriptiongetRandomVectorScorer(VectorSimilarityFunction similarityFunction, KnnVectorValues vectorValues, byte[] target) Returns aRandomVectorScorerfor the given set of vectors and target vector.getRandomVectorScorer(VectorSimilarityFunction similarityFunction, KnnVectorValues vectorValues, float[] target) Returns aRandomVectorScorerfor the given set of vectors and target vector.getRandomVectorScorerSupplier(VectorSimilarityFunction similarityFunction, KnnVectorValues vectorValues) Returns aRandomVectorScorerSupplierthat can be used to score vectorstoString()
-
Constructor Details
-
PrefetchableFlatVectorScorer
Constructs a new prefetchable scorer wrapper.- Parameters:
flatVectorsScorer- the underlying scorer to delegate to
-
-
Method Details
-
getRandomVectorScorerSupplier
public RandomVectorScorerSupplier getRandomVectorScorerSupplier(VectorSimilarityFunction similarityFunction, KnnVectorValues vectorValues) throws IOException Description copied from interface:FlatVectorsScorerReturns aRandomVectorScorerSupplierthat can be used to score vectors- Specified by:
getRandomVectorScorerSupplierin interfaceFlatVectorsScorer- Parameters:
similarityFunction- the similarity function to usevectorValues- the vector values to score- Returns:
- a
RandomVectorScorerSupplierthat can be used to score vectors - Throws:
IOException- if an I/O error occurs
-
getRandomVectorScorer
public RandomVectorScorer getRandomVectorScorer(VectorSimilarityFunction similarityFunction, KnnVectorValues vectorValues, float[] target) throws IOException Description copied from interface:FlatVectorsScorerReturns aRandomVectorScorerfor the given set of vectors and target vector.- Specified by:
getRandomVectorScorerin interfaceFlatVectorsScorer- Parameters:
similarityFunction- the similarity function to usevectorValues- the vector values to scoretarget- the target vector- Returns:
- a
RandomVectorScorerfor the given field and target vector. - Throws:
IOException- if an I/O error occurs when reading from the index.
-
getRandomVectorScorer
public RandomVectorScorer getRandomVectorScorer(VectorSimilarityFunction similarityFunction, KnnVectorValues vectorValues, byte[] target) throws IOException Description copied from interface:FlatVectorsScorerReturns aRandomVectorScorerfor the given set of vectors and target vector.- Specified by:
getRandomVectorScorerin interfaceFlatVectorsScorer- Parameters:
similarityFunction- the similarity function to usevectorValues- the vector values to scoretarget- the target vector- Returns:
- a
RandomVectorScorerfor the given field and target vector. - Throws:
IOException- if an I/O error occurs when reading from the index.
-
toString
-