2021-04-07 12:38:48 +02:00
|
|
|
mod facet_distinct;
|
|
|
|
mod map_distinct;
|
|
|
|
mod noop_distinct;
|
|
|
|
|
|
|
|
use roaring::RoaringBitmap;
|
|
|
|
|
|
|
|
pub use facet_distinct::FacetDistinct;
|
|
|
|
pub use map_distinct::MapDistinct;
|
|
|
|
pub use noop_distinct::NoopDistinct;
|
|
|
|
use crate::DocumentId;
|
|
|
|
|
2021-04-14 12:00:45 +02:00
|
|
|
/// A trait implemented by document interators that are returned by calls to `Distinct::distinct`.
|
|
|
|
/// It provides a way to get back the ownership to the excluded set.
|
2021-04-07 12:38:48 +02:00
|
|
|
pub trait DocIter: Iterator<Item=anyhow::Result<DocumentId>> {
|
2021-04-14 12:00:45 +02:00
|
|
|
/// Returns ownership on the internal exluded set.
|
2021-04-07 12:38:48 +02:00
|
|
|
fn into_excluded(self) -> RoaringBitmap;
|
|
|
|
}
|
|
|
|
|
2021-04-14 12:00:45 +02:00
|
|
|
/// A trait that is implemented by structs that perform a distinct on `candidates`. Calling distinct
|
|
|
|
/// must return an iterator containing only distinct documents, and add the discarded documents to
|
|
|
|
/// the excluded set. The excluded set can later be retrieved by calling `DocIter::excluded` on the
|
|
|
|
/// returned iterator.
|
2021-04-07 12:38:48 +02:00
|
|
|
pub trait Distinct<'a> {
|
|
|
|
type Iter: DocIter;
|
|
|
|
|
|
|
|
fn distinct(&'a mut self, candidates: RoaringBitmap, excluded: RoaringBitmap) -> Self::Iter;
|
|
|
|
}
|