Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the second parameter of MultiBulkString #2042

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/commands/cmd_hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class CommandHVals : public Commander {
for (const auto &p : field_values) {
values.emplace_back(p.value);
}
*output = conn->MultiBulkString(values, false);
*output = ArrayOfBulkStrings(values);

return Status::OK();
}
Expand Down Expand Up @@ -350,7 +350,7 @@ class CommandHRangeByLex : public Commander {
kv_pairs.emplace_back(p.field);
kv_pairs.emplace_back(p.value);
}
*output = conn->MultiBulkString(kv_pairs, false);
*output = ArrayOfBulkStrings(kv_pairs);

return Status::OK();
}
Expand Down Expand Up @@ -417,7 +417,7 @@ class CommandHRandField : public Commander {
if (no_parameters_)
*output = s.IsNotFound() ? conn->NilString() : redis::BulkString(result_entries[0]);
else
*output = conn->MultiBulkString(result_entries, false);
*output = ArrayOfBulkStrings(result_entries);
return Status::OK();
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/cmd_json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class CommandJsonObjkeys : public Commander {
*output = redis::MultiLen(results.size());
for (const auto &item : results) {
if (item.has_value()) {
*output += conn->MultiBulkString(item.value(), false);
*output += ArrayOfBulkStrings(item.value());
} else {
*output += conn->NilString();
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/cmd_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ class CommandLRange : public Commander {
return {Status::RedisExecErr, s.ToString()};
}

*output = conn->MultiBulkString(elems, false);
*output = ArrayOfBulkStrings(elems);
return Status::OK();
}

Expand Down Expand Up @@ -839,7 +839,7 @@ class CommandLPos : public Commander {
for (const auto &index : indexes) {
values.emplace_back(std::to_string(index));
}
*output = conn->MultiBulkString(values, false);
*output = ArrayOfBulkStrings(values);
}
return Status::OK();
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/cmd_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class CommandNamespace : public Commander {
}
namespaces.emplace_back(kDefaultNamespace);
namespaces.emplace_back(config->requirepass);
*output = conn->MultiBulkString(namespaces, false);
*output = ArrayOfBulkStrings(namespaces);
} else {
auto token = srv->GetNamespace()->Get(args_[2]);
if (token.Is<Status::NotFound>()) {
Expand Down Expand Up @@ -835,7 +835,7 @@ class CommandScan : public CommandScanBase {
list.emplace_back(redis::BulkString("0"));
}

list.emplace_back(conn->MultiBulkString(keys, false));
list.emplace_back(ArrayOfBulkStrings(keys));

return redis::Array(list);
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/cmd_zset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ class CommandZRandMember : public Commander {
if (no_parameters_)
*output = s.IsNotFound() ? conn->NilString() : redis::BulkString(result_entries[0]);
else
*output = conn->MultiBulkString(result_entries, false);
*output = ArrayOfBulkStrings(result_entries);
return Status::OK();
}

Expand Down
4 changes: 2 additions & 2 deletions src/commands/scan_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class CommandScanBase : public Commander {
list.emplace_back(redis::BulkString("0"));
}

list.emplace_back(conn->MultiBulkString(keys, false));
list.emplace_back(ArrayOfBulkStrings(keys));

return redis::Array(list);
}
Expand Down Expand Up @@ -129,7 +129,7 @@ class CommandSubkeyScanBase : public CommandScanBase {
fvs.emplace_back(values[i]);
}
}
list.emplace_back(conn->MultiBulkString(fvs, false));
list.emplace_back(ArrayOfBulkStrings(fvs));
return redis::Array(list);
}

Expand Down
5 changes: 2 additions & 3 deletions src/server/redis_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,10 @@ std::string Connection::Bool(bool b) const {
return Integer(b ? 1 : 0);
}

std::string Connection::MultiBulkString(const std::vector<std::string> &values,
bool output_nil_for_empty_string) const {
std::string Connection::MultiBulkString(const std::vector<std::string> &values) const {
std::string result = "*" + std::to_string(values.size()) + CRLF;
for (const auto &value : values) {
if (value.empty() && output_nil_for_empty_string) {
if (value.empty()) {
result += NilString();
} else {
result += BulkString(value);
Expand Down
2 changes: 1 addition & 1 deletion src/server/redis_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Connection : public EvbufCallbackBase<Connection> {
}
std::string NilString() const { return redis::NilString(protocol_version_); }
std::string NilArray() const { return protocol_version_ == RESP::v3 ? "_" CRLF : "*-1" CRLF; }
std::string MultiBulkString(const std::vector<std::string> &values, bool output_nil_for_empty_string = true) const;
std::string MultiBulkString(const std::vector<std::string> &values) const;
std::string MultiBulkString(const std::vector<std::string> &values,
const std::vector<rocksdb::Status> &statuses) const;
template <typename T, std::enable_if_t<std::is_integral_v<T>, int> = 0>
Expand Down