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 asBlockTreeTermsWriter, 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 protectedPostingsWriterBase()Sole constructor.
-
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 voidinit(IndexOutput termsOut, SegmentWriteState state)Called once after startup, before any terms have been added.abstract 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 BlockTermStatewriteTerm(BytesRef term, TermsEnum termsEnum, FixedBitSet docsSeen)Write all postings for one term; use the providedTermsEnumto pull aPostingsEnum.
-
-
-
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 providedtermsOut.- Throws:
IOException
-
writeTerm
public abstract BlockTermState writeTerm(BytesRef term, TermsEnum termsEnum, FixedBitSet docsSeen) throws IOException
Write all postings for one term; use the providedTermsEnumto pull aPostingsEnum. This method should not re-position theTermsEnum! It is already positioned on the term that should be written. This method must set the bit in the providedFixedBitSetfor 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(long[] longs, DataOutput out, FieldInfo fieldInfo, BlockTermState state, boolean absolute) throws 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:
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 IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-