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

Package org.apache.lucene.codecs.hnsw

# Class FlatFieldVectorsWriter<T>

java.lang.Object
org.apache.lucene.codecs.KnnFieldVectorsWriter<T>
org.apache.lucene.codecs.hnsw.FlatFieldVectorsWriter<T>

Type Parameters:
  `T` - an array type; the type of vectors to be written

All Implemented Interfaces:
  `Accountable`

public abstract class FlatFieldVectorsWriter<T> extends KnnFieldVectorsWriter<T>
Vectors' writer for a field

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
  Constructor
  Description
  `FlatFieldVectorsWriter()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `KnnVectorValues`
  `asKnnVectorValues(VectorEncoding encoding, int dim)`
  Returns a `KnnVectorValues` view over the vectors to be written.
  `abstract void`
  `finish()`
  indicates that this writer is done and no new vectors are allowed to be added
  `abstract DocsWithFieldSet`
  `getDocsWithFieldSet()`
  `abstract List<T>`
  `getVectors()`
  `abstract boolean`
  `isFinished()`

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

  `addValue, copyValue`

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

- ## Constructor Details

  - ### FlatFieldVectorsWriter

    public FlatFieldVectorsWriter()

- ## Method Details

  - ### getVectors

    public abstract List<T> getVectors()
    Returns:
      a list of vectors to be written

  - ### asKnnVectorValues

    public KnnVectorValues asKnnVectorValues(VectorEncoding encoding, int dim) throws IOException
    Returns a `KnnVectorValues` view over the vectors to be written.

    This default implementation uses `getVectors()` and wraps them via `FloatVectorValues.fromFloats(java.util.List<float[]>, int)` / `ByteVectorValues.fromBytes(java.util.List<byte[]>, int)`. Subclasses backed by alternative storage may override to return a richer view (e.g. one that exposes capability information to scorers, or avoids heap materialization).

    Parameters:
      `encoding` - the vector encoding/element type
      `dim` - the field's declared vector dimension
    Throws:
      `IOException`

  - ### getDocsWithFieldSet

    public abstract DocsWithFieldSet getDocsWithFieldSet()
    Returns:
      the docsWithFieldSet for the field writer

  - ### finish

    public abstract void finish() throws IOException
    indicates that this writer is done and no new vectors are allowed to be added
    Throws:
      `IOException` - if an I/O error occurs

  - ### isFinished

    public abstract boolean isFinished()
    Returns:
      true if the writer is done and no new vectors are allowed to be added