Package org.apache.lucene.index
Class KnnVectorValues
java.lang.Object
org.apache.lucene.index.KnnVectorValues
- Direct Known Subclasses:
ByteVectorValues
,FloatVectorValues
This class abstracts addressing of document vector values indexed as
KnnFloatVectorField
or KnnByteVectorField
.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A DocIdSetIterator that also provides an index() method tracking a distinct ordinal for a vector associated with each doc. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract KnnVectorValues
copy()
Creates a new copy of thisKnnVectorValues
.protected KnnVectorValues.DocIndexIterator
Creates an iterator for instances where every doc has a value, and the value ordinals are equal to the docids.protected KnnVectorValues.DocIndexIterator
Creates an iterator from this instance's ordinal-to-docid mapping which must be monotonic (docid increases when ordinal does).abstract int
Return the dimension of the vectorsprotected static KnnVectorValues.DocIndexIterator
fromDISI
(DocIdSetIterator docsWithField) Creates an iterator from a DocIdSetIterator indicating which docs have values, and for which ordinals increase monotonically with docid.getAcceptOrds
(Bits acceptDocs) Returns a Bits accepting docs accepted by the argument and having a vector valueabstract VectorEncoding
The vector encoding of these values.int
Returns the vector byte length, defaults to dimension multiplied by float byte sizeiterator()
Create an iterator for this instance.int
ordToDoc
(int ord) Return the docid of the document indexed with the given vector ordinal.abstract int
size()
Return the number of vectors for this field.
-
Constructor Details
-
KnnVectorValues
public KnnVectorValues()
-
-
Method Details
-
dimension
public abstract int dimension()Return the dimension of the vectors -
size
public abstract int size()Return the number of vectors for this field.- Returns:
- the number of vectors returned by this iterator
-
ordToDoc
public int ordToDoc(int ord) Return the docid of the document indexed with the given vector ordinal. This default implementation returns the argument and is appropriate for dense values implementations where every doc has a single value. -
copy
Creates a new copy of thisKnnVectorValues
. This is helpful when you need to access different values at once, to avoid overwriting the underlying vector returned.- Throws:
IOException
-
getVectorByteLength
public int getVectorByteLength()Returns the vector byte length, defaults to dimension multiplied by float byte size -
getEncoding
The vector encoding of these values. -
getAcceptOrds
Returns a Bits accepting docs accepted by the argument and having a vector value -
iterator
Create an iterator for this instance. -
createDenseIterator
Creates an iterator for instances where every doc has a value, and the value ordinals are equal to the docids. -
fromDISI
Creates an iterator from a DocIdSetIterator indicating which docs have values, and for which ordinals increase monotonically with docid. -
createSparseIterator
Creates an iterator from this instance's ordinal-to-docid mapping which must be monotonic (docid increases when ordinal does).
-