You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "git-hulk (via GitHub)" <gi...@apache.org> on 2023/05/26 05:22:48 UTC

[GitHub] [incubator-kvrocks] git-hulk commented on a diff in pull request #1468: Add the support of the ZMPOP command

git-hulk commented on code in PR #1468:
URL: https://github.com/apache/incubator-kvrocks/pull/1468#discussion_r1206252921


##########
src/commands/cmd_zset.cc:
##########
@@ -266,6 +268,74 @@ class CommandZPopMax : public CommandZPop {
   CommandZPopMax() : CommandZPop(false) {}
 };
 
+class CommandZMPop : public Commander {
+ public:
+  CommandZMPop() = default;
+
+  Status Parse(const std::vector<std::string> &args) override {
+    CommandParser parser(args, 1);
+    numkeys_ = GET_OR_RET(parser.TakeInt<int>(NumericRange<int>{1, std::numeric_limits<int>::max()}));
+    for (int i = 0; i < numkeys_; ++i) {
+      keys_.emplace_back(GET_OR_RET(parser.TakeStr()));
+    }
+    bool has_min_flag = false;

Review Comment:
   It's a bit confusing, when the MAX was passed then we set the has_min_flag to true. I think we can an enum to represent this state:
   
   where = ZSET_NONE
   
   if (parser.EatEqICase("min")) {
     where = ZSET_MIN
   } else if (parser.EatEqICase("max")) {
     where = ZSET_MAX
   }
   if (where == ZSET_NONE) {
    // invalid syntax
   }



-- 
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