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


##########
src/types/json.h:
##########
@@ -144,6 +146,50 @@ struct JsonValue {
     return Status::OK();
   }
 
+  Status StrAppend(std::string_view path, const std::string &append_value, 
std::vector<uint64_t> &append_cnt) {
+    try {
+      std::string append_trimmed;
+      jsoncons::json append_json = jsoncons::json::parse(append_value);
+      if (append_json.is_string()) {
+        append_trimmed = append_json.as_string();
+      } else {
+        return {Status::NotOK, "STRAPPEND need input a string to append"};
+      }
+
+      jsoncons::jsonpath::json_replace(
+          value, path, [&append_trimmed, &append_cnt](const std::string & 
/*path*/, jsoncons::json &origin) {
+            if (origin.is_string()) {
+              auto origin_trimmed = origin.as<std::string>();
+              append_cnt.push_back(origin_trimmed.length() + 
append_trimmed.length());
+              jsoncons::json new_value(origin_trimmed + append_trimmed);
+              origin = new_value;

Review Comment:
   ```suggestion
                 origin = origin_str + append_str;
   ```



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