feat: support for the sort command[draft]#2230
feat: support for the sort command[draft]#2230PokIsemaine wants to merge 0 commit intoapache:unstablefrom
Conversation
I think we can leave them unimplemented first
About oom currently it's a bit hard to manage the memory by custom allocator. Maybe we can separate a machine/process level global memory tracking module and check that. This can separate to an other patch or discuss it firstly |
Thanks! |
jihuayu
left a comment
There was a problem hiding this comment.
@PokIsemaine Thanks for your PR. Your code is amazingly clean. The test cases are also very detailed.
For these TODO comments, I think we can keep them.
The logic LGTM.
But according to our conventions, this command should be placed in the cmd_key.cc file, and the core logic of the Execute function should be extracted and placed in the redis::Database class.
Below is a example:
kvrocks/src/commands/cmd_key.cc
Lines 138 to 149 in 26cbdb9
|
src/commands/commander.h
Outdated
| else if (flag == "movable-keys") | ||
| flags |= kCmdMovableKeys; |
There was a problem hiding this comment.
This flag is meaningless in Kvrocks. Please remove it and refer to KeyRangeVecGen.
There was a problem hiding this comment.
Okay, I need to learn about KeyRangeVecGen.
src/commands/commander.h
Outdated
| else if (flag == "deny-oom") | ||
| flags |= kCmdDenyOom; |
There was a problem hiding this comment.
I think we don't plan to implement it in this PR, so please remove it.
There was a problem hiding this comment.
I agree with this, thanks for the heads up, I'll remove the flags later on.
src/commands/commander.h
Outdated
| kCmdDenyOom = 1ULL << 13, // "deny-oom" flag | ||
| kCmdMovableKeys = 1ULL << 14, // "movable-keys" flag |
src/commands/cmd_sort.cc
Outdated
| bool desc_ = false; // ASC/DESC | ||
| bool alpha_ = false; // ALPHA | ||
| std::string storekey_; // STORE | ||
| }; |
There was a problem hiding this comment.
The implementation of SORT should be in redis_db.cc. The parsing part can be in cmd_key.cc.
Thanks for the advice, I'll probably do it this weekend |
6a0f885 to
1e402bc
Compare




I'm trying to support the
sortcommand and later thesort_rocommand for kvrocks, this is my first time submitting a pull request for this project and I need some advice, so I set it to draft temporarily.The help I need is as follows:
There are three TODOs in the code and I don’t know how to deal with them. It seems that they are related to
ACL,Cluster,CLIENT_SCRIPT, but I have not found relevant support for kvrocks at present. What should I do? The following is the relevant code in the redis implementation:How to support
denyoomandmovablekeysflags, or whether kvrocks needs to support it?If you can provide me with any advice I would be very grateful!
The information and code I referenced are as follows:
command docs sortandcommand info sortto obtain the parameters, flags and other information of the sort command