jackyyyyyssss commented on code in PR #2236:
URL: https://github.com/apache/kvrocks/pull/2236#discussion_r1562725543


##########
src/commands/scan_base.h:
##########
@@ -90,23 +91,24 @@ class CommandSubkeyScanBase : public CommandScanBase {
   CommandSubkeyScanBase() : CommandScanBase() {}
 
   Status Parse(const std::vector<std::string> &args) override {
-    if (args.size() % 2 == 0) {
-      return {Status::RedisParseErr, errWrongNumOfArguments};
-    }
-
-    key_ = args[1];
-    ParseCursor(args[2]);
-    if (args.size() >= 5) {
-      Status s = ParseMatchAndCountParam(util::ToLower(args[3]), args_[4]);
-      if (!s.IsOK()) {
-        return s;
-      }
-    }
-
-    if (args.size() >= 7) {
-      Status s = ParseMatchAndCountParam(util::ToLower(args[5]), args_[6]);
-      if (!s.IsOK()) {
-        return s;
+    CommandParser parser(args, 1);
+    key_ = GET_OR_RET(parser.TakeStr());
+    ParseCursor(GET_OR_RET(parser.TakeStr()));
+    while (parser.Good()) {
+      if (parser.EatEqICase("match")) {
+        prefix_ = GET_OR_RET(parser.TakeStr());
+        if (!prefix_.empty() && prefix_.back() == '*') {
+          prefix_ = prefix_.substr(0, prefix_.size() - 1);
+        } else {
+          return {Status::RedisParseErr, "currently only key prefix matching 
is supported"};
+        }
+      } else if (parser.EatEqICase("count")) {
+        limit_ = GET_OR_RET(parser.TakeInt());
+        if (limit_ <= 0) {
+          return {Status::RedisParseErr, errInvalidSyntax};
+        }
+      } else {
+        return {Status::RedisParseErr, errWrongNumOfArguments};

Review Comment:
   I have a question about whether this parsing is written in CommandScanBase, 
or if both have differences written in their respective places, with the public 
part written in base. However, if so, what should be the template value for 
CommandParser as a method parameter? like this   template <typename Iter>
     Status ProcessCommandParser(CommandParser<Iter>  &parser) {..}



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

Reply via email to