Do not commit updates, let the user do

This commit is contained in:
Clément Renault 2019-10-11 11:29:47 +02:00
parent 4b130fa2e5
commit 12b80e08be
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
6 changed files with 22 additions and 27 deletions

View file

@ -101,7 +101,7 @@ fn index_command(command: IndexCommand, database: Database) -> Result<(), Box<dy
toml::from_str(&string).unwrap()
};
let writer = rkv.write().unwrap();
let mut writer = rkv.write().unwrap();
match index.main.schema(&writer)? {
Some(current_schema) => {
if current_schema != schema {
@ -109,7 +109,10 @@ fn index_command(command: IndexCommand, database: Database) -> Result<(), Box<dy
}
writer.abort();
},
None => index.schema_update(writer, schema)?,
None => {
index.schema_update(&mut writer, schema)?;
writer.commit().unwrap();
},
}
let mut rdr = csv::Reader::from_path(command.csv_data_path)?;
@ -147,9 +150,10 @@ fn index_command(command: IndexCommand, database: Database) -> Result<(), Box<dy
println!();
let writer = rkv.write().unwrap();
let mut writer = rkv.write().unwrap();
println!("committing update...");
let update_id = additions.finalize(writer)?;
let update_id = additions.finalize(&mut writer)?;
writer.commit().unwrap();
max_update_id = max_update_id.max(update_id);
println!("committed update {}", update_id);
}