Class Lucene104ScalarQuantizedVectorsWriter
java.lang.Object
org.apache.lucene.codecs.KnnVectorsWriter
org.apache.lucene.codecs.hnsw.FlatVectorsWriter
org.apache.lucene.codecs.lucene104.Lucene104ScalarQuantizedVectorsWriter
- All Implemented Interfaces:
Closeable,AutoCloseable,Accountable
Writes quantized vector values and metadata to index segments in the format for Lucene 10.4.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.codecs.hnsw.FlatVectorsWriter
FlatVectorsWriter.MergeScorerDataNested classes/interfaces inherited from class org.apache.lucene.codecs.KnnVectorsWriter
KnnVectorsWriter.MergedVectorValues -
Field Summary
Fields inherited from class org.apache.lucene.codecs.hnsw.FlatVectorsWriter
vectorsScorerFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Constructor Summary
ConstructorsConstructorDescriptionLucene104ScalarQuantizedVectorsWriter(SegmentWriteState state, QuantizedByteVectorValues.ScalarEncoding encoding, FlatVectorsWriter rawVectorDelegate, Lucene104ScalarQuantizedVectorScorer vectorsScorer) Sole constructor -
Method Summary
Modifier and TypeMethodDescriptionAdd a new field for indexingvoidclose()voidfinish()Called once at the end before closevoidflush(int maxDoc, Sorter.DocMap sortMap) Flush all buffered data on disk *voidmergeOneFlatVectorField(FieldInfo fieldInfo, MergeState mergeState) mergeOneFlatVectorFieldForMergeScorer(FieldInfo fieldInfo, MergeState mergeState, IntPredicate needsMergeScorer) Merges one field and, while writing the merged vectors, optionally prepares what a merge scorer needs, so that the merged float vectors need not be read back.longReturns an estimate of the JVM heap memory used by this object in bytes.Methods inherited from class org.apache.lucene.codecs.hnsw.FlatVectorsWriter
getFlatVectorScorer, mergeOneFieldMethods inherited from class org.apache.lucene.codecs.KnnVectorsWriter
mapOldOrdToNewOrd, mergeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
Constructor Details
-
Lucene104ScalarQuantizedVectorsWriter
public Lucene104ScalarQuantizedVectorsWriter(SegmentWriteState state, QuantizedByteVectorValues.ScalarEncoding encoding, FlatVectorsWriter rawVectorDelegate, Lucene104ScalarQuantizedVectorScorer vectorsScorer) throws IOException Sole constructor- Throws:
IOException
-
-
Method Details
-
addField
Description copied from class:FlatVectorsWriterAdd a new field for indexing- Specified by:
addFieldin classFlatVectorsWriter- Parameters:
fieldInfo- fieldInfo of the field to add- Returns:
- a writer for the field
- Throws:
IOException- if an I/O error occurs when adding the field
-
flush
Description copied from class:KnnVectorsWriterFlush all buffered data on disk *- Specified by:
flushin classKnnVectorsWriter- Throws:
IOException
-
finish
Description copied from class:KnnVectorsWriterCalled once at the end before close- Specified by:
finishin classKnnVectorsWriter- Throws:
IOException
-
mergeOneFlatVectorField
- Specified by:
mergeOneFlatVectorFieldin classFlatVectorsWriter- Throws:
IOException
-
mergeOneFlatVectorFieldForMergeScorer
public FlatVectorsWriter.MergeScorerData mergeOneFlatVectorFieldForMergeScorer(FieldInfo fieldInfo, MergeState mergeState, IntPredicate needsMergeScorer) throws IOException Merges one field and, while writing the merged vectors, optionally prepares what a merge scorer needs, so that the merged float vectors need not be read back.A wrapping writer should forward this method along with
FlatVectorsWriter.mergeOneFlatVectorField(org.apache.lucene.index.FieldInfo, org.apache.lucene.index.MergeState). Forwarding only the latter stays correct, but the wrapped writer then prepares nothing. Forwarding helps only when the wrapping format's reader over the merged segment is the wrapped writer's own reader. OtherwiseFlatVectorsWriter.MergeScorerData.scorerSupplier(org.apache.lucene.codecs.hnsw.FlatVectorsReader)rejects the prepared data and the merge uses its fallback.HNSW merges call this overload rather than
mergeOneFlatVectorField(FieldInfo, MergeState), so subclasses that customize merging must override this method too.- Overrides:
mergeOneFlatVectorFieldForMergeScorerin classFlatVectorsWriter- Parameters:
fieldInfo- field to mergemergeState- merge stateneedsMergeScorer- whether to prepare scorer data for a vector count. The writer applies this predicate to the number of live vectors written after deletions, so it does not prepare data for a merged field that is too small to build a graph.- Returns:
- prepared data that the caller must close, or
nullif none was prepared, which is what the default implementation returns and what any writer returns for a field it cannot prepare for. The caller then builds the scorer itself. - Throws:
IOException- if an I/O error occurs
-
close
- Throws:
IOException
-
ramBytesUsed
public long ramBytesUsed()Description copied from interface:AccountableReturns an estimate of the JVM heap memory used by this object in bytes. The method name uses "ram" for historical reasons; only JVM heap memory should be reported. Off-heap resources such as memory-mapped files or native direct buffers should not be included. Negative values are illegal.
-