git-hulk commented on code in PR #1856:
URL: https://github.com/apache/kvrocks/pull/1856#discussion_r1371473877


##########
src/types/redis_json.cc:
##########
@@ -187,4 +187,34 @@ rocksdb::Status Json::Clear(const std::string &user_key, 
const std::string &path
 
   return write(ns_key, &metadata, json_val);
 }
+
+rocksdb::Status Json::ArrLen(const std::string &user_key, const std::string 
&path, std::vector<uint64_t> &arr_lens) {
+  auto ns_key = AppendNamespacePrefix(user_key);
+
+  std::string bytes;
+  JsonMetadata metadata;
+  Slice rest;
+
+  auto s = GetMetadata(kRedisJson, ns_key, &bytes, &metadata, &rest);
+  if (!s.ok()) {
+    return s;
+  }
+
+  if (metadata.format != JsonStorageFormat::JSON) {
+    return rocksdb::Status::NotSupported("JSON storage format not supported");
+  }
+
+  auto json_res = JsonValue::FromString(rest.ToStringView());
+  if (!json_res) {
+    return rocksdb::Status::Corruption(json_res.Msg());
+  }
+
+  auto json_val = *std::move(json_res);

Review Comment:
   ```suggestion
     auto ns_key = AppendNamespacePrefix(user_key);
     JsonMetadata metadata;
     JsonValue json_val;
     auto s = read(ns_key, &metadata, &json_val);
     if (!s.ok()) return s;
   ```



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