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

lijibing 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 f92fc911cd2 [Bug](function) fix wrong output_char_size on 
hll_to_base64 (#36529)
f92fc911cd2 is described below

commit f92fc911cd23dfb4f211dcf6a30732a50709da57
Author: Pxl <pxl...@qq.com>
AuthorDate: Wed Jun 19 22:54:41 2024 +0800

    [Bug](function) fix wrong output_char_size on hll_to_base64 (#36529)
    
    ## Proposed changes
    1. fix wrong output_char_size on hll_to_base64
    2. fix some wrong usage of internal error
---
 be/src/io/fs/s3_file_system.cpp       | 12 ++++++------
 be/src/io/fs/stream_load_pipe.cpp     |  6 +++---
 be/src/runtime/message_body_sink.h    |  9 +++++----
 be/src/vec/functions/function_hll.cpp |  4 ++--
 4 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/be/src/io/fs/s3_file_system.cpp b/be/src/io/fs/s3_file_system.cpp
index 648a80cda8c..ffc656bfc0f 100644
--- a/be/src/io/fs/s3_file_system.cpp
+++ b/be/src/io/fs/s3_file_system.cpp
@@ -52,9 +52,9 @@
 namespace doris::io {
 namespace {
 #ifndef CHECK_S3_CLIENT
-#define CHECK_S3_CLIENT(client)                               \
-    if (!client) {                                            \
-        return Status::InternalError("init s3 client error"); \
+#define CHECK_S3_CLIENT(client)                                 \
+    if (!client) {                                              \
+        return Status::InvalidArgument("init s3 client error"); \
     }
 #endif
 
@@ -81,7 +81,7 @@ ObjClientHolder::~ObjClientHolder() = default;
 Status ObjClientHolder::init() {
     _client = S3ClientFactory::instance().create(_conf);
     if (!_client) {
-        return Status::InternalError("failed to init s3 client with conf {}", 
_conf.to_string());
+        return Status::InvalidArgument("failed to init s3 client with conf 
{}", _conf.to_string());
     }
 
     return Status::OK();
@@ -105,7 +105,7 @@ Status ObjClientHolder::reset(const S3ClientConf& conf) {
 
     auto client = S3ClientFactory::instance().create(reset_conf);
     if (!client) {
-        return Status::InternalError("failed to init s3 client with conf {}", 
conf.to_string());
+        return Status::InvalidArgument("failed to init s3 client with conf 
{}", conf.to_string());
     }
 
     LOG(INFO) << "reset s3 client with new conf: " << conf.to_string();
@@ -123,7 +123,7 @@ Result<int64_t> ObjClientHolder::object_file_size(const 
std::string& bucket,
                                                   const std::string& key) 
const {
     auto client = get();
     if (!client) {
-        return ResultError(Status::InternalError("init s3 client error"));
+        return ResultError(Status::InvalidArgument("init s3 client error"));
     }
 
     auto resp = client->head_object({
diff --git a/be/src/io/fs/stream_load_pipe.cpp 
b/be/src/io/fs/stream_load_pipe.cpp
index ecce306bdf1..21c3856a815 100644
--- a/be/src/io/fs/stream_load_pipe.cpp
+++ b/be/src/io/fs/stream_load_pipe.cpp
@@ -63,7 +63,7 @@ Status StreamLoadPipe::read_at_impl(size_t /*offset*/, Slice 
result, size_t* byt
         }
         // cancelled
         if (_cancelled) {
-            return Status::InternalError<false>("cancelled: {}", 
_cancelled_reason);
+            return Status::Cancelled("cancelled: {}", _cancelled_reason);
         }
         // finished
         if (_buf_queue.empty()) {
@@ -167,7 +167,7 @@ Status 
StreamLoadPipe::_read_next_buffer(std::unique_ptr<uint8_t[]>* data, size_
     }
     // cancelled
     if (_cancelled) {
-        return Status::InternalError<false>("cancelled: {}", 
_cancelled_reason);
+        return Status::Cancelled("cancelled: {}", _cancelled_reason);
     }
     // finished
     if (_buf_queue.empty()) {
@@ -209,7 +209,7 @@ Status StreamLoadPipe::_append(const ByteBufferPtr& buf, 
size_t proto_byte_size)
             }
         }
         if (_cancelled) {
-            return Status::InternalError<false>("cancelled: {}", 
_cancelled_reason);
+            return Status::Cancelled("cancelled: {}", _cancelled_reason);
         }
         _buf_queue.push_back(buf);
         if (_use_proto) {
diff --git a/be/src/runtime/message_body_sink.h 
b/be/src/runtime/message_body_sink.h
index a396cc36485..7f31856e6b4 100644
--- a/be/src/runtime/message_body_sink.h
+++ b/be/src/runtime/message_body_sink.h
@@ -21,6 +21,7 @@
 
 #include <memory>
 #include <string>
+#include <utility>
 
 #include "common/status.h"
 #include "util/byte_buffer.h"
@@ -29,7 +30,7 @@ namespace doris {
 
 class MessageBodySink {
 public:
-    virtual ~MessageBodySink() {}
+    virtual ~MessageBodySink() = default;
     virtual Status append(const char* data, size_t size) = 0;
     virtual Status append(const ByteBufferPtr& buf) { return append(buf->ptr, 
buf->remaining()); }
     // called when all data has been append
@@ -43,14 +44,14 @@ public:
 protected:
     bool _finished = false;
     bool _cancelled = false;
-    std::string _cancelled_reason = "";
+    std::string _cancelled_reason;
 };
 
 // write message to a local file
 class MessageBodyFileSink : public MessageBodySink {
 public:
-    MessageBodyFileSink(const std::string& path) : _path(path) {}
-    virtual ~MessageBodyFileSink();
+    MessageBodyFileSink(std::string path) : _path(std::move(path)) {}
+    ~MessageBodyFileSink() override;
 
     Status open();
 
diff --git a/be/src/vec/functions/function_hll.cpp 
b/be/src/vec/functions/function_hll.cpp
index ddf0468360c..a6b91e27c2d 100644
--- a/be/src/vec/functions/function_hll.cpp
+++ b/be/src/vec/functions/function_hll.cpp
@@ -278,11 +278,11 @@ struct HllToBase64 {
         for (size_t i = 0; i < size; ++i) {
             auto& hll_val = const_cast<HyperLogLog&>(data[i]);
             auto ser_size = hll_val.max_serialized_size();
-            output_char_size += ser_size * (int)(4.0 * ceil((double)ser_size / 
3.0));
+            output_char_size += (int)(4.0 * ceil((double)ser_size / 3.0));
         }
         ColumnString::check_chars_length(output_char_size, size);
         chars.resize(output_char_size);
-        auto chars_data = chars.data();
+        auto* chars_data = chars.data();
 
         size_t cur_ser_size = 0;
         size_t last_ser_size = 0;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to