torwig commented on code in PR #2352:
URL: https://github.com/apache/kvrocks/pull/2352#discussion_r1623392400
##########
src/types/redis_stream.cc:
##########
@@ -339,20 +339,40 @@ rocksdb::Status Stream::DeletePelEntries(const Slice
&stream_name, const std::st
WriteBatchLogData log_data(kRedisStream);
batch->PutLogData(log_data.Encode());
+ std::map<std::string, uint64_t> consumer_acknowledges;
for (const auto &id : entry_ids) {
std::string entry_key = internalPelKeyFromGroupAndEntryId(ns_key,
metadata, group_name, id);
std::string value;
s = storage_->Get(rocksdb::ReadOptions(), stream_cf_handle_, entry_key,
&value);
if (s.ok()) {
*acknowledged += 1;
batch->Delete(stream_cf_handle_, entry_key);
+
+ // increment ack for each related consumer
+ auto pel_entry = decodeStreamPelEntryValue(value);
+ if (consumer_acknowledges.find(pel_entry.consumer_name) ==
consumer_acknowledges.cend()) {
Review Comment:
We can simplify this if-else:
`consumer_acknowledges[pel_entry.consumer_name]++;`
This leverages the fact that consumer_acknowledges[pel_entry.consumer_name]
will automatically initialize to 0 if pel_entry.consumer_name is not already a
key in the map, and then increments it by 1.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]