From 28bd8b6c6b84dc7947ab49b6baa4cb0e4dc891d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lecrenier?= Date: Thu, 20 Oct 2022 09:56:43 +0200 Subject: [PATCH] Remove key from index_tasks database when the value is empty --- .../task_deletion_processed.snap | 1 - .../task_deletion_processed.snap | 1 - index-scheduler/src/utils.rs | 15 +++++---------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/index-scheduler/src/snapshots/lib.rs/task_deletion_delete_same_task_twice/task_deletion_processed.snap b/index-scheduler/src/snapshots/lib.rs/task_deletion_delete_same_task_twice/task_deletion_processed.snap index 740edb2ed..e38225dc4 100644 --- a/index-scheduler/src/snapshots/lib.rs/task_deletion_delete_same_task_twice/task_deletion_processed.snap +++ b/index-scheduler/src/snapshots/lib.rs/task_deletion_delete_same_task_twice/task_deletion_processed.snap @@ -19,7 +19,6 @@ succeeded [2,3,] "taskDeletion" [2,3,] ---------------------------------------------------------------------- ### Index Tasks: -catto [] doggo [1,] ---------------------------------------------------------------------- ### Index Mapper: diff --git a/index-scheduler/src/snapshots/lib.rs/task_deletion_deleteable/task_deletion_processed.snap b/index-scheduler/src/snapshots/lib.rs/task_deletion_deleteable/task_deletion_processed.snap index 8378a940a..f470097a9 100644 --- a/index-scheduler/src/snapshots/lib.rs/task_deletion_deleteable/task_deletion_processed.snap +++ b/index-scheduler/src/snapshots/lib.rs/task_deletion_deleteable/task_deletion_processed.snap @@ -18,7 +18,6 @@ succeeded [2,] "taskDeletion" [2,] ---------------------------------------------------------------------- ### Index Tasks: -catto [] doggo [1,] ---------------------------------------------------------------------- ### Index Mapper: diff --git a/index-scheduler/src/utils.rs b/index-scheduler/src/utils.rs index f82976b3d..4bab8dc93 100644 --- a/index-scheduler/src/utils.rs +++ b/index-scheduler/src/utils.rs @@ -112,15 +112,6 @@ impl IndexScheduler { Ok(self.index_tasks.get(rtxn, index)?.unwrap_or_default()) } - pub(crate) fn put_index( - &self, - wtxn: &mut RwTxn, - index: &str, - bitmap: &RoaringBitmap, - ) -> Result<()> { - Ok(self.index_tasks.put(wtxn, index, bitmap)?) - } - pub(crate) fn update_index( &self, wtxn: &mut RwTxn, @@ -129,7 +120,11 @@ impl IndexScheduler { ) -> Result<()> { let mut tasks = self.index_tasks(wtxn, index)?; f(&mut tasks); - self.put_index(wtxn, index, &tasks)?; + if tasks.is_empty() { + self.index_tasks.delete(wtxn, index)?; + } else { + self.index_tasks.put(wtxn, index, &tasks)?; + } Ok(()) }