From b1bc50580735d5d51f4be43fc12a6cf901beeb5e Mon Sep 17 00:00:00 2001 From: Francesco Allara Date: Wed, 14 Feb 2024 11:49:27 +0100 Subject: [PATCH] Add index name to unsortable columns error message --- fuzzers/src/bin/fuzz-indexing.rs | 2 +- index-scheduler/src/index_mapper/index_map.rs | 10 +++++----- index-scheduler/src/index_mapper/mod.rs | 4 ++-- meilitool/src/main.rs | 2 +- milli/examples/index.rs | 2 +- milli/examples/search.rs | 2 +- milli/examples/settings.rs | 2 +- milli/src/error.rs | 2 +- milli/src/index.rs | 2 +- milli/src/search/new/tests/integration.rs | 2 +- milli/tests/search/facet_distribution.rs | 2 +- milli/tests/search/mod.rs | 2 +- milli/tests/search/query_criteria.rs | 2 +- milli/tests/search/typo_tolerance.rs | 2 +- 14 files changed, 19 insertions(+), 19 deletions(-) diff --git a/fuzzers/src/bin/fuzz-indexing.rs b/fuzzers/src/bin/fuzz-indexing.rs index 64081aba9..608933016 100644 --- a/fuzzers/src/bin/fuzz-indexing.rs +++ b/fuzzers/src/bin/fuzz-indexing.rs @@ -56,7 +56,7 @@ fn main() { Some(path) => TempDir::new_in(path).unwrap(), None => TempDir::new().unwrap(), }; - let index = Index::new("", options, tempdir.path()).unwrap(); + let index = Index::new(None, options, tempdir.path()).unwrap(); let indexer_config = IndexerConfig::default(); let index_documents_config = IndexDocumentsConfig::default(); diff --git a/index-scheduler/src/index_mapper/index_map.rs b/index-scheduler/src/index_mapper/index_map.rs index 6be82e147..cf8288461 100644 --- a/index-scheduler/src/index_mapper/index_map.rs +++ b/index-scheduler/src/index_mapper/index_map.rs @@ -103,7 +103,7 @@ impl ReopenableIndex { return Ok(()); } map.unavailable.remove(&self.uuid); - map.create("", &self.uuid, path, None, self.enable_mdb_writemap, self.map_size)?; + map.create(None, &self.uuid, path, None, self.enable_mdb_writemap, self.map_size)?; } Ok(()) } @@ -167,7 +167,7 @@ impl IndexMap { /// pub fn create( &mut self, - name: &str, + name: Option, uuid: &Uuid, path: &Path, date: Option<(OffsetDateTime, OffsetDateTime)>, @@ -297,7 +297,7 @@ impl IndexMap { /// Create or open an index in the specified path. /// The path *must* exist or an error will be thrown. fn create_or_open_index( - name: &str, + name: Option, path: &Path, date: Option<(OffsetDateTime, OffsetDateTime)>, enable_mdb_writemap: bool, @@ -312,14 +312,14 @@ fn create_or_open_index( if let Some((created, updated)) = date { Ok(Index::new_with_creation_dates( - Some(String::from(name)), + name, options, path, created, updated, )?) } else { - Ok(Index::new(Some(String::from(name)), options, path)?) + Ok(Index::new(name, options, path)?) } } diff --git a/index-scheduler/src/index_mapper/mod.rs b/index-scheduler/src/index_mapper/mod.rs index 34e037266..95ddd4145 100644 --- a/index-scheduler/src/index_mapper/mod.rs +++ b/index-scheduler/src/index_mapper/mod.rs @@ -182,7 +182,7 @@ impl IndexMapper { // This is very unlikely to happen in practice. // TODO: it would be better to lazily create the index. But we need an Index::open function for milli. let index = self.index_map.write().unwrap().create( - &name, + Some(name.to_string()), &uuid, &index_path, date, @@ -372,7 +372,7 @@ impl IndexMapper { let index_path = self.base_path.join(uuid.to_string()); break index_map.create( - name, + Some(name.to_string()), &uuid, &index_path, None, diff --git a/meilitool/src/main.rs b/meilitool/src/main.rs index 4af5107ff..1cbab32c5 100644 --- a/meilitool/src/main.rs +++ b/meilitool/src/main.rs @@ -267,7 +267,7 @@ fn export_a_dump( for result in index_mapping.iter(&rtxn)? { let (uid, uuid) = result?; let index_path = db_path.join("indexes").join(uuid.to_string()); - let index = Index::new("", EnvOpenOptions::new(), &index_path).with_context(|| { + let index = Index::new(None, EnvOpenOptions::new(), &index_path).with_context(|| { format!("While trying to open the index at path {:?}", index_path.display()) })?; diff --git a/milli/examples/index.rs b/milli/examples/index.rs index 14eb45cf4..466c0a853 100644 --- a/milli/examples/index.rs +++ b/milli/examples/index.rs @@ -41,7 +41,7 @@ fn main() -> Result<(), Box> { options.map_size(100 * 1024 * 1024 * 1024); // 100 GB std::fs::create_dir_all(&index_path).unwrap(); - let index = Index::new(program_name.as_str(), options, index_path).unwrap(); + let index = Index::new(Some(program_name), options, index_path).unwrap(); let mut wtxn = index.write_txn().unwrap(); let config = IndexerConfig::default(); diff --git a/milli/examples/search.rs b/milli/examples/search.rs index 5c9fe5f07..1b31b8bf5 100644 --- a/milli/examples/search.rs +++ b/milli/examples/search.rs @@ -28,7 +28,7 @@ fn main() -> Result<(), Box> { let mut options = EnvOpenOptions::new(); options.map_size(100 * 1024 * 1024 * 1024); // 100 GB - let index = Index::new(program_name.as_str(), options, dataset)?; + let index = Index::new(Some(program_name), options, dataset)?; let txn = index.read_txn()?; let mut query = String::new(); while stdin().read_line(&mut query)? > 0 { diff --git a/milli/examples/settings.rs b/milli/examples/settings.rs index bcf50058f..846e3b070 100644 --- a/milli/examples/settings.rs +++ b/milli/examples/settings.rs @@ -10,7 +10,7 @@ fn main() { let mut options = EnvOpenOptions::new(); options.map_size(100 * 1024 * 1024 * 1024); // 100 GB - let index = Index::new("", options, "data_movies.ms").unwrap(); + let index = Index::new(None, options, "data_movies.ms").unwrap(); let mut wtxn = index.write_txn().unwrap(); let config = IndexerConfig::default(); diff --git a/milli/src/error.rs b/milli/src/error.rs index 1aca14d51..6326f696d 100644 --- a/milli/src/error.rs +++ b/milli/src/error.rs @@ -469,7 +469,7 @@ fn conditionally_lookup_for_error_message() { for (list, suffix) in messages { let err = UserError::InvalidSortableAttribute { field: "name".to_string(), - index: "index".to_string(), + index_name: Some("index".to_string()), valid_fields: list, hidden_fields: false, }; diff --git a/milli/src/index.rs b/milli/src/index.rs index ad78f3946..b000cde27 100644 --- a/milli/src/index.rs +++ b/milli/src/index.rs @@ -1557,7 +1557,7 @@ pub(crate) mod tests { let mut options = EnvOpenOptions::new(); options.map_size(size); let _tempdir = TempDir::new_in(".").unwrap(); - let inner = Index::new("temp", options, _tempdir.path()).unwrap(); + let inner = Index::new(Some("temp".to_string()), options, _tempdir.path()).unwrap(); let indexer_config = IndexerConfig::default(); let index_documents_config = IndexDocumentsConfig::default(); Self { inner, indexer_config, index_documents_config, _tempdir } diff --git a/milli/src/search/new/tests/integration.rs b/milli/src/search/new/tests/integration.rs index 54cbd29fd..a60821b19 100644 --- a/milli/src/search/new/tests/integration.rs +++ b/milli/src/search/new/tests/integration.rs @@ -13,7 +13,7 @@ pub fn setup_search_index_with_criteria(criteria: &[Criterion]) -> Index { let path = tempfile::tempdir().unwrap(); let mut options = EnvOpenOptions::new(); options.map_size(10 * 1024 * 1024); // 10 MB - let index = Index::new("", options, &path).unwrap(); + let index = Index::new(Some("".to_string()), options, &path).unwrap(); let mut wtxn = index.write_txn().unwrap(); let config = IndexerConfig::default(); diff --git a/milli/tests/search/facet_distribution.rs b/milli/tests/search/facet_distribution.rs index 02da34283..55bc78fb2 100644 --- a/milli/tests/search/facet_distribution.rs +++ b/milli/tests/search/facet_distribution.rs @@ -13,7 +13,7 @@ fn test_facet_distribution_with_no_facet_values() { let path = tempfile::tempdir().unwrap(); let mut options = EnvOpenOptions::new(); options.map_size(10 * 1024 * 1024); // 10 MB - let index = Index::new("", options, &path).unwrap(); + let index = Index::new(None, options, &path).unwrap(); let mut wtxn = index.write_txn().unwrap(); let config = IndexerConfig::default(); diff --git a/milli/tests/search/mod.rs b/milli/tests/search/mod.rs index 71fbbea76..3ecbe6d67 100644 --- a/milli/tests/search/mod.rs +++ b/milli/tests/search/mod.rs @@ -31,7 +31,7 @@ pub fn setup_search_index_with_criteria(criteria: &[Criterion]) -> Index { let path = tempfile::tempdir().unwrap(); let mut options = EnvOpenOptions::new(); options.map_size(10 * 1024 * 1024); // 10 MB - let index = Index::new("", options, &path).unwrap(); + let index = Index::new(None, options, &path).unwrap(); let mut wtxn = index.write_txn().unwrap(); let config = IndexerConfig::default(); diff --git a/milli/tests/search/query_criteria.rs b/milli/tests/search/query_criteria.rs index 8b882b356..35c18426d 100644 --- a/milli/tests/search/query_criteria.rs +++ b/milli/tests/search/query_criteria.rs @@ -262,7 +262,7 @@ fn criteria_ascdesc() { let path = tempfile::tempdir().unwrap(); let mut options = EnvOpenOptions::new(); options.map_size(12 * 1024 * 1024); // 10 MB - let index = Index::new("", options, &path).unwrap(); + let index = Index::new(None, options, &path).unwrap(); let mut wtxn = index.write_txn().unwrap(); let config = IndexerConfig::default(); diff --git a/milli/tests/search/typo_tolerance.rs b/milli/tests/search/typo_tolerance.rs index 3e5d9dc9f..83024fb2f 100644 --- a/milli/tests/search/typo_tolerance.rs +++ b/milli/tests/search/typo_tolerance.rs @@ -104,7 +104,7 @@ fn test_typo_disabled_on_word() { let tmp = tempdir().unwrap(); let mut options = EnvOpenOptions::new(); options.map_size(4096 * 100); - let index = Index::new("", options, tmp.path()).unwrap(); + let index = Index::new(None, options, tmp.path()).unwrap(); let mut builder = milli::documents::DocumentsBatchBuilder::new(Vec::new()); let doc1 = json!({