PragmaTwice commented on code in PR #3164:
URL: https://github.com/apache/kvrocks/pull/3164#discussion_r2354171469
##########
src/commands/cmd_timeseries.cc:
##########
@@ -784,12 +784,93 @@ class CommandTSGet : public CommandTSAggregatorBase {
std::string user_key_;
};
+class CommandTSMGetBase : public CommandTSAggregatorBase {
+ public:
+ CommandTSMGetBase(size_t skip_num, size_t tail_skip_num) :
CommandTSAggregatorBase(skip_num, tail_skip_num) {}
+
+ protected:
+ static Status handleWithLabels([[maybe_unused]] TSOptionsParser &parser,
bool &with_labels) {
+ with_labels = true;
+ return Status::OK();
+ }
+ Status handleSelectedLabels(TSOptionsParser &parser, std::set<std::string>
&selected_labels) {
+ while (parser.Good()) {
+ auto &value = parser.RawPeek();
+ if (containsKeyword(value)) {
+ break;
+ }
+ selected_labels.emplace(parser.TakeStr().GetValue());
+ }
+ return Status::OK();
+ }
+ Status handleFilterExpr(TSOptionsParser &parser, TSMGetOption::FilterOption
&filter_option) {
+ auto filter_parser = TSMQueryFilterParser(filter_option);
+ while (parser.Good()) {
+ auto &value = parser.RawPeek();
+ if (containsKeyword(value)) {
+ break;
+ }
+ auto s = filter_parser.Parse(parser.TakeStr().GetValue());
+ if (!s.IsOK()) return s;
+ }
+ return filter_parser.Check();
+ }
+};
+
+class CommandTSMGet : public CommandTSMGetBase {
+ public:
+ CommandTSMGet() : CommandTSMGetBase(0, 0) { registerDefaultHandlers(); }
+ Status Parse(const std::vector<std::string> &args) override {
+ if (args.size() < 3) {
+ return {Status::RedisParseErr, "wrong number of arguments for 'ts.mget'
command"};
+ }
+ return CommandTSMGetBase::Parse(args);
+ }
+ Status Execute(engine::Context &ctx, Server *srv, Connection *conn,
std::string *output) override {
Review Comment:
I think we should exclude the cluster mode here? Maybe just return an error
to indicate that it is not supported.
##########
src/commands/cmd_timeseries.cc:
##########
@@ -784,12 +784,93 @@ class CommandTSGet : public CommandTSAggregatorBase {
std::string user_key_;
};
+class CommandTSMGetBase : public CommandTSAggregatorBase {
+ public:
+ CommandTSMGetBase(size_t skip_num, size_t tail_skip_num) :
CommandTSAggregatorBase(skip_num, tail_skip_num) {}
+
+ protected:
+ static Status handleWithLabels([[maybe_unused]] TSOptionsParser &parser,
bool &with_labels) {
+ with_labels = true;
+ return Status::OK();
+ }
+ Status handleSelectedLabels(TSOptionsParser &parser, std::set<std::string>
&selected_labels) {
+ while (parser.Good()) {
+ auto &value = parser.RawPeek();
+ if (containsKeyword(value)) {
+ break;
+ }
+ selected_labels.emplace(parser.TakeStr().GetValue());
+ }
+ return Status::OK();
+ }
+ Status handleFilterExpr(TSOptionsParser &parser, TSMGetOption::FilterOption
&filter_option) {
+ auto filter_parser = TSMQueryFilterParser(filter_option);
+ while (parser.Good()) {
+ auto &value = parser.RawPeek();
+ if (containsKeyword(value)) {
+ break;
+ }
+ auto s = filter_parser.Parse(parser.TakeStr().GetValue());
+ if (!s.IsOK()) return s;
+ }
+ return filter_parser.Check();
+ }
+};
+
+class CommandTSMGet : public CommandTSMGetBase {
+ public:
+ CommandTSMGet() : CommandTSMGetBase(0, 0) { registerDefaultHandlers(); }
+ Status Parse(const std::vector<std::string> &args) override {
+ if (args.size() < 3) {
+ return {Status::RedisParseErr, "wrong number of arguments for 'ts.mget'
command"};
+ }
+ return CommandTSMGetBase::Parse(args);
+ }
+ Status Execute(engine::Context &ctx, Server *srv, Connection *conn,
std::string *output) override {
Review Comment:
I think we should exclude the cluster mode here? Maybe just return an error
to indicate that it is not supported. cc @yezhizi
--
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]