jackyyyyyssss commented on code in PR #2236:
URL: https://github.com/apache/kvrocks/pull/2236#discussion_r1563670085
##########
src/commands/scan_base.h:
##########
@@ -31,28 +32,33 @@ inline constexpr const char *kCursorPrefix = "_";
class CommandScanBase : public Commander {
public:
- Status ParseMatchAndCountParam(const std::string &type, std::string value) {
- if (type == "match") {
- prefix_ = std::move(value);
- if (!prefix_.empty() && prefix_[prefix_.size() - 1] == '*') {
- prefix_ = prefix_.substr(0, prefix_.size() - 1);
- return Status::OK();
- }
-
- return {Status::RedisParseErr, "only keys prefix match was supported"};
- } else if (type == "count") {
- auto parse_result = ParseInt<int>(value, 10);
- if (!parse_result) {
- return {Status::RedisParseErr, "count param should be type int"};
- }
-
- limit_ = *parse_result;
- if (limit_ <= 0) {
- return {Status::RedisParseErr, errInvalidSyntax};
+ Status Parse(const std::vector<std::string> &args) override {
+ CommandParser parser(args, 1);
+ if (util::ToLower(args[0]) != "scan") {
+ key_ = GET_OR_RET(parser.TakeStr());
+ }
+ ParseCursor(GET_OR_RET(parser.TakeStr()));
+ while (parser.Good()) {
+ if (parser.EatEqICase("match")) {
+ prefix_ = GET_OR_RET(parser.TakeStr());
+ if (!prefix_.empty() && prefix_.back() == '*') {
+ prefix_ = prefix_.substr(0, prefix_.size() - 1);
+ } else {
+ return {Status::RedisParseErr, "currently only key prefix matching
is supported"};
+ }
+ } else if (parser.EatEqICase("count")) {
+ limit_ = GET_OR_RET(parser.TakeInt());
+ if (limit_ <= 0) {
+ return {Status::RedisParseErr, errInvalidSyntax};
+ }
+ } else if (parser.EatEqICase("type")) {
+ // HSCAN SSCAN ZSCAN Will not enter
Review Comment:
Maybe my description is a bit inaccurate. After other commands are added,
error prompts will be return
--
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]