[−][src]Struct porigon::TopScoreCollector
Documents collector, keeping track of the top N items (based on their score).
Internally, this uses a binary min-heap as an efficient manner of keeping track of the top N documents.
Methods
impl TopScoreCollector
[src]
pub fn new(limit: usize) -> Self
[src]
Constructs a new TopScoreCollector
with a hardcoded limit
of documents.
pub fn reset(&mut self)
[src]
Resets the internal state of the collector.
pub fn consume_stream<'f, I, S>(&mut self, streamer: I) where
I: for<'a> IntoStreamer<'a, Into = S, Item = (&'a [u8], u64, Score)>,
S: 'f + for<'a> Streamer<'a, Item = (&'a [u8], u64, Score)>,
[src]
I: for<'a> IntoStreamer<'a, Into = S, Item = (&'a [u8], u64, Score)>,
S: 'f + for<'a> Streamer<'a, Item = (&'a [u8], u64, Score)>,
Consumes a fst::Streamer
, collecting the items and only keeping the top N items (based on
their score).
Example
use porigon::{Searchable, TopScoreCollector}; let searchable = Searchable::build_from_iter(vec!( ("foo".as_bytes(), 1), ("foobar".as_bytes(), 2), )).unwrap(); let mut collector = TopScoreCollector::new(1); collector.consume_stream( searchable .starts_with("foo") .rescore(|_, index, _| index * 2) ); collector.consume_stream( searchable .exact_match("foobar") ); assert_eq!(collector.top_documents()[0].index, 2);
pub fn top_documents(&mut self) -> &[Document]
[src]
Returns a slice of the processed top documents, ordered by their score.
Auto Trait Implementations
impl RefUnwindSafe for TopScoreCollector
impl Send for TopScoreCollector
impl Sync for TopScoreCollector
impl Unpin for TopScoreCollector
impl UnwindSafe for TopScoreCollector
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,