Class OffHeapVectorValues
- java.lang.Object
-
- org.apache.lucene.search.DocIdSetIterator
-
- org.apache.lucene.index.VectorValues
-
- org.apache.lucene.codecs.lucene92.OffHeapVectorValues
-
- All Implemented Interfaces:
RandomAccessVectorValues
,RandomAccessVectorValuesProducer
- Direct Known Subclasses:
OffHeapVectorValues.DenseOffHeapVectorValues
,OffHeapVectorValues.EmptyOffHeapVectorValues
,OffHeapVectorValues.SparseOffHeapVectorValues
abstract class OffHeapVectorValues extends VectorValues implements RandomAccessVectorValues, RandomAccessVectorValuesProducer
Read the vector values from the index input. This supports both iterated and random access.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
OffHeapVectorValues.DenseOffHeapVectorValues
private static class
OffHeapVectorValues.EmptyOffHeapVectorValues
private static class
OffHeapVectorValues.SparseOffHeapVectorValues
-
Field Summary
Fields Modifier and Type Field Description protected BytesRef
binaryValue
protected java.nio.ByteBuffer
byteBuffer
protected int
byteSize
protected int
dimension
protected int
size
protected IndexInput
slice
protected float[]
value
-
Fields inherited from class org.apache.lucene.index.VectorValues
EMPTY, MAX_DIMENSIONS
-
Fields inherited from class org.apache.lucene.search.DocIdSetIterator
NO_MORE_DOCS
-
-
Constructor Summary
Constructors Constructor Description OffHeapVectorValues(int dimension, int size, IndexInput slice)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description BytesRef
binaryValue(int targetOrd)
Return the vector indexed at the given ordinal value as an array of bytes in a BytesRef; these are the bytes corresponding to the float array.long
cost()
Returns the estimated cost of thisDocIdSetIterator
.int
dimension()
Return the dimension of the vectors(package private) abstract Bits
getAcceptOrds(Bits acceptDocs)
(package private) static OffHeapVectorValues
load(Lucene92HnswVectorsReader.FieldEntry fieldEntry, IndexInput vectorData)
abstract int
ordToDoc(int ord)
private void
readValue(int targetOrd)
int
size()
TODO: should we use cost() for this? We rely on its always being exactly the number of documents having a value for this field, which is not guaranteed by the cost() contract, but in all the implementations so far they are the same.float[]
vectorValue(int targetOrd)
Return the vector value indexed at the given ordinal.-
Methods inherited from class org.apache.lucene.index.VectorValues
binaryValue, vectorValue
-
Methods inherited from class org.apache.lucene.search.DocIdSetIterator
advance, all, docID, empty, nextDoc, range, slowAdvance
-
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.index.RandomAccessVectorValuesProducer
randomAccess
-
-
-
-
Field Detail
-
dimension
protected final int dimension
-
size
protected final int size
-
slice
protected final IndexInput slice
-
binaryValue
protected final BytesRef binaryValue
-
byteBuffer
protected final java.nio.ByteBuffer byteBuffer
-
byteSize
protected final int byteSize
-
value
protected final float[] value
-
-
Constructor Detail
-
OffHeapVectorValues
OffHeapVectorValues(int dimension, int size, IndexInput slice)
-
-
Method Detail
-
dimension
public int dimension()
Description copied from class:VectorValues
Return the dimension of the vectors- Specified by:
dimension
in interfaceRandomAccessVectorValues
- Specified by:
dimension
in classVectorValues
-
size
public int size()
Description copied from class:VectorValues
TODO: should we use cost() for this? We rely on its always being exactly the number of documents having a value for this field, which is not guaranteed by the cost() contract, but in all the implementations so far they are the same.- Specified by:
size
in interfaceRandomAccessVectorValues
- Specified by:
size
in classVectorValues
- Returns:
- the number of vectors returned by this iterator
-
cost
public long cost()
Description copied from class:DocIdSetIterator
Returns the estimated cost of thisDocIdSetIterator
.This is generally an upper bound of the number of documents this iterator might match, but may be a rough heuristic, hardcoded value, or otherwise completely inaccurate.
- Specified by:
cost
in classDocIdSetIterator
-
vectorValue
public float[] vectorValue(int targetOrd) throws java.io.IOException
Description copied from interface:RandomAccessVectorValues
Return the vector value indexed at the given ordinal. The provided floating point array may be shared and overwritten by subsequent calls to this method andRandomAccessVectorValues.binaryValue(int)
.- Specified by:
vectorValue
in interfaceRandomAccessVectorValues
- Parameters:
targetOrd
- a valid ordinal, ≥ 0 and <RandomAccessVectorValues.size()
.- Throws:
java.io.IOException
-
binaryValue
public BytesRef binaryValue(int targetOrd) throws java.io.IOException
Description copied from interface:RandomAccessVectorValues
Return the vector indexed at the given ordinal value as an array of bytes in a BytesRef; these are the bytes corresponding to the float array. The provided bytes may be shared and overwritten by subsequent calls to this method andRandomAccessVectorValues.vectorValue(int)
.- Specified by:
binaryValue
in interfaceRandomAccessVectorValues
- Parameters:
targetOrd
- a valid ordinal, ≥ 0 and <RandomAccessVectorValues.size()
.- Throws:
java.io.IOException
-
readValue
private void readValue(int targetOrd) throws java.io.IOException
- Throws:
java.io.IOException
-
ordToDoc
public abstract int ordToDoc(int ord)
-
load
static OffHeapVectorValues load(Lucene92HnswVectorsReader.FieldEntry fieldEntry, IndexInput vectorData) throws java.io.IOException
- Throws:
java.io.IOException
-
-