From 8bfa43f9a71a7eb92a3fe8407fdac76098f05434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Mon, 19 Oct 2020 13:56:32 +0200 Subject: [PATCH] Update the iter_metas UpdateStore method --- src/update_store.rs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/update_store.rs b/src/update_store.rs index 923ab42a4..e0f796af4 100644 --- a/src/update_store.rs +++ b/src/update_store.rs @@ -147,28 +147,24 @@ impl UpdateStore { } } - /// Iterate over the pending and the processed metas one after the other, - /// calling the user defined callback for each meta. - pub fn iter_meta(&self, mut f: F) -> heed::Result<()> + /// Execute the user defined function with both meta-store iterators, the first + /// iterator is the *pending* meta one and the secind is the *processed* meta one. + pub fn iter_metas(&self, mut f: F) -> heed::Result where M: for<'a> Deserialize<'a>, - F: FnMut(u64, M), + F: for<'a> FnMut( + heed::RoIter<'a, OwnedType, SerdeJson>, + heed::RoIter<'a, OwnedType, SerdeJson>, + ) -> heed::Result, { let rtxn = self.env.read_txn()?; - // We iterate over the pending updates. - for result in self.pending_meta.iter(&rtxn)? { - let (key, meta) = result?; - (f)(key.get(), meta); - } + // We get both the pending and processed meta iterators. + let pending_iter = self.pending_meta.iter(&rtxn)?; + let processed_iter = self.processed_meta.iter(&rtxn)?; - // We iterate over the processed updates. - for result in self.processed_meta.iter(&rtxn)? { - let (key, meta) = result?; - (f)(key.get(), meta); - } - - Ok(()) + // We execute the user defined function with both iterators. + (f)(pending_iter, processed_iter) } /// Returns the update associated meta or `None` if the update deosn't exist.