mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-19 01:18:31 +08:00
d08b76a323
We used the heed typed transaction to make it safe (https://github.com/Kerollmops/heed/pull/27).
35 lines
1.2 KiB
Rust
35 lines
1.2 KiB
Rust
use crate::database::{MainT, UpdateT};
|
|
use crate::update::{next_update_id, Update};
|
|
use crate::{store, MResult, RankedMap};
|
|
|
|
pub fn apply_clear_all(
|
|
writer: &mut heed::RwTxn<MainT>,
|
|
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<UpdateT>,
|
|
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::clear_all();
|
|
updates_store.put_update(writer, last_update_id, &update)?;
|
|
|
|
Ok(last_update_id)
|
|
}
|