Package org.apache.lucene.codecs
Class PushPostingsWriterBase
java.lang.Object
org.apache.lucene.codecs.PostingsWriterBase
org.apache.lucene.codecs.PushPostingsWriterBase
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
Lucene101PostingsWriter
Extension of
PostingsWriterBase, adding a push API for writing each element of the
postings. This API is somewhat analogous to an XML SAX API, while PostingsWriterBase is
more like an XML DOM API.- See Also:
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FieldInfoFieldInfoof current field being written.protected IndexOptionsIndexOptionsof current field being writtenprotected booleanTrue if the current field writes freqs.protected booleanTrue if the current field writes offsets.protected booleanTrue if the current field writes payloads.protected booleanTrue if the current field writes positions. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddPosition(int position, BytesRef payload, int startOffset, int endOffset) Add a new position and payload, and start/end offset.abstract voidCalled when we are done adding positions and payloads for each doc.abstract voidfinishTerm(BlockTermState state) Finishes the current term.abstract BlockTermStateReturn a newly created empty TermStatevoidSets 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 voidstartDoc(int docID, int freq) Adds a new doc in this term.abstract voidstartTerm(NumericDocValues norms) Start a new term.final BlockTermStatewriteTerm(BytesRef term, TermsEnum termsEnum, FixedBitSet docsSeen, NormsProducer norms) Write all postings for one term; use the providedTermsEnumto pull aPostingsEnum.Methods inherited from class org.apache.lucene.codecs.PostingsWriterBase
close, encodeTerm, init
-
Field Details
-
fieldInfo
FieldInfoof current field being written. -
indexOptions
IndexOptionsof current field being written -
writeFreqs
protected boolean writeFreqsTrue if the current field writes freqs. -
writePositions
protected boolean writePositionsTrue if the current field writes positions. -
writePayloads
protected boolean writePayloadsTrue if the current field writes payloads. -
writeOffsets
protected boolean writeOffsetsTrue if the current field writes offsets.
-
-
Constructor Details
-
PushPostingsWriterBase
protected PushPostingsWriterBase()Sole constructor. (For invocation by subclass constructors, typically implicit.)
-
-
Method Details
-
newTermState
Return a newly created empty TermState- Throws:
IOException
-
startTerm
Start a new term. Note that a matching call tofinishTerm(BlockTermState)is done, only if the term has at least one document.- Throws:
IOException
-
finishTerm
Finishes the current term. The providedBlockTermStatecontains the term's summary statistics, and will holds metadata from PBF when returned- Throws:
IOException
-
setField
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.- Specified by:
setFieldin classPostingsWriterBase
-
writeTerm
public final BlockTermState writeTerm(BytesRef term, TermsEnum termsEnum, FixedBitSet docsSeen, NormsProducer norms) throws IOException Description copied from class:PostingsWriterBaseWrite 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.- Specified by:
writeTermin classPostingsWriterBase- Throws:
IOException
-
startDoc
Adds a new doc in this term.freqwill 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 and 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 theBytesReffor the payload between calls (method must fully consume the payload).startOffsetandendOffsetwill be -1 when offsets are not indexed.- Throws:
IOException
-
finishDoc
Called when we are done adding positions and payloads for each doc.- Throws:
IOException
-