Remove key from index_tasks database when the value is empty

This commit is contained in:
Loïc Lecrenier 2022-10-20 09:56:43 +02:00 committed by Clément Renault
parent 169f386418
commit 28bd8b6c6b
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
3 changed files with 5 additions and 12 deletions

View File

@ -19,7 +19,6 @@ succeeded [2,3,]
"taskDeletion" [2,3,]
----------------------------------------------------------------------
### Index Tasks:
catto []
doggo [1,]
----------------------------------------------------------------------
### Index Mapper:

View File

@ -18,7 +18,6 @@ succeeded [2,]
"taskDeletion" [2,]
----------------------------------------------------------------------
### Index Tasks:
catto []
doggo [1,]
----------------------------------------------------------------------
### Index Mapper:

View File

@ -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(())
}