@@ -479,14 +479,6 @@ DbSlice::AutoUpdater::AutoUpdater(const Fields& fields) : fields_(fields) {
479
479
fields_.orig_heap_size = fields.it ->second .MallocUsed ();
480
480
}
481
481
482
- DbSlice::AddOrFindResult& DbSlice::AddOrFindResult::operator =(ItAndUpdater&& o) {
483
- it = o.it ;
484
- exp_it = o.exp_it ;
485
- is_new = false ;
486
- post_updater = std::move (o).post_updater ;
487
- return *this ;
488
- }
489
-
490
482
DbSlice::ItAndUpdater DbSlice::FindMutable (const Context& cntx, string_view key) {
491
483
return std::move (FindMutableInternal (cntx, key, std::nullopt).value ());
492
484
}
@@ -626,12 +618,11 @@ auto DbSlice::FindInternal(const Context& cntx, string_view key, optional<unsign
626
618
return res;
627
619
}
628
620
629
- OpResult<DbSlice::AddOrFindResult > DbSlice::AddOrFind (const Context& cntx, string_view key) {
621
+ OpResult<DbSlice::ItAndUpdater > DbSlice::AddOrFind (const Context& cntx, string_view key) {
630
622
return AddOrFindInternal (cntx, key);
631
623
}
632
624
633
- OpResult<DbSlice::AddOrFindResult> DbSlice::AddOrFindInternal (const Context& cntx,
634
- string_view key) {
625
+ OpResult<DbSlice::ItAndUpdater> DbSlice::AddOrFindInternal (const Context& cntx, string_view key) {
635
626
DCHECK (IsDbValid (cntx.db_index ));
636
627
637
628
DbTable& db = *db_arr_[cntx.db_index ];
@@ -644,15 +635,15 @@ OpResult<DbSlice::AddOrFindResult> DbSlice::AddOrFindInternal(const Context& cnt
644
635
645
636
// PreUpdate() might have caused a deletion of `it`
646
637
if (res->it .IsOccupied ()) {
647
- return DbSlice::AddOrFindResult {
638
+ return ItAndUpdater {
648
639
.it = it,
649
640
.exp_it = exp_it,
650
- .is_new = false ,
651
641
.post_updater = AutoUpdater ({.action = AutoUpdater::DestructorAction::kRun ,
652
642
.db_slice = this ,
653
643
.db_ind = cntx.db_index ,
654
644
.it = it,
655
- .key = key})};
645
+ .key = key}),
646
+ .is_new = false };
656
647
} else {
657
648
res = OpStatus::KEY_NOTFOUND;
658
649
}
@@ -760,15 +751,14 @@ OpResult<DbSlice::AddOrFindResult> DbSlice::AddOrFindInternal(const Context& cnt
760
751
db.slots_stats [sid].key_count += 1 ;
761
752
}
762
753
763
- return DbSlice::AddOrFindResult{
764
- .it = Iterator (it, StringOrView::FromView (key)),
765
- .exp_it = ExpIterator{},
766
- .is_new = true ,
767
- .post_updater = AutoUpdater ({.action = AutoUpdater::DestructorAction::kRun ,
768
- .db_slice = this ,
769
- .db_ind = cntx.db_index ,
770
- .it = Iterator (it, StringOrView::FromView (key)),
771
- .key = key})};
754
+ return ItAndUpdater{.it = Iterator (it, StringOrView::FromView (key)),
755
+ .exp_it = ExpIterator{},
756
+ .post_updater = AutoUpdater ({.action = AutoUpdater::DestructorAction::kRun ,
757
+ .db_slice = this ,
758
+ .db_ind = cntx.db_index ,
759
+ .it = Iterator (it, StringOrView::FromView (key)),
760
+ .key = key}),
761
+ .is_new = true };
772
762
}
773
763
774
764
void DbSlice::ActivateDb (DbIndex db_ind) {
@@ -1049,11 +1039,10 @@ OpResult<int64_t> DbSlice::UpdateExpire(const Context& cntx, Iterator prime_it,
1049
1039
}
1050
1040
}
1051
1041
1052
- OpResult<DbSlice::AddOrFindResult> DbSlice::AddOrUpdateInternal (const Context& cntx,
1053
- std::string_view key,
1054
- PrimeValue obj,
1055
- uint64_t expire_at_ms,
1056
- bool force_update) {
1042
+ OpResult<DbSlice::ItAndUpdater> DbSlice::AddOrUpdateInternal (const Context& cntx,
1043
+ std::string_view key, PrimeValue obj,
1044
+ uint64_t expire_at_ms,
1045
+ bool force_update) {
1057
1046
DCHECK (!obj.IsRef ());
1058
1047
1059
1048
auto op_result = AddOrFind (cntx, key);
@@ -1084,8 +1073,8 @@ OpResult<DbSlice::AddOrFindResult> DbSlice::AddOrUpdateInternal(const Context& c
1084
1073
return op_result;
1085
1074
}
1086
1075
1087
- OpResult<DbSlice::AddOrFindResult > DbSlice::AddOrUpdate (const Context& cntx, string_view key,
1088
- PrimeValue obj, uint64_t expire_at_ms) {
1076
+ OpResult<DbSlice::ItAndUpdater > DbSlice::AddOrUpdate (const Context& cntx, string_view key,
1077
+ PrimeValue obj, uint64_t expire_at_ms) {
1089
1078
return AddOrUpdateInternal (cntx, key, std::move (obj), expire_at_ms, true );
1090
1079
}
1091
1080
@@ -1545,6 +1534,7 @@ void DbSlice::SetNotifyKeyspaceEvents(std::string_view notify_keyspace_events) {
1545
1534
}
1546
1535
1547
1536
void DbSlice::QueueInvalidationTrackingMessageAtomic (std::string_view key) {
1537
+ FiberAtomicGuard guard;
1548
1538
auto it = client_tracking_map_.find (key);
1549
1539
if (it == client_tracking_map_.end ()) {
1550
1540
return ;
@@ -1651,10 +1641,6 @@ size_t DbSlice::StopSampleKeys(DbIndex db_ind) {
1651
1641
return count;
1652
1642
}
1653
1643
1654
- void DbSlice::PerformDeletion (PrimeIterator del_it, DbTable* table) {
1655
- return PerformDeletion (Iterator::FromPrime (del_it), table);
1656
- }
1657
-
1658
1644
void DbSlice::PerformDeletionAtomic (Iterator del_it, ExpIterator exp_it, DbTable* table) {
1659
1645
FiberAtomicGuard guard;
1660
1646
size_t table_before = table->table_memory ();
0 commit comments