pub struct PostingList { /* private fields */ }Expand description
Ordered sequence of (doc_id, payload) pairs.
Invariant: entries is sorted by doc_id ascending and contains no
duplicate doc_ids.
Implementations§
Source§impl PostingList
impl PostingList
Sourcepub fn from_unsorted(entries: Vec<PostingEntry>) -> Self
pub fn from_unsorted(entries: Vec<PostingEntry>) -> Self
Construct from possibly unsorted, possibly duplicated entries.
Sorts by doc_id ascending and keeps the first occurrence on
duplicate doc_ids.
Sourcepub fn from_sorted_unchecked(entries: Vec<PostingEntry>) -> Self
pub fn from_sorted_unchecked(entries: Vec<PostingEntry>) -> Self
Construct from entries that are already sorted by doc_id ascending
and contain no duplicate doc_ids.
In debug builds this checks the invariant. In release builds it is O(1) — the caller is responsible for upholding the invariant. Used by internal merges that produce sorted output by construction.
Sourcepub fn merge_union(&self, other: &Self) -> Self
pub fn merge_union(&self, other: &Self) -> Self
Keep the union of both supports and merge payloads on a shared
doc_id.
This is not Boolean join on full posting values: scores add and fields
from other take precedence on collision. Use Self::support when a
Boolean-algebra value is required.
Sourcepub fn merge_intersection(&self, other: &Self) -> Self
pub fn merge_intersection(&self, other: &Self) -> Self
Keep the intersection of both supports and merge payloads on each
shared doc_id.
This is not Boolean meet on full posting values. Its payload policy is
the same as Self::merge_union.
Sourcepub fn merge_intersection_owned(self, other: &Self) -> Self
pub fn merge_intersection_owned(self, other: &Self) -> Self
Consuming intersection merge that avoids a result allocation for large
inputs by reusing the left posting buffer. Small inputs retain the
lower-overhead allocating path. Payload semantics are identical to
PostingList::merge_intersection, including right-hand field
precedence.
Sourcepub fn merge_support_intersection_owned(self, other: &Self) -> Self
pub fn merge_support_intersection_owned(self, other: &Self) -> Self
Intersect document support and reconstruct every retained entry with a
default payload. This is the physical meet for membership-only operator
subtrees; unlike Self::merge_intersection_owned, it deliberately
does not observe or combine scores, positions, or fields.
Sourcepub fn exclude(&self, other: &Self) -> Self
pub fn exclude(&self, other: &Self) -> Self
A - B: entries of A whose doc_id does not appear in B.
A membership filter preserves left payloads and the sorted invariant;
the temporary BTreeSet provides deterministic O(log |B|) probes.
Sourcepub fn ranked(&self) -> RankedView<'_>
pub fn ranked(&self) -> RankedView<'_>
Build a score-ordered view without changing posting storage order.
Sourcepub fn with_scores<F>(&self, score_fn: F) -> Self
pub fn with_scores<F>(&self, score_fn: F) -> Self
Apply a scoring function to every entry, returning a new posting list.
Sourcepub fn get_entry(&self, doc_id: DocId) -> Option<&PostingEntry>
pub fn get_entry(&self, doc_id: DocId) -> Option<&PostingEntry>
Look up an entry by doc_id. O(log n) via binary search.
pub fn entries(&self) -> &[PostingEntry]
pub fn doc_ids(&self) -> impl Iterator<Item = DocId> + '_
Sourcepub fn support(&self) -> DocSet
pub fn support(&self) -> DocSet
Project this payload-bearing relation onto its document-id support.
Sourcepub fn from_support(support: &DocSet) -> Self
pub fn from_support(support: &DocSet) -> Self
Create document-id-ordered posting storage with a default payload for
every id in support.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> Iter<'_, PostingEntry> ⓘ
Trait Implementations§
Source§impl Clone for PostingList
impl Clone for PostingList
Source§fn clone(&self) -> PostingList
fn clone(&self) -> PostingList
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more