From be3b00350c9fed3c6d1bd2e94e78b8af5e81897a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lecrenier?= Date: Tue, 13 Dec 2022 10:15:22 +0100 Subject: [PATCH] Apply review suggestions: naming and documentation --- milli/src/update/delete_documents.rs | 20 +++++++++++++------- milli/src/update/index_documents/mod.rs | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/milli/src/update/delete_documents.rs b/milli/src/update/delete_documents.rs index 0f77e2b13..6c0f66685 100644 --- a/milli/src/update/delete_documents.rs +++ b/milli/src/update/delete_documents.rs @@ -29,16 +29,22 @@ pub struct DeleteDocuments<'t, 'u, 'i> { disable_soft_deletion: bool, } +/// Result of a [`DeleteDocuments`] operation. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct DocumentDeletionResult { pub deleted_documents: u64, pub remaining_documents: u64, } + +/// Result of a [`DeleteDocuments`] operation, used for internal purposes. +/// +/// It is a superset of the [`DocumentDeletionResult`] structure, giving +/// additional information about the algorithm used to delete the documents. #[derive(Debug)] -pub struct DetailedDocumentDeletionResult { +pub(crate) struct DetailedDocumentDeletionResult { pub deleted_documents: u64, pub remaining_documents: u64, - pub used_soft_deletion: bool, + pub soft_deletion_used: bool, } impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> { @@ -78,7 +84,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> { let DetailedDocumentDeletionResult { deleted_documents, remaining_documents, - used_soft_deletion: _, + soft_deletion_used: _, } = self.execute_inner()?; Ok(DocumentDeletionResult { deleted_documents, remaining_documents }) @@ -100,7 +106,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> { return Ok(DetailedDocumentDeletionResult { deleted_documents: 0, remaining_documents: 0, - used_soft_deletion: false, + soft_deletion_used: false, }); } @@ -116,7 +122,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> { return Ok(DetailedDocumentDeletionResult { deleted_documents: current_documents_ids_len, remaining_documents, - used_soft_deletion: false, + soft_deletion_used: false, }); } @@ -181,7 +187,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> { return Ok(DetailedDocumentDeletionResult { deleted_documents: self.to_delete_docids.len(), remaining_documents: documents_ids.len(), - used_soft_deletion: true, + soft_deletion_used: true, }); } @@ -511,7 +517,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> { Ok(DetailedDocumentDeletionResult { deleted_documents: self.to_delete_docids.len(), remaining_documents: documents_ids.len(), - used_soft_deletion: false, + soft_deletion_used: false, }) } } diff --git a/milli/src/update/index_documents/mod.rs b/milli/src/update/index_documents/mod.rs index 478a74065..74a8d2779 100644 --- a/milli/src/update/index_documents/mod.rs +++ b/milli/src/update/index_documents/mod.rs @@ -337,7 +337,7 @@ where deletion_builder.delete_documents(&replaced_documents_ids); let deleted_documents_result = deletion_builder.execute_inner()?; debug!("{} documents actually deleted", deleted_documents_result.deleted_documents); - if !deleted_documents_result.used_soft_deletion { + if !deleted_documents_result.soft_deletion_used { external_documents_ids.delete_soft_deleted_documents_ids_from_fsts()?; } }