2019-10-23 16:32:11 +02:00
|
|
|
use crate::update::{next_update_id, Update};
|
2019-10-24 14:20:07 +02:00
|
|
|
use crate::{store, MResult, RankedMap};
|
2019-10-23 16:32:11 +02:00
|
|
|
|
|
|
|
pub fn apply_clear_all(
|
|
|
|
writer: &mut heed::RwTxn,
|
|
|
|
main_store: store::Main,
|
|
|
|
documents_fields_store: store::DocumentsFields,
|
|
|
|
documents_fields_counts_store: store::DocumentsFieldsCounts,
|
|
|
|
postings_lists_store: store::PostingsLists,
|
|
|
|
docs_words_store: store::DocsWords,
|
|
|
|
) -> MResult<()> {
|
|
|
|
main_store.put_words_fst(writer, &fst::Set::default())?;
|
|
|
|
main_store.put_ranked_map(writer, &RankedMap::default())?;
|
|
|
|
main_store.put_number_of_documents(writer, |_| 0)?;
|
|
|
|
documents_fields_store.clear(writer)?;
|
|
|
|
documents_fields_counts_store.clear(writer)?;
|
|
|
|
postings_lists_store.clear(writer)?;
|
|
|
|
docs_words_store.clear(writer)?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn push_clear_all(
|
|
|
|
writer: &mut heed::RwTxn,
|
|
|
|
updates_store: store::Updates,
|
|
|
|
updates_results_store: store::UpdatesResults,
|
|
|
|
) -> MResult<u64> {
|
|
|
|
let last_update_id = next_update_id(writer, updates_store, updates_results_store)?;
|
|
|
|
let update = Update::ClearAll;
|
|
|
|
updates_store.put_update(writer, last_update_id, &update)?;
|
|
|
|
|
|
|
|
Ok(last_update_id)
|
|
|
|
}
|