-
Notifications
You must be signed in to change notification settings - Fork 1.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
[Solves #254] Add support for RANDOMKEY command #1093
base: master
Are you sure you want to change the base?
Conversation
Since the existing owner of the issue did not submit any PRs for a while, let's go ahead with this one. Assigning the issue to you. I'll go through this PR in a bit |
Let's ensure we don't return expired but non-evicted keys. |
0960371
to
e33e207
Compare
Updated and rebased with new changes on upstream master |
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.
Also, please add integration tests to resp, http, websockets.
bc83cfe
to
b84fd3f
Compare
@SyedMa3 looks good? |
If we have to get it done in less than O(0) time complexity, we would have to dive deep into the map implementation of Go. I found this article which explores random key in Article: https://lukechampine.com/hackmap.html We can take inspiration and maybe do something like this if it's possible? What do you guys think? |
This is quite a big task to take up. Maybe we can put this off for later since it is not of the highest priority to have this command run in O(1) time. Thanks for exploring and diving deep into this @SyedMa3. If someone wants to take up this task independently then that's great. However, the core team is stretched thin across a lot of the different projects which are going on right now and won't be able to provide active support on the initiative to make this run faster. |
@JyotinderSingh @SyedMa3 lemme know if there is anything to be changed here. |
2c7138b
to
521798e
Compare
This PR does not compile, could you please take a look @xanish? |
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.
7748e9a
to
319f450
Compare
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 adding support for the RANDOMKEY command @xanish! I've left a few comments.
Some of the test cases are failing, please take a look. |
136a60e
to
f636322
Compare
@JyotinderSingh can you check now |
@xanish thanks for working on this feature. We are going to make multi-threading the default mode of operation for DiceDB in the coming days. We will need to migrate this command as a part of this change itself. I'm pulling in @AshwinKul28 to help lead the discussion on that and guide you about it since multithreading support for this command will not be straightforward. Feel free to take your time on the implementation. |
Hey @AshwinKul28 can you direct me on this? i will have free time from this weekend so i can wrap this up. |
Hey @JyotinderSingh @AshwinKul28 does everything seem fine here? Can we get it merged? |
Will review this soon, thanks for working on this! |
Hey @JyotinderSingh @arpitbbhayani,
Sorry if it was not allowed to initiate a pull without getting assigned (Issue #254) (If it was feel free to discard this MR).
I had implemented this some weeks back but did not get a reply so decided to commit and push the changes.
For now I've made it so that it uses the existing KEYS implementation and works in O(n). It took approximately 1ms for 100k key entries and 40ms for 1m entries based on the go test benchmark.
If we need it in O(1) might have to create a separate key slice to keep track of the keys and extract RANDOMKEY in O(1).
Additionally, I have skipped the loop to check if the RANDOMKEY is expired, so it is possible for a non-evicted expired key to be returned, again can make changes as needed for the requirement.
Thanks.