-
Notifications
You must be signed in to change notification settings - Fork 991
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
Conversation
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
if (status != OpStatus::OK) { | ||
return status; | ||
} | ||
return vec; |
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 ? :
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.
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(); |
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 it really be negative?
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.
yes, like with python arrays
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); | ||
} |
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.
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
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.
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
No description provided.