Package org.apache.lucene.codecs
Class PostingsWriterBase
- java.lang.Object
-
- org.apache.lucene.codecs.PostingsConsumer
-
- org.apache.lucene.codecs.PostingsWriterBase
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
Lucene41PostingsWriter
public abstract class PostingsWriterBase extends PostingsConsumer implements java.io.Closeable
Extension ofPostingsConsumerto 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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract voidclose()abstract voidencodeTerm(long[] longs, DataOutput out, FieldInfo fieldInfo, BlockTermState state, boolean absolute)Encode metadata as long[] and byte[].abstract voidfinishTerm(BlockTermState state)Finishes the current term.abstract voidinit(IndexOutput termsOut)Called once after startup, before any terms have been added.abstract BlockTermStatenewTermState()Return a newly created empty TermStateabstract intsetField(FieldInfo fieldInfo)Sets the current field for writing, and returns the fixed length of long[] metadata (which is fixed per field), called when the writing switches to another field.abstract voidstartTerm()Start a new term.-
Methods inherited from class org.apache.lucene.codecs.PostingsConsumer
addPosition, finishDoc, merge, startDoc
-
-
-
-
Method Detail
-
init
public abstract void init(IndexOutput termsOut) throws java.io.IOException
Called once after startup, before any terms have been added. Implementations typically write a header to the providedtermsOut.- Throws:
java.io.IOException
-
newTermState
public abstract BlockTermState newTermState() throws java.io.IOException
Return a newly created empty TermState- Throws:
java.io.IOException
-
startTerm
public abstract void startTerm() throws java.io.IOExceptionStart a new term. Note that a matching call tofinishTerm(BlockTermState)is done, only if the term has at least one document.- Throws:
java.io.IOException
-
finishTerm
public abstract void finishTerm(BlockTermState state) throws java.io.IOException
Finishes the current term. The providedBlockTermStatecontains the term's summary statistics, and will holds metadata from PBF when returned- Throws:
java.io.IOException
-
encodeTerm
public abstract void encodeTerm(long[] longs, DataOutput out, FieldInfo fieldInfo, BlockTermState state, boolean absolute) throws java.io.IOExceptionEncode metadata as long[] and byte[].absolutecontrols whether current term is delta encoded according to latest term. Usually elements inlongsare file pointers, so each one always increases when a new term is consumed.outis used to write generic bytes, which are not monotonic. NOTE: sometimes long[] might contain "don't care" values that are unused, e.g. the pointer to postings list may not be defined for some terms but is defined for others, if it is designed to inline some postings data in term dictionary. In this case, the postings writer should always use the last value, so that each element in metadata long[] remains monotonic.- Throws:
java.io.IOException
-
setField
public abstract int setField(FieldInfo fieldInfo)
Sets the current field for writing, and returns the fixed length of long[] metadata (which is fixed per field), called when the writing switches to another field.
-
close
public abstract void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-