org.apache.lucene.codecs

## Class PostingsWriterBase

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

- All Implemented Interfaces:
    Closeable, AutoCloseable
  Direct Known Subclasses:
    Lucene41PostingsWriter

      public abstract class PostingsWriterBase
      extends PostingsConsumer
      implements Closeable

  Extension of `PostingsConsumer` to support pluggable term dictionaries.

  This class contains additional hooks to interact with the provided term dictionaries such as `BlockTreeTermsWriter`. If you want to re-use an existing implementation and are only interested in customizing the format of the postings list, extend this class instead.

  See Also:
    `PostingsReaderBase`
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Constructor Summary

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

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `close()`
    `abstract void` | `finishTerm(TermStats stats)` Finishes the current term.
    `abstract void` | `flushTermsBlock(int start, int count)` Flush count terms starting at start "backwards", as a block.
    `abstract void` | `setField(FieldInfo fieldInfo)` Called when the writing switches to another field.
    `abstract void` | `start(IndexOutput termsOut)` Called once after startup, before any terms have been added.
    `abstract void` | `startTerm()` Start a new term.

    - ### Methods inherited from class org.apache.lucene.codecs.PostingsConsumer

      `addPosition, finishDoc, merge, startDoc`

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

    - #### start

          public abstract void start(IndexOutput termsOut)
                              throws IOException

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

    - #### startTerm

          public abstract void startTerm()
                                  throws IOException

      Start a new term. Note that a matching call to `finishTerm(TermStats)` is done, only if the term has at least one document.
      Throws:
        `IOException`

    - #### flushTermsBlock

          public abstract void flushTermsBlock(int start,
                             int count)
                                        throws IOException

      Flush count terms starting at start "backwards", as a block. start is a negative offset from the end of the terms stack, ie bigger start means further back in the stack.
      Throws:
        `IOException`

    - #### finishTerm

          public abstract void finishTerm(TermStats stats)
                                   throws IOException

      Finishes the current term. The provided `TermStats` contains the term's summary statistics.
      Throws:
        `IOException`

    - #### setField

          public abstract void setField(FieldInfo fieldInfo)

      Called when the writing switches to another field.

    - #### close

          public abstract void close()
                              throws IOException

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

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.