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


##########
src/commands/cmd_json.cc:
##########
@@ -171,10 +171,44 @@ class CommandJsonClear : public Commander {
   }
 };
 
+class CommandJsonArrLen : 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];
+    } else if (args_.size() > 3) {
+      return {Status::RedisExecErr, "The number of arguments is more than 
expected"};
+    }
+
+    std::vector<uint64_t> results;
+    auto s = json.ArrLen(args_[1], path, results);
+    if (s.IsNotFound()) {
+      *output = redis::NilString();
+      return Status::OK();
+    }
+    if (!s.ok()) return {Status::RedisExecErr, s.ToString()};
+
+    *output = redis::MultiLen(results.size());
+    for (size_t len : results) {
+      if (len >= 0) {

Review Comment:
   This condition is always evaluated to `true`.



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