Package org.apache.lucene.codecs

## Class PostingsWriterBase

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

- All Implemented Interfaces:
    `Closeable`, `AutoCloseable`
  Direct Known Subclasses:
    `PushPostingsWriterBase`

      public abstract class PostingsWriterBase
      extends Object
      implements Closeable

  Class that plugs into term dictionaries, such as `Lucene90BlockTreeTermsWriter`, and handles writing postings.
  See Also:
    `PostingsReaderBase`
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `abstract void` | `close()` |
    `abstract void` | `encodeTerm​(DataOutput out, FieldInfo fieldInfo, BlockTermState state, boolean absolute)` | Encode metadata as long[] and byte[].
    `abstract void` | `init​(IndexOutput termsOut, SegmentWriteState state)` | Called once after startup, before any terms have been added.
    `abstract void` | `setField​(FieldInfo fieldInfo)` | Sets the current field for writing.
    `abstract BlockTermState` | `writeTerm​(BytesRef term, TermsEnum termsEnum, FixedBitSet docsSeen, NormsProducer norms)` | Write all postings for one term; use the provided `TermsEnum` to pull a `PostingsEnum`.

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

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

- - ### Constructor Detail

    - #### PostingsWriterBase

          protected PostingsWriterBase()

      Sole constructor. (For invocation by subclass constructors, typically implicit.)

  - ### Method Detail

    - #### init

          public abstract void init​(IndexOutput termsOut,
                                    SegmentWriteState state)
                             throws IOException

      Called once after startup, before any terms have been added. Implementations typically write a header to the provided `termsOut`.
      Throws:
        `IOException`

    - #### writeTerm

          public abstract BlockTermState writeTerm​(BytesRef term,
                                                   TermsEnum termsEnum,
                                                   FixedBitSet docsSeen,
                                                   NormsProducer norms)
                                            throws IOException

      Write all postings for one term; use the provided `TermsEnum` to pull a `PostingsEnum`. This method should not re-position the `TermsEnum`! It is already positioned on the term that should be written. This method must set the bit in the provided `FixedBitSet` for every docID written. If no docs were written, this method should return null, and the terms dict will skip the term.
      Throws:
        `IOException`

    - #### encodeTerm

          public abstract void encodeTerm​(DataOutput out,
                                          FieldInfo fieldInfo,
                                          BlockTermState state,
                                          boolean absolute)
                                   throws IOException

      Encode metadata as long[] and byte[]. `absolute` controls whether current term is delta encoded according to latest term. Usually elements in `longs` are file pointers, so each one always increases when a new term is consumed. `out` is used to write generic bytes, which are not monotonic.
      Throws:
        `IOException`

    - #### setField

          public abstract void setField​(FieldInfo fieldInfo)

      Sets the current field for writing.

    - #### close

          public abstract void close()
                              throws IOException

      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `Closeable`
      Throws:
        `IOException`