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

3
Cargo.lock generated
View File

@@ -5168,8 +5168,7 @@ checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422"
[[package]]
name = "roaring"
version = "0.10.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19e8d2cfa184d94d0726d650a9f4a1be7f9b76ac9fdb954219878dc00c1c1e7b"
source = "git+https://github.com/RoaringBitmap/roaring-rs.git#6535a822358fce546eb021da8b02d52e4906fe7a"
dependencies = [
"bytemuck",
"byteorder",

View File

@@ -49,3 +49,6 @@ opt-level = 3
opt-level = 3
[profile.dev.package.roaring]
opt-level = 3
[patch.crates-io]
roaring = { git = "https://github.com/RoaringBitmap/roaring-rs.git" }

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