mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-31 15:31:53 +08:00
Introduce the FacetGroupLazyValue type
This commit is contained in:
parent
ff2e498267
commit
e4a69c5ac3
@ -47,6 +47,12 @@ pub struct FacetGroupValue {
|
|||||||
pub bitmap: RoaringBitmap,
|
pub bitmap: RoaringBitmap,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct FacetGroupLazyValue<'b> {
|
||||||
|
pub size: u8,
|
||||||
|
pub bitmap_bytes: &'b [u8],
|
||||||
|
}
|
||||||
|
|
||||||
pub struct FacetGroupKeyCodec<T> {
|
pub struct FacetGroupKeyCodec<T> {
|
||||||
_phantom: PhantomData<T>,
|
_phantom: PhantomData<T>,
|
||||||
}
|
}
|
||||||
@ -69,6 +75,7 @@ where
|
|||||||
Ok(Cow::Owned(v))
|
Ok(Cow::Owned(v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> heed::BytesDecode<'a> for FacetGroupKeyCodec<T>
|
impl<'a, T> heed::BytesDecode<'a> for FacetGroupKeyCodec<T>
|
||||||
where
|
where
|
||||||
T: BytesDecode<'a>,
|
T: BytesDecode<'a>,
|
||||||
@ -84,6 +91,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct FacetGroupValueCodec;
|
pub struct FacetGroupValueCodec;
|
||||||
|
|
||||||
impl<'a> heed::BytesEncode<'a> for FacetGroupValueCodec {
|
impl<'a> heed::BytesEncode<'a> for FacetGroupValueCodec {
|
||||||
type EItem = FacetGroupValue;
|
type EItem = FacetGroupValue;
|
||||||
|
|
||||||
@ -93,11 +101,23 @@ impl<'a> heed::BytesEncode<'a> for FacetGroupValueCodec {
|
|||||||
Ok(Cow::Owned(v))
|
Ok(Cow::Owned(v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> heed::BytesDecode<'a> for FacetGroupValueCodec {
|
impl<'a> heed::BytesDecode<'a> for FacetGroupValueCodec {
|
||||||
type DItem = FacetGroupValue;
|
type DItem = FacetGroupValue;
|
||||||
|
|
||||||
fn bytes_decode(bytes: &'a [u8]) -> Result<Self::DItem, BoxedError> {
|
fn bytes_decode(bytes: &'a [u8]) -> Result<Self::DItem, BoxedError> {
|
||||||
let size = bytes[0];
|
let size = bytes[0];
|
||||||
let bitmap = CboRoaringBitmapCodec::deserialize_from(&bytes[1..])?;
|
let bitmap = CboRoaringBitmapCodec::deserialize_from(&bytes[1..])?;
|
||||||
Ok(FacetGroupValue { size, bitmap })
|
Ok(FacetGroupValue { size, bitmap })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct FacetGroupLazyValueCodec;
|
||||||
|
|
||||||
|
impl<'a> heed::BytesDecode<'a> for FacetGroupLazyValueCodec {
|
||||||
|
type DItem = FacetGroupLazyValue<'a>;
|
||||||
|
|
||||||
|
fn bytes_decode(bytes: &'a [u8]) -> Result<Self::DItem, BoxedError> {
|
||||||
|
Ok(FacetGroupLazyValue { size: bytes[0], bitmap_bytes: &bytes[1..] })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user