mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 14:54:27 +01:00
Add option to avoid soft deletion of documents
This commit is contained in:
parent
ee1abfd1c1
commit
d885de1600
@ -26,6 +26,8 @@ pub struct DeleteDocuments<'t, 'u, 'i> {
|
|||||||
index: &'i Index,
|
index: &'i Index,
|
||||||
external_documents_ids: ExternalDocumentsIds<'static>,
|
external_documents_ids: ExternalDocumentsIds<'static>,
|
||||||
to_delete_docids: RoaringBitmap,
|
to_delete_docids: RoaringBitmap,
|
||||||
|
#[cfg(test)]
|
||||||
|
disable_soft_delete: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
@ -46,9 +48,16 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
|
|||||||
index,
|
index,
|
||||||
external_documents_ids,
|
external_documents_ids,
|
||||||
to_delete_docids: RoaringBitmap::new(),
|
to_delete_docids: RoaringBitmap::new(),
|
||||||
|
#[cfg(test)]
|
||||||
|
disable_soft_delete: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
fn disable_soft_delete(&mut self, disable: bool) {
|
||||||
|
self.disable_soft_delete = disable;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn delete_document(&mut self, docid: u32) {
|
pub fn delete_document(&mut self, docid: u32) {
|
||||||
self.to_delete_docids.insert(docid);
|
self.to_delete_docids.insert(docid);
|
||||||
}
|
}
|
||||||
@ -147,7 +156,20 @@ 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.
|
||||||
if percentage_available > 10 && percentage_used_by_soft_deleted_documents < 10 {
|
let disable_soft_delete = {
|
||||||
|
#[cfg(not(test))]
|
||||||
|
{
|
||||||
|
false
|
||||||
|
}
|
||||||
|
#[cfg(test)]
|
||||||
|
{
|
||||||
|
self.disable_soft_delete
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if !disable_soft_delete
|
||||||
|
&& percentage_available > 10
|
||||||
|
&& 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(DocumentDeletionResult {
|
return Ok(DocumentDeletionResult {
|
||||||
deleted_documents: self.to_delete_docids.len(),
|
deleted_documents: self.to_delete_docids.len(),
|
||||||
|
Loading…
Reference in New Issue
Block a user