pub struct Frontier<C> { /* private fields */ }Expand description
Active cursors of a query.
Exhausted lanes are retired lazily by retire_exhausted
(also called by the methods that move cursors), so len() counts lanes
that still have elements once that has run.
Implementations§
Source§impl<C: PostingCursor> Frontier<C>
impl<C: PostingCursor> Frontier<C>
Sourcepub fn new(lanes: impl IntoIterator<Item = Lane<C>>) -> Self
pub fn new(lanes: impl IntoIterator<Item = Lane<C>>) -> Self
Build from lanes. Lanes with an exhausted cursor or a zero query weight are dropped right away.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn lanes(&self) -> &[Lane<C>]
Sourcepub fn retire_exhausted(&mut self)
pub fn retire_exhausted(&mut self)
Drop lanes whose cursor is past the end.
Sourcepub fn min_id(&self) -> Option<RecordId>
pub fn min_id(&self) -> Option<RecordId>
Smallest current id across lanes: the next record that could be
scored. None when every lane is exhausted.
Sourcepub fn max_last_id(&self) -> Option<RecordId>
pub fn max_last_id(&self) -> Option<RecordId>
Largest last id across lanes: no record beyond it exists in any lane.
Sourcepub fn best_possible(&self) -> f64
pub fn best_possible(&self) -> f64
Upper bound on the score of any record no lane has consumed yet: the
sum of every lane’s headroom. +inf when a lane is unbounded.
Sourcepub fn skip_below(&mut self, threshold: f32) -> Skip
pub fn skip_below(&mut self, threshold: f32) -> Skip
Advance cursors past every id whose score cannot strictly exceed
threshold.
Lanes are sorted by current id and their headrooms accumulated in that order. The pivot is the first lane at which the running total could beat the threshold. A record with an id below the pivot’s current id can only appear in lanes ordered before the pivot, whose combined headroom is below the threshold; those lanes are seeked to the pivot id. Without a pivot, nothing left can qualify.
Sourcepub fn score_window(
&mut self,
lo: RecordId,
hi: RecordId,
scores: &mut [f32],
seen: &mut [bool],
)
pub fn score_window( &mut self, lo: RecordId, hi: RecordId, scores: &mut [f32], seen: &mut [bool], )
Consume every element with id in lo..=hi from every lane and add
query_weight * weight into scores[id - lo], marking
seen[id - lo]. Both buffers must be at least hi - lo + 1 long
and scores must be zeroed for the slots that matter. Contributions
are added in lane order, so a record’s score is the same f32 sum
regardless of which window it lands in.