mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Remove the FacetValueStringCodec
This commit is contained in:
parent
adfd4da24c
commit
757b2b502a
8 changed files with 26 additions and 26 deletions
|
@ -2,7 +2,7 @@ use std::borrow::Cow;
|
|||
use std::convert::TryInto;
|
||||
use std::num::NonZeroU8;
|
||||
|
||||
use crate::FieldId;
|
||||
use crate::{try_split_array_at, FieldId};
|
||||
|
||||
/// A codec that stores the field id, level 1 and higher and the groups ids.
|
||||
///
|
||||
|
@ -13,12 +13,13 @@ impl<'a> heed::BytesDecode<'a> for FacetLevelValueU32Codec {
|
|||
type DItem = (FieldId, NonZeroU8, u32, u32);
|
||||
|
||||
fn bytes_decode(bytes: &'a [u8]) -> Option<Self::DItem> {
|
||||
let (field_id, bytes) = bytes.split_first()?;
|
||||
let (field_id_bytes, bytes) = try_split_array_at(bytes)?;
|
||||
let field_id = u16::from_be_bytes(field_id_bytes);
|
||||
let (level, bytes) = bytes.split_first()?;
|
||||
let level = NonZeroU8::new(*level)?;
|
||||
let left = bytes[16..20].try_into().ok().map(u32::from_be_bytes)?;
|
||||
let right = bytes[20..].try_into().ok().map(u32::from_be_bytes)?;
|
||||
Some((*field_id, level, left, right))
|
||||
let left = bytes[8..12].try_into().ok().map(u32::from_be_bytes)?;
|
||||
let right = bytes[12..].try_into().ok().map(u32::from_be_bytes)?;
|
||||
Some((field_id, level, left, right))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,8 +43,8 @@ impl heed::BytesEncode<'_> for FacetLevelValueU32Codec {
|
|||
let bytes = right.to_be_bytes();
|
||||
buffer[12..].copy_from_slice(&bytes[..]);
|
||||
|
||||
let mut bytes = Vec::with_capacity(buffer.len() + 2);
|
||||
bytes.push(*field_id);
|
||||
let mut bytes = Vec::with_capacity(buffer.len() + 2 + 1);
|
||||
bytes.extend_from_slice(&field_id.to_be_bytes());
|
||||
bytes.push(level.get());
|
||||
bytes.extend_from_slice(&buffer);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::borrow::Cow;
|
||||
use std::str;
|
||||
|
||||
use crate::FieldId;
|
||||
use crate::{try_split_array_at, FieldId};
|
||||
|
||||
/// A codec that stores the field id, level 0, and facet string.
|
||||
///
|
||||
|
@ -16,7 +16,7 @@ pub struct FacetStringLevelZeroCodec;
|
|||
impl FacetStringLevelZeroCodec {
|
||||
pub fn serialize_into(field_id: FieldId, value: &str, out: &mut Vec<u8>) {
|
||||
out.reserve(value.len() + 2);
|
||||
out.push(field_id);
|
||||
out.extend_from_slice(&field_id.to_be_bytes());
|
||||
out.push(0); // the level zero (for LMDB ordering only)
|
||||
out.extend_from_slice(value.as_bytes());
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ impl<'a> heed::BytesDecode<'a> for FacetStringLevelZeroCodec {
|
|||
type DItem = (FieldId, &'a str);
|
||||
|
||||
fn bytes_decode(bytes: &'a [u8]) -> Option<Self::DItem> {
|
||||
let (field_id, bytes) = bytes.split_first()?;
|
||||
let (field_id_bytes, bytes) = try_split_array_at(bytes)?;
|
||||
let field_id = u16::from_be_bytes(field_id_bytes);
|
||||
let (level, bytes) = bytes.split_first()?;
|
||||
|
||||
if *level != 0 {
|
||||
|
@ -34,7 +35,7 @@ impl<'a> heed::BytesDecode<'a> for FacetStringLevelZeroCodec {
|
|||
}
|
||||
|
||||
let value = str::from_utf8(bytes).ok()?;
|
||||
Some((*field_id, value))
|
||||
Some((field_id, value))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ mod facet_level_value_f64_codec;
|
|||
mod facet_level_value_u32_codec;
|
||||
mod facet_string_level_zero_codec;
|
||||
mod facet_string_zero_bounds_value_codec;
|
||||
mod facet_value_string_codec;
|
||||
mod field_doc_id_facet_f64_codec;
|
||||
mod field_doc_id_facet_string_codec;
|
||||
|
||||
|
@ -10,6 +9,5 @@ pub use self::facet_level_value_f64_codec::FacetLevelValueF64Codec;
|
|||
pub use self::facet_level_value_u32_codec::FacetLevelValueU32Codec;
|
||||
pub use self::facet_string_level_zero_codec::FacetStringLevelZeroCodec;
|
||||
pub use self::facet_string_zero_bounds_value_codec::FacetStringZeroBoundsValueCodec;
|
||||
pub use self::facet_value_string_codec::FacetValueStringCodec;
|
||||
pub use self::field_doc_id_facet_f64_codec::FieldDocIdFacetF64Codec;
|
||||
pub use self::field_doc_id_facet_string_codec::FieldDocIdFacetStringCodec;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue