Skip to content
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

Merged
merged 3 commits into from
Feb 26, 2024
Merged

chore: Del and NUMINCRBY use json::Path #2655

merged 3 commits into from
Feb 26, 2024

Conversation

romange
Copy link
Collaborator

@romange romange commented Feb 24, 2024

Also, fix various protocol bug when we sent simple string instead of sending bulk strings.

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);
Copy link
Contributor

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

Copy link
Collaborator Author

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.

enum ArithmeticOpType { OP_ADD, OP_MULTIPLY };

// Returns true in case of overflow
bool BinOpApply(double num, bool num_is_double, ArithmeticOpType op, JsonType* val) {
Copy link
Contributor

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

auto cb = [&](optional<string_view>, JsonType* val) {
if (val->is_number()) {
bool res = BinOpApply(num, has_fractional_part, op_type, val);
if (res) {
Copy link
Contributor

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

Copy link
Collaborator Author

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>
dranikpg
dranikpg previously approved these changes Feb 26, 2024
Copy link
Contributor

@dranikpg dranikpg left a 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?

BorysTheDev
BorysTheDev previously approved these changes Feb 26, 2024
@romange
Copy link
Collaborator Author

romange commented Feb 26, 2024

@dranikpg I was in the middle of writing you that I am surprised myself how come TEST_F(JsonFamilyTest, NumIncrBy) did not find the problem and suddenly understood that it never tested an index path 🤦. Will add

@romange romange dismissed stale reviews from BorysTheDev and dranikpg via a6e8148 February 26, 2024 13:43
@romange romange enabled auto-merge (squash) February 26, 2024 13:43
@romange
Copy link
Collaborator Author

romange commented Feb 26, 2024

@BorysTheDev Added the test for incrementing d[2] that exposes the bug I had.

@romange romange merged commit 91c299b into main Feb 26, 2024
10 checks passed
@romange romange deleted the Pr1 branch February 26, 2024 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants