mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 21:04:27 +01:00
Introduce the obkv heed codec
This commit is contained in:
parent
f6eecb855e
commit
2210818114
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -1021,6 +1021,7 @@ dependencies = [
|
||||
"log 0.4.11",
|
||||
"memmap",
|
||||
"near-proximity",
|
||||
"obkv",
|
||||
"once_cell",
|
||||
"rayon",
|
||||
"ringtail",
|
||||
@ -1241,6 +1242,12 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
|
||||
|
||||
[[package]]
|
||||
name = "obkv"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce30a214135d83e7250f2e8fad781f7cb987e3a3f1b4529712d891594bda311c"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.4.0"
|
||||
|
@ -21,6 +21,7 @@ levenshtein_automata = { version = "0.2.0", features = ["fst_automaton"] }
|
||||
linked-hash-map = "0.5.3"
|
||||
memmap = "0.7.0"
|
||||
near-proximity = { git = "https://github.com/Kerollmops/plane-sweep-proximity", rev = "6608205" }
|
||||
obkv = "0.1.0"
|
||||
once_cell = "1.4.0"
|
||||
rayon = "1.3.1"
|
||||
ringtail = "0.3.0"
|
||||
|
@ -2,6 +2,7 @@ mod beu32_str_codec;
|
||||
mod bo_roaring_bitmap_codec;
|
||||
mod cbo_roaring_bitmap_codec;
|
||||
mod csv_string_record_codec;
|
||||
mod obkv_codec;
|
||||
mod roaring_bitmap_codec;
|
||||
mod str_str_u8_codec;
|
||||
|
||||
@ -9,5 +10,6 @@ pub use self::beu32_str_codec::BEU32StrCodec;
|
||||
pub use self::bo_roaring_bitmap_codec::BoRoaringBitmapCodec;
|
||||
pub use self::cbo_roaring_bitmap_codec::CboRoaringBitmapCodec;
|
||||
pub use self::csv_string_record_codec::CsvStringRecordCodec;
|
||||
pub use self::obkv_codec::ObkvCodec;
|
||||
pub use self::roaring_bitmap_codec::RoaringBitmapCodec;
|
||||
pub use self::str_str_u8_codec::StrStrU8Codec;
|
||||
|
20
src/heed_codec/obkv_codec.rs
Normal file
20
src/heed_codec/obkv_codec.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use std::borrow::Cow;
|
||||
use obkv::{KvReader, KvWriter};
|
||||
|
||||
pub struct ObkvCodec;
|
||||
|
||||
impl<'a> heed::BytesDecode<'a> for ObkvCodec {
|
||||
type DItem = KvReader<'a>;
|
||||
|
||||
fn bytes_decode(bytes: &'a [u8]) -> Option<Self::DItem> {
|
||||
Some(KvReader::new(bytes))
|
||||
}
|
||||
}
|
||||
|
||||
impl heed::BytesEncode<'_> for ObkvCodec {
|
||||
type EItem = KvWriter<Vec<u8>>;
|
||||
|
||||
fn bytes_encode(item: &Self::EItem) -> Option<Cow<[u8]>> {
|
||||
item.clone().into_inner().map(Cow::Owned).ok()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user