mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
Fix the merge for roaring bitmap
This commit is contained in:
parent
b625d31c7d
commit
bb885a5810
@ -402,37 +402,28 @@ mod indexer {
|
|||||||
del: Option<&[u8]>,
|
del: Option<&[u8]>,
|
||||||
add: Option<&[u8]>,
|
add: Option<&[u8]>,
|
||||||
) -> Result<Operation> {
|
) -> Result<Operation> {
|
||||||
let bitmap = match current {
|
let current = current.map(CboRoaringBitmapCodec::deserialize_from).transpose()?;
|
||||||
Some(current_bitmap_bytes) => {
|
let del = del.map(CboRoaringBitmapCodec::deserialize_from).transpose()?;
|
||||||
let bitmap_without_del = match del {
|
let add = add.map(CboRoaringBitmapCodec::deserialize_from).transpose()?;
|
||||||
Some(del_bytes) => {
|
|
||||||
let del_bitmap = CboRoaringBitmapCodec::deserialize_from(del_bytes)?;
|
|
||||||
CboRoaringBitmapCodec::intersection_with_serialized(
|
|
||||||
current_bitmap_bytes,
|
|
||||||
&del_bitmap,
|
|
||||||
)?
|
|
||||||
}
|
|
||||||
None => CboRoaringBitmapCodec::deserialize_from(current_bitmap_bytes)?,
|
|
||||||
};
|
|
||||||
|
|
||||||
match add {
|
match (current, del, add) {
|
||||||
Some(add_bytes) => {
|
(None, None, None) => Ok(Operation::Ignore), // but it's strange
|
||||||
let add = CboRoaringBitmapCodec::deserialize_from(add_bytes)?;
|
(None, None, Some(add)) => Ok(Operation::Write(add)),
|
||||||
bitmap_without_del | add
|
(None, Some(_del), None) => Ok(Operation::Ignore), // but it's strange
|
||||||
}
|
(None, Some(_del), Some(add)) => Ok(Operation::Write(add)),
|
||||||
None => bitmap_without_del,
|
(Some(_current), None, None) => Ok(Operation::Ignore), // but it's strange
|
||||||
}
|
(Some(current), None, Some(add)) => Ok(Operation::Write(current | add)),
|
||||||
}
|
(Some(current), Some(del), add) => {
|
||||||
None => match add {
|
let output = match add {
|
||||||
Some(add_bytes) => CboRoaringBitmapCodec::deserialize_from(add_bytes)?,
|
Some(add) => (current - del) | add,
|
||||||
None => return Ok(Operation::Ignore),
|
None => current - del,
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
if output.is_empty() {
|
||||||
if bitmap.is_empty() {
|
|
||||||
Ok(Operation::Delete)
|
Ok(Operation::Delete)
|
||||||
} else {
|
} else {
|
||||||
Ok(Operation::Write(bitmap))
|
Ok(Operation::Write(output))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user