Fix tests

This commit is contained in:
Francesco Allara 2024-02-13 21:33:09 +01:00
parent c9708f7d0c
commit a082f14c69
25 changed files with 94 additions and 115 deletions

View file

@ -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("", &self.uuid, path, None, self.enable_mdb_writemap, self.map_size)?;
}
Ok(())
}
@ -167,6 +167,7 @@ impl IndexMap {
///
pub fn create(
&mut self,
name: &str,
uuid: &Uuid,
path: &Path,
date: Option<(OffsetDateTime, OffsetDateTime)>,
@ -176,7 +177,7 @@ impl IndexMap {
if !matches!(self.get_unavailable(uuid), Missing) {
panic!("Attempt to open an index that was unavailable");
}
let index = create_or_open_index(path, date, enable_mdb_writemap, map_size)?;
let index = create_or_open_index(name, path, date, enable_mdb_writemap, map_size)?;
match self.available.insert(*uuid, index.clone()) {
InsertionOutcome::InsertedNew => (),
InsertionOutcome::Evicted(evicted_uuid, evicted_index) => {
@ -296,6 +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,
path: &Path,
date: Option<(OffsetDateTime, OffsetDateTime)>,
enable_mdb_writemap: bool,
@ -309,9 +311,9 @@ fn create_or_open_index(
}
if let Some((created, updated)) = date {
Ok(Index::new_with_creation_dates(options, path, created, updated)?)
Ok(Index::new_with_creation_dates(name, options, path, created, updated)?)
} else {
Ok(Index::new(options, path)?)
Ok(Index::new(name, options, path)?)
}
}

View file

@ -182,6 +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,
&uuid,
&index_path,
date,
@ -371,6 +372,7 @@ impl IndexMapper {
let index_path = self.base_path.join(uuid.to_string());
break index_map.create(
name,
&uuid,
&index_path,
None,