org.apache.lucene.codecs
Class PostingsConsumer

java.lang.Object
  extended by org.apache.lucene.codecs.PostingsConsumer
Direct Known Subclasses:
PostingsWriterBase

public abstract class PostingsConsumer
extends Object

Abstract API that consumes postings for an individual term.

The lifecycle is:

  1. PostingsConsumer is returned for each term by TermsConsumer.startTerm(BytesRef).
  2. startDoc(int, int) is called for each document where the term occurs, specifying id and term frequency for that document.
  3. If positions are enabled for the field, then addPosition(int, BytesRef, int, int) will be called for each occurrence in the document.
  4. finishDoc() is called when the producer is done adding positions to the document.

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

Constructor Summary
protected PostingsConsumer()
          Sole constructor.
 
Method Summary
abstract  void addPosition(int position, BytesRef payload, int startOffset, int endOffset)
          Add a new position & payload, and start/end offset.
abstract  void finishDoc()
          Called when we are done adding positions & payloads for each doc.
 TermStats merge(MergeState mergeState, FieldInfo.IndexOptions indexOptions, DocsEnum postings, FixedBitSet visitedDocs)
          Default merge impl: append documents, mapping around deletes
abstract  void startDoc(int docID, int freq)
          Adds a new doc in this term.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PostingsConsumer

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

Method Detail

startDoc

public abstract void startDoc(int docID,
                              int freq)
                       throws IOException
Adds a new doc in this term. freq will be -1 when term frequencies are omitted for the field.

Throws:
IOException

addPosition

public abstract void addPosition(int position,
                                 BytesRef payload,
                                 int startOffset,
                                 int endOffset)
                          throws IOException
Add a new position & payload, and start/end offset. A null payload means no payload; a non-null payload with zero length also means no payload. Caller may reuse the BytesRef for the payload between calls (method must fully consume the payload). startOffset and endOffset will be -1 when offsets are not indexed.

Throws:
IOException

finishDoc

public abstract void finishDoc()
                        throws IOException
Called when we are done adding positions & payloads for each doc.

Throws:
IOException

merge

public TermStats merge(MergeState mergeState,
                       FieldInfo.IndexOptions indexOptions,
                       DocsEnum postings,
                       FixedBitSet visitedDocs)
                throws IOException
Default merge impl: append documents, mapping around deletes

Throws:
IOException


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