Table of Contents

Public struct 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

Public field t_lazyPosPool

Public field t_posCountsPool

Public field t_posOffsetsPool

Public property DocFreq

Gets the total number of documents in this postings list.

Public property DocId

Gets the current document ID, or -1 if the cursor has not been advanced or is exhausted.

Public property Empty

A pre-built empty postings enum that is immediately exhausted.

Public property Freq

Gets the term frequency in the current document. Returns 1 if frequency data is unavailable.

Public property IsExhausted

Gets a value indicating whether the cursor has passed the last document.

Public method 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.

Public method Create(IndexInput, long, byte)

Creates a PostingsEnum by reading from a memory-mapped IndexInput at the specified offset.

Public method 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().

Public method Dispose()

Returns all rented buffers back to System.Buffers.ArrayPool`1.

Public method 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).

Public method 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.

Public method MoveNext()

Advances the cursor to the next document. Returns true if a document was found.

Public method Reset()

Resets the cursor to before the first document, allowing the list to be re-iterated.

Public method ValidateFileHeader(IndexInput)

Validates the postings file header. Returns the format version. Should be called when opening a segment, before using Create/CreateWithPositions.