Skip to main content

Frontier

Struct Frontier 

Source
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>

Source

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.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn lanes(&self) -> &[Lane<C>]

Source

pub fn retire_exhausted(&mut self)

Drop lanes whose cursor is past the end.

Source

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.

Source

pub fn max_last_id(&self) -> Option<RecordId>

Largest last id across lanes: no record beyond it exists in any lane.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<C: Debug> Debug for Frontier<C>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C> Freeze for Frontier<C>
where Vec<Lane<C>>: Freeze,

§

impl<C> RefUnwindSafe for Frontier<C>
where Vec<Lane<C>>: RefUnwindSafe,

§

impl<C> Send for Frontier<C>
where Vec<Lane<C>>: Send,

§

impl<C> Sync for Frontier<C>
where Vec<Lane<C>>: Sync,

§

impl<C> Unpin for Frontier<C>
where Vec<Lane<C>>: Unpin,

§

impl<C> UnsafeUnpin for Frontier<C>
where Vec<Lane<C>>: UnsafeUnpin,

§

impl<C> UnwindSafe for Frontier<C>
where Vec<Lane<C>>: UnwindSafe,

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> 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, 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, <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.