org.apache.lucene.codecs
Class DocValuesConsumer

java.lang.Object
  extended by org.apache.lucene.codecs.DocValuesConsumer

public abstract class DocValuesConsumer
extends Object

Abstract API that consumes IndexableFields. DocValuesConsumer are always associated with a specific field and segments. Concrete implementations of this API write the given IndexableField into a implementation specific format depending on the fields meta-data.

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

Field Summary
protected  BytesRef spare
          Spare BytesRef that subclasses can reuse.
 
Constructor Summary
protected DocValuesConsumer()
          Sole constructor.
 
Method Summary
abstract  void add(int docID, IndexableField value)
          Adds the given IndexableField instance to this DocValuesConsumer
abstract  void finish(int docCount)
          Called when the consumer of this API is done adding values.
protected abstract  DocValues.Type getType()
          Returns the DocValues.Type of this consumer.
abstract  int getValueSize()
          Returns the value size this consumer accepts or -1 iff this consumer is value size agnostic ie.
protected  void merge(DocValues reader, int docBase, int docCount, Bits liveDocs)
          Merges the given DocValues into this DocValuesConsumer.
 void merge(MergeState mergeState, DocValues[] docValues)
          Merges the given MergeState into this DocValuesConsumer.
protected  void mergeDoc(Field scratchField, DocValues.Source source, int docID, int sourceDoc)
          Merges a document with the given docID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

spare

protected final BytesRef spare
Spare BytesRef that subclasses can reuse.

Constructor Detail

DocValuesConsumer

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

Method Detail

getType

protected abstract DocValues.Type getType()
Returns the DocValues.Type of this consumer.


add

public abstract void add(int docID,
                         IndexableField value)
                  throws IOException
Adds the given IndexableField instance to this DocValuesConsumer

Parameters:
docID - the document ID to add the value for. The docID must always increase or be 0 if it is the first call to this method.
value - the value to add
Throws:
IOException - if an IOException occurs

finish

public abstract void finish(int docCount)
                     throws IOException
Called when the consumer of this API is done adding values.

Parameters:
docCount - the total number of documents in this DocValuesConsumer. Must be greater than or equal the last given docID to add(int, IndexableField).
Throws:
IOException - If an I/O error occurs

getValueSize

public abstract int getValueSize()
Returns the value size this consumer accepts or -1 iff this consumer is value size agnostic ie. accepts variable length values.

NOTE: the return value is undefined until the consumer has successfully consumed at least one value.

Returns:
the value size this consumer accepts or -1 iff this consumer is value size agnostic ie. accepts variable length values.

merge

public void merge(MergeState mergeState,
                  DocValues[] docValues)
           throws IOException
Merges the given MergeState into this DocValuesConsumer.

Parameters:
mergeState - the state to merge
docValues - docValues array containing one instance per reader ( MergeState.readers) or null if the reader has no DocValues instance.
Throws:
IOException - if an IOException occurs

merge

protected void merge(DocValues reader,
                     int docBase,
                     int docCount,
                     Bits liveDocs)
              throws IOException
Merges the given DocValues into this DocValuesConsumer.

Throws:
IOException - if an IOException occurs

mergeDoc

protected void mergeDoc(Field scratchField,
                        DocValues.Source source,
                        int docID,
                        int sourceDoc)
                 throws IOException
Merges a document with the given docID. The methods implementation obtains the value for the sourceDoc id from the current DocValues.Source.

This method is used during merging to provide implementation agnostic default merge implementation.

All documents IDs between the given ID and the previously given ID or 0 if the method is call the first time are filled with default values depending on the implementation. The given document ID must always be greater than the previous ID or 0 if called the first time.

Throws:
IOException


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