Class Lucene99FlatVectorsWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, Accountable

    public final class Lucene99FlatVectorsWriter
    extends FlatVectorsWriter
    Writes vector values to index segments.
    • Constructor Detail

      • Lucene99FlatVectorsWriter

        public Lucene99FlatVectorsWriter​(SegmentWriteState state,
                                         FlatVectorsScorer scorer)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • addField

        public FlatFieldVectorsWriter<?> addField​(FieldInfo fieldInfo,
                                                  KnnFieldVectorsWriter<?> indexWriter)
                                           throws java.io.IOException
        Description copied from class: FlatVectorsWriter
        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.
        Specified by:
        addField in class FlatVectorsWriter
        Parameters:
        fieldInfo - fieldInfo of the field to add
        indexWriter - the writer to delegate to, can be null
        Returns:
        a writer for the field
        Throws:
        java.io.IOException - if an I/O error occurs when adding the field
      • finish

        public void finish()
                    throws java.io.IOException
        Description copied from class: FlatVectorsWriter
        Called once at the end before close
        Specified by:
        finish in class FlatVectorsWriter
        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.
      • writeSortedFloat32Vectors

        private long writeSortedFloat32Vectors​(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData,
                                               int[] ordMap)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeSortedByteVectors

        private long writeSortedByteVectors​(Lucene99FlatVectorsWriter.FieldWriter<?> fieldData,
                                            int[] ordMap)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • mergeOneFieldToIndex

        public CloseableRandomVectorScorerSupplier mergeOneFieldToIndex​(FieldInfo fieldInfo,
                                                                        MergeState mergeState)
                                                                 throws java.io.IOException
        Description copied from class: FlatVectorsWriter
        Write 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:
        mergeOneFieldToIndex in class FlatVectorsWriter
        Parameters:
        fieldInfo - fieldInfo of the field to merge
        mergeState - 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:
        java.io.IOException - if an I/O error occurs when merging
      • writeMeta

        private void writeMeta​(FieldInfo field,
                               int maxDoc,
                               long vectorDataOffset,
                               long vectorDataLength,
                               DocsWithFieldSet docsWithField)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeByteVectorData

        private static DocsWithFieldSet writeByteVectorData​(IndexOutput output,
                                                            ByteVectorValues byteVectorValues)
                                                     throws java.io.IOException
        Writes the byte vector values to the output and returns a set of documents that contains vectors.
        Throws:
        java.io.IOException
      • writeVectorData

        private static DocsWithFieldSet writeVectorData​(IndexOutput output,
                                                        FloatVectorValues floatVectorValues)
                                                 throws java.io.IOException
        Writes the vector values to the output and returns a set of documents that contains vectors.
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Throws:
        java.io.IOException