Apply review suggestions: naming and documentation

This commit is contained in:
Loïc Lecrenier 2022-12-13 10:15:22 +01:00
parent e3ee553dcc
commit be3b00350c
2 changed files with 14 additions and 8 deletions

View File

@ -29,16 +29,22 @@ pub struct DeleteDocuments<'t, 'u, 'i> {
disable_soft_deletion: bool, disable_soft_deletion: bool,
} }
/// Result of a [`DeleteDocuments`] operation.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct DocumentDeletionResult { pub struct DocumentDeletionResult {
pub deleted_documents: u64, pub deleted_documents: u64,
pub remaining_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)] #[derive(Debug)]
pub struct DetailedDocumentDeletionResult { pub(crate) struct DetailedDocumentDeletionResult {
pub deleted_documents: u64, pub deleted_documents: u64,
pub remaining_documents: u64, pub remaining_documents: u64,
pub used_soft_deletion: bool, pub soft_deletion_used: bool,
} }
impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> { impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
@ -78,7 +84,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
let DetailedDocumentDeletionResult { let DetailedDocumentDeletionResult {
deleted_documents, deleted_documents,
remaining_documents, remaining_documents,
used_soft_deletion: _, soft_deletion_used: _,
} = self.execute_inner()?; } = self.execute_inner()?;
Ok(DocumentDeletionResult { deleted_documents, remaining_documents }) Ok(DocumentDeletionResult { deleted_documents, remaining_documents })
@ -100,7 +106,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
return Ok(DetailedDocumentDeletionResult { return Ok(DetailedDocumentDeletionResult {
deleted_documents: 0, deleted_documents: 0,
remaining_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 { return Ok(DetailedDocumentDeletionResult {
deleted_documents: current_documents_ids_len, deleted_documents: current_documents_ids_len,
remaining_documents, 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 { return Ok(DetailedDocumentDeletionResult {
deleted_documents: self.to_delete_docids.len(), deleted_documents: self.to_delete_docids.len(),
remaining_documents: documents_ids.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 { Ok(DetailedDocumentDeletionResult {
deleted_documents: self.to_delete_docids.len(), deleted_documents: self.to_delete_docids.len(),
remaining_documents: documents_ids.len(), remaining_documents: documents_ids.len(),
used_soft_deletion: false, soft_deletion_used: false,
}) })
} }
} }

View File

@ -337,7 +337,7 @@ where
deletion_builder.delete_documents(&replaced_documents_ids); deletion_builder.delete_documents(&replaced_documents_ids);
let deleted_documents_result = deletion_builder.execute_inner()?; let deleted_documents_result = deletion_builder.execute_inner()?;
debug!("{} documents actually deleted", deleted_documents_result.deleted_documents); 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()?; external_documents_ids.delete_soft_deleted_documents_ids_from_fsts()?;
} }
} }