Package org.apache.lucene.index
Class ByteVectorValues
java.lang.Object
org.apache.lucene.index.KnnVectorValues
org.apache.lucene.index.ByteVectorValues
- Direct Known Subclasses:
OffHeapByteVectorValues,QuantizedByteVectorValues,QuantizedByteVectorValues
This class provides access to per-document floating point vector values indexed as
KnnByteVectorField.- 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.index.KnnVectorValues
KnnVectorValues.DocIndexIterator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckField(LeafReader in, String field) Checks the Vector Encoding of a fieldabstract ByteVectorValuescopy()Creates a new copy of thisKnnVectorValues.static ByteVectorValuesCreates aByteVectorValuesfrom a list of byte arrays.The vector encoding of these values.rescorer(byte[] target) Rescore using the given query vector and the currentByteVectorValues.scorer(byte[] query) Return aVectorScorerfor the given query vector.abstract byte[]vectorValue(int ord) Return the vector value for the given vector ordinal which must be in [0, size() - 1], otherwise IndexOutOfBoundsException is thrown.Methods inherited from class org.apache.lucene.index.KnnVectorValues
createDenseIterator, createSparseIterator, dimension, fromDISI, getAcceptOrds, getVectorByteLength, iterator, ordToDoc, size
-
Constructor Details
-
ByteVectorValues
protected ByteVectorValues()Sole constructor
-
-
Method Details
-
vectorValue
Return the vector value for the given vector ordinal which must be in [0, size() - 1], otherwise IndexOutOfBoundsException is thrown. The returned array may be shared across calls.- Returns:
- the vector value
- Throws:
IOException
-
copy
Description copied from class:KnnVectorValuesCreates a new copy of thisKnnVectorValues. This is helpful when you need to access different values at once, to avoid overwriting the underlying vector returned.- Specified by:
copyin classKnnVectorValues- Throws:
IOException
-
checkField
Checks the Vector Encoding of a field- Throws:
IllegalStateException- iffieldhas vectors, but using a different encoding- WARNING: This API is experimental and might change in incompatible ways in the next release.
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
scorer
Return aVectorScorerfor the given query vector. When the underlying format quantizes the vectors, this will return aVectorScorerthat scores against the quantized vectors.- Parameters:
query- the query vector- Returns:
- a
VectorScorerinstance or null - Throws:
IOException
-
rescorer
Rescore using the given query vector and the currentByteVectorValues. This is unique from scorer() in that it is explicitly for rescoring an existing set of hits and thus will often utilize the highest fidelity scoring algorithm available. This is useful when the initial search used a quantized index or an approximate scoring algorithm, and now we want to rescore the hits using the full fidelity vectors. The default implementation is to callscorer(byte[])assuming that the scorer is already the highest fidelity implementation available.- Parameters:
target- the query vector- Returns:
- a
VectorScorerinstance or null - Throws:
IOException- if an I/O error occurs
-
getEncoding
Description copied from class:KnnVectorValuesThe vector encoding of these values.- Specified by:
getEncodingin classKnnVectorValues
-
fromBytes
Creates aByteVectorValuesfrom a list of byte arrays.- Parameters:
vectors- the list of byte arraysdim- the dimension of the vectors- Returns:
- a
ByteVectorValuesinstancec
-