mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
chore: minor refactorings around dense_set deletions (#4390)
chore: refactorings around deletions Done as a preparation to introduce asynchronous deletions for sets/zsets/hmaps. 1. Restrict the interface around DbSlice::Del. Now it requires for the iterator to be valid and the checks should be explicit before the call. Most callers already provides a valid iterator. 2. Some minor refactoring in compact_object_test. 3. Expose DenseSet::ClearStep to allow iterative deletions of elements. Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
3b082e42b8
commit
7a68528022
14 changed files with 116 additions and 93 deletions
|
@ -913,8 +913,13 @@ OpResult<long> OpDel(const OpArgs& op_args, string_view key, string_view path,
|
|||
if (json_path.RefersToRootElement()) {
|
||||
auto& db_slice = op_args.GetDbSlice();
|
||||
auto it = db_slice.FindMutable(op_args.db_cntx, key).it; // post_updater will run immediately
|
||||
return static_cast<long>(db_slice.Del(op_args.db_cntx, it));
|
||||
if (IsValid(it)) {
|
||||
db_slice.Del(op_args.db_cntx, it);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
JsonMemTracker tracker;
|
||||
// FindMutable because we need to run the AutoUpdater at the end which will account
|
||||
// the deltas calculated from the MemoryTracker
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue