-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New ZRANGESTORE Command #7844
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
New ZRANGESTORE Command #7844
Conversation
|
@jonahharris thank you for this PR. However, this PR is quite impossible to review (and merge), it looks like your editor re-formatted all the code, so every line is changed. The obvious problems with this are:
Besides, this is not the redis style, although it may not be to anyone's liking, it's better to have consistent style across the project. It also looks like you changed the structure of the file (although i can't be sure), please avoid unnecessary changes, for an easier review. I know it would be complicated to change it at this stage, but it would be a necessary effort in order to move forward. one other request, please copy most the detailed description of the change that you posted in the issue to the PR's top comment, i'll use that as the commit comment when i squash-merge this. Thanks again for the efforts. |
|
Yeah. I mentioned the formatting stuff in the issue. I'm happy to copy the changes into the normal Redis format - I just can't work with that format when I'm adding functionality as it's not very clean/organized. I'll get that updated and resubmitted shortly. |
|
Merged changes and made most formatting changes. Still need to correct indentation for new code. |
|
@jonahharris I saw some question about function prototypes in my email but I can't find it here, maybe you deleted it. |
|
I deleted it as I reordered everything to not really need them, but the one I couldn’t remove will go to the top. Now that the diff is readable, let me know what else you’d like changed and I’ll try to get to it ASAP. |
oranagra
left a comment
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.
@jonahharris i reviewed all the code and added many comments.
some are about styling, and if you prefer not to deal with it, i can make a quick sweep to change it before merging.
other comments are about the implementation and bugs.
but most important one is about the command syntax, i think we had some misunderstanding, if my comment makes sense to you, please revise the code, if not, we should open it for a wider discussion..
lastly, we'll need to add some test coverage and documentation for the new commands, but we can deal with it later.
|
@jonahharris just want to confirm that the ball is at your court. |
|
Hey @oranagra - yes, I'm currently working on that. I only had a few consecutive days I could work on it and now I'm back to piecemeal. I'm almost done with all the changes you requested and hope to have that up in the next day or so. |
|
@oranagra assuming all goes well, what would you predict the release timeline looks like? I want to make sure this doesn't fall off and, with that timeline in mind, I'll figure out how to devote time to it. I probably have only an hour or so left, but have been pretty busy. I'll try to get to it this weekend, but will rebalance the stuff on my plate to ensure it does if I need to. |
|
@jonahharris we aim to release 6.2 at the end of the year, or at least have release candidate. |
|
@jonahharris, friendly reminder: we have about a month before putting out a release candidate. |
|
@jonahharris we probably missed the mark of 6.2 RC1, but maybe these changes can still make it to RC2. |
|
Damn. Time flies. I will definitely get this done by EOW. |
|
@jonahharris gentle nudge about this. in case you want someone else to try and pick this up from where you left it. |
|
i'm picking this up. (posting to avoid collision) |
|
@redis/core-team please approve a new ZRANGESTORE command and improvements to ZRANGE (see top comment) |
|
initial draft for the documentation PR: redis/redis-doc#1482 |
|
I don't know. It all makes sense to me and seems easy enough to understand. Most people I know who look at the Redis docs tend to just copy the examples and tailor them to their own case. As long as there are examples with the descriptions, as there are for the current commands, I don't see how it's any different. |
madolson
left a comment
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.
Minor comment, API LGTM
yossigo
left a comment
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.
API LGTM, only had a quick look at the code.
Co-authored-by: Yossi Gottlieb <yossigo@gmail.com>
| addReplyBulkCBuffer(c,ln->ele,sdslen(ln->ele)); | ||
| if (withscores) addReplyDouble(c,ln->score); | ||
| handler->emitResultFromCBuffer(handler, ln->ele, sdslen(ln->ele), | ||
| ((withscores) ? ln->score : ln->score)); |
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.
@oranagra ((withscores) ? ln->score : ln->score) Shouldn't it be changed to ln->score
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're right, the ternary op can be dropped. but at least that's not a bug.
the store variant always passes true for withscores, and the non-store variant ignores the score if it wasn't requested.
| break; | ||
| } | ||
|
|
||
| if (opt_withscores || store) { |
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.
@oranagra I read the zunionInterDiffGenericCommand function, it should be similar, when there is a flag store, only the number of results will be replied, without specific data.
If there is a store flag, zrangeResultHandlerScoreEmissionEnable should not effect.
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'm not sure what you mean by this comment.
in case store is set, the call to zrangeResultHandlerScoreEmissionEnable is in some way redundant. since the two variables it sets are only used by the non-store variant handlers, so we can remove the || store from the above condition, and this function will never be called.
there's something a bit ugly in my final changes to this PR, is that i added the store argument to this function.
in theory, the handler should know what to do.
but i wanted to give syntax error on the WITHSCORES argument on the store variant, and added that store argument, that's where the mess started.
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.
struct zrange_result_handler {
zrange_consumer_type type;
client *client;
robj *dstkey;
robj *dstobj;
void *userdata;
int withscores;
int should_emit_array_length;
int store; <- here what I add
zrangeResultBeginFunction beginResultEmission;
zrangeResultFinalizeFunction finalizeResultEmission;
zrangeResultEmitCBufferFunction emitResultFromCBuffer;
zrangeResultEmitLongLongFunction emitResultFromLongLong;
};Your idea should be exactly what I am trying to do. zrange_result_handler should know what it should do.
oranagra
left a comment
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.
@sundb thanks for this review.
if i understand you correctly, you're suggesting some cleanups (not reporting bugs or improvements).
since this one is merged already, feel free to open a PR for these.
| addReplyBulkCBuffer(c,ln->ele,sdslen(ln->ele)); | ||
| if (withscores) addReplyDouble(c,ln->score); | ||
| handler->emitResultFromCBuffer(handler, ln->ele, sdslen(ln->ele), | ||
| ((withscores) ? ln->score : ln->score)); |
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're right, the ternary op can be dropped. but at least that's not a bug.
the store variant always passes true for withscores, and the non-store variant ignores the score if it wasn't requested.
| break; | ||
| } | ||
|
|
||
| if (opt_withscores || store) { |
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'm not sure what you mean by this comment.
in case store is set, the call to zrangeResultHandlerScoreEmissionEnable is in some way redundant. since the two variables it sets are only used by the non-store variant handlers, so we can remove the || store from the above condition, and this function will never be called.
there's something a bit ugly in my final changes to this PR, is that i added the store argument to this function.
in theory, the handler should know what to do.
but i wanted to give syntax error on the WITHSCORES argument on the store variant, and added that store argument, that's where the mess started.
Add ZRANGESTORE command, and improve ZSTORE command to deprecated Z[REV]RANGE[BYSCORE|BYLEX]. Syntax for the new ZRANGESTORE command: ZRANGESTORE [BYSCORE | BYLEX] [REV] [LIMIT offset count] New syntax for ZRANGE: ZRANGE [BYSCORE | BYLEX] [REV] [WITHSCORES] [LIMIT offset count] Old syntax for ZRANGE: ZRANGE [WITHSCORES] Other ZRANGE commands remain unchanged. The implementation uses common code for all of these, by utilizing a consumer interface that in one command response to the client, and in the other command stores a zset key. Co-authored-by: Oran Agra <oran@redislabs.com>
…10337) Avoid deferred array reply on genericZrangebyrankCommand() when consumer type is client. I.e. any ZRANGE / ZREVRNGE (when tank is used). This was a performance regression introduced in #7844 (v 6.2) mainly affecting pipelined workloads. Co-authored-by: Oran Agra <oran@redislabs.com> (cherry picked from commit 1dc89e2)
Add ZRANGESTORE command, and improve ZSTORE command to deprecated Z[REV]RANGE[BYSCORE|BYLEN].
Syntax for the new ZRANGESTORE command:
ZRANGESTORE [BYSCORE | BYLEX] [REV] [LIMIT offset count]
New syntax for ZRANGE:
ZRANGE [BYSCORE | BYLEX] [REV] [WITHSCORES] [LIMIT offset count]
Old syntax for ZRANGE:
ZRANGE [WITHSCORES]
Other ZRANGE commands remain unchanged.
The implementation uses common code for all of these, by utilizing a consumer interface that in one
command response to the client, and in the other command stores a zset key.