2019-11-26 16:12:06 +01:00
|
|
|
use crate::database::{MainT, UpdateT};
|
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(
|
2019-11-26 16:12:06 +01:00
|
|
|
writer: &mut heed::RwTxn<MainT>,
|
2020-01-16 16:29:50 +01:00
|
|
|
index: &store::Index,
|
2019-10-23 16:32:11 +02:00
|
|
|
) -> MResult<()> {
|
2020-01-16 16:29:50 +01:00
|
|
|
index.main.put_words_fst(writer, &fst::Set::default())?;
|
2020-05-20 14:49:41 +02:00
|
|
|
index.main.put_external_docids(writer, &fst::Map::default())?;
|
|
|
|
index.main.put_internal_docids(writer, &sdset::SetBuf::default())?;
|
2020-01-16 16:29:50 +01:00
|
|
|
index.main.put_ranked_map(writer, &RankedMap::default())?;
|
|
|
|
index.main.put_number_of_documents(writer, |_| 0)?;
|
|
|
|
index.documents_fields.clear(writer)?;
|
|
|
|
index.documents_fields_counts.clear(writer)?;
|
|
|
|
index.postings_lists.clear(writer)?;
|
|
|
|
index.docs_words.clear(writer)?;
|
|
|
|
index.prefix_documents_cache.clear(writer)?;
|
|
|
|
index.prefix_postings_lists_cache.clear(writer)?;
|
2019-10-23 16:32:11 +02:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn push_clear_all(
|
2019-11-26 16:12:06 +01:00
|
|
|
writer: &mut heed::RwTxn<UpdateT>,
|
2019-10-23 16:32:11 +02:00
|
|
|
updates_store: store::Updates,
|
|
|
|
updates_results_store: store::UpdatesResults,
|
|
|
|
) -> MResult<u64> {
|
|
|
|
let last_update_id = next_update_id(writer, updates_store, updates_results_store)?;
|
2019-11-12 18:00:47 +01:00
|
|
|
let update = Update::clear_all();
|
2019-10-23 16:32:11 +02:00
|
|
|
updates_store.put_update(writer, last_update_id, &update)?;
|
|
|
|
|
|
|
|
Ok(last_update_id)
|
|
|
|
}
|