Module org.apache.lucene.core
Class Lucene99ScalarQuantizedVectorsReader
- java.lang.Object
-
- org.apache.lucene.codecs.hnsw.FlatVectorsReader
-
- org.apache.lucene.codecs.lucene99.Lucene99ScalarQuantizedVectorsReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,Accountable
,QuantizedVectorsReader
public final class Lucene99ScalarQuantizedVectorsReader extends FlatVectorsReader implements QuantizedVectorsReader
Reads Scalar Quantized vectors from the index segments along with index data structures.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Lucene99ScalarQuantizedVectorsReader.FieldEntry
private static class
Lucene99ScalarQuantizedVectorsReader.QuantizedVectorValues
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,Lucene99ScalarQuantizedVectorsReader.FieldEntry>
fields
private IndexInput
quantizedVectorData
private FlatVectorsReader
rawVectorsReader
private static long
SHALLOW_SIZE
-
Fields inherited from class org.apache.lucene.codecs.hnsw.FlatVectorsReader
vectorScorer
-
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
-
Constructor Summary
Constructors Constructor Description Lucene99ScalarQuantizedVectorsReader(SegmentReadState state, FlatVectorsReader rawVectorsReader, FlatVectorsScorer scorer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkIntegrity()
Checks consistency of this reader.void
close()
ByteVectorValues
getByteVectorValues(java.lang.String field)
Returns theByteVectorValues
for the givenfield
.FloatVectorValues
getFloatVectorValues(java.lang.String field)
Returns theFloatVectorValues
for the givenfield
.ScalarQuantizer
getQuantizationState(java.lang.String fieldName)
QuantizedByteVectorValues
getQuantizedVectorValues(java.lang.String fieldName)
RandomVectorScorer
getRandomVectorScorer(java.lang.String field, byte[] target)
Returns aRandomVectorScorer
for the given field and target vector.RandomVectorScorer
getRandomVectorScorer(java.lang.String field, float[] target)
Returns aRandomVectorScorer
for the given field and target vector.private static IndexInput
openDataInput(SegmentReadState state, int versionMeta, java.lang.String fileExtension, java.lang.String codecName, IOContext context)
long
ramBytesUsed()
Return the memory usage of this object in bytes.private Lucene99ScalarQuantizedVectorsReader.FieldEntry
readField(IndexInput input, int versionMeta, FieldInfo info)
private void
readFields(ChecksumIndexInput meta, int versionMeta, FieldInfos infos)
(package private) static void
validateFieldEntry(FieldInfo info, Lucene99ScalarQuantizedVectorsReader.FieldEntry fieldEntry)
-
Methods inherited from class org.apache.lucene.codecs.hnsw.FlatVectorsReader
getFlatVectorScorer
-
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.util.Accountable
getChildResources
-
-
-
-
Field Detail
-
SHALLOW_SIZE
private static final long SHALLOW_SIZE
-
fields
private final java.util.Map<java.lang.String,Lucene99ScalarQuantizedVectorsReader.FieldEntry> fields
-
quantizedVectorData
private final IndexInput quantizedVectorData
-
rawVectorsReader
private final FlatVectorsReader rawVectorsReader
-
-
Constructor Detail
-
Lucene99ScalarQuantizedVectorsReader
public Lucene99ScalarQuantizedVectorsReader(SegmentReadState state, FlatVectorsReader rawVectorsReader, FlatVectorsScorer scorer) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
readFields
private void readFields(ChecksumIndexInput meta, int versionMeta, FieldInfos infos) throws java.io.IOException
- Throws:
java.io.IOException
-
validateFieldEntry
static void validateFieldEntry(FieldInfo info, Lucene99ScalarQuantizedVectorsReader.FieldEntry fieldEntry)
-
checkIntegrity
public void checkIntegrity() throws java.io.IOException
Description copied from class:FlatVectorsReader
Checks consistency of this reader.Note that this may be costly in terms of I/O, e.g. may involve computing a checksum value against large data files.
- Specified by:
checkIntegrity
in classFlatVectorsReader
- Throws:
java.io.IOException
-
getFloatVectorValues
public FloatVectorValues getFloatVectorValues(java.lang.String field) throws java.io.IOException
Description copied from class:FlatVectorsReader
Returns theFloatVectorValues
for the givenfield
. The behavior is undefined if the given field doesn't have KNN vectors enabled on itsFieldInfo
. The return value is nevernull
.- Specified by:
getFloatVectorValues
in classFlatVectorsReader
- Throws:
java.io.IOException
-
getByteVectorValues
public ByteVectorValues getByteVectorValues(java.lang.String field) throws java.io.IOException
Description copied from class:FlatVectorsReader
Returns theByteVectorValues
for the givenfield
. The behavior is undefined if the given field doesn't have KNN vectors enabled on itsFieldInfo
. The return value is nevernull
.- Specified by:
getByteVectorValues
in classFlatVectorsReader
- Throws:
java.io.IOException
-
openDataInput
private static IndexInput openDataInput(SegmentReadState state, int versionMeta, java.lang.String fileExtension, java.lang.String codecName, IOContext context) throws java.io.IOException
- Throws:
java.io.IOException
-
getRandomVectorScorer
public RandomVectorScorer getRandomVectorScorer(java.lang.String field, float[] target) throws java.io.IOException
Description copied from class:FlatVectorsReader
Returns aRandomVectorScorer
for the given field and target vector.- Specified by:
getRandomVectorScorer
in classFlatVectorsReader
- Parameters:
field
- the field to searchtarget
- the target vector- Returns:
- a
RandomVectorScorer
for the given field and target vector. - Throws:
java.io.IOException
- if an I/O error occurs when reading from the index.
-
getRandomVectorScorer
public RandomVectorScorer getRandomVectorScorer(java.lang.String field, byte[] target) throws java.io.IOException
Description copied from class:FlatVectorsReader
Returns aRandomVectorScorer
for the given field and target vector.- Specified by:
getRandomVectorScorer
in classFlatVectorsReader
- Parameters:
field
- the field to searchtarget
- the target vector- Returns:
- a
RandomVectorScorer
for the given field and target vector. - Throws:
java.io.IOException
- if an I/O error occurs when reading from the index.
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
ramBytesUsed
public long ramBytesUsed()
Description copied from interface:Accountable
Return the memory usage of this object in bytes. Negative values are illegal.- Specified by:
ramBytesUsed
in interfaceAccountable
-
readField
private Lucene99ScalarQuantizedVectorsReader.FieldEntry readField(IndexInput input, int versionMeta, FieldInfo info) throws java.io.IOException
- Throws:
java.io.IOException
-
getQuantizedVectorValues
public QuantizedByteVectorValues getQuantizedVectorValues(java.lang.String fieldName) throws java.io.IOException
- Specified by:
getQuantizedVectorValues
in interfaceQuantizedVectorsReader
- Throws:
java.io.IOException
-
getQuantizationState
public ScalarQuantizer getQuantizationState(java.lang.String fieldName)
- Specified by:
getQuantizationState
in interfaceQuantizedVectorsReader
-
-