Add index name to unsortable columns error message

This commit is contained in:
Francesco Allara 2024-02-14 11:49:27 +01:00
parent d00c187349
commit b1bc505807
14 changed files with 19 additions and 19 deletions

View File

@ -56,7 +56,7 @@ fn main() {
Some(path) => TempDir::new_in(path).unwrap(), Some(path) => TempDir::new_in(path).unwrap(),
None => TempDir::new().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 indexer_config = IndexerConfig::default();
let index_documents_config = IndexDocumentsConfig::default(); let index_documents_config = IndexDocumentsConfig::default();

View File

@ -103,7 +103,7 @@ impl ReopenableIndex {
return Ok(()); return Ok(());
} }
map.unavailable.remove(&self.uuid); 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(()) Ok(())
} }
@ -167,7 +167,7 @@ impl IndexMap {
/// ///
pub fn create( pub fn create(
&mut self, &mut self,
name: &str, name: Option<String>,
uuid: &Uuid, uuid: &Uuid,
path: &Path, path: &Path,
date: Option<(OffsetDateTime, OffsetDateTime)>, date: Option<(OffsetDateTime, OffsetDateTime)>,
@ -297,7 +297,7 @@ impl IndexMap {
/// Create or open an index in the specified path. /// Create or open an index in the specified path.
/// The path *must* exist or an error will be thrown. /// The path *must* exist or an error will be thrown.
fn create_or_open_index( fn create_or_open_index(
name: &str, name: Option<String>,
path: &Path, path: &Path,
date: Option<(OffsetDateTime, OffsetDateTime)>, date: Option<(OffsetDateTime, OffsetDateTime)>,
enable_mdb_writemap: bool, enable_mdb_writemap: bool,
@ -312,14 +312,14 @@ fn create_or_open_index(
if let Some((created, updated)) = date { if let Some((created, updated)) = date {
Ok(Index::new_with_creation_dates( Ok(Index::new_with_creation_dates(
Some(String::from(name)), name,
options, options,
path, path,
created, created,
updated, updated,
)?) )?)
} else { } else {
Ok(Index::new(Some(String::from(name)), options, path)?) Ok(Index::new(name, options, path)?)
} }
} }

View File

@ -182,7 +182,7 @@ impl IndexMapper {
// This is very unlikely to happen in practice. // 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. // 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( let index = self.index_map.write().unwrap().create(
&name, Some(name.to_string()),
&uuid, &uuid,
&index_path, &index_path,
date, date,
@ -372,7 +372,7 @@ impl IndexMapper {
let index_path = self.base_path.join(uuid.to_string()); let index_path = self.base_path.join(uuid.to_string());
break index_map.create( break index_map.create(
name, Some(name.to_string()),
&uuid, &uuid,
&index_path, &index_path,
None, None,

View File

@ -267,7 +267,7 @@ fn export_a_dump(
for result in index_mapping.iter(&rtxn)? { for result in index_mapping.iter(&rtxn)? {
let (uid, uuid) = result?; let (uid, uuid) = result?;
let index_path = db_path.join("indexes").join(uuid.to_string()); 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()) format!("While trying to open the index at path {:?}", index_path.display())
})?; })?;

View File

@ -41,7 +41,7 @@ fn main() -> Result<(), Box<dyn Error>> {
options.map_size(100 * 1024 * 1024 * 1024); // 100 GB options.map_size(100 * 1024 * 1024 * 1024); // 100 GB
std::fs::create_dir_all(&index_path).unwrap(); 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 mut wtxn = index.write_txn().unwrap();
let config = IndexerConfig::default(); let config = IndexerConfig::default();

View File

@ -28,7 +28,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut options = EnvOpenOptions::new(); let mut options = EnvOpenOptions::new();
options.map_size(100 * 1024 * 1024 * 1024); // 100 GB 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 txn = index.read_txn()?;
let mut query = String::new(); let mut query = String::new();
while stdin().read_line(&mut query)? > 0 { while stdin().read_line(&mut query)? > 0 {

View File

@ -10,7 +10,7 @@ fn main() {
let mut options = EnvOpenOptions::new(); let mut options = EnvOpenOptions::new();
options.map_size(100 * 1024 * 1024 * 1024); // 100 GB 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 mut wtxn = index.write_txn().unwrap();
let config = IndexerConfig::default(); let config = IndexerConfig::default();

View File

@ -469,7 +469,7 @@ fn conditionally_lookup_for_error_message() {
for (list, suffix) in messages { for (list, suffix) in messages {
let err = UserError::InvalidSortableAttribute { let err = UserError::InvalidSortableAttribute {
field: "name".to_string(), field: "name".to_string(),
index: "index".to_string(), index_name: Some("index".to_string()),
valid_fields: list, valid_fields: list,
hidden_fields: false, hidden_fields: false,
}; };

View File

@ -1557,7 +1557,7 @@ pub(crate) mod tests {
let mut options = EnvOpenOptions::new(); let mut options = EnvOpenOptions::new();
options.map_size(size); options.map_size(size);
let _tempdir = TempDir::new_in(".").unwrap(); 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 indexer_config = IndexerConfig::default();
let index_documents_config = IndexDocumentsConfig::default(); let index_documents_config = IndexDocumentsConfig::default();
Self { inner, indexer_config, index_documents_config, _tempdir } Self { inner, indexer_config, index_documents_config, _tempdir }

View File

@ -13,7 +13,7 @@ pub fn setup_search_index_with_criteria(criteria: &[Criterion]) -> Index {
let path = tempfile::tempdir().unwrap(); let path = tempfile::tempdir().unwrap();
let mut options = EnvOpenOptions::new(); let mut options = EnvOpenOptions::new();
options.map_size(10 * 1024 * 1024); // 10 MB 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 mut wtxn = index.write_txn().unwrap();
let config = IndexerConfig::default(); let config = IndexerConfig::default();

View File

@ -13,7 +13,7 @@ fn test_facet_distribution_with_no_facet_values() {
let path = tempfile::tempdir().unwrap(); let path = tempfile::tempdir().unwrap();
let mut options = EnvOpenOptions::new(); let mut options = EnvOpenOptions::new();
options.map_size(10 * 1024 * 1024); // 10 MB 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 mut wtxn = index.write_txn().unwrap();
let config = IndexerConfig::default(); let config = IndexerConfig::default();

View File

@ -31,7 +31,7 @@ pub fn setup_search_index_with_criteria(criteria: &[Criterion]) -> Index {
let path = tempfile::tempdir().unwrap(); let path = tempfile::tempdir().unwrap();
let mut options = EnvOpenOptions::new(); let mut options = EnvOpenOptions::new();
options.map_size(10 * 1024 * 1024); // 10 MB 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 mut wtxn = index.write_txn().unwrap();
let config = IndexerConfig::default(); let config = IndexerConfig::default();

View File

@ -262,7 +262,7 @@ fn criteria_ascdesc() {
let path = tempfile::tempdir().unwrap(); let path = tempfile::tempdir().unwrap();
let mut options = EnvOpenOptions::new(); let mut options = EnvOpenOptions::new();
options.map_size(12 * 1024 * 1024); // 10 MB 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 mut wtxn = index.write_txn().unwrap();
let config = IndexerConfig::default(); let config = IndexerConfig::default();

View File

@ -104,7 +104,7 @@ fn test_typo_disabled_on_word() {
let tmp = tempdir().unwrap(); let tmp = tempdir().unwrap();
let mut options = EnvOpenOptions::new(); let mut options = EnvOpenOptions::new();
options.map_size(4096 * 100); 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 mut builder = milli::documents::DocumentsBatchBuilder::new(Vec::new());
let doc1 = json!({ let doc1 = json!({