Skip to main content

ScoreSink

Trait ScoreSink 

Source
pub trait ScoreSink {
    // Required methods
    fn offer(&mut self, id: RecordId, score: f32);
    fn threshold(&self) -> Option<f32>;
    fn into_results(self) -> Vec<(RecordId, f32)>;
}
Expand description

Consumer of (id, score) pairs produced by the search loop.

The loop offers records in increasing id order and asks for the threshold before scoring a window: a record whose score cannot strictly exceed it is not worth scoring. Because later records have larger ids and ties go to the lower id, a score equal to the threshold can never displace what the sink already holds.

Required Methods§

Source

fn offer(&mut self, id: RecordId, score: f32)

Offer one scored record.

Source

fn threshold(&self) -> Option<f32>

Score a new record must strictly beat to be retained, or None if every record is still welcome.

Source

fn into_results(self) -> Vec<(RecordId, f32)>

Retained records, sorted by score descending then id ascending.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§