| 521 | } |
| 522 | |
| 523 | bool RedisClusterChannel::ExecuteIntegerAggregate(const ParsedCommand& cmd, |
| 524 | butil::IOBuf* encoded_reply, |
| 525 | Controller* cntl) { |
| 526 | if (cmd.args.size() < 2) { |
| 527 | AppendErrorReply(encoded_reply, |
| 528 | "ERR wrong number of arguments"); |
| 529 | return true; |
| 530 | } |
| 531 | |
| 532 | int64_t total = 0; |
| 533 | for (size_t i = 1; i < cmd.args.size(); ++i) { |
| 534 | std::vector<std::string> sub_args; |
| 535 | sub_args.push_back(cmd.args[0]); |
| 536 | sub_args.push_back(cmd.args[i]); |
| 537 | |
| 538 | SingleCommandResult sub_result; |
| 539 | if (!ExecuteSingleCommand(sub_args, NULL, &sub_result, cntl)) { |
| 540 | return false; |
| 541 | } |
| 542 | if (sub_result.is_error) { |
| 543 | encoded_reply->swap(sub_result.encoded_reply); |
| 544 | return true; |
| 545 | } |
| 546 | total += sub_result.integer_value; |
| 547 | } |
| 548 | |
| 549 | AppendIntegerReply(encoded_reply, total); |
| 550 | return true; |
| 551 | } |
| 552 | |
| 553 | bool RedisClusterChannel::ExecuteEvalLike(const ParsedCommand& cmd, |
| 554 | butil::IOBuf* encoded_reply, |