Package org.apache.lucene.codecs

## Class FlatVectorsWriter

- java.lang.Object
- - org.apache.lucene.codecs.FlatVectorsWriter

- All Implemented Interfaces:
    `Closeable`, `AutoCloseable`, `Accountable`
  Direct Known Subclasses:
    `Lucene99FlatVectorsWriter`, `Lucene99ScalarQuantizedVectorsWriter`

      public abstract class FlatVectorsWriter
      extends Object
      implements Accountable, Closeable

  Vectors' writer for a field that allows additional indexing logic to be implemented by the caller
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Field Summary

    - ### Fields inherited from interface org.apache.lucene.util.Accountable

      `NULL_ACCOUNTABLE`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `FlatVectorsWriter()` | Sole constructor

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `abstract FlatFieldVectorsWriter<?>` | `addField​(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.
    `abstract void` | `finish()` | Called once at the end before close
    `abstract void` | `flush​(int maxDoc, Sorter.DocMap sortMap)` | Flush all buffered data on disk *
    `void` | `mergeOneField​(FieldInfo fieldInfo, MergeState mergeState)` | Write field for merging
    `abstract CloseableRandomVectorScorerSupplier` | `mergeOneFieldToIndex​(FieldInfo fieldInfo, MergeState mergeState)` | Write the field for merging, providing a scorer over the newly merged flat vectors.

    - ### 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, ramBytesUsed`

    - ### Methods inherited from interface java.io.Closeable

      `close`

- - ### Constructor Detail

    - #### FlatVectorsWriter

          protected FlatVectorsWriter()

      Sole constructor

  - ### Method Detail

    - #### addField

          public abstract FlatFieldVectorsWriter<?> addField​(FieldInfo fieldInfo,
                                                             KnnFieldVectorsWriter<?> indexWriter)
                                                      throws IOException

      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.
      Parameters:
        `fieldInfo` - fieldInfo of the field to add
        `indexWriter` - 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

    - #### mergeOneFieldToIndex

          public abstract CloseableRandomVectorScorerSupplier mergeOneFieldToIndex​(FieldInfo fieldInfo,
                                                                                   MergeState mergeState)
                                                                            throws IOException

      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.
      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:
        `IOException` - if an I/O error occurs when merging

    - #### mergeOneField

          public void mergeOneField​(FieldInfo fieldInfo,
                                    MergeState mergeState)
                             throws IOException

      Write field for merging
      Throws:
        `IOException`

    - #### finish

          public abstract void finish()
                               throws IOException

      Called once at the end before close
      Throws:
        `IOException`

    - #### flush

          public abstract void flush​(int maxDoc,
                                     Sorter.DocMap sortMap)
                              throws IOException

      Flush all buffered data on disk *
      Throws:
        `IOException`