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: fully switch to dual parsing with json::Path #2654

Merged
merged 1 commit into from
Feb 24, 2024
Merged

chore: fully switch to dual parsing with json::Path #2654

merged 1 commit into from
Feb 24, 2024

Conversation

romange
Copy link
Collaborator

@romange romange commented Feb 23, 2024

No description provided.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
@romange romange requested a review from BorysTheDev February 23, 2024 19:01
Comment on lines +605 to 608
if (status != OpStatus::OK) {
return status;
}
return vec;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit ? :

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ternary operator requires all the returned expressions be of the same type, which makes it less elegant here

}
size_t removal_index;
if (index < 0) {
int temp_index = index + val->size();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it really be negative?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, like with python arrays

Comment on lines +824 to +838
if (std::holds_alternative<json::Path>(expression)) {
const json::Path& json_path = std::get<json::Path>(expression);
auto cb = [&vec, index](optional<string_view>, JsonType* val) {
ArrayPop(nullopt, index, val, &vec);
return false;
};
status = UpdateEntry(op_args, key, json_path, std::move(cb));
} else {
auto cb = [&](const auto& path, JsonType& val) {
ArrayPop(nullopt, index, &val, &vec);
return false;
};

status = UpdateEntry(op_args, key, path, cb);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please consider to make one callback, because they are the same and you can use some type deduction to create one common type for JsonType

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these c++ gymnastics here are not worth it - the code is transitional and we will remove JsonExpression once everyone will be handled by json::Path spend some time released

@romange romange merged commit 050649d into main Feb 24, 2024
10 checks passed
@romange romange deleted the Pr4 branch February 24, 2024 11:26
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.

2 participants