@@ -308,7 +308,7 @@ class CommandTSCreateBase : public KeywordCommandBase {
308308
309309class CommandTSCreate : public CommandTSCreateBase {
310310 public:
311- CommandTSCreate () { registerDefaultHandlers (); }
311+ CommandTSCreate () { CommandTSCreateBase:: registerDefaultHandlers (); }
312312 Status Parse (const std::vector<std::string> &args) override {
313313 if (args.size () < 2 ) {
314314 return {Status::RedisParseErr, errWrongNumOfArguments};
@@ -379,7 +379,7 @@ class CommandTSInfo : public Commander {
379379
380380class CommandTSAdd : public CommandTSCreateBase {
381381 public:
382- CommandTSAdd () { registerDefaultHandlers (); }
382+ CommandTSAdd () { CommandTSAdd:: registerDefaultHandlers (); }
383383 Status Parse (const std::vector<std::string> &args) override {
384384 if (args.size () < 4 ) {
385385 return {Status::RedisParseErr, errWrongNumOfArguments};
@@ -577,30 +577,24 @@ class CommandTSRangeBase : virtual public CommandTSAggregatorBase {
577577 Status Parse (const std::vector<std::string> &args) override {
578578 TSOptionsParser parser (std::next (args.begin (), static_cast <std::ptrdiff_t >(skip_num_)), args.end ());
579579 // Parse start timestamp
580- auto start_ts = parser.TakeInt <uint64_t >();
581- if (!start_ts.IsOK ()) {
582- auto start_ts_str = parser.TakeStr ();
583- if (!start_ts_str.IsOK () || start_ts_str.GetValue () != " -" ) {
584- return {Status::RedisParseErr, " wrong fromTimestamp" };
585- }
586- // "-" means use default start timestamp: 0
587- } else {
588- is_start_explicit_set_ = true ;
589- option_.start_ts = start_ts.GetValue ();
590- }
591580
592- // Parse end timestamp
593- auto end_ts = parser.TakeInt <uint64_t >();
594- if (!end_ts.IsOK ()) {
595- auto end_ts_str = parser.TakeStr ();
596- if (!end_ts_str.IsOK () || end_ts_str.GetValue () != " +" ) {
597- return {Status::RedisParseErr, " wrong toTimestamp" };
581+ auto parse_ts = [](TSOptionsParser &parser, bool *is_set_flag, uint64_t *start_ts,
582+ std::string_view error_msg) -> Status {
583+ auto ts = parser.TakeInt <uint64_t >();
584+ if (!ts.IsOK ()) {
585+ auto ts_str = parser.TakeStr ();
586+ if (!ts_str.IsOK () || ts_str.GetValue () != " -" ) {
587+ return {Status::RedisParseErr, std::string (error_msg)};
588+ }
589+ // "-" means use default start timestamp: 0
590+ } else {
591+ *is_set_flag = true ;
592+ *start_ts = ts.GetValue ();
598593 }
599- // "+" means use default end timestamp: MAX_TIMESTAMP
600- } else {
601- is_end_explicit_set_ = true ;
602- option_.end_ts = end_ts.GetValue ();
603- }
594+ return Status::OK ();
595+ };
596+ GET_OR_RET (parse_ts (parser, &is_start_explicit_set_, &option_.start_ts , " wrong fromTimestamp" ));
597+ GET_OR_RET (parse_ts (parser, &is_end_explicit_set_, &option_.end_ts , " wrong toTimestamp" ));
604598 KeywordCommandBase::setSkipNum (skip_num_ + 2 );
605599 auto s = KeywordCommandBase::Parse (args);
606600 if (!s.IsOK ()) return s;
@@ -727,7 +721,7 @@ class CommandTSRangeBase : virtual public CommandTSAggregatorBase {
727721
728722class CommandTSRange : public CommandTSRangeBase {
729723 public:
730- CommandTSRange () : CommandTSRangeBase(2 ) { registerDefaultHandlers (); }
724+ CommandTSRange () : CommandTSRangeBase(2 ) { CommandTSRangeBase:: registerDefaultHandlers (); }
731725 Status Parse (const std::vector<std::string> &args) override {
732726 if (args.size () < 4 ) {
733727 return {Status::RedisParseErr, " wrong number of arguments for 'ts.range' command" };
@@ -753,7 +747,7 @@ class CommandTSRange : public CommandTSRangeBase {
753747
754748class CommandTSCreateRule : public CommandTSAggregatorBase {
755749 public:
756- explicit CommandTSCreateRule () { registerDefaultHandlers (); }
750+ explicit CommandTSCreateRule () { CommandTSAggregatorBase:: registerDefaultHandlers (); }
757751 Status Parse (const std::vector<std::string> &args) override {
758752 if (args.size () < 6 ) {
759753 return {Status::NotOK, " wrong number of arguments for 'TS.CREATERULE' command" };
@@ -780,7 +774,7 @@ class CommandTSCreateRule : public CommandTSAggregatorBase {
780774
781775class CommandTSGet : public CommandTSAggregatorBase {
782776 public:
783- CommandTSGet () { registerDefaultHandlers (); }
777+ CommandTSGet () { CommandTSGet:: registerDefaultHandlers (); }
784778 Status Parse (const std::vector<std::string> &args) override {
785779 if (args.size () < 2 ) {
786780 return {Status::RedisParseErr, " wrong number of arguments for 'ts.get' command" };
@@ -838,6 +832,7 @@ class CommandTSMGetBase : virtual public CommandTSAggregatorBase {
838832 }
839833 return Status::OK ();
840834 }
835+
841836 Status handleFilterExpr (TSOptionsParser &parser, TSMGetOption::FilterOption &filter_option) {
842837 auto filter_parser = TSMQueryFilterParser (filter_option);
843838 while (parser.Good ()) {
@@ -857,7 +852,7 @@ class CommandTSMGetBase : virtual public CommandTSAggregatorBase {
857852
858853class CommandTSMGet : public CommandTSMGetBase {
859854 public:
860- CommandTSMGet () { registerDefaultHandlers (); }
855+ CommandTSMGet () { CommandTSMGet:: registerDefaultHandlers (); }
861856 Status Parse (const std::vector<std::string> &args) override {
862857 if (args.size () < 3 ) {
863858 return {Status::RedisParseErr, " wrong number of arguments for 'ts.mget' command" };
@@ -902,7 +897,7 @@ class CommandTSMGet : public CommandTSMGetBase {
902897
903898class CommandTSMRange : public CommandTSRangeBase , public CommandTSMGetBase {
904899 public:
905- CommandTSMRange () : CommandTSRangeBase(1 ) { registerDefaultHandlers (); }
900+ CommandTSMRange () : CommandTSRangeBase(1 ) { CommandTSMRange:: registerDefaultHandlers (); }
906901 Status Parse (const std::vector<std::string> &args) override {
907902 if (args.size () < 5 ) {
908903 return {Status::RedisParseErr, errTSMRangeArgsNum};
@@ -1001,7 +996,7 @@ class CommandTSMRange : public CommandTSRangeBase, public CommandTSMGetBase {
1001996
1002997class CommandTSIncrByDecrBy : public CommandTSCreateBase {
1003998 public:
1004- CommandTSIncrByDecrBy () { registerDefaultHandlers (); }
999+ CommandTSIncrByDecrBy () { CommandTSIncrByDecrBy:: registerDefaultHandlers (); }
10051000 Status Parse (const std::vector<std::string> &args) override {
10061001 CommandParser parser (args, 2 );
10071002 auto value_parse = parser.TakeFloat <double >();
0 commit comments