Apply suggestions from code review

Co-authored-by: Irevoire <tamo@meilisearch.com>
This commit is contained in:
marin 2021-06-01 11:18:37 +02:00 committed by GitHub
parent 6609f9e3be
commit df6ba0e824
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 11 deletions

View File

@ -24,7 +24,7 @@ const DATA_FILE_NAME: &str = "documents.jsonl";
impl Index { impl Index {
pub fn dump(&self, path: impl AsRef<Path>) -> anyhow::Result<()> { pub fn dump(&self, path: impl AsRef<Path>) -> anyhow::Result<()> {
// acquire write txn make sure any ongoing write is finnished before we start. // acquire write txn make sure any ongoing write is finished before we start.
let txn = self.env.write_txn()?; let txn = self.env.write_txn()?;
self.dump_documents(&txn, &path)?; self.dump_documents(&txn, &path)?;

View File

@ -76,14 +76,6 @@ struct Settings {
pub attributes_for_faceting: Option<Option<Vec<String>>>, pub attributes_for_faceting: Option<Option<Vec<String>>>,
} }
impl std::ops::Deref for Settings {
type Target = Option<Option<BTreeSet<String>>>;
fn deref(&self) -> &Self::Target {
&self.stop_words
}
}
fn load_index( fn load_index(
src: impl AsRef<Path>, src: impl AsRef<Path>,
dst: impl AsRef<Path>, dst: impl AsRef<Path>,
@ -128,7 +120,7 @@ fn load_index(
// Finaly, we extract the original milli::Index and close it // Finaly, we extract the original milli::Index and close it
Arc::try_unwrap(index.0) Arc::try_unwrap(index.0)
.map_err(|_e| "Couln't close index properly") .map_err(|_e| "Couldn't close the index properly")
.unwrap() .unwrap()
.prepare_for_closing() .prepare_for_closing()
.wait(); .wait();

View File

@ -200,7 +200,7 @@ where
let temp_dump_file = tempfile::NamedTempFile::new_in(&self.path)?; let temp_dump_file = tempfile::NamedTempFile::new_in(&self.path)?;
compression::to_tar_gz(temp_dump_path, temp_dump_file.path())?; compression::to_tar_gz(temp_dump_path, temp_dump_file.path())?;
let dump_path = self.path.join(format!("{}.dump", self.uid)); let dump_path = self.path.join(self.uid).with_extension("dump");
temp_dump_file.persist(&dump_path)?; temp_dump_file.persist(&dump_path)?;
Ok(dump_path) Ok(dump_path)