Skip to main content

TermStream

Struct TermStream 

Source
pub struct TermStream<'segment> { /* private fields */ }
Expand description

One query term’s merged postings across the weighted fields of a segment.

The merge is lazy: nothing is materialized, so a pruned traversal that skips a block never decodes it. That is the difference between reading a format and copying one.

Implementations§

Source§

impl<'segment> TermStream<'segment>

Source

pub fn open( segment: &'segment SealedSegment, term: &[u8], weights: &FieldWeights, ) -> Option<Self>

Opens the stream for term over the weighted fields of segment.

Returns None when no weighted field carries the term.

Source

pub fn reset(&mut self)

Rewinds every run to the first posting.

Source

pub const fn current_row(&self) -> Option<u32>

Returns the merged row at the head.

Source

pub fn current_tf(&mut self) -> Option<u32>

Returns the merged weighted tf at the head, computing it on first demand. This is the only place a traversal pays a tf decode.

Source

pub fn advance(&mut self)

Advances past the current row.

Source

pub fn seek(&mut self, row: u32)

Advances to the first merged row at or after row.

Source

pub const fn exhausted(&self) -> bool

Returns true when every run is spent.

Source

pub fn blocks_decoded(&self) -> u64

Blocks this stream decoded.

Source

pub fn blocks_skipped(&self) -> u64

Blocks this stream jumped over without decoding.

Source

pub fn tf_blocks_decoded(&self) -> u64

Blocks whose tf run this stream actually unpacked.

At most Self::blocks_decoded; strictly less whenever a landed block was jumped past without any of its postings being scored.

Source

pub fn posting_count(&self) -> usize

Postings this stream can produce, summed over its runs.

Read from the block metadata, so it costs no decode.

Source

pub fn block_bound(&self, scorer: &TermScorer) -> f64

The bound over the blocks the runs currently sit in.

See the module docs for why (Tmax, Lmin) dominates every merged row under any weight table.

Source

pub fn bound_for(&self, row: u32, scorer: &TermScorer) -> f64

The bound over the blocks that could contain row, without decode.

Each run contributes the impact pair of the block its skip keys say could hold row; a run that has already passed row, or whose remaining blocks all end below it, contributes nothing — which is exact rather than conservative, because postings ascend. Costs one binary search over skip keys per run and no decode, so a candidate can be refused before any cursor is paid to move.

Source

pub fn bound_horizon_for(&self, row: u32) -> Option<u32>

The largest row for which Self::bound_for still dominates.

§Why a traversal needs this

Self::bound_for answers about one row. A traversal that has just proved that row unreachable wants to know how far that proof reaches, so it can seek past a whole span instead of landing in the next block to ask the same question again.

Every run reports the row at which its own answer would change: the skip key of the block the bound came from, or — for a run whose head already sits above row, and which therefore contributed nothing — the row before that head. The minimum is the row through which EVERY run’s contribution is still the one that went into the bound, so the bound dominates the whole span.

None when no run bounds the span: every run is spent at or past row and can never contribute again.

Source

pub fn upper_bound(&self, scorer: &TermScorer) -> f64

The bound over every block of every run: the term’s upper bound.

Trait Implementations§

Source§

impl<'segment> Clone for TermStream<'segment>

Source§

fn clone(&self) -> Self

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<'segment> Debug for TermStream<'segment>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'segment> Freeze for TermStream<'segment>

§

impl<'segment> RefUnwindSafe for TermStream<'segment>

§

impl<'segment> Send for TermStream<'segment>

§

impl<'segment> Sync for TermStream<'segment>

§

impl<'segment> Unpin for TermStream<'segment>

§

impl<'segment> UnsafeUnpin for TermStream<'segment>

§

impl<'segment> UnwindSafe for TermStream<'segment>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.