mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-24 13:54:26 +01:00
37 lines
796 B
Rust
37 lines
796 B
Rust
|
use roaring::RoaringBitmap;
|
||
|
|
||
|
use crate::DocumentId;
|
||
|
use super::{DocIter, Distinct};
|
||
|
|
||
|
pub struct NoopDistinct;
|
||
|
|
||
|
pub struct NoopDistinctIter {
|
||
|
candidates: roaring::bitmap::IntoIter,
|
||
|
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,
|
||
|
}
|
||
|
}
|
||
|
}
|