[chore](fmt) Remove stringstream by fmt (#25474)
Signed-off-by: Jack Drogon <jack.xsuperman@gmail.com>
This commit is contained in:
@ -17,6 +17,8 @@
|
||||
|
||||
#include "agent/cgroup_cpu_ctl.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace doris {
|
||||
|
||||
Status CgroupCpuCtl::init() {
|
||||
@ -60,9 +62,7 @@ Status CgroupCpuCtl::write_cg_sys_file(std::string file_path, int value, std::st
|
||||
return Status::InternalError("open path failed, path={}", file_path);
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << value << std::endl;
|
||||
const std::string& str = ss.str();
|
||||
auto str = fmt::format("{}\n", value);
|
||||
int ret = write(fd, str.c_str(), str.size());
|
||||
if (ret == -1) {
|
||||
LOG(ERROR) << msg << " write sys file failed";
|
||||
@ -114,4 +114,4 @@ Status CgroupV1CpuCtl::add_thread_to_cgroup() {
|
||||
std::lock_guard<std::shared_mutex> w_lock(_lock_mutex);
|
||||
return CgroupCpuCtl::write_cg_sys_file(_cgroup_v1_cpu_query_task_path, tid, msg, true);
|
||||
}
|
||||
} // namespace doris
|
||||
} // namespace doris
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
// IWYU pragma: no_include <bthread/errno.h>
|
||||
#include <errno.h> // IWYU pragma: keep
|
||||
#include <fmt/format.h>
|
||||
#include <gen_cpp/FrontendService.h>
|
||||
#include <gen_cpp/HeartbeatService_types.h>
|
||||
#include <gen_cpp/Types_types.h>
|
||||
@ -53,7 +54,6 @@ class TReportRequest;
|
||||
|
||||
using std::map;
|
||||
using std::string;
|
||||
using std::stringstream;
|
||||
using apache::thrift::transport::TTransportException;
|
||||
|
||||
namespace doris {
|
||||
@ -226,9 +226,7 @@ bool AgentUtils::exec_cmd(const string& command, string* errmsg, bool redirect_s
|
||||
// Execute command.
|
||||
FILE* fp = popen(cmd.c_str(), "r");
|
||||
if (fp == nullptr) {
|
||||
std::stringstream err_stream;
|
||||
err_stream << "popen failed. " << strerror(errno) << ", with errno: " << errno << ".\n";
|
||||
*errmsg = err_stream.str();
|
||||
*errmsg = fmt::format("popen failed. {}, with errno: {}.\n", strerror(errno), errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -244,10 +242,8 @@ bool AgentUtils::exec_cmd(const string& command, string* errmsg, bool redirect_s
|
||||
if (errno == ECHILD) {
|
||||
*errmsg += "pclose cannot obtain the child status.\n";
|
||||
} else {
|
||||
std::stringstream err_stream;
|
||||
err_stream << "Close popen failed. " << strerror(errno) << ", with errno: " << errno
|
||||
<< "\n";
|
||||
*errmsg += err_stream.str();
|
||||
*errmsg += fmt::format("Close popen failed. {}, with errno: {}.\n", strerror(errno),
|
||||
errno);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -986,9 +986,8 @@ Status VFileScanner::_init_expr_ctxes() {
|
||||
auto slot_id = slot_info.slot_id;
|
||||
auto it = full_src_slot_map.find(slot_id);
|
||||
if (it == std::end(full_src_slot_map)) {
|
||||
std::stringstream ss;
|
||||
ss << "Unknown source slot descriptor, slot_id=" << slot_id;
|
||||
return Status::InternalError(ss.str());
|
||||
return Status::InternalError(
|
||||
fmt::format("Unknown source slot descriptor, slot_id={}", slot_id));
|
||||
}
|
||||
if (slot_info.is_file_slot) {
|
||||
_file_slot_descs.emplace_back(it->second);
|
||||
|
||||
Reference in New Issue
Block a user