diff --git a/be/src/agent/cgroup_cpu_ctl.cpp b/be/src/agent/cgroup_cpu_ctl.cpp index 7e1b6b8149..d8a18c8c13 100644 --- a/be/src/agent/cgroup_cpu_ctl.cpp +++ b/be/src/agent/cgroup_cpu_ctl.cpp @@ -17,6 +17,8 @@ #include "agent/cgroup_cpu_ctl.h" +#include + 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 w_lock(_lock_mutex); return CgroupCpuCtl::write_cg_sys_file(_cgroup_v1_cpu_query_task_path, tid, msg, true); } -} // namespace doris \ No newline at end of file +} // namespace doris diff --git a/be/src/agent/utils.cpp b/be/src/agent/utils.cpp index 2c98a6906b..0c6f977783 100644 --- a/be/src/agent/utils.cpp +++ b/be/src/agent/utils.cpp @@ -19,6 +19,7 @@ // IWYU pragma: no_include #include // IWYU pragma: keep +#include #include #include #include @@ -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; } diff --git a/be/src/vec/exec/scan/vfile_scanner.cpp b/be/src/vec/exec/scan/vfile_scanner.cpp index ddb8df3ce0..44fa7dc240 100644 --- a/be/src/vec/exec/scan/vfile_scanner.cpp +++ b/be/src/vec/exec/scan/vfile_scanner.cpp @@ -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);