This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new f75ee49cb46 [chore](fmt) Remove stringstream by fmt (#25474)
f75ee49cb46 is described below

commit f75ee49cb462a7adc52f7defabedcc71f3f12f6e
Author: Jack Drogon <[email protected]>
AuthorDate: Mon Oct 16 08:31:54 2023 -0500

    [chore](fmt) Remove stringstream by fmt (#25474)
    
    Signed-off-by: Jack Drogon <[email protected]>
---
 be/src/agent/cgroup_cpu_ctl.cpp        |  8 ++++----
 be/src/agent/utils.cpp                 | 12 ++++--------
 be/src/vec/exec/scan/vfile_scanner.cpp |  5 ++---
 3 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/be/src/agent/cgroup_cpu_ctl.cpp b/be/src/agent/cgroup_cpu_ctl.cpp
index 7e1b6b81492..d8a18c8c130 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 <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
\ No newline at end of file
+} // namespace doris
diff --git a/be/src/agent/utils.cpp b/be/src/agent/utils.cpp
index 2c98a6906b8..0c6f977783f 100644
--- a/be/src/agent/utils.cpp
+++ b/be/src/agent/utils.cpp
@@ -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;
     }
diff --git a/be/src/vec/exec/scan/vfile_scanner.cpp 
b/be/src/vec/exec/scan/vfile_scanner.cpp
index ddb8df3ce08..44fa7dc240b 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);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to