-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support for command JSON.OBJKEYS
#498
Comments
@arpitbbhayani I'll signup for this |
@vigneshrajkumar assigned, thanks for picking this up. |
Hey @lucifercr07 @vigneshrajkumar , |
Assigned |
Hey @JyotinderSingh @lucifercr07 , The inner arrays will be randomly arranged + keys inside inner array will also be in random order. Similar to what happens with I have implemented functionality of JSON.OBJKEYS, but was confused with what approach can I take to perform integration test. As of now, for testing, once I have output, I am trying to sort each individual inner array (if it is a list of key), and then matching it with expected result (which is also sorted in same way). Have tested on mutliple cases, and also verified the results with redis-stack-server, and they look correct. Do you have some other idea which I can take for testing in this particular case? ![]() |
Array ordering inside array fields is deterministic. Field ordering inside JSON is not deterministic. You cannot sort the array as a part of the test, since it defeats the purpose of the array being a sorted container. Note that our JSON.GET implementation also maintains correct array ordering. So this is a non-issue. However in case of field ordering being non deterministic, we have tackled this so far by providing all possible permutations of the result set. Another more idiomatic possibility if you can it in your test code is to use assert.ElementsMatch (it's present somewhere in the code) |
Also, we don't need to handle this in our server code, JSON standard doesn't enforce key ordering for the json fields. |
We had discussion around thjs behaviour in the following pull request #365 |
Hey @JyotinderSingh , Ordering inside Array is fine, they are deterministic. What I meant to say is, in case of If we say Now, the All the above four combinations are possible (some more are possible too) and are correct. So, in these cases, maybe sorting and then comparing with sorted expected value would be a good way to test. Other way can be to have all possible permutations(of array of arrays) as expected value, and then check if result is one of them. |
We have a helper method to check for array permutations, can we make use of that? |
I can see one : |
Yeah, got it. Can you try to make the existing method work with multiple levels? If that doesn't work we can go ahead with writing the permutations ourselves and comparing against those. |
Co-authored-by: Jyotinder Singh <jyotindrsingh@gmail.com>
Add support for the
JSON.OBJKEYS
command in DiceDB similar to theJSON.OBJKEYS
command in Redis. Please refer to the following commit in Redis to understand the implementation specifics - source.Write unit and integration tests for the command referring to the tests written in the Redis codebase 7.2.5. For integration tests, you can refer to the
tests
folder. Note: they have usedTCL
for the test suite, and we need to port that to our way of writing integration tests using the relevant helper methods. Please refer to our tests directory.For the command, benchmark the code and measure the time taken and memory allocs using
benchmem
and try to keep them to the bare minimum.The text was updated successfully, but these errors were encountered: