mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-10-11 06:06:32 +00:00
Patch the CBO roaring encoders to use the main branch
This commit is contained in:
@@ -43,8 +43,10 @@ impl heed::BytesEncode<'_> for BoRoaringBitmapCodec {
|
||||
type EItem = RoaringBitmap;
|
||||
|
||||
fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, BoxedError> {
|
||||
let mut item = item.clone();
|
||||
item.optimize();
|
||||
let mut out = Vec::new();
|
||||
BoRoaringBitmapCodec::serialize_into(item, &mut out);
|
||||
BoRoaringBitmapCodec::serialize_into(&item, &mut out);
|
||||
Ok(Cow::Owned(out))
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ use crate::update::del_add::{DelAdd, KvReaderDelAdd};
|
||||
/// This is the limit where using a byteorder became less size efficient
|
||||
/// than using a direct roaring encoding, it is also the point where we are able
|
||||
/// to determine the encoding used only by using the array of bytes length.
|
||||
pub const THRESHOLD: usize = 7;
|
||||
pub const THRESHOLD: usize = 3;
|
||||
|
||||
/// A conditionnal codec that either use the RoaringBitmap
|
||||
/// or a lighter ByteOrder en/decoding method.
|
||||
@@ -177,8 +177,10 @@ impl heed::BytesEncode<'_> for CboRoaringBitmapCodec {
|
||||
type EItem = RoaringBitmap;
|
||||
|
||||
fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, BoxedError> {
|
||||
let mut vec = Vec::with_capacity(Self::serialized_size(item));
|
||||
Self::serialize_into_vec(item, &mut vec);
|
||||
let mut item = item.clone();
|
||||
item.optimize();
|
||||
let mut vec = Vec::with_capacity(Self::serialized_size(&item));
|
||||
Self::serialize_into_vec(&item, &mut vec);
|
||||
Ok(Cow::Owned(vec))
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,8 @@ impl heed::BytesEncode<'_> for RoaringBitmapCodec {
|
||||
type EItem = RoaringBitmap;
|
||||
|
||||
fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, BoxedError> {
|
||||
let mut item = item.clone();
|
||||
item.optimize();
|
||||
let mut bytes = Vec::with_capacity(item.serialized_size());
|
||||
item.serialize_into(&mut bytes)?;
|
||||
Ok(Cow::Owned(bytes))
|
||||
|
Reference in New Issue
Block a user