mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 21:04:27 +01:00
Remove custom implementation of BytesEncode/Decode for the FieldId
This commit is contained in:
parent
80b962b4f4
commit
4f0bd317df
@ -1,28 +0,0 @@
|
||||
use std::borrow::Cow;
|
||||
use std::convert::TryInto;
|
||||
|
||||
use heed::zerocopy::AsBytes;
|
||||
|
||||
use crate::{FieldId, BEU16};
|
||||
|
||||
pub struct FieldIdCodec;
|
||||
|
||||
impl<'a> heed::BytesDecode<'a> for FieldIdCodec {
|
||||
type DItem = FieldId;
|
||||
|
||||
fn bytes_decode(bytes: &'a [u8]) -> Option<Self::DItem> {
|
||||
let bytes: [u8; 2] = bytes[..2].try_into().ok()?;
|
||||
let field_id = BEU16::from(bytes).get();
|
||||
Some(field_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> heed::BytesEncode<'a> for FieldIdCodec {
|
||||
type EItem = FieldId;
|
||||
|
||||
fn bytes_encode(field_id: &Self::EItem) -> Option<Cow<[u8]>> {
|
||||
let field_id = BEU16::new(*field_id);
|
||||
let bytes = field_id.as_bytes();
|
||||
Some(Cow::Owned(bytes.to_vec()))
|
||||
}
|
||||
}
|
@ -5,7 +5,9 @@ mod facet_string_level_zero_value_codec;
|
||||
mod facet_string_zero_bounds_value_codec;
|
||||
mod field_doc_id_facet_f64_codec;
|
||||
mod field_doc_id_facet_string_codec;
|
||||
mod field_id_codec;
|
||||
|
||||
use crate::BEU16;
|
||||
use heed::types::OwnedType;
|
||||
|
||||
pub use self::facet_level_value_f64_codec::FacetLevelValueF64Codec;
|
||||
pub use self::facet_level_value_u32_codec::FacetLevelValueU32Codec;
|
||||
@ -16,7 +18,8 @@ pub use self::facet_string_level_zero_value_codec::{
|
||||
pub use self::facet_string_zero_bounds_value_codec::FacetStringZeroBoundsValueCodec;
|
||||
pub use self::field_doc_id_facet_f64_codec::FieldDocIdFacetF64Codec;
|
||||
pub use self::field_doc_id_facet_string_codec::FieldDocIdFacetStringCodec;
|
||||
pub use self::field_id_codec::FieldIdCodec;
|
||||
|
||||
pub type FieldIdCodec = OwnedType<BEU16>;
|
||||
|
||||
/// Tries to split a slice in half at the given middle point,
|
||||
/// `None` if the slice is too short.
|
||||
|
@ -21,7 +21,7 @@ use crate::{
|
||||
default_criteria, BEU32StrCodec, BoRoaringBitmapCodec, CboRoaringBitmapCodec, Criterion,
|
||||
DocumentId, ExternalDocumentsIds, FacetDistribution, FieldDistribution, FieldId,
|
||||
FieldIdWordCountCodec, GeoPoint, ObkvCodec, Result, RoaringBitmapCodec, RoaringBitmapLenCodec,
|
||||
Search, StrBEU32Codec, StrStrU8Codec, BEU32,
|
||||
Search, StrBEU32Codec, StrStrU8Codec, BEU16, BEU32,
|
||||
};
|
||||
|
||||
pub const DEFAULT_MIN_WORD_LEN_ONE_TYPO: u8 = 5;
|
||||
@ -819,7 +819,7 @@ impl Index {
|
||||
rtxn: &RoTxn,
|
||||
field_id: FieldId,
|
||||
) -> heed::Result<RoaringBitmap> {
|
||||
match self.facet_id_exists_docids.get(rtxn, &field_id)? {
|
||||
match self.facet_id_exists_docids.get(rtxn, &BEU16::new(field_id))? {
|
||||
Some(docids) => Ok(docids),
|
||||
None => Ok(RoaringBitmap::new()),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user