Lucene99FlatVectorsWriter (Lucene 10.5.0 core API)
Description: declaration: package: org.apache.lucene.codecs.lucene99, class: Lucene99FlatVectorsWriter

Package org.apache.lucene.codecs.lucene99

# Class Lucene99FlatVectorsWriter

java.lang.Object
org.apache.lucene.codecs.KnnVectorsWriter
org.apache.lucene.codecs.hnsw.FlatVectorsWriter
org.apache.lucene.codecs.lucene99.Lucene99FlatVectorsWriter

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`, `Accountable`

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

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.KnnVectorsWriter

  `KnnVectorsWriter.MergedVectorValues`

- ## Field Summary

  ### Fields inherited from class org.apache.lucene.codecs.hnsw.FlatVectorsWriter

  `vectorsScorer`

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

  `NULL_ACCOUNTABLE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Lucene99FlatVectorsWriter(SegmentWriteState state, FlatVectorsScorer scorer)`
  Constructs a writer that uses the default factory to build per-field vector storage.
  `Lucene99FlatVectorsWriter(SegmentWriteState state, FlatVectorsScorer scorer, IOFunction<FieldInfo,FlatFieldVectorsWriter<?>> strategyFactory)`
  Constructs a writer that uses the supplied `strategyFactory` to build per-field vector storage.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `FlatFieldVectorsWriter<?>`
  `addField(FieldInfo fieldInfo)`
  Add a new field for indexing
  `void`
  `close()`
  `void`
  `finish()`
  Called once at the end before close
  `void`
  `flush(int maxDoc, Sorter.DocMap sortMap)`
  Flush all buffered data on disk *
  `void`
  `mergeOneFlatVectorField(FieldInfo fieldInfo, MergeState mergeState)`
  `long`
  `ramBytesUsed()`
  Returns an estimate of the JVM heap memory used by this object in bytes.

  ### Methods inherited from class org.apache.lucene.codecs.hnsw.FlatVectorsWriter

  `getFlatVectorScorer, mergeOneField`

  ### Methods inherited from class org.apache.lucene.codecs.KnnVectorsWriter

  `mapOldOrdToNewOrd, merge`

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

- ## Constructor Details

  - ### Lucene99FlatVectorsWriter

    public Lucene99FlatVectorsWriter(SegmentWriteState state, FlatVectorsScorer scorer) throws IOException
    Constructs a writer that uses the default factory to build per-field vector storage. This default factory creates instances of `FlatFieldVectorsWriter` that store vector data as a List of on-heap arrays, one per-vector (see `DefaultFieldWriter`).
    Parameters:
      `state` - the segment write state
      `scorer` - the flat vectors scorer used to score vectors at index-build time
    Throws:
      `IOException`

  - ### Lucene99FlatVectorsWriter

    public Lucene99FlatVectorsWriter(SegmentWriteState state, FlatVectorsScorer scorer, IOFunction<FieldInfo,FlatFieldVectorsWriter<?>> strategyFactory) throws IOException
    Constructs a writer that uses the supplied `strategyFactory` to build per-field vector storage. The factory is consulted on every `addField(FieldInfo)` call and returns a user-defined `FlatFieldVectorsWriter`.

    Note: the strategy is only consulted during indexing (i.e. via `addField(FieldInfo)` and the subsequent `flush(int, org.apache.lucene.index.Sorter.DocMap)`). Merges write directly to the new segment via `mergeOneFlatVectorField(org.apache.lucene.index.FieldInfo, org.apache.lucene.index.MergeState)` and do not go through the strategy.

    Parameters:
      `state` - the segment write state
      `scorer` - the flat vectors scorer used to score vectors at index-build time
      `strategyFactory` - the per-field storage factory; receives the `FieldInfo` for the field being added and returns the `FlatFieldVectorsWriter` that will back it
    Throws:
      `IOException`

- ## Method Details

  - ### addField

    public FlatFieldVectorsWriter<?> addField(FieldInfo fieldInfo) throws IOException
    Description copied from class: `FlatVectorsWriter`
    Add a new field for indexing
    Specified by:
      `addField` in class `FlatVectorsWriter`
    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

    public void flush(int maxDoc, Sorter.DocMap sortMap) throws IOException
    Description copied from class: `KnnVectorsWriter`
    Flush all buffered data on disk *
    Specified by:
      `flush` in class `KnnVectorsWriter`
    Throws:
      `IOException`

  - ### finish

    public void finish() throws IOException
    Description copied from class: `KnnVectorsWriter`
    Called once at the end before close
    Specified by:
      `finish` in class `KnnVectorsWriter`
    Throws:
      `IOException`

  - ### ramBytesUsed

    public long ramBytesUsed()
    Description copied from interface: `Accountable`
    Returns 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.

  - ### mergeOneFlatVectorField

    public void mergeOneFlatVectorField(FieldInfo fieldInfo, MergeState mergeState) throws IOException
    Specified by:
      `mergeOneFlatVectorField` in class `FlatVectorsWriter`
    Throws:
      `IOException`

  - ### close

    public void close() throws IOException
    Throws:
      `IOException`