From 361f9c4062864cf28f9380bee503f24232d6a6e7 Mon Sep 17 00:00:00 2001 From: ChillFish8 Date: Sat, 3 Jun 2023 17:57:52 +0100 Subject: [PATCH 01/10] Fix windows build --- src/directory/mmap_directory.rs | 77 ++++++++++++++++++++++----------- src/lib.rs | 1 + 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index 420f919f84..ea372a0dd2 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -21,6 +21,7 @@ use crate::directory::{ AntiCallToken, Directory, DirectoryLock, FileHandle, Lock, OwnedBytes, TerminatingWrite, WatchCallback, WatchHandle, WritePtr, }; +#[cfg(unix)] use crate::Advice; pub type ArcBytes = Arc + Send + Sync + 'static>; @@ -31,12 +32,26 @@ pub(crate) fn make_io_err(msg: String) -> io::Error { io::Error::new(io::ErrorKind::Other, msg) } +#[cfg(unix)] /// Returns `None` iff the file exists, can be read, but is empty (and hence -/// cannot be mmapped) -fn open_mmap( +/// cannot be mmapped), this method also allows for optional [Advice] to be +/// specified for the given workload. +fn open_mmap_with_advice( full_path: &Path, madvice_opt: Option, ) -> result::Result, OpenReadError> { + let mmap_opt = open_mmap(full_path)?; + + if let (Some(mmap), Some(madvice)) = (&mmap_opt, madvice_opt) { + let _ = mmap.advise(madvice); + } + + Ok(mmap_opt) +} + +/// Returns `None` iff the file exists, can be read, but is empty (and hence +/// cannot be mmapped) +fn open_mmap(full_path: &Path) -> result::Result, OpenReadError> { let file = File::open(full_path).map_err(|io_err| { if io_err.kind() == io::ErrorKind::NotFound { OpenReadError::FileDoesNotExist(full_path.to_path_buf()) @@ -59,9 +74,7 @@ fn open_mmap( .map(Some) .map_err(|io_err| OpenReadError::wrap_io_error(io_err, full_path.to_path_buf())) }?; - if let (Some(mmap), Some(madvice)) = (&mmap_opt, madvice_opt) { - let _ = mmap.advise(madvice); - } + Ok(mmap_opt) } @@ -83,15 +96,20 @@ pub struct CacheInfo { struct MmapCache { counters: CacheCounters, cache: HashMap, + #[cfg(unix)] madvice_opt: Option, } impl MmapCache { - fn new(madvice_opt: Option) -> MmapCache { + #[cfg(unix)] + fn with_advice(&mut self, madvice_opt: Option) { + self.madvice_opt = madvice_opt + } + + fn new() -> MmapCache { MmapCache { counters: CacheCounters::default(), cache: HashMap::default(), - madvice_opt, } } @@ -125,7 +143,10 @@ impl MmapCache { } self.cache.remove(full_path); self.counters.miss += 1; - let mmap_opt = open_mmap(full_path, self.madvice_opt)?; + #[cfg(unix)] + let mmap_opt = open_mmap_with_advice(full_path, self.madvice_opt)?; + #[cfg(not(unix))] + let mmap_opt = open_mmap(full_path)?; Ok(mmap_opt.map(|mmap| { let mmap_arc: ArcBytes = Arc::new(mmap); let mmap_weak = Arc::downgrade(&mmap_arc); @@ -160,19 +181,20 @@ struct MmapDirectoryInner { } impl MmapDirectoryInner { - fn new( - root_path: PathBuf, - temp_directory: Option, - madvice_opt: Option, - ) -> MmapDirectoryInner { + fn new(root_path: PathBuf, temp_directory: Option) -> MmapDirectoryInner { MmapDirectoryInner { - mmap_cache: RwLock::new(MmapCache::new(madvice_opt)), + mmap_cache: RwLock::new(MmapCache::new()), _temp_directory: temp_directory, watcher: FileWatcher::new(&root_path.join(*META_FILEPATH)), root_path, } } + #[cfg(unix)] + fn with_advice(&mut self, madvice_opt: Option) { + self.mmap_cache.write().with_advice(madvice_opt) + } + fn watch(&self, callback: WatchCallback) -> WatchHandle { self.watcher.watch(callback) } @@ -185,17 +207,21 @@ impl fmt::Debug for MmapDirectory { } impl MmapDirectory { - fn new( - root_path: PathBuf, - temp_directory: Option, - madvice_opt: Option, - ) -> MmapDirectory { - let inner = MmapDirectoryInner::new(root_path, temp_directory, madvice_opt); + fn new(root_path: PathBuf, temp_directory: Option) -> MmapDirectory { + let inner = MmapDirectoryInner::new(root_path, temp_directory); MmapDirectory { inner: Arc::new(inner), } } + #[cfg(unix)] + /// Pass specific madvice flags when opening a new mmap file. + /// + /// This is only supported on unix platforms. + fn with_advice(&mut self, madvice_opt: Option) { + self.inner.with_advice(madvice_opt) + } + /// Creates a new MmapDirectory in a temporary directory. /// /// This is mostly useful to test the MmapDirectory itself. @@ -206,7 +232,6 @@ impl MmapDirectory { Ok(MmapDirectory::new( tempdir.path().to_path_buf(), Some(tempdir), - None, )) } @@ -215,20 +240,22 @@ impl MmapDirectory { /// Returns an error if the `directory_path` does not /// exist or if it is not a directory. pub fn open>(directory_path: P) -> Result { - Self::open_with_access_pattern_impl(directory_path.as_ref(), None) + Self::open_with_access_pattern_impl(directory_path.as_ref()) } + #[cfg(unix)] /// Opens a MmapDirectory in a directory, with a given access pattern. pub fn open_with_madvice>( directory_path: P, madvice: Advice, ) -> Result { - Self::open_with_access_pattern_impl(directory_path.as_ref(), Some(madvice)) + let dir = Self::open_with_access_pattern_impl(directory_path.as_ref())?; + dir.with_advice(Some(madvice)); + Ok(dir) } fn open_with_access_pattern_impl( directory_path: &Path, - madvice_opt: Option, ) -> Result { if !directory_path.exists() { return Err(OpenDirectoryError::DoesNotExist(PathBuf::from( @@ -256,7 +283,7 @@ impl MmapDirectory { directory_path, ))); } - Ok(MmapDirectory::new(canonical_path, None, madvice_opt)) + Ok(MmapDirectory::new(canonical_path, None)) } /// Joins a relative_path to the directory `root_path` diff --git a/src/lib.rs b/src/lib.rs index fa13ab2fda..bba4846cc7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -191,6 +191,7 @@ pub use crate::schema::{DateOptions, DateTimePrecision, Document, Term}; /// Index format version. const INDEX_FORMAT_VERSION: u32 = 5; +#[cfg(unix)] pub use memmap2::Advice; /// Structure version for the index. From e784bc42f1b66886f099fc943c00218404f444c1 Mon Sep 17 00:00:00 2001 From: ChillFish8 Date: Sat, 3 Jun 2023 17:59:45 +0100 Subject: [PATCH 02/10] Make pub --- src/directory/mmap_directory.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index ea372a0dd2..212b59feb5 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -218,7 +218,7 @@ impl MmapDirectory { /// Pass specific madvice flags when opening a new mmap file. /// /// This is only supported on unix platforms. - fn with_advice(&mut self, madvice_opt: Option) { + pub fn with_advice(&mut self, madvice_opt: Option) { self.inner.with_advice(madvice_opt) } From 413300caa1da929235c79f2af21734404ffea71a Mon Sep 17 00:00:00 2001 From: ChillFish8 Date: Sat, 3 Jun 2023 18:01:51 +0100 Subject: [PATCH 03/10] Update docs --- src/directory/mmap_directory.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index 212b59feb5..86310f040c 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -245,6 +245,8 @@ impl MmapDirectory { #[cfg(unix)] /// Opens a MmapDirectory in a directory, with a given access pattern. + /// + /// This is only supported on unix platforms. pub fn open_with_madvice>( directory_path: P, madvice: Advice, From 56302c5190c29269df2db715625aa61a8f276475 Mon Sep 17 00:00:00 2001 From: ChillFish8 Date: Sat, 3 Jun 2023 18:04:58 +0100 Subject: [PATCH 04/10] Re arrange --- src/directory/mmap_directory.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index 86310f040c..1a9e2c7795 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -101,11 +101,6 @@ struct MmapCache { } impl MmapCache { - #[cfg(unix)] - fn with_advice(&mut self, madvice_opt: Option) { - self.madvice_opt = madvice_opt - } - fn new() -> MmapCache { MmapCache { counters: CacheCounters::default(), @@ -113,6 +108,11 @@ impl MmapCache { } } + #[cfg(unix)] + fn with_advice(&mut self, madvice_opt: Option) { + self.madvice_opt = madvice_opt + } + fn get_info(&self) -> CacheInfo { let paths: Vec = self.cache.keys().cloned().collect(); CacheInfo { From 5948f304c2579621f2b164956ae739de820430fa Mon Sep 17 00:00:00 2001 From: ChillFish8 Date: Sat, 3 Jun 2023 18:20:08 +0100 Subject: [PATCH 05/10] Fix compilation error on unix --- src/directory/mmap_directory.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index 1a9e2c7795..f74cf11e35 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -6,6 +6,7 @@ use std::path::{Path, PathBuf}; use std::sync::{Arc, RwLock, Weak}; use std::{fmt, result}; +use aho_corasick::Anchored::No; use common::StableDeref; use fs4::FileExt; use memmap2::Mmap; @@ -105,6 +106,8 @@ impl MmapCache { MmapCache { counters: CacheCounters::default(), cache: HashMap::default(), + #[cfg(unix)] + madvice_opt: None, } } @@ -192,7 +195,7 @@ impl MmapDirectoryInner { #[cfg(unix)] fn with_advice(&mut self, madvice_opt: Option) { - self.mmap_cache.write().with_advice(madvice_opt) + self.mmap_cache.write().unwrap().with_advice(madvice_opt) } fn watch(&self, callback: WatchCallback) -> WatchHandle { From c1d94fd12bc4df27025fbee48622c0a2756d2cce Mon Sep 17 00:00:00 2001 From: ChillFish8 Date: Sat, 3 Jun 2023 18:32:13 +0100 Subject: [PATCH 06/10] Fix unix borrows --- src/directory/mmap_directory.rs | 34 +++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index f74cf11e35..13ab7e539c 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -6,7 +6,6 @@ use std::path::{Path, PathBuf}; use std::sync::{Arc, RwLock, Weak}; use std::{fmt, result}; -use aho_corasick::Anchored::No; use common::StableDeref; use fs4::FileExt; use memmap2::Mmap; @@ -218,11 +217,16 @@ impl MmapDirectory { } #[cfg(unix)] - /// Pass specific madvice flags when opening a new mmap file. - /// - /// This is only supported on unix platforms. - pub fn with_advice(&mut self, madvice_opt: Option) { - self.inner.with_advice(madvice_opt) + fn with_advice( + root_path: PathBuf, + temp_directory: Option, + madvice_opt: Option, + ) { + let mut inner = MmapDirectoryInner::new(root_path, temp_directory); + inner.with_advice(madvice_opt); + MmapDirectory { + inner: Arc::new(inner), + } } /// Creates a new MmapDirectory in a temporary directory. @@ -243,7 +247,8 @@ impl MmapDirectory { /// Returns an error if the `directory_path` does not /// exist or if it is not a directory. pub fn open>(directory_path: P) -> Result { - Self::open_with_access_pattern_impl(directory_path.as_ref()) + let canonical_path = Self::resolve_directory_path(directory_path.as_ref())?; + Ok(MmapDirectory::new(canonical_path, None)) } #[cfg(unix)] @@ -254,14 +259,15 @@ impl MmapDirectory { directory_path: P, madvice: Advice, ) -> Result { - let dir = Self::open_with_access_pattern_impl(directory_path.as_ref())?; - dir.with_advice(Some(madvice)); - Ok(dir) + let canonical_path = Self::resolve_directory_path(directory_path.as_ref())?; + Ok(MmapDirectory::with_advice( + canonical_path, + None, + madvice_opt, + )) } - fn open_with_access_pattern_impl( - directory_path: &Path, - ) -> Result { + fn resolve_directory_path(directory_path: &Path) -> Result { if !directory_path.exists() { return Err(OpenDirectoryError::DoesNotExist(PathBuf::from( directory_path, @@ -288,7 +294,7 @@ impl MmapDirectory { directory_path, ))); } - Ok(MmapDirectory::new(canonical_path, None)) + Ok(canonical_path) } /// Joins a relative_path to the directory `root_path` From 6bf98bd923a625355ee443a66a896eb1fd112358 Mon Sep 17 00:00:00 2001 From: ChillFish8 Date: Sat, 3 Jun 2023 18:35:37 +0100 Subject: [PATCH 07/10] Revert "Fix unix borrows" This reverts commit c1d94fd12bc4df27025fbee48622c0a2756d2cce. --- src/directory/mmap_directory.rs | 34 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index 13ab7e539c..f74cf11e35 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -6,6 +6,7 @@ use std::path::{Path, PathBuf}; use std::sync::{Arc, RwLock, Weak}; use std::{fmt, result}; +use aho_corasick::Anchored::No; use common::StableDeref; use fs4::FileExt; use memmap2::Mmap; @@ -217,16 +218,11 @@ impl MmapDirectory { } #[cfg(unix)] - fn with_advice( - root_path: PathBuf, - temp_directory: Option, - madvice_opt: Option, - ) { - let mut inner = MmapDirectoryInner::new(root_path, temp_directory); - inner.with_advice(madvice_opt); - MmapDirectory { - inner: Arc::new(inner), - } + /// Pass specific madvice flags when opening a new mmap file. + /// + /// This is only supported on unix platforms. + pub fn with_advice(&mut self, madvice_opt: Option) { + self.inner.with_advice(madvice_opt) } /// Creates a new MmapDirectory in a temporary directory. @@ -247,8 +243,7 @@ impl MmapDirectory { /// Returns an error if the `directory_path` does not /// exist or if it is not a directory. pub fn open>(directory_path: P) -> Result { - let canonical_path = Self::resolve_directory_path(directory_path.as_ref())?; - Ok(MmapDirectory::new(canonical_path, None)) + Self::open_with_access_pattern_impl(directory_path.as_ref()) } #[cfg(unix)] @@ -259,15 +254,14 @@ impl MmapDirectory { directory_path: P, madvice: Advice, ) -> Result { - let canonical_path = Self::resolve_directory_path(directory_path.as_ref())?; - Ok(MmapDirectory::with_advice( - canonical_path, - None, - madvice_opt, - )) + let dir = Self::open_with_access_pattern_impl(directory_path.as_ref())?; + dir.with_advice(Some(madvice)); + Ok(dir) } - fn resolve_directory_path(directory_path: &Path) -> Result { + fn open_with_access_pattern_impl( + directory_path: &Path, + ) -> Result { if !directory_path.exists() { return Err(OpenDirectoryError::DoesNotExist(PathBuf::from( directory_path, @@ -294,7 +288,7 @@ impl MmapDirectory { directory_path, ))); } - Ok(canonical_path) + Ok(MmapDirectory::new(canonical_path, None)) } /// Joins a relative_path to the directory `root_path` From 5deabf591e203218a12aff62941a6aef8a71425d Mon Sep 17 00:00:00 2001 From: ChillFish8 Date: Sat, 3 Jun 2023 18:36:02 +0100 Subject: [PATCH 08/10] Fix unix borrows and revert original change --- src/directory/mmap_directory.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index f74cf11e35..0e1c3646f2 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -194,7 +194,7 @@ impl MmapDirectoryInner { } #[cfg(unix)] - fn with_advice(&mut self, madvice_opt: Option) { + fn with_advice(&self, madvice_opt: Option) { self.mmap_cache.write().unwrap().with_advice(madvice_opt) } @@ -221,7 +221,7 @@ impl MmapDirectory { /// Pass specific madvice flags when opening a new mmap file. /// /// This is only supported on unix platforms. - pub fn with_advice(&mut self, madvice_opt: Option) { + pub fn with_advice(&self, madvice_opt: Option) { self.inner.with_advice(madvice_opt) } From 156d12bc7c1b3ef2b7bfc173553fe82811f7bb28 Mon Sep 17 00:00:00 2001 From: ChillFish8 Date: Sat, 3 Jun 2023 18:36:28 +0100 Subject: [PATCH 09/10] Fix warning --- src/directory/mmap_directory.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index 0e1c3646f2..d77e2fe51f 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -6,7 +6,6 @@ use std::path::{Path, PathBuf}; use std::sync::{Arc, RwLock, Weak}; use std::{fmt, result}; -use aho_corasick::Anchored::No; use common::StableDeref; use fs4::FileExt; use memmap2::Mmap; From 21ce6e4d96f7ee0ad580411f0f0aa21df365f74a Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Thu, 8 Jun 2023 16:47:14 +0900 Subject: [PATCH 10/10] Cleaner code. --- src/directory/mmap_directory.rs | 86 ++++++++++++--------------------- 1 file changed, 32 insertions(+), 54 deletions(-) diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index d77e2fe51f..7419cbe49b 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -1,10 +1,10 @@ use std::collections::HashMap; +use std::fmt; use std::fs::{self, File, OpenOptions}; use std::io::{self, BufWriter, Read, Seek, Write}; use std::ops::Deref; use std::path::{Path, PathBuf}; use std::sync::{Arc, RwLock, Weak}; -use std::{fmt, result}; use common::StableDeref; use fs4::FileExt; @@ -32,26 +32,9 @@ pub(crate) fn make_io_err(msg: String) -> io::Error { io::Error::new(io::ErrorKind::Other, msg) } -#[cfg(unix)] -/// Returns `None` iff the file exists, can be read, but is empty (and hence -/// cannot be mmapped), this method also allows for optional [Advice] to be -/// specified for the given workload. -fn open_mmap_with_advice( - full_path: &Path, - madvice_opt: Option, -) -> result::Result, OpenReadError> { - let mmap_opt = open_mmap(full_path)?; - - if let (Some(mmap), Some(madvice)) = (&mmap_opt, madvice_opt) { - let _ = mmap.advise(madvice); - } - - Ok(mmap_opt) -} - /// Returns `None` iff the file exists, can be read, but is empty (and hence /// cannot be mmapped) -fn open_mmap(full_path: &Path) -> result::Result, OpenReadError> { +fn open_mmap(full_path: &Path) -> Result, OpenReadError> { let file = File::open(full_path).map_err(|io_err| { if io_err.kind() == io::ErrorKind::NotFound { OpenReadError::FileDoesNotExist(full_path.to_path_buf()) @@ -111,8 +94,8 @@ impl MmapCache { } #[cfg(unix)] - fn with_advice(&mut self, madvice_opt: Option) { - self.madvice_opt = madvice_opt + fn set_advice(&mut self, madvice: Advice) { + self.madvice_opt = Some(madvice); } fn get_info(&self) -> CacheInfo { @@ -135,6 +118,16 @@ impl MmapCache { } } + fn open_mmap_impl(&self, full_path: &Path) -> Result, OpenReadError> { + let mmap_opt = open_mmap(full_path)?; + #[cfg(unix)] + if let (Some(mmap), Some(madvice)) = (mmap_opt.as_ref(), self.madvice_opt) { + // We ignore madvise errors. + let _ = mmap.advise(madvice); + } + Ok(mmap_opt) + } + // Returns None if the file exists but as a len of 0 (and hence is not mmappable). fn get_mmap(&mut self, full_path: &Path) -> Result, OpenReadError> { if let Some(mmap_weak) = self.cache.get(full_path) { @@ -145,10 +138,7 @@ impl MmapCache { } self.cache.remove(full_path); self.counters.miss += 1; - #[cfg(unix)] - let mmap_opt = open_mmap_with_advice(full_path, self.madvice_opt)?; - #[cfg(not(unix))] - let mmap_opt = open_mmap(full_path)?; + let mmap_opt = self.open_mmap_impl(full_path)?; Ok(mmap_opt.map(|mmap| { let mmap_arc: ArcBytes = Arc::new(mmap); let mmap_weak = Arc::downgrade(&mmap_arc); @@ -192,11 +182,6 @@ impl MmapDirectoryInner { } } - #[cfg(unix)] - fn with_advice(&self, madvice_opt: Option) { - self.mmap_cache.write().unwrap().with_advice(madvice_opt) - } - fn watch(&self, callback: WatchCallback) -> WatchHandle { self.watcher.watch(callback) } @@ -216,14 +201,6 @@ impl MmapDirectory { } } - #[cfg(unix)] - /// Pass specific madvice flags when opening a new mmap file. - /// - /// This is only supported on unix platforms. - pub fn with_advice(&self, madvice_opt: Option) { - self.inner.with_advice(madvice_opt) - } - /// Creates a new MmapDirectory in a temporary directory. /// /// This is mostly useful to test the MmapDirectory itself. @@ -237,28 +214,29 @@ impl MmapDirectory { )) } - /// Opens a MmapDirectory in a directory. - /// - /// Returns an error if the `directory_path` does not - /// exist or if it is not a directory. - pub fn open>(directory_path: P) -> Result { - Self::open_with_access_pattern_impl(directory_path.as_ref()) - } - - #[cfg(unix)] /// Opens a MmapDirectory in a directory, with a given access pattern. /// /// This is only supported on unix platforms. - pub fn open_with_madvice>( - directory_path: P, + #[cfg(unix)] + pub fn open_with_madvice( + directory_path: impl AsRef, madvice: Advice, ) -> Result { - let dir = Self::open_with_access_pattern_impl(directory_path.as_ref())?; - dir.with_advice(Some(madvice)); + let dir = Self::open_impl_to_avoid_monomorphization(directory_path.as_ref())?; + dir.inner.mmap_cache.write().unwrap().set_advice(madvice); Ok(dir) } - fn open_with_access_pattern_impl( + /// Opens a MmapDirectory in a directory. + /// + /// Returns an error if the `directory_path` does not + /// exist or if it is not a directory. + pub fn open(directory_path: impl AsRef) -> Result { + Self::open_impl_to_avoid_monomorphization(directory_path.as_ref()) + } + + #[inline(never)] + fn open_impl_to_avoid_monomorphization( directory_path: &Path, ) -> Result { if !directory_path.exists() { @@ -396,7 +374,7 @@ pub(crate) fn atomic_write(path: &Path, content: &[u8]) -> io::Result<()> { } impl Directory for MmapDirectory { - fn get_file_handle(&self, path: &Path) -> result::Result, OpenReadError> { + fn get_file_handle(&self, path: &Path) -> Result, OpenReadError> { debug!("Open Read {:?}", path); let full_path = self.resolve_path(path); @@ -419,7 +397,7 @@ impl Directory for MmapDirectory { /// Any entry associated with the path in the mmap will be /// removed before the file is deleted. - fn delete(&self, path: &Path) -> result::Result<(), DeleteError> { + fn delete(&self, path: &Path) -> Result<(), DeleteError> { let full_path = self.resolve_path(path); fs::remove_file(full_path).map_err(|e| { if e.kind() == io::ErrorKind::NotFound {