Patch the CBO roaring encoders to use the main branch

This commit is contained in:
Kerollmops
2025-06-17 12:13:06 +02:00
parent abb399b802
commit 67b08a180f
5 changed files with 14 additions and 6 deletions

View File

@@ -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))
}
}

View File

@@ -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))
}
}

View File

@@ -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))