PostingsEnum
- Namespace
- Rowles.LeanLucene.Codecs.Postings
- Assembly
- Rowles.LeanLucene.dll
Forward-only cursor over a postings list. Decodes doc IDs and frequencies once into ArrayPool-rented buffers, then yields (DocId, Freq) pairs via MoveNext(). Optionally decodes positions when created via CreateWithPositions(IndexInput, long, byte).
Lifetime contract: When using the lazy position path, this struct holds a raw
byte* pointer into a memory-mapped IndexInput. The source input
(_sourceInput) must remain open and un-disposed for the entire lifetime
of this PostingsEnum. Callers must not dispose the IndexInput while any PostingsEnum
referencing it is still alive.
public struct PostingsEnum : IDisposable
t_lazyPosPool
t_posCountsPool
t_posOffsetsPool
DocFreq
Gets the total number of documents in this postings list.
DocId
Gets the current document ID, or -1 if the cursor has not been advanced or is exhausted.
Empty
A pre-built empty postings enum that is immediately exhausted.
Freq
Gets the term frequency in the current document. Returns 1 if frequency data is unavailable.
IsExhausted
Gets a value indicating whether the cursor has passed the last document.
Advance(int)
Advances to the first document >= targetDocId. Returns true if found. Lazy mode delegates to BlockPostingsEnum skip data for O(log N) seeking. Eager mode uses binary search on the pre-decoded docId array.
Create(IndexInput, long, byte)
Creates a PostingsEnum by reading from a memory-mapped IndexInput at the specified offset.
CreateWithPositions(IndexInput, long, byte)
Creates a PostingsEnum that lazily decodes position data for phrase queries. During creation, only per-doc byte offsets and position counts are recorded. Actual position values are decoded on-demand via GetCurrentPositions().
Dispose()
Returns all rented buffers back to System.Buffers.ArrayPool`1.
GetCurrentPositions()
Returns positions for the current document. Supports both eager (pre-decoded) and lazy (on-demand) position data. Returns empty span if positions were not available. Caches the last decoded result to avoid redundant VarInt decoding when called multiple times for the same document (common in phrase evaluation).
GetPayload(int)
Gets the payload for a specific position index of the current document. Requires GetCurrentPositions() to have been called first on this document to populate payload offsets. Returns empty span when no payloads are stored.
MoveNext()
Advances the cursor to the next document. Returns true if a document was found.
Reset()
Resets the cursor to before the first document, allowing the list to be re-iterated.
ValidateFileHeader(IndexInput)
Validates the postings file header. Returns the format version. Should be called when opening a segment, before using Create/CreateWithPositions.