mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-26 13:03:18 +08:00
530a3e2df3
Signed-off-by: cui fliter <imcusg@gmail.com>
25 lines
528 B
Rust
25 lines
528 B
Rust
use std::sync::Arc;
|
|
|
|
use memmap2::Mmap;
|
|
|
|
/// Wrapper around Mmap allowing to virtually clone grenad-chunks
|
|
/// in a parallel process like the indexing.
|
|
#[derive(Debug, Clone)]
|
|
pub struct ClonableMmap {
|
|
inner: Arc<Mmap>,
|
|
}
|
|
|
|
impl AsRef<[u8]> for ClonableMmap {
|
|
fn as_ref(&self) -> &[u8] {
|
|
self.inner.as_ref()
|
|
}
|
|
}
|
|
|
|
impl From<Mmap> for ClonableMmap {
|
|
fn from(inner: Mmap) -> ClonableMmap {
|
|
ClonableMmap { inner: Arc::new(inner) }
|
|
}
|
|
}
|
|
|
|
pub type CursorClonableMmap = std::io::Cursor<ClonableMmap>;
|