-
Notifications
You must be signed in to change notification settings - Fork 504
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 the support of the ZMPOP command #1468
Conversation
Signed-off-by: MizukiCry <YuukaC@outlook.com>
@MizukiCry Thank you for your contribution. Unfortunately, there are some functions that don't have test coverage. However, we are thriving to test all the new features and changes so it would be great if you provide test cases. |
great job!
|
Yeah, it is definitely an efficient way to prove to us that your code can work well.
You are welcome to add them if you want. |
Signed-off-by: MizukiCry <YuukaC@outlook.com>
Signed-off-by: MizukiCry <YuukaC@outlook.com>
Please use |
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.
Generally, LGTM.
@MizukiCry Good job!
Many thanks to @PragmaTwice for reviewing and helping with this PR.
Fixed. |
Others are good to me |
Signed-off-by: MizukiCry <YuukaC@outlook.com>
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.
LGTM, thanks for your contribution.
Thanks all, merging... |
Thanks @MizukiCry again. |
We did not check for repeated parameters before, so the following code is executable: ``` 127.0.0.1:6666> zmpop 1 zset min max (nil) 127.0.0.1:6666> zmpop 1 zset min count 10 count 100 (nil) 127.0.0.1:6666> zmpop 1 zset min min max max min (nil) 127.0.0.1:6666> zmpop 1 zset min count 10 count 100 max (nil) 127.0.0.1:6666> bzmpop 0.1 1 zset min max (nil) 127.0.0.1:6666> bzmpop 0.1 1 zset min count 1 count 10 (nil) ``` Now we don't allow duplicate parameters (throw a syntax error): ``` 127.0.0.1:6666> zmpop 1 zset min max (error) ERR syntax error 127.0.0.1:6666> zmpop 1 zset min count 10 count 100 (error) ERR syntax error 127.0.0.1:6666> zmpop 1 zset min min max max min (error) ERR syntax error 127.0.0.1:6666> zmpop 1 zset min count 10 count 100 max (error) ERR syntax error 127.0.0.1:6666> bzmpop 0.1 1 zset min max (error) ERR syntax error 127.0.0.1:6666> bzmpop 0.1 1 zset min count 1 count 10 (error) ERR syntax error ``` Also added some tests to cover these wrong error paths. Refs: ZMPOP was added in apache#1468 and BZMPOP was added in apache#1490.
This PR supports the ZMPOP command like Redis.
ZMPOP numkeys key [key ...] <MIN | MAX> [COUNT count]
Worstly O(K) + O(M*log(N))
K: numkeys
N: the number of elements in the zset
M: the number of elements popped.
It returns nil if no elements popped.
Close #1458
By the way, do I need to add test cases for it? Similar commands like
ZPOPMIN / MAX
also don't have corresponding test cases.