Format the repo.

master
Damir Jelić 2020-01-05 15:59:43 +01:00
parent d117555509
commit 5c590ff157
3 changed files with 9 additions and 8 deletions

View File

@ -8,7 +8,7 @@ use crate::document::{extract_value, Document};
use crate::query::Query; use crate::query::Query;
use crate::schema::Schema; use crate::schema::Schema;
use crate::searcher::Searcher; use crate::searcher::Searcher;
use crate::{to_pyerr, get_field}; use crate::{get_field, to_pyerr};
use tantivy as tv; use tantivy as tv;
use tantivy::directory::MmapDirectory; use tantivy::directory::MmapDirectory;
use tantivy::schema::{NamedFieldDocument, Term, Value}; use tantivy::schema::{NamedFieldDocument, Term, Value};
@ -80,8 +80,7 @@ impl IndexWriter {
/// Detect and removes the files that are not used by the index anymore. /// Detect and removes the files that are not used by the index anymore.
fn garbage_collect_files(&mut self) -> PyResult<()> { fn garbage_collect_files(&mut self) -> PyResult<()> {
use futures::executor::block_on; use futures::executor::block_on;
block_on(self.inner_index_writer block_on(self.inner_index_writer.garbage_collect_files())
.garbage_collect_files())
.map_err(to_pyerr)?; .map_err(to_pyerr)?;
Ok(()) Ok(())
} }
@ -334,8 +333,7 @@ impl Index {
} }
} }
} else { } else {
for (field, field_entry) in self.index.schema().fields() for (field, field_entry) in self.index.schema().fields() {
{
if field_entry.is_indexed() { if field_entry.is_indexed() {
default_fields.push(field); default_fields.push(field);
} }

View File

@ -85,11 +85,14 @@ pub(crate) fn to_pyerr<E: ToString>(err: E) -> PyErr {
exceptions::ValueError::py_err(err.to_string()) exceptions::ValueError::py_err(err.to_string())
} }
pub(crate) fn get_field(schema: &tv::schema::Schema, field_name: &str) -> PyResult<tv::schema::Field> { pub(crate) fn get_field(
schema: &tv::schema::Schema,
field_name: &str,
) -> PyResult<tv::schema::Field> {
let field = schema.get_field(field_name).ok_or_else(|| { let field = schema.get_field(field_name).ok_or_else(|| {
exceptions::ValueError::py_err(format!( exceptions::ValueError::py_err(format!(
"Field `{}` is not defined in the schema.", "Field `{}` is not defined in the schema.",
field_name field_name
)) ))
})?; })?;

View File

@ -2,7 +2,7 @@
use crate::document::Document; use crate::document::Document;
use crate::query::Query; use crate::query::Query;
use crate::{to_pyerr}; use crate::to_pyerr;
use pyo3::exceptions::ValueError; use pyo3::exceptions::ValueError;
use pyo3::prelude::*; use pyo3::prelude::*;
use pyo3::PyObjectProtocol; use pyo3::PyObjectProtocol;