-
Notifications
You must be signed in to change notification settings - Fork 876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mutate method to jsonpath #2606
Conversation
src/core/json/path.cc
Outdated
bool erase = Mutate(cb, it->key(), &it->value()); | ||
if (erase) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
if (Mutate(cb, it->key(), &it->value())) {
src/core/json/path.cc
Outdated
if (res) { | ||
it = node->erase(it); | ||
} else { | ||
++it; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it = res ? node->erase(it) : it + 1;
auto cb = [&vec](optional<string_view>, JsonType* val) { | ||
if (val->is_bool()) { | ||
bool next_val = val->as_bool() ^ true; | ||
*val = next_val; | ||
vec.emplace_back(next_val); | ||
} else { | ||
vec.emplace_back(nullopt); | ||
} | ||
return false; | ||
}; | ||
json::MutatePath(expr, std::move(cb), pv.GetJson()); | ||
it_res->post_updater.Run(); | ||
op_args.shard->search_indices()->AddDoc(key, op_args.db_cntx, pv); | ||
} else { | ||
auto cb = [&vec](const auto&, JsonType& val) { | ||
if (val.is_bool()) { | ||
bool current_val = val.as_bool() ^ true; | ||
val = current_val; | ||
vec.emplace_back(current_val); | ||
} else { | ||
vec.emplace_back(nullopt); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cb are the same but pointer type, I think you can implement one callback via another or do a pointer dereference with constexpr if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not worth it since it's a transitional code and once we are confident it's robust we will delete the old one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any case I have approved it
Plug it in into OpToggle op. Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
* Add mutate method to jsonpath Plug it in into OpToggle op. --------- Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Plug it in into OpToggle op.