-
Notifications
You must be signed in to change notification settings - Fork 694
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 noscores option to command ZSCAN. #324
Add noscores option to command ZSCAN. #324
Conversation
Signed-off-by: Chen Tianjie <TJ_Chen@outlook.com>
f3b952b
to
41c7e6c
Compare
I suggested this command. Nobody asked for it, but it seems like a logical thing to add together with HSCAN NOVALUES. @valkey-io/core-team Let's have a vote on this new argument. Give your 👍 or 👎 please. |
I was pretty strongly against this command because I don't want to add commands that aren't solving a problem. HSCAN without values made more sense, because values can be large, but here the values are just decimals which can never be that expensive. |
Whether values are expensive to return to client is a relative thing. If the sds length of scores and members are in the same order of magnitude (in which case, names of members are short), we can certainly save considerable traffic by using |
I see it was rejected in the previous redis core-team. i agree with madolson that we should not add commands that aren't solving a problem. But on the other hands, although it may not solve many problems, it seem it does will slove some problems (like CharlesChen888's case). Another thing is that it is symmetrical will HSCAN novalues. (i am a guy prefer symmetrical) |
IMHO, ZSCAN and HSCAN have no much differences, and I prefer keeping symmetry : ) |
@CharlesChen888 please don't vote when it's a core team vote (AKA technical steering committee). We're trying to be transparent and do voting in the open. Feel free to do other emojis and to thumbs up or down on other comments. |
I would just like to clarify this isn't solving any known problem, it's a solution (reducing usage) to an imagined problem. I was asking for a use case where you would want to incrementally scan a semi-large sorted set and only care about the field names (and not care about order I suppose). Ideally we would be able to articulate "why" a user would want to use this command. Another reason the old team was against is that this can already be solved by ZRANGE (which by default doesn't include scores). A valid counter point here is that ZSCAN is more efficient, since we are skipping the O(Log(N)) seek at the start of each ZRANGE, but we haven't seen folks materially complain about that.
I still don't really think symmetry is a needed or useful property for Valkey. We can make the same argument about a lot of other commands, like why doesn't I don't specifically care about this command that strongly, I just don't want this to be the start of adding a bunch of more commands for "symmetry". |
Perhaps "symmetry" wasn't the most precise term, using the "same type" might be a more fitting description. The topic of whether user demand should precede the implementation of commands, or vice versa, is quite interesting. In this case, I lean towards implementing the command first. My intuition tells me that upon seeing |
What is the end to end use case here? This proposal seems to suggest that there is a need to retrieve just the members of the sorted set, unordered. What would an application do with this information? As far as general guidelines are concerned, I agree that we should not get ahead of ourselves too much and "predict" use cases, especially in the user facing interface areas. It is a slippery slope. |
Perhaps sending messages to all players on a ranking list (which is one of the most common use cases for zset), and the list is too long for a single |
You can incrementally scan through a sorted set with ZRANGE though. It has different properties of the SCAN though, since it wouldn't guarantee at least once delivery I suppose, since the scores could change. |
I have no objecttion to add this option. Becuase according to the SCAN, SSCAN, HSCAN and ZSCAN doc (https://redis.io/docs/latest/commands/scan/) , the return value is a two element multi-bulk reply, where the first element is a string representing an unsigned 64 bit number (the cursor), and the second element is a multi-bulk with an array of elements. For the ZSCAN, if option NOSCORES is added, only the member value as an array is returned, without their scores. It could make the client codes much easiter. |
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 you add a history
section to zscan.json as well for this new noscores
option?
Signed-off-by: Chen Tianjie <TJ_Chen@outlook.com>
Signed-off-by: Chen Tianjie <TJ_Chen@outlook.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #324 +/- ##
===========================================
Coverage ? 68.43%
===========================================
Files ? 109
Lines ? 61689
Branches ? 0
===========================================
Hits ? 42215
Misses ? 19474
Partials ? 0
|
Signed-off-by: Chen Tianjie <TJ_Chen@outlook.com>
Signed-off-by: Chen Tianjie <TJ_Chen@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
Still missing a doc PR, but other than that also LGTM. |
OK, this is ready to merge. @CharlesChen888 Do you have a doc PR for this? |
@zuiderkwast doc PR is ready. |
Doc PR for valkey-io/valkey#324 Signed-off-by: Chen Tianjie <TJ_Chen@outlook.com>
Command syntax is now: ``` ZSCAN key cursor [MATCH pattern] [COUNT count] [NOSCORES] ``` Return format: ``` 127.0.0.1:6379> zadd z 1 a 2 b 3 c (integer) 3 127.0.0.1:6379> zscan z 0 1) "0" 2) 1) "a" 2) "1" 3) "b" 4) "2" 5) "c" 6) "3" 127.0.0.1:6379> zscan z 0 noscores 1) "0" 2) 1) "a" 2) "b" 3) "c" ``` when NOSCORES is on, the command will only return members in the zset, without scores. For client side parsing the command return, I believe it is fine as long as the command is backwards compatible. The return structure are still lists, what has changed is the content. And clients can tell the difference by the subcommand they use. Since `novalues` option of `HSCAN` is already accepted (redis/redis#12765), I think similar thing can be done to `ZSCAN`. --------- Signed-off-by: Chen Tianjie <TJ_Chen@outlook.com>
Command syntax is now:
Return format:
when NOSCORES is on, the command will only return members in the zset, without scores.
For client side parsing the command return, I believe it is fine as long as the command is backwards compatible. The return structure are still lists, what has changed is the content. And clients can tell the difference by the subcommand they use.
Since
novalues
option ofHSCAN
is already accepted (redis/redis#12765), I think similar thing can be done toZSCAN
.