Yangsx-1 commented on code in PR #1490:
URL:
https://github.com/apache/incubator-kvrocks/pull/1490#discussion_r1232080274
##########
src/commands/cmd_zset.cc:
##########
@@ -221,64 +223,217 @@ class CommandZLexCount : public Commander {
RangeLexSpec spec_;
};
-class CommandZPop : public Commander {
+class CommandZPop : public Commander,
+ private EvbufCallbackBase<CommandZPop, false>,
+ private EventCallbackBase<CommandZPop> {
public:
- explicit CommandZPop(bool min) : min_(min) {}
+ explicit CommandZPop(bool min, bool block) : min_(min), block_(block) {}
Status Parse(const std::vector<std::string> &args) override {
- if (args.size() > 3) {
- return {Status::RedisParseErr, errWrongNumOfArguments};
- }
+ if (!block_) {
+ if (args.size() > 3) {
+ return {Status::RedisParseErr, errWrongNumOfArguments};
+ }
+
+ if (args.size() == 3) {
+ auto parse_result = ParseInt<int>(args[2], 10);
+ if (!parse_result) {
+ return {Status::RedisParseErr, errValueNotInteger};
+ }
- if (args.size() == 3) {
- auto parse_result = ParseInt<int>(args[2], 10);
- if (!parse_result) {
- return {Status::RedisParseErr, errValueNotInteger};
+ count_ = *parse_result;
}
+ keys_.push_back(args[1]);
+ return Commander::Parse(args);
+ }
+ auto parse_result = ParseInt<int>(args[args.size() - 1], 10);
- count_ = *parse_result;
+ if (!parse_result) {
+ return {Status::RedisParseErr, "timeout is not an integer or out of
range"};
}
+
+ if (*parse_result < 0) {
+ return {Status::RedisParseErr, errTimeoutIsNegative};
+ }
+
+ timeout_ = *parse_result;
+
+ keys_ = std::vector<std::string>(args.begin() + 1, args.end() - 1);
return Commander::Parse(args);
Review Comment:
Ok, i'll split zpopmin/max, do i also need to split zmpop and bzmpop?
I think there are many same codes in zmpop and bzmpop, so the two commands
can merge together.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]