Package org.apache.lucene.codecs.hnsw
Class FlatVectorsReader
- java.lang.Object
-
- org.apache.lucene.codecs.hnsw.FlatVectorsReader
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Accountable
- Direct Known Subclasses:
Lucene99FlatVectorsReader,Lucene99ScalarQuantizedVectorsReader
public abstract class FlatVectorsReader extends Object implements Closeable, Accountable
Reads vectors from an index. When searching this reader, it iterates every vector in the index and scores themThis class is useful when:
- the number of vectors is small
- when used along side some additional indexing structure that can be used to better search the vectors (like HNSW).
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Field Summary
Fields Modifier and Type Field Description protected FlatVectorsScorervectorScorerScorer for flat vectors-
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFlatVectorsReader(FlatVectorsScorer vectorsScorer)Sole constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidcheckIntegrity()Checks consistency of this reader.abstract ByteVectorValuesgetByteVectorValues(String field)Returns theByteVectorValuesfor the givenfield.FlatVectorsScorergetFlatVectorScorer()abstract FloatVectorValuesgetFloatVectorValues(String field)Returns theFloatVectorValuesfor the givenfield.abstract RandomVectorScorergetRandomVectorScorer(String field, byte[] target)Returns aRandomVectorScorerfor the given field and target vector.abstract RandomVectorScorergetRandomVectorScorer(String field, float[] target)Returns aRandomVectorScorerfor the given field and target vector.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.lucene.util.Accountable
getChildResources, ramBytesUsed
-
-
-
-
Field Detail
-
vectorScorer
protected final FlatVectorsScorer vectorScorer
Scorer for flat vectors
-
-
Constructor Detail
-
FlatVectorsReader
protected FlatVectorsReader(FlatVectorsScorer vectorsScorer)
Sole constructor
-
-
Method Detail
-
getFlatVectorScorer
public FlatVectorsScorer getFlatVectorScorer()
- Returns:
- the
FlatVectorsScorerfor this reader.
-
getRandomVectorScorer
public abstract RandomVectorScorer getRandomVectorScorer(String field, float[] target) throws IOException
Returns aRandomVectorScorerfor the given field and target vector.- Parameters:
field- the field to searchtarget- 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 abstract RandomVectorScorer getRandomVectorScorer(String field, byte[] target) throws IOException
Returns aRandomVectorScorerfor the given field and target vector.- Parameters:
field- the field to searchtarget- 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.
-
checkIntegrity
public abstract void checkIntegrity() throws IOExceptionChecks consistency of this reader.Note that this may be costly in terms of I/O, e.g. may involve computing a checksum value against large data files.
- Throws:
IOException- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
getFloatVectorValues
public abstract FloatVectorValues getFloatVectorValues(String field) throws IOException
Returns theFloatVectorValuesfor the givenfield. The behavior is undefined if the given field doesn't have KNN vectors enabled on itsFieldInfo. The return value is nevernull.- Throws:
IOException
-
getByteVectorValues
public abstract ByteVectorValues getByteVectorValues(String field) throws IOException
Returns theByteVectorValuesfor the givenfield. The behavior is undefined if the given field doesn't have KNN vectors enabled on itsFieldInfo. The return value is nevernull.- Throws:
IOException
-
-