From 1228c2948d8ce2f8e31d38c0bd97c80991e81485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 28 Oct 2020 11:17:36 +0100 Subject: [PATCH] Add a comment about the ClearDocuments operation in the DeleteDocuments --- src/subcommand/serve.rs | 4 +--- src/update/delete_documents.rs | 5 +++++ src/update/index_documents/mod.rs | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/subcommand/serve.rs b/src/subcommand/serve.rs index 379bb68db..471a1da52 100644 --- a/src/subcommand/serve.rs +++ b/src/subcommand/serve.rs @@ -264,9 +264,7 @@ pub fn run(opt: Opt) -> anyhow::Result<()> { let meta = match result { Ok(()) => format!("valid update content"), - Err(e) => { - format!("error while processing update content: {}", e) - } + Err(e) => format!("error while processing update content: {:?}", e), }; let processed = UpdateStatus::Processed { update_id, meta: meta.clone() }; diff --git a/src/update/delete_documents.rs b/src/update/delete_documents.rs index 6a5d02068..b72140791 100644 --- a/src/update/delete_documents.rs +++ b/src/update/delete_documents.rs @@ -57,6 +57,11 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> { documents_ids.intersect_with(&self.documents_ids); self.index.put_documents_ids(self.wtxn, &documents_ids)?; + // TODO we should be able to execute a ClearDocuments operation when the number of documents + // to delete is exactly the number of documents in the database, however it seems that + // clearing a database in LMDB requires a commit for it to be effective, we can't clear + // and assume that the database is empty in the same wtxn or something. + let fields_ids_map = self.index.fields_ids_map(self.wtxn)?; let id_field = fields_ids_map.id("id").expect(r#"the field "id" to be present"#); diff --git a/src/update/index_documents/mod.rs b/src/update/index_documents/mod.rs index d8ffbca43..1b3b1d36c 100644 --- a/src/update/index_documents/mod.rs +++ b/src/update/index_documents/mod.rs @@ -398,6 +398,8 @@ impl<'t, 'u, 'i> IndexDocuments<'t, 'u, 'i> { WriteMethod::Append }; + debug!("Writing using the write method: {:?}", write_method); + // We write the fields ids map into the main database self.index.put_fields_ids_map(self.wtxn, &fields_ids_map)?;