torwig commented on code in PR #1856:
URL: https://github.com/apache/kvrocks/pull/1856#discussion_r1371477073
##########
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);
+ auto append_res = json_val.ArrLen(path, arr_lens);
Review Comment:
Perhaps, this is copy-paste (from Append) so you would like to change
`append_res` to `len_res` to avoid code readers being confused.
--
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]