Module org.apache.lucene.core
Class Lucene99FlatVectorsWriter
java.lang.Object
org.apache.lucene.codecs.FlatVectorsWriter
org.apache.lucene.codecs.lucene99.Lucene99FlatVectorsWriter
- All Implemented Interfaces:
Closeable,AutoCloseable,Accountable
Writes vector values to index segments.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class(package private) static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<Lucene99FlatVectorsWriter.FieldWriter<?>> private booleanprivate final IndexOutputprivate final SegmentWriteStateprivate static final longprivate final IndexOutputFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddField(FieldInfo fieldInfo, KnnFieldVectorsWriter<?> indexWriter) Add a new field for indexing, allowing the user to provide a writer that the flat vectors writer can delegate to if additional indexing logic is required.voidclose()voidfinish()Called once at the end before closevoidflush(int maxDoc, Sorter.DocMap sortMap) Flush all buffered data on disk *voidmergeOneField(FieldInfo fieldInfo, MergeState mergeState) Write field for mergingmergeOneFieldToIndex(FieldInfo fieldInfo, MergeState mergeState) Write the field for merging, providing a scorer over the newly merged flat vectors.longReturn the memory usage of this object in bytes.private static DocsWithFieldSetwriteByteVectorData(IndexOutput output, ByteVectorValues byteVectorValues) Writes the byte vector values to the output and returns a set of documents that contains vectors.private voidwriteByteVectors(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData) private voidwriteField(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData, int maxDoc) private voidwriteFloat32Vectors(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData) private voidwriteMeta(FieldInfo field, int maxDoc, long vectorDataOffset, long vectorDataLength, DocsWithFieldSet docsWithField) private longwriteSortedByteVectors(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData, int[] ordMap) private longwriteSortedFloat32Vectors(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData, int[] ordMap) private voidwriteSortingField(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData, int maxDoc, Sorter.DocMap sortMap) private static DocsWithFieldSetwriteVectorData(IndexOutput output, FloatVectorValues floatVectorValues) Writes the vector values to the output and returns a set of documents that contains vectors.Methods 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
-
Field Details
-
SHALLLOW_RAM_BYTES_USED
private static final long SHALLLOW_RAM_BYTES_USED -
segmentWriteState
-
meta
-
vectorData
-
fields
-
finished
private boolean finished
-
-
Constructor Details
-
Lucene99FlatVectorsWriter
Lucene99FlatVectorsWriter(SegmentWriteState state) throws IOException - Throws:
IOException
-
-
Method Details
-
addField
public FlatFieldVectorsWriter<?> addField(FieldInfo fieldInfo, KnnFieldVectorsWriter<?> indexWriter) throws IOException Description copied from class:FlatVectorsWriterAdd a new field for indexing, allowing the user to provide a writer that the flat vectors writer can delegate to if additional indexing logic is required.- Specified by:
addFieldin classFlatVectorsWriter- Parameters:
fieldInfo- fieldInfo of the field to addindexWriter- the writer to delegate to, can be null- Returns:
- a writer for the field
- Throws:
IOException- if an I/O error occurs when adding the field
-
flush
Description copied from class:FlatVectorsWriterFlush all buffered data on disk *- Specified by:
flushin classFlatVectorsWriter- Throws:
IOException
-
finish
Description copied from class:FlatVectorsWriterCalled once at the end before close- Specified by:
finishin classFlatVectorsWriter- Throws:
IOException
-
ramBytesUsed
public long ramBytesUsed()Description copied from interface:AccountableReturn the memory usage of this object in bytes. Negative values are illegal. -
writeField
private void writeField(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData, int maxDoc) throws IOException - Throws:
IOException
-
writeFloat32Vectors
private void writeFloat32Vectors(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData) throws IOException - Throws:
IOException
-
writeByteVectors
private void writeByteVectors(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData) throws IOException - Throws:
IOException
-
writeSortingField
private void writeSortingField(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData, int maxDoc, Sorter.DocMap sortMap) throws IOException - Throws:
IOException
-
writeSortedFloat32Vectors
private long writeSortedFloat32Vectors(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData, int[] ordMap) throws IOException - Throws:
IOException
-
writeSortedByteVectors
private long writeSortedByteVectors(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData, int[] ordMap) throws IOException - Throws:
IOException
-
mergeOneField
Description copied from class:FlatVectorsWriterWrite field for merging- Overrides:
mergeOneFieldin classFlatVectorsWriter- Throws:
IOException
-
mergeOneFieldToIndex
public CloseableRandomVectorScorerSupplier mergeOneFieldToIndex(FieldInfo fieldInfo, MergeState mergeState) throws IOException Description copied from class:FlatVectorsWriterWrite the field for merging, providing a scorer over the newly merged flat vectors. This way any additional merging logic can be implemented by the user of this class.- Specified by:
mergeOneFieldToIndexin classFlatVectorsWriter- Parameters:
fieldInfo- fieldInfo of the field to mergemergeState- mergeState of the segments to merge- Returns:
- a scorer over the newly merged flat vectors, which should be closed as it holds a temporary file handle to read over the newly merged vectors
- Throws:
IOException- if an I/O error occurs when merging
-
writeMeta
private void writeMeta(FieldInfo field, int maxDoc, long vectorDataOffset, long vectorDataLength, DocsWithFieldSet docsWithField) throws IOException - Throws:
IOException
-
writeByteVectorData
private static DocsWithFieldSet writeByteVectorData(IndexOutput output, ByteVectorValues byteVectorValues) throws IOException Writes the byte vector values to the output and returns a set of documents that contains vectors.- Throws:
IOException
-
writeVectorData
private static DocsWithFieldSet writeVectorData(IndexOutput output, FloatVectorValues floatVectorValues) throws IOException Writes the vector values to the output and returns a set of documents that contains vectors.- Throws:
IOException
-
close
- Throws:
IOException
-