mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-12-02 18:15:38 +08:00
34 lines
635 B
Rust
34 lines
635 B
Rust
|
mod doc_ids;
|
||
|
mod doc_indexes;
|
||
|
|
||
|
use std::ops::Deref;
|
||
|
use std::sync::Arc;
|
||
|
|
||
|
use fst::raw::MmapReadOnly;
|
||
|
|
||
|
pub use self::doc_ids::{DocIds, DocIdsBuilder};
|
||
|
pub use self::doc_indexes::{DocIndexes, DocIndexesBuilder};
|
||
|
|
||
|
#[derive(Clone)]
|
||
|
enum Data {
|
||
|
Shared {
|
||
|
vec: Arc<Vec<u8>>,
|
||
|
offset: usize,
|
||
|
len: usize,
|
||
|
},
|
||
|
Mmap(MmapReadOnly),
|
||
|
}
|
||
|
|
||
|
impl Deref for Data {
|
||
|
type Target = [u8];
|
||
|
|
||
|
fn deref(&self) -> &Self::Target {
|
||
|
match self {
|
||
|
Data::Shared { vec, offset, len } => {
|
||
|
&vec[*offset..offset + len]
|
||
|
},
|
||
|
Data::Mmap(m) => m.as_slice(),
|
||
|
}
|
||
|
}
|
||
|
}
|