Skip to main content

PostingList

Struct PostingList 

Source
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

Source

pub fn new() -> Self

Construct an empty posting list.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn ranked(&self) -> RankedView<'_>

Build a score-ordered view without changing posting storage order.

Source

pub fn with_scores<F>(&self, score_fn: F) -> Self
where F: Fn(&PostingEntry) -> f64,

Apply a scoring function to every entry, returning a new posting list.

Source

pub fn get_entry(&self, doc_id: DocId) -> Option<&PostingEntry>

Look up an entry by doc_id. O(log n) via binary search.

Source

pub fn entries(&self) -> &[PostingEntry]

Source

pub fn doc_ids(&self) -> impl Iterator<Item = DocId> + '_

Source

pub fn support(&self) -> DocSet

Project this payload-bearing relation onto its document-id support.

Source

pub fn from_support(support: &DocSet) -> Self

Create document-id-ordered posting storage with a default payload for every id in support.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn iter(&self) -> Iter<'_, PostingEntry>

Trait Implementations§

Source§

impl Clone for PostingList

Source§

fn clone(&self) -> PostingList

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PostingList

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PostingList

Source§

fn default() -> PostingList

Returns the “default value” for a type. Read more
Source§

impl From<&DocSet> for PostingList

Source§

fn from(support: &DocSet) -> Self

Converts to this type from the input type.
Source§

impl From<&PostingList> for DocSet

Source§

fn from(posting_list: &PostingList) -> Self

Converts to this type from the input type.
Source§

impl From<DocSet> for PostingList

Source§

fn from(support: DocSet) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<PostingEntry> for PostingList

Source§

fn from_iter<I: IntoIterator<Item = PostingEntry>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl IntoIterator for PostingList

Source§

type Item = PostingEntry

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<PostingEntry>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a PostingList

Source§

type Item = &'a PostingEntry

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, PostingEntry>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for PostingList

Source§

fn eq(&self, other: &PostingList) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PostingList

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.