2021-04-14 12:00:45 +02:00
|
|
|
use roaring::{RoaringBitmap, bitmap::IntoIter};
|
2021-04-07 12:38:48 +02:00
|
|
|
|
|
|
|
use crate::DocumentId;
|
|
|
|
use super::{DocIter, Distinct};
|
|
|
|
|
2021-04-14 12:00:45 +02:00
|
|
|
/// A distinct implementer that does not perform any distinct, and simply returns an iterator to
|
|
|
|
/// the candidates.
|
2021-04-07 12:38:48 +02:00
|
|
|
pub struct NoopDistinct;
|
|
|
|
|
|
|
|
pub struct NoopDistinctIter {
|
2021-04-14 12:00:45 +02:00
|
|
|
candidates: IntoIter,
|
2021-04-07 12:38:48 +02:00
|
|
|
excluded: RoaringBitmap,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Iterator for NoopDistinctIter {
|
|
|
|
type Item = anyhow::Result<DocumentId>;
|
|
|
|
|
|
|
|
fn next(&mut self) -> Option<Self::Item> {
|
|
|
|
self.candidates.next().map(Result::Ok)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DocIter for NoopDistinctIter {
|
|
|
|
fn into_excluded(self) -> RoaringBitmap {
|
|
|
|
self.excluded
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Distinct<'_> for NoopDistinct {
|
|
|
|
type Iter = NoopDistinctIter;
|
|
|
|
|
|
|
|
fn distinct(&mut self, candidates: RoaringBitmap, excluded: RoaringBitmap) -> Self::Iter {
|
|
|
|
NoopDistinctIter {
|
|
|
|
candidates: candidates.into_iter(),
|
|
|
|
excluded,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|