mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-25 11:35:05 +08:00
Do not check before pushing in bitmaps
This commit is contained in:
parent
ff931edb55
commit
4ce5d3d66d
@ -198,30 +198,29 @@ impl DelAddRoaringBitmap {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
struct PushOptimizedBitmap {
|
struct PushOptimizedBitmap {
|
||||||
max: Option<u32>,
|
|
||||||
bitmap: RoaringBitmap,
|
bitmap: RoaringBitmap,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PushOptimizedBitmap {
|
impl PushOptimizedBitmap {
|
||||||
|
#[inline]
|
||||||
fn from_bitmap(bitmap: RoaringBitmap) -> PushOptimizedBitmap {
|
fn from_bitmap(bitmap: RoaringBitmap) -> PushOptimizedBitmap {
|
||||||
PushOptimizedBitmap { max: bitmap.max(), bitmap }
|
PushOptimizedBitmap { bitmap }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn from_single(single: u32) -> PushOptimizedBitmap {
|
fn from_single(single: u32) -> PushOptimizedBitmap {
|
||||||
PushOptimizedBitmap { max: Some(single), bitmap: RoaringBitmap::from([single]) }
|
PushOptimizedBitmap { bitmap: RoaringBitmap::from([single]) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn insert(&mut self, n: u32) {
|
fn insert(&mut self, n: u32) {
|
||||||
if self.max.map_or(true, |max| n > max) {
|
if !self.bitmap.push(n) {
|
||||||
self.max = Some(n);
|
|
||||||
self.bitmap.push(n);
|
|
||||||
} else {
|
|
||||||
self.bitmap.insert(n);
|
self.bitmap.insert(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn union_with_bitmap(&mut self, bitmap: RoaringBitmap) {
|
fn union_with_bitmap(&mut self, bitmap: RoaringBitmap) {
|
||||||
self.bitmap |= bitmap;
|
self.bitmap |= bitmap;
|
||||||
self.max = self.bitmap.max();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user