Struct tantivy::directory::MmapDirectory
source · pub struct MmapDirectory { /* private fields */ }
Expand description
Directory storing data in files, read via mmap.
The Mmap object are cached to limit the system calls.
In the MmapDirectory
, locks are implemented using the fs2
crate definition of locks.
On MacOS & linux, it relies on flock
(aka BSD Lock
). These locks solve most of the
problems related to POSIX Locks, but may their contract may not be respected on NFS
depending on the implementation.
On Windows the semantics are again different.
Implementations§
source§impl MmapDirectory
impl MmapDirectory
sourcepub fn create_from_tempdir() -> Result<MmapDirectory, OpenDirectoryError>
pub fn create_from_tempdir() -> Result<MmapDirectory, OpenDirectoryError>
Creates a new MmapDirectory in a temporary directory.
This is mostly useful to test the MmapDirectory itself. For your unit tests, prefer the RamDirectory.
sourcepub fn open_with_madvice(
directory_path: impl AsRef<Path>,
madvice: Advice
) -> Result<MmapDirectory, OpenDirectoryError>
pub fn open_with_madvice( directory_path: impl AsRef<Path>, madvice: Advice ) -> Result<MmapDirectory, OpenDirectoryError>
Opens a MmapDirectory in a directory, with a given access pattern.
This is only supported on unix platforms.
sourcepub fn open(
directory_path: impl AsRef<Path>
) -> Result<MmapDirectory, OpenDirectoryError>
pub fn open( directory_path: impl AsRef<Path> ) -> Result<MmapDirectory, OpenDirectoryError>
Opens a MmapDirectory in a directory.
Returns an error if the directory_path
does not
exist or if it is not a directory.
sourcepub fn get_cache_info(&self) -> CacheInfo
pub fn get_cache_info(&self) -> CacheInfo
Returns some statistical information about the Mmap cache.
The MmapDirectory
embeds a MmapDirectory
to avoid multiplying the mmap
system calls.
Trait Implementations§
source§impl Clone for MmapDirectory
impl Clone for MmapDirectory
source§fn clone(&self) -> MmapDirectory
fn clone(&self) -> MmapDirectory
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MmapDirectory
impl Debug for MmapDirectory
source§impl Directory for MmapDirectory
impl Directory for MmapDirectory
source§fn delete(&self, path: &Path) -> Result<(), DeleteError>
fn delete(&self, path: &Path) -> Result<(), DeleteError>
Any entry associated with the path in the mmap will be removed before the file is deleted.
source§fn get_file_handle(
&self,
path: &Path
) -> Result<Arc<dyn FileHandle>, OpenReadError>
fn get_file_handle( &self, path: &Path ) -> Result<Arc<dyn FileHandle>, OpenReadError>
FileHandle
. Read moresource§fn exists(&self, path: &Path) -> Result<bool, OpenReadError>
fn exists(&self, path: &Path) -> Result<bool, OpenReadError>
source§fn open_write(&self, path: &Path) -> Result<WritePtr, OpenWriteError>
fn open_write(&self, path: &Path) -> Result<WritePtr, OpenWriteError>
source§fn atomic_read(&self, path: &Path) -> Result<Vec<u8>, OpenReadError>
fn atomic_read(&self, path: &Path) -> Result<Vec<u8>, OpenReadError>
Directory::atomic_write()
. Read moresource§fn atomic_write(&self, path: &Path, content: &[u8]) -> Result<()>
fn atomic_write(&self, path: &Path, content: &[u8]) -> Result<()>
source§fn acquire_lock(&self, lock: &Lock) -> Result<DirectoryLock, LockError>
fn acquire_lock(&self, lock: &Lock) -> Result<DirectoryLock, LockError>
source§fn watch(&self, watch_callback: WatchCallback) -> Result<WatchHandle>
fn watch(&self, watch_callback: WatchCallback) -> Result<WatchHandle>
meta.json
using the Directory::atomic_write()
API is detected. Read moreAuto Trait Implementations§
impl Freeze for MmapDirectory
impl RefUnwindSafe for MmapDirectory
impl Send for MmapDirectory
impl Sync for MmapDirectory
impl Unpin for MmapDirectory
impl UnwindSafe for MmapDirectory
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> DirectoryClone for T
impl<T> DirectoryClone for T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.