You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "torwig (via GitHub)" <gi...@apache.org> on 2023/05/18 13:08:37 UTC

[GitHub] [incubator-kvrocks] torwig commented on a diff in pull request #1444: feat: add sintercard command from redis 7.0

torwig commented on code in PR #1444:
URL: https://github.com/apache/incubator-kvrocks/pull/1444#discussion_r1197795058


##########
src/types/redis_set.cc:
##########
@@ -338,19 +338,42 @@ rocksdb::Status Set::Inter(const std::vector<Slice> &keys, std::vector<std::stri
   for (const auto &member : target_members) {
     member_counters[member] = 1;
   }
+
+  bool has_limit = limit > 0;
   for (size_t i = 1; i < keys.size(); i++) {
     s = Members(keys[i], &target_members);
     if (!s.ok() || target_members.empty()) return s;
     for (const auto &member : target_members) {
-      if (member_counters.find(member) == member_counters.end()) continue;
+      if (member_counters.count(member) == 0) continue;
       member_counters[member]++;
+      if (has_limit && member_counters[member] == keys.size()) {
+        members->emplace_back(member);
+        if (--limit == 0) {
+          limit = -1;

Review Comment:
   The variable `limit` is of type `uint64_t`. How it could be assigned to `-1` and later checked via the condition `limit < 0`?



-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org