Lucene90CompressingTermVectorsWriter (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.codecs.lucene90.compressing, class: Lucene90CompressingTermVectorsWriter

Package org.apache.lucene.codecs.lucene90.compressing

# Class Lucene90CompressingTermVectorsWriter

java.lang.Object
org.apache.lucene.codecs.TermVectorsWriter
org.apache.lucene.codecs.lucene90.compressing.Lucene90CompressingTermVectorsWriter

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

public final class Lucene90CompressingTermVectorsWriter extends TermVectorsWriter
`TermVectorsWriter` for `Lucene90CompressingTermVectorsFormat`.

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`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addPosition(int position, int startOffset, int endOffset, BytesRef payload)`
  Adds a term position and offsets
  `void`
  `addProx(int numProx, DataInput positions, DataInput offsets)`
  Called by IndexWriter when writing new segments.
  `void`
  `close()`
  `void`
  `finish(int numDocs)`
  Called before `TermVectorsWriter.close()`, passing in the number of documents that were written.
  `void`
  `finishDocument()`
  Called after a doc and all its fields have been added.
  `void`
  `finishField()`
  Called after a field and all its terms have been added.
  `Collection<Accountable>`
  `getChildResources()`
  Returns nested resources of this class.
  `int`
  `merge(MergeState mergeState)`
  Merges in the term vectors from the readers in `mergeState`.
  `long`
  `ramBytesUsed()`
  Returns an estimate of the JVM heap memory used by this object in bytes.
  `void`
  `startDocument(int numVectorFields)`
  Called before writing the term vectors of the document.
  `void`
  `startField(FieldInfo info, int numTerms, boolean positions, boolean offsets, boolean payloads)`
  Called before writing the terms of the field.
  `void`
  `startTerm(BytesRef term, int freq)`
  Adds a term and its term frequency `freq`.

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

  `addAllDocVectors, finishTerm`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### close

    public void close() throws IOException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Specified by:
      `close` in class `TermVectorsWriter`
    Throws:
      `IOException`

  - ### startDocument

    public void startDocument(int numVectorFields) throws IOException
    Description copied from class: `TermVectorsWriter`
    Called before writing the term vectors of the document. `TermVectorsWriter.startField(FieldInfo, int, boolean, boolean, boolean)` will be called `numVectorFields` times. Note that if term vectors are enabled, this is called even if the document has no vector fields, in this case `numVectorFields` will be zero.
    Specified by:
      `startDocument` in class `TermVectorsWriter`
    Throws:
      `IOException`

  - ### finishDocument

    public void finishDocument() throws IOException
    Description copied from class: `TermVectorsWriter`
    Called after a doc and all its fields have been added.
    Overrides:
      `finishDocument` in class `TermVectorsWriter`
    Throws:
      `IOException`

  - ### startField

    public void startField(FieldInfo info, int numTerms, boolean positions, boolean offsets, boolean payloads) throws IOException
    Description copied from class: `TermVectorsWriter`
    Called before writing the terms of the field. `TermVectorsWriter.startTerm(BytesRef, int)` will be called `numTerms` times.
    Specified by:
      `startField` in class `TermVectorsWriter`
    Throws:
      `IOException`

  - ### finishField

    public void finishField() throws IOException
    Description copied from class: `TermVectorsWriter`
    Called after a field and all its terms have been added.
    Overrides:
      `finishField` in class `TermVectorsWriter`
    Throws:
      `IOException`

  - ### startTerm

    public void startTerm(BytesRef term, int freq) throws IOException
    Description copied from class: `TermVectorsWriter`
    Adds a term and its term frequency `freq`. If this field has positions and/or offsets enabled, then `TermVectorsWriter.addPosition(int, int, int, BytesRef)` will be called `freq` times respectively.
    Specified by:
      `startTerm` in class `TermVectorsWriter`
    Throws:
      `IOException`

  - ### addPosition

    public void addPosition(int position, int startOffset, int endOffset, BytesRef payload) throws IOException
    Description copied from class: `TermVectorsWriter`
    Adds a term position and offsets
    Specified by:
      `addPosition` in class `TermVectorsWriter`
    Throws:
      `IOException`

  - ### finish

    public void finish(int numDocs) throws IOException
    Description copied from class: `TermVectorsWriter`
    Called before `TermVectorsWriter.close()`, passing in the number of documents that were written. Note that this is intentionally redundant (equivalent to the number of calls to `TermVectorsWriter.startDocument(int)`, but a Codec should check that this is the case to detect the JRE bug described in LUCENE-1282.
    Specified by:
      `finish` in class `TermVectorsWriter`
    Throws:
      `IOException`

  - ### addProx

    public void addProx(int numProx, DataInput positions, DataInput offsets) throws IOException
    Description copied from class: `TermVectorsWriter`
    Called by IndexWriter when writing new segments.

    This is an expert API that allows the codec to consume positions and offsets directly from the indexer.

    The default implementation calls `TermVectorsWriter.addPosition(int, int, int, BytesRef)`, but subclasses can override this if they want to efficiently write all the positions, then all the offsets, for example.

    NOTE: This API is extremely expert and subject to change or removal!!!

    Overrides:
      `addProx` in class `TermVectorsWriter`
    Throws:
      `IOException`

  - ### merge

    public int merge(MergeState mergeState) throws IOException
    Description copied from class: `TermVectorsWriter`
    Merges in the term vectors from the readers in `mergeState`. The default implementation skips over deleted documents, and uses `TermVectorsWriter.startDocument(int)`, `TermVectorsWriter.startField(FieldInfo, int, boolean, boolean, boolean)`, `TermVectorsWriter.startTerm(BytesRef, int)`, `TermVectorsWriter.addPosition(int, int, int, BytesRef)`, and `TermVectorsWriter.finish(int)`, returning the number of documents that were written. Implementations can override this method for more sophisticated merging (bulk-byte copying, etc).
    Overrides:
      `merge` in class `TermVectorsWriter`
    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.

  - ### getChildResources

    public Collection<Accountable> getChildResources()
    Description copied from interface: `Accountable`
    Returns nested resources of this class. The result should be a point-in-time snapshot (to avoid race conditions).
    See Also:
      - `Accountables`