Module org.apache.lucene.core
Class Lucene912PostingsWriter
java.lang.Object
org.apache.lucene.codecs.PostingsWriterBase
org.apache.lucene.codecs.PushPostingsWriterBase
org.apache.lucene.codecs.lucene912.Lucene912PostingsWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
Writer for
Lucene912PostingsFormat
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private int
(package private) final long[]
private int
(package private) IndexOutput
private long
(package private) static final Lucene912PostingsFormat.IntBlockTermState
private boolean
private final ForDeltaUtil
(package private) final long[]
private int
private int
private int
(package private) Lucene912PostingsFormat.IntBlockTermState
private final CompetitiveImpactAccumulator
private int
private long
private long
private final ByteBuffersDataOutput
Output for a single block.private final CompetitiveImpactAccumulator
private int
private long
private long
private final ByteBuffersDataOutput
Output for groups of 32 blocks.private int
private int
private int
private int
(package private) IndexOutput
private NumericDocValues
(package private) final long[]
(package private) final long[]
private byte[]
private int
(package private) final long[]
(package private) IndexOutput
private long
private final PForUtil
private int
(package private) final long[]
(package private) IndexOutput
private long
private final ByteBuffersDataOutput
Scratch output that we use to be able to prepend the encoded length, e.g.Fields inherited from class org.apache.lucene.codecs.PushPostingsWriterBase
fieldInfo, indexOptions, writeFreqs, writeOffsets, writePayloads, writePositions
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPosition
(int position, BytesRef payload, int startOffset, int endOffset) Add a new position and payload, and start/end offset.void
close()
void
encodeTerm
(DataOutput out, FieldInfo fieldInfo, BlockTermState _state, boolean absolute) Encode metadata as long[] and byte[].void
Called when we are done adding positions and payloads for each doc.void
finishTerm
(BlockTermState _state) Called when we are done adding docs to this termprivate void
flushDocBlock
(boolean finishTerm) void
init
(IndexOutput termsOut, SegmentWriteState state) Called once after startup, before any terms have been added.Return a newly created empty TermStatevoid
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.void
startDoc
(int docID, int termDocFreq) Adds a new doc in this term.void
startTerm
(NumericDocValues norms) Start a new term.(package private) static void
writeImpacts
(Collection<Impact> impacts, DataOutput out) private void
(package private) static void
writeVInt15
(DataOutput out, int v) Special vints that are encoded on 2 bytes if they require 15 bits or less.(package private) static void
writeVLong15
(DataOutput out, long v) Methods inherited from class org.apache.lucene.codecs.PushPostingsWriterBase
writeTerm
-
Field Details
-
EMPTY_STATE
-
metaOut
IndexOutput metaOut -
docOut
IndexOutput docOut -
posOut
IndexOutput posOut -
payOut
IndexOutput payOut -
lastState
-
docStartFP
private long docStartFP -
posStartFP
private long posStartFP -
payStartFP
private long payStartFP -
docDeltaBuffer
final long[] docDeltaBuffer -
freqBuffer
final long[] freqBuffer -
docBufferUpto
private int docBufferUpto -
posDeltaBuffer
final long[] posDeltaBuffer -
payloadLengthBuffer
final long[] payloadLengthBuffer -
offsetStartDeltaBuffer
final long[] offsetStartDeltaBuffer -
offsetLengthBuffer
final long[] offsetLengthBuffer -
posBufferUpto
private int posBufferUpto -
payloadBytes
private byte[] payloadBytes -
payloadByteUpto
private int payloadByteUpto -
level0LastDocID
private int level0LastDocID -
level0LastPosFP
private long level0LastPosFP -
level0LastPayFP
private long level0LastPayFP -
level1LastDocID
private int level1LastDocID -
level1LastPosFP
private long level1LastPosFP -
level1LastPayFP
private long level1LastPayFP -
docID
private int docID -
lastDocID
private int lastDocID -
lastPosition
private int lastPosition -
lastStartOffset
private int lastStartOffset -
docCount
private int docCount -
pforUtil
-
forDeltaUtil
-
fieldHasNorms
private boolean fieldHasNorms -
norms
-
level0FreqNormAccumulator
-
level1CompetitiveFreqNormAccumulator
-
maxNumImpactsAtLevel0
private int maxNumImpactsAtLevel0 -
maxImpactNumBytesAtLevel0
private int maxImpactNumBytesAtLevel0 -
maxNumImpactsAtLevel1
private int maxNumImpactsAtLevel1 -
maxImpactNumBytesAtLevel1
private int maxImpactNumBytesAtLevel1 -
scratchOutput
Scratch output that we use to be able to prepend the encoded length, e.g. impacts. -
level0Output
Output for a single block. This is useful to be able to prepend skip data before each block, which can only be computed once the block is encoded. The content is then typically copied tolevel1Output
. -
level1Output
Output for groups of 32 blocks. This is useful to prepend skip data for these 32 blocks, which can only be done once we have encoded these 32 blocks. The content is then typically copied todocCount
.
-
-
Constructor Details
-
Lucene912PostingsWriter
Sole constructor.- Throws:
IOException
-
-
Method Details
-
newTermState
Description copied from class:PushPostingsWriterBase
Return a newly created empty TermState- Specified by:
newTermState
in classPushPostingsWriterBase
-
init
Description copied from class:PostingsWriterBase
Called once after startup, before any terms have been added. Implementations typically write a header to the providedtermsOut
.- Specified by:
init
in classPostingsWriterBase
- Throws:
IOException
-
setField
Description copied from class:PushPostingsWriterBase
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.- Overrides:
setField
in classPushPostingsWriterBase
-
startTerm
Description copied from class:PushPostingsWriterBase
Start a new term. Note that a matching call toPushPostingsWriterBase.finishTerm(BlockTermState)
is done, only if the term has at least one document.- Specified by:
startTerm
in classPushPostingsWriterBase
-
startDoc
Description copied from class:PushPostingsWriterBase
Adds a new doc in this term.freq
will be -1 when term frequencies are omitted for the field.- Specified by:
startDoc
in classPushPostingsWriterBase
- Throws:
IOException
-
addPosition
public void addPosition(int position, BytesRef payload, int startOffset, int endOffset) throws IOException Description copied from class:PushPostingsWriterBase
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 theBytesRef
for the payload between calls (method must fully consume the payload).startOffset
andendOffset
will be -1 when offsets are not indexed.- Specified by:
addPosition
in classPushPostingsWriterBase
- Throws:
IOException
-
finishDoc
Description copied from class:PushPostingsWriterBase
Called when we are done adding positions and payloads for each doc.- Specified by:
finishDoc
in classPushPostingsWriterBase
- Throws:
IOException
-
writeVInt15
Special vints that are encoded on 2 bytes if they require 15 bits or less. VInt becomes especially slow when the number of bytes is variable, so this special layout helps in the case when the number likely requires 15 bits or less- Throws:
IOException
-
writeVLong15
- Throws:
IOException
- See Also:
-
flushDocBlock
- Throws:
IOException
-
writeLevel1SkipData
- Throws:
IOException
-
writeImpacts
- Throws:
IOException
-
finishTerm
Called when we are done adding docs to this term- Specified by:
finishTerm
in classPushPostingsWriterBase
- Throws:
IOException
-
encodeTerm
public void encodeTerm(DataOutput out, FieldInfo fieldInfo, BlockTermState _state, boolean absolute) throws IOException Description copied from class:PostingsWriterBase
Encode metadata as long[] and byte[].absolute
controls whether current term is delta encoded according to latest term. Usually elements inlongs
are file pointers, so each one always increases when a new term is consumed.out
is used to write generic bytes, which are not monotonic.- Specified by:
encodeTerm
in classPostingsWriterBase
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classPostingsWriterBase
- Throws:
IOException
-