Module org.apache.lucene.core
Package org.apache.lucene.util.hnsw
Interface RandomAccessVectorValues
- All Known Subinterfaces:
RandomAccessQuantizedByteVectorValues,RandomAccessVectorValues.Bytes,RandomAccessVectorValues.Floats
- All Known Implementing Classes:
Lucene90HnswVectorsReader.OffHeapFloatVectorValues,Lucene91HnswVectorsReader.OffHeapFloatVectorValues,OffHeapByteVectorValues,OffHeapByteVectorValues,OffHeapByteVectorValues.DenseOffHeapVectorValues,OffHeapByteVectorValues.DenseOffHeapVectorValues,OffHeapByteVectorValues.EmptyOffHeapVectorValues,OffHeapByteVectorValues.EmptyOffHeapVectorValues,OffHeapByteVectorValues.SparseOffHeapVectorValues,OffHeapByteVectorValues.SparseOffHeapVectorValues,OffHeapFloatVectorValues,OffHeapFloatVectorValues,OffHeapFloatVectorValues,OffHeapFloatVectorValues.DenseOffHeapVectorValues,OffHeapFloatVectorValues.DenseOffHeapVectorValues,OffHeapFloatVectorValues.DenseOffHeapVectorValues,OffHeapFloatVectorValues.EmptyOffHeapVectorValues,OffHeapFloatVectorValues.EmptyOffHeapVectorValues,OffHeapFloatVectorValues.EmptyOffHeapVectorValues,OffHeapFloatVectorValues.SparseOffHeapVectorValues,OffHeapFloatVectorValues.SparseOffHeapVectorValues,OffHeapFloatVectorValues.SparseOffHeapVectorValues,OffHeapQuantizedByteVectorValues,OffHeapQuantizedByteVectorValues.DenseOffHeapVectorValues,OffHeapQuantizedByteVectorValues.EmptyOffHeapVectorValues,OffHeapQuantizedByteVectorValues.SparseOffHeapVectorValues,Word2VecModel
public interface RandomAccessVectorValues
Provides random access to vectors by dense ordinal. This interface is used by HNSW-based
implementations of KNN search.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceByte vector values.static interfaceFloat vector values. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a new copy of thisRandomAccessVectorValues.intReturn the dimension of the returned vector valuesCreates aRandomAccessVectorValues.Bytesfrom a list of byte arrays.fromFloats(List<float[]> vectors, int dim) Creates aRandomAccessVectorValues.Floatsfrom a list of float arrays.default BitsgetAcceptOrds(Bits acceptDocs) Returns theBitsrepresenting live documents.default IndexInputgetSlice()Returns a slice of the underlyingIndexInputthat contains the vector values if availableintReturns the byte length of the vector values.default intordToDoc(int ord) Translates vector ordinal to the correct document ID.intsize()Return the number of vector values
-
Method Details
-
size
int size()Return the number of vector values -
dimension
int dimension()Return the dimension of the returned vector values -
copy
Creates a new copy of thisRandomAccessVectorValues. This is helpful when you need to access different values at once, to avoid overwriting the underlying vector returned.- Throws:
IOException
-
getSlice
Returns a slice of the underlyingIndexInputthat contains the vector values if available -
getVectorByteLength
int getVectorByteLength()Returns the byte length of the vector values. -
ordToDoc
default int ordToDoc(int ord) Translates vector ordinal to the correct document ID. By default, this is an identity function.- Parameters:
ord- the vector ordinal- Returns:
- the document Id for that vector ordinal
-
getAcceptOrds
Returns theBitsrepresenting live documents. By default, this is an identity function.- Parameters:
acceptDocs- the accept docs- Returns:
- the accept docs
-
fromFloats
Creates aRandomAccessVectorValues.Floatsfrom a list of float arrays.- Parameters:
vectors- the list of float arraysdim- the dimension of the vectors- Returns:
- a
RandomAccessVectorValues.Floatsinstance
-
fromBytes
Creates aRandomAccessVectorValues.Bytesfrom a list of byte arrays.- Parameters:
vectors- the list of byte arraysdim- the dimension of the vectors- Returns:
- a
RandomAccessVectorValues.Bytesinstance
-