-
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
chore: Del and NUMINCRBY use json::Path #2655
Conversation
27f9921
to
e71c576
Compare
Also, fix various protocol bugs when we sent simple string instead of sending bulk strings. Fixed a typo in path.cc that lead to a data race bug. Finally, flip the flag in regression tests to start covering json::Path code. Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Dfs().Mutate(path, callback, json); | ||
return 0; | ||
Dfs dfs; | ||
dfs.Mutate(path, callback, json); |
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.
maybe we can create static method Mutate that return Dfs object and we don't need to create the object before
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.
I do not see a problem with this code.
src/server/json_family.cc
Outdated
enum ArithmeticOpType { OP_ADD, OP_MULTIPLY }; | ||
|
||
// Returns true in case of overflow | ||
bool BinOpApply(double num, bool num_is_double, ArithmeticOpType op, JsonType* val) { |
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.
I would prefer to see result JsonType and overflow flag like out parameter, current implementation looks awkward
src/server/json_family.cc
Outdated
auto cb = [&](optional<string_view>, JsonType* val) { | ||
if (val->is_number()) { | ||
bool res = BinOpApply(num, has_fractional_part, op_type, val); | ||
if (res) { |
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.
can we assign is_result_overflow in the if? and maybe remove res variable
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.
we can not since the callback may be called several times and we should not reset is_result_overflow if has been set at least once.
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
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.
Maybe we should cover the two previous seeder failures with a simple test?
@dranikpg I was in the middle of writing you that I am surprised myself how come |
@BorysTheDev Added the test for incrementing |
Also, fix various protocol bug when we sent simple string instead of sending bulk strings.