jihuayu commented on code in PR #1867:
URL: https://github.com/apache/kvrocks/pull/1867#discussion_r1397108280
##########
src/types/json.h:
##########
@@ -179,6 +179,33 @@ struct JsonValue {
return result_count;
}
+ StatusOr<std::vector<std::optional<uint64_t>>> ArrInsert(std::string_view
path, const int64_t &index,
+ const
std::vector<jsoncons::json> &insert_values) {
+ std::vector<std::optional<uint64_t>> result_count;
+
+ try {
+ jsoncons::jsonpath::json_replace(
+ value, path, [&insert_values, &result_count, index](const
std::string & /*path*/, jsoncons::json &val) {
+ if (val.is_array()) {
+ auto len = static_cast<int64_t>(val.size());
+ if (index >= len /*index > 0*/ || len + index < 0 /*index < 0*/)
{
Review Comment:
I means that when index > 0, we should check if index >= len. And when index
< 0, we should check if index + len < 0.
It seems that this comment could be easily misunderstood. Should I delete it?
--
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]