mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-30 00:34:26 +01:00
Merge pull request #213 from meilisearch/do-not-commit-ourselves
Do not commit updates, let the user do
This commit is contained in:
commit
97de72de83
@ -101,7 +101,7 @@ fn index_command(command: IndexCommand, database: Database) -> Result<(), Box<dy
|
|||||||
toml::from_str(&string).unwrap()
|
toml::from_str(&string).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
let writer = rkv.write().unwrap();
|
let mut writer = rkv.write().unwrap();
|
||||||
match index.main.schema(&writer)? {
|
match index.main.schema(&writer)? {
|
||||||
Some(current_schema) => {
|
Some(current_schema) => {
|
||||||
if current_schema != schema {
|
if current_schema != schema {
|
||||||
@ -109,7 +109,10 @@ fn index_command(command: IndexCommand, database: Database) -> Result<(), Box<dy
|
|||||||
}
|
}
|
||||||
writer.abort();
|
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)?;
|
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!();
|
println!();
|
||||||
|
|
||||||
let writer = rkv.write().unwrap();
|
let mut writer = rkv.write().unwrap();
|
||||||
println!("committing update...");
|
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);
|
max_update_id = max_update_id.max(update_id);
|
||||||
println!("committed update {}", update_id);
|
println!("committed update {}", update_id);
|
||||||
}
|
}
|
||||||
|
@ -109,10 +109,9 @@ impl Index {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn schema_update(&self, mut writer: rkv::Writer, schema: Schema) -> MResult<()> {
|
pub fn schema_update(&self, writer: &mut rkv::Writer, schema: Schema) -> MResult<()> {
|
||||||
update::push_schema_update(&mut writer, self.updates, self.updates_results, schema)?;
|
|
||||||
writer.commit()?;
|
|
||||||
let _ = self.updates_notifier.send(());
|
let _ = self.updates_notifier.send(());
|
||||||
|
update::push_schema_update(writer, self.updates, self.updates_results, schema)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,18 +36,16 @@ impl<D> DocumentsAddition<D> {
|
|||||||
self.documents.push(document);
|
self.documents.push(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finalize(self, mut writer: rkv::Writer) -> MResult<u64>
|
pub fn finalize(self, writer: &mut rkv::Writer) -> MResult<u64>
|
||||||
where D: serde::Serialize
|
where D: serde::Serialize
|
||||||
{
|
{
|
||||||
|
let _ = self.updates_notifier.send(());
|
||||||
let update_id = push_documents_addition(
|
let update_id = push_documents_addition(
|
||||||
&mut writer,
|
writer,
|
||||||
self.updates_store,
|
self.updates_store,
|
||||||
self.updates_results_store,
|
self.updates_results_store,
|
||||||
self.documents,
|
self.documents,
|
||||||
)?;
|
)?;
|
||||||
writer.commit()?;
|
|
||||||
let _ = self.updates_notifier.send(());
|
|
||||||
|
|
||||||
Ok(update_id)
|
Ok(update_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,16 +49,14 @@ impl DocumentsDeletion {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finalize(self, mut writer: rkv::Writer) -> MResult<u64> {
|
pub fn finalize(self, writer: &mut rkv::Writer) -> MResult<u64> {
|
||||||
|
let _ = self.updates_notifier.send(());
|
||||||
let update_id = push_documents_deletion(
|
let update_id = push_documents_deletion(
|
||||||
&mut writer,
|
writer,
|
||||||
self.updates_store,
|
self.updates_store,
|
||||||
self.updates_results_store,
|
self.updates_results_store,
|
||||||
self.documents,
|
self.documents,
|
||||||
)?;
|
)?;
|
||||||
writer.commit()?;
|
|
||||||
let _ = self.updates_notifier.send(());
|
|
||||||
|
|
||||||
Ok(update_id)
|
Ok(update_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,16 +39,14 @@ impl SynonymsAddition {
|
|||||||
self.synonyms.entry(synonym).or_insert_with(Vec::new).extend(alternatives);
|
self.synonyms.entry(synonym).or_insert_with(Vec::new).extend(alternatives);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finalize(self, mut writer: rkv::Writer) -> MResult<u64> {
|
pub fn finalize(self, writer: &mut rkv::Writer) -> MResult<u64> {
|
||||||
|
let _ = self.updates_notifier.send(());
|
||||||
let update_id = push_synonyms_addition(
|
let update_id = push_synonyms_addition(
|
||||||
&mut writer,
|
writer,
|
||||||
self.updates_store,
|
self.updates_store,
|
||||||
self.updates_results_store,
|
self.updates_results_store,
|
||||||
self.synonyms,
|
self.synonyms,
|
||||||
)?;
|
)?;
|
||||||
writer.commit()?;
|
|
||||||
let _ = self.updates_notifier.send(());
|
|
||||||
|
|
||||||
Ok(update_id)
|
Ok(update_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,16 +49,14 @@ impl SynonymsDeletion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finalize(self, mut writer: rkv::Writer) -> MResult<u64> {
|
pub fn finalize(self, writer: &mut rkv::Writer) -> MResult<u64> {
|
||||||
|
let _ = self.updates_notifier.send(());
|
||||||
let update_id = push_synonyms_deletion(
|
let update_id = push_synonyms_deletion(
|
||||||
&mut writer,
|
writer,
|
||||||
self.updates_store,
|
self.updates_store,
|
||||||
self.updates_results_store,
|
self.updates_results_store,
|
||||||
self.synonyms,
|
self.synonyms,
|
||||||
)?;
|
)?;
|
||||||
writer.commit()?;
|
|
||||||
let _ = self.updates_notifier.send(());
|
|
||||||
|
|
||||||
Ok(update_id)
|
Ok(update_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user