PragmaTwice commented on code in PR #2236:
URL: https://github.com/apache/kvrocks/pull/2236#discussion_r1561011262
##########
src/commands/scan_base.h:
##########
@@ -79,6 +85,38 @@ class CommandScanBase : public Commander {
return redis::Array(list);
}
+ static Status ParseScanParameters(const std::vector<std::string> &args,
ScanParameters *params) {
+ for (size_t i = 2; i < args.size(); i = i + 2) {
+ if (util::ToLower(args[i]) == "match") {
+ params->match = args[i + 1];
+ if (!params->match.empty() && params->match[params->match.size() - 1]
== '*') {
+ params->match = params->match.substr(0, params->match.size() - 1);
+ } else {
+ return {Status::RedisParseErr, "only keys prefix match was
supported"};
+ }
+ } else if (util::ToLower(args[i]) == "count") {
+ auto parse_result = ParseInt<int>(args[i + 1], 10);
+ if (!parse_result) {
+ return {Status::RedisParseErr, "count param should be type int"};
+ }
+ params->count = *parse_result;
+ if (params->count <= 0) {
+ return {Status::RedisParseErr, errInvalidSyntax};
+ }
+ } else if (util::ToLower(args[i]) == "type") {
+ // ignoring post implementation
+ } else {
+ return {Status::RedisParseErr, errWrongNumOfArguments};
+ }
+ }
+
+ return Status::OK();
+ }
+ void FillScanAttributes(const ScanParameters *params) {
+ prefix_ = params->match;
+ limit_ = params->count;
+ }
Review Comment:
No need. Please just assign these values in `ParseScanParameters`.
--
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]