PragmaTwice commented on code in PR #1704:
URL: https://github.com/apache/kvrocks/pull/1704#discussion_r1306615516


##########
src/commands/cmd_stream.cc:
##########
@@ -205,6 +206,92 @@ class CommandXDel : public Commander {
   std::vector<redis::StreamEntryID> ids_;
 };
 
+class CommandXGroup : public Commander {
+ public:
+  Status Parse(const std::vector<std::string> &args) override {
+    CommandParser parser(args, 1);
+    subcommand_ = util::ToLower(GET_OR_RET(parser.TakeStr()));
+    stream_name_ = GET_OR_RET(parser.TakeStr());
+    group_name_ = GET_OR_RET(parser.TakeStr());
+    if (std::isdigit(group_name_[0])) {
+      return {Status::RedisParseErr, "group name cannot start with number"};
+    }
+
+    if (subcommand_ == "create") {
+      if (args.size() < 5 || args.size() > 8) {
+        return {Status::RedisParseErr, errWrongNumOfArguments};
+      }
+
+      xgroup_create_options_.last_id = GET_OR_RET(parser.TakeStr());
+
+      while (parser.Good()) {
+        if (parser.EatEqICase("mkstream")) {
+          xgroup_create_options_.mkstream = true;
+        } else if (parser.EatEqICase("entriesread")) {
+          if (!parser.Good()) {
+            return {Status::RedisParseErr, 
errUnknownSubcommandOrWrongArguments};
+          }
+          auto parse_result = parser.TakeInt<int64_t>();
+          if (!parse_result.IsOK()) {
+            return {Status::RedisParseErr, errValueNotInteger};
+          }
+          if (parse_result.GetValue() < 0 && parse_result.GetValue() != -1) {
+            return {Status::RedisParseErr, "value for ENTRIESREAD must be 
positive or -1"};
+          }
+          xgroup_create_options_.entries_read = parse_result.GetValue();
+        }

Review Comment:
   ```suggestion
           } else {
             return parser.InvalidSyntax();
           }
   ```



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