mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 00:31:02 +00:00
Put the documents MTBL back into LMDB
We makes sure to write the documents into a file before memory mapping it and putting it into LMDB, this way we avoid moving it to RAM
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
mod mtbl_codec;
|
||||
mod roaring_bitmap_codec;
|
||||
mod str_beu32_codec;
|
||||
|
||||
pub use self::mtbl_codec::MtblCodec;
|
||||
pub use self::roaring_bitmap_codec::RoaringBitmapCodec;
|
||||
pub use self::str_beu32_codec::StrBEU32Codec;
|
||||
|
20
src/heed_codec/mtbl_codec.rs
Normal file
20
src/heed_codec/mtbl_codec.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use std::borrow::Cow;
|
||||
use oxidized_mtbl::Reader;
|
||||
|
||||
pub struct MtblCodec;
|
||||
|
||||
impl<'a> heed::BytesDecode<'a> for MtblCodec {
|
||||
type DItem = Reader<&'a [u8]>;
|
||||
|
||||
fn bytes_decode(bytes: &'a [u8]) -> Option<Self::DItem> {
|
||||
Reader::new(bytes).ok()
|
||||
}
|
||||
}
|
||||
|
||||
impl heed::BytesEncode<'_> for MtblCodec {
|
||||
type EItem = [u8];
|
||||
|
||||
fn bytes_encode(item: &Self::EItem) -> Option<Cow<[u8]>> {
|
||||
Some(Cow::Borrowed(item))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user