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>
impl<'segment> TermStream<'segment>
Sourcepub fn open(
segment: &'segment SealedSegment,
term: &[u8],
weights: &FieldWeights,
) -> Option<Self>
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.
Sourcepub const fn current_row(&self) -> Option<u32>
pub const fn current_row(&self) -> Option<u32>
Returns the merged row at the head.
Sourcepub fn current_tf(&mut self) -> Option<u32>
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.
Sourcepub fn blocks_decoded(&self) -> u64
pub fn blocks_decoded(&self) -> u64
Blocks this stream decoded.
Sourcepub fn blocks_skipped(&self) -> u64
pub fn blocks_skipped(&self) -> u64
Blocks this stream jumped over without decoding.
Sourcepub fn tf_blocks_decoded(&self) -> u64
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.
Sourcepub fn posting_count(&self) -> usize
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.
Sourcepub fn block_bound(&self, scorer: &TermScorer) -> f64
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.
Sourcepub fn bound_for(&self, row: u32, scorer: &TermScorer) -> f64
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.
Sourcepub fn bound_horizon_for(&self, row: u32) -> Option<u32>
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.
Sourcepub fn upper_bound(&self, scorer: &TermScorer) -> f64
pub fn upper_bound(&self, scorer: &TermScorer) -> f64
The bound over every block of every run: the term’s upper bound.