guojidan commented on code in PR #1841:
URL: https://github.com/apache/kvrocks/pull/1841#discussion_r1370151863


##########
src/commands/cmd_json.cc:
##########
@@ -171,10 +171,49 @@ class CommandJsonClear : public Commander {
   }
 };
 
-REDIS_REGISTER_COMMANDS(MakeCmdAttr<CommandJsonSet>("json.set", 4, "write", 1, 
1, 1),
+class CommandJsonStrAppend : public Commander {
+ public:
+  Status Execute(Server *svr, Connection *conn, std::string *output) override {
+    redis::Json json(svr->storage, conn->GetNamespace());
+
+    // path default, if not provided
+    std::string path = "$";
+    if (args_.size() == 4) {
+      path = args_[2];
+    }
+    std::vector<int64_t> results;
+    auto s = json.StrAppend(args_[1], path, args_[3], results);
+    if (!s.ok()) return {Status::RedisExecErr, s.ToString()};
+
+    *output = redis::IntegerArray(results);
+    return Status::OK();
+  }
+};
+
+class CommandJsonStrLen : public Commander {
+ public:
+  Status Execute(Server *svr, Connection *conn, std::string *output) override {
+    redis::Json json(svr->storage, conn->GetNamespace());
+
+    std::string path = "$";
+    if (args_.size() == 3) {
+      path = args_[2];
+    }
+    std::vector<int64_t> results;
+    auto s = json.StrLen(args_[1], path, results);
+    if (!s.ok()) return {Status::RedisExecErr, s.ToString()};
+
+    *output = redis::IntegerArray(results);
+    return Status::OK();
+  }
+};
+
+REDIS_REGISTER_COMMANDS(MakeCmdAttr<CommandJsonSet>("json.set", -3, "write", 
1, 1, 1),

Review Comment:
   yes,I am overwrite someone else's code when rebase



##########
src/commands/cmd_json.cc:
##########
@@ -171,10 +171,49 @@ class CommandJsonClear : public Commander {
   }
 };
 
-REDIS_REGISTER_COMMANDS(MakeCmdAttr<CommandJsonSet>("json.set", 4, "write", 1, 
1, 1),
+class CommandJsonStrAppend : public Commander {
+ public:
+  Status Execute(Server *svr, Connection *conn, std::string *output) override {
+    redis::Json json(svr->storage, conn->GetNamespace());
+
+    // path default, if not provided
+    std::string path = "$";
+    if (args_.size() == 4) {
+      path = args_[2];
+    }
+    std::vector<int64_t> results;
+    auto s = json.StrAppend(args_[1], path, args_[3], results);
+    if (!s.ok()) return {Status::RedisExecErr, s.ToString()};
+
+    *output = redis::IntegerArray(results);
+    return Status::OK();
+  }
+};
+
+class CommandJsonStrLen : public Commander {
+ public:
+  Status Execute(Server *svr, Connection *conn, std::string *output) override {
+    redis::Json json(svr->storage, conn->GetNamespace());
+
+    std::string path = "$";
+    if (args_.size() == 3) {
+      path = args_[2];
+    }
+    std::vector<int64_t> results;
+    auto s = json.StrLen(args_[1], path, results);
+    if (!s.ok()) return {Status::RedisExecErr, s.ToString()};
+
+    *output = redis::IntegerArray(results);
+    return Status::OK();
+  }
+};
+
+REDIS_REGISTER_COMMANDS(MakeCmdAttr<CommandJsonSet>("json.set", -3, "write", 
1, 1, 1),

Review Comment:
   yes,I am overwrite someone else's code when rebase



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