-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat(server): implement JSON.TOGGLE & JSON.ARRLEN & JSON.OBJLEN commands #228
Conversation
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.
Thanks for implementing this!
src/server/json_family.cc
Outdated
(*cntx)->StartArray(result->size()); | ||
for (auto& it: *result) { | ||
if (it.has_value()) { | ||
(*cntx)->SendLong(*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.
@romange, Should I implement a function that retrieves a long long
value, right?
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.
you mean like SendLong
? Then no, because on 64bit architectures long long
and long
is the same and we are only 64bit.
src/server/json_family.cc
Outdated
vector<OptLongLong> vec; | ||
auto cb = [&](const string& path, json& val) { | ||
if (val.is_number()) { | ||
auto current_val = val.as<long long>() * num; |
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 should return an OVERFLOW error if the result is out of the range of 64-bit IEEE double.
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.
In order to provide fully compatible behavior, we need to setup an elasticache instance and learn how these special cases are handled there. That's out of scope of this assignment at this point.
what I usually do is I write // TODO: ....
comments when the code needs further enhancement.
src/server/json_family.cc
Outdated
return result.status(); | ||
} | ||
|
||
vector<OptLongLong> 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.
please add a comment TODO: to check how double and boolean are handled by INCRBY
Please see #240. I suggest that you copy
|
a02b27a
to
55c96ea
Compare
This PR contains only the commands described in the title. Other JSON commands that were related to this PR will copy to another PR with a significant refactor(Thanks for the comments). |
37d8c60
to
1e23005
Compare
…nds (dragonflydb#241) Signed-off-by: iko1 <[email protected]>
if (result->empty()) { | ||
(*cntx)->SendNullArray(); | ||
} else { | ||
(*cntx)->StartArray(result->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.
there are three repetitions of the same code of sending a long array.
We can factor them out in the next changes.
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 put it as a requirement for the next PR.
…nds (#228) feat(server): implement JSON.TOGGLE & JSON.ARRLEN & JSON.OBJLEN commands (#241) Signed-off-by: iko1 <[email protected]> Signed-off-by: iko1 <[email protected]>
…nds (#228) feat(server): implement JSON.TOGGLE & JSON.ARRLEN & JSON.OBJLEN commands (#241) Signed-off-by: iko1 <[email protected]> Signed-off-by: iko1 <[email protected]>
Signed-off-by: iko1 [email protected]
fixes: #241