Package org.apache.lucene.util.hnsw
Interface RandomAccessVectorValues
-
- All Known Subinterfaces:
RandomAccessQuantizedByteVectorValues
,RandomAccessVectorValues.Bytes
,RandomAccessVectorValues.Floats
- All Known Implementing Classes:
OffHeapByteVectorValues
,OffHeapByteVectorValues.DenseOffHeapVectorValues
,OffHeapFloatVectorValues
,OffHeapFloatVectorValues.DenseOffHeapVectorValues
,OffHeapQuantizedByteVectorValues
,OffHeapQuantizedByteVectorValues.DenseOffHeapVectorValues
public interface RandomAccessVectorValues
Provides random access to vectors by dense ordinal. This interface is used by HNSW-based implementations of KNN search.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
RandomAccessVectorValues.Bytes
Byte vector values.static interface
RandomAccessVectorValues.Floats
Float vector values.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description RandomAccessVectorValues
copy()
Creates a new copy of thisRandomAccessVectorValues
.int
dimension()
Return the dimension of the returned vector valuesstatic RandomAccessVectorValues.Bytes
fromBytes(List<byte[]> vectors, int dim)
Creates aRandomAccessVectorValues.Bytes
from a list of byte arrays.static RandomAccessVectorValues.Floats
fromFloats(List<float[]> vectors, int dim)
Creates aRandomAccessVectorValues.Floats
from a list of float arrays.default Bits
getAcceptOrds(Bits acceptDocs)
Returns theBits
representing live documents.default IndexInput
getSlice()
Returns a slice of the underlyingIndexInput
that contains the vector values if availableint
getVectorByteLength()
Returns the byte length of the vector values.default int
ordToDoc(int ord)
Translates vector ordinal to the correct document ID.int
size()
Return the number of vector values
-
-
-
Method Detail
-
size
int size()
Return the number of vector values
-
dimension
int dimension()
Return the dimension of the returned vector values
-
copy
RandomAccessVectorValues copy() throws IOException
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
default IndexInput getSlice()
Returns a slice of the underlyingIndexInput
that 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
default Bits getAcceptOrds(Bits acceptDocs)
Returns theBits
representing live documents. By default, this is an identity function.- Parameters:
acceptDocs
- the accept docs- Returns:
- the accept docs
-
fromFloats
static RandomAccessVectorValues.Floats fromFloats(List<float[]> vectors, int dim)
Creates aRandomAccessVectorValues.Floats
from a list of float arrays.- Parameters:
vectors
- the list of float arraysdim
- the dimension of the vectors- Returns:
- a
RandomAccessVectorValues.Floats
instance
-
fromBytes
static RandomAccessVectorValues.Bytes fromBytes(List<byte[]> vectors, int dim)
Creates aRandomAccessVectorValues.Bytes
from a list of byte arrays.- Parameters:
vectors
- the list of byte arraysdim
- the dimension of the vectors- Returns:
- a
RandomAccessVectorValues.Bytes
instance
-
-