mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-24 21:50:07 +01:00
Hard or soft delete according to the deletion strategy
This commit is contained in:
parent
fc7618d49b
commit
e2ae3b24aa
@ -186,6 +186,9 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
|
|||||||
|
|
||||||
soft_deleted_docids |= &self.to_delete_docids;
|
soft_deleted_docids |= &self.to_delete_docids;
|
||||||
|
|
||||||
|
// decide for a hard or soft deletion depending on the strategy
|
||||||
|
let soft_deletion = match self.strategy {
|
||||||
|
DeletionStrategy::Dynamic => {
|
||||||
// if we have less documents to delete than the threshold we simply save them in
|
// if we have less documents to delete than the threshold we simply save them in
|
||||||
// the `soft_deleted_documents_ids` bitmap and early exit.
|
// the `soft_deleted_documents_ids` bitmap and early exit.
|
||||||
let size_used = self.index.used_size()?;
|
let size_used = self.index.used_size()?;
|
||||||
@ -208,11 +211,14 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
|
|||||||
// We run the deletion.
|
// We run the deletion.
|
||||||
// - With 100Go of disk and 50Go used including 15Go of soft-deleted documents
|
// - With 100Go of disk and 50Go used including 15Go of soft-deleted documents
|
||||||
// We run the deletion.
|
// We run the deletion.
|
||||||
|
percentage_available > 10 && percentage_used_by_soft_deleted_documents < 10
|
||||||
|
}
|
||||||
|
DeletionStrategy::AlwaysSoft => true,
|
||||||
|
DeletionStrategy::AlwaysHard => false,
|
||||||
|
};
|
||||||
|
|
||||||
if !self.disable_soft_deletion
|
if soft_deletion {
|
||||||
&& percentage_available > 10
|
// Keep the soft-deleted in the DB
|
||||||
&& percentage_used_by_soft_deleted_documents < 10
|
|
||||||
{
|
|
||||||
self.index.put_soft_deleted_documents_ids(self.wtxn, &soft_deleted_docids)?;
|
self.index.put_soft_deleted_documents_ids(self.wtxn, &soft_deleted_docids)?;
|
||||||
return Ok(DetailedDocumentDeletionResult {
|
return Ok(DetailedDocumentDeletionResult {
|
||||||
deleted_documents: self.to_delete_docids.len(),
|
deleted_documents: self.to_delete_docids.len(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user