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

gavinchou 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 916e3a4ecd4 [improvement](be) Avoid eager formatting in hot paths 
(#66366)
916e3a4ecd4 is described below

commit 916e3a4ecd44ab60015143ceb5cbb10e0ca99258
Author: Mryange <[email protected]>
AuthorDate: Thu Aug 13 18:41:07 2026 +0800

    [improvement](be) Avoid eager formatting in hot paths (#66366)
    
    ### What problem does this PR solve?
    
    Related PR: #66363
    
    Problem Summary: Successful delete bitmap cache checks repeatedly
    traversed both bitmaps to construct an unused error message, and
    nullable LARGEINT Arrow serialization formatted values before checking
    whether rows were null. Reuse the computed bitmap cardinalities,
    construct the mismatch message only on failure, and format LARGEINT
    values only for non-null rows.
---
 be/src/cloud/cloud_tablet.cpp                      | 16 +++++------
 .../data_type_serde/data_type_number_serde.cpp     |  4 +--
 .../data_type_serde/data_type_serde_arrow_test.cpp | 31 +++++++++++++++++-----
 3 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/be/src/cloud/cloud_tablet.cpp b/be/src/cloud/cloud_tablet.cpp
index 940e4633124..3550d0f3db2 100644
--- a/be/src/cloud/cloud_tablet.cpp
+++ b/be/src/cloud/cloud_tablet.cpp
@@ -1586,14 +1586,14 @@ Status CloudTablet::check_delete_bitmap_cache(int64_t 
txn_id,
     Status st = engine.txn_delete_bitmap_cache().get_delete_bitmap(
             txn_id, tablet_id(), &cached_delete_bitmap, nullptr, nullptr);
     if (st.ok()) {
-        bool res = (expected_delete_bitmap->cardinality() == 
cached_delete_bitmap->cardinality());
-        auto msg = fmt::format(
-                "delete bitmap cache check failed, cur_cardinality={}, 
cached_cardinality={}"
-                "txn_id={}, tablet_id={}",
-                expected_delete_bitmap->cardinality(), 
cached_delete_bitmap->cardinality(), txn_id,
-                tablet_id());
-        if (!res) {
-            DCHECK(res) << msg;
+        const auto expected_cardinality = 
expected_delete_bitmap->cardinality();
+        const auto cached_cardinality = cached_delete_bitmap->cardinality();
+        if (expected_cardinality != cached_cardinality) {
+            auto msg = fmt::format(
+                    "delete bitmap cache check failed, cur_cardinality={}, 
cached_cardinality={}"
+                    ", txn_id={}, tablet_id={}",
+                    expected_cardinality, cached_cardinality, txn_id, 
tablet_id());
+            DCHECK_EQ(expected_cardinality, cached_cardinality) << msg;
             return Status::InternalError<false>(msg);
         }
     }
diff --git a/be/src/core/data_type_serde/data_type_number_serde.cpp 
b/be/src/core/data_type_serde/data_type_number_serde.cpp
index bde0575383e..857d8eacc91 100644
--- a/be/src/core/data_type_serde/data_type_number_serde.cpp
+++ b/be/src/core/data_type_serde/data_type_number_serde.cpp
@@ -696,12 +696,12 @@ Status 
DataTypeNumberSerDe<T>::write_column_to_arrow(const IColumn& column, cons
     } else if constexpr (T == TYPE_LARGEINT) {
         auto& string_builder = 
assert_cast<arrow::StringBuilder&>(*array_builder);
         for (size_t i = start; i < end; ++i) {
-            auto& data_value = col_data[i];
-            std::string value_str = fmt::format("{}", data_value);
             if (null_map && (*null_map)[i]) {
                 RETURN_IF_ERROR(
                         checkArrowStatus(string_builder.AppendNull(), column, 
*array_builder));
             } else {
+                const auto& data_value = col_data[i];
+                std::string value_str = fmt::format("{}", data_value);
                 RETURN_IF_ERROR(checkArrowStatus(
                         string_builder.Append(value_str.data(),
                                               cast_set<int, size_t, 
false>(value_str.length())),
diff --git a/be/test/core/data_type_serde/data_type_serde_arrow_test.cpp 
b/be/test/core/data_type_serde/data_type_serde_arrow_test.cpp
index 7b20c2f82d0..a80ab6f885d 100644
--- a/be/test/core/data_type_serde/data_type_serde_arrow_test.cpp
+++ b/be/test/core/data_type_serde/data_type_serde_arrow_test.cpp
@@ -397,14 +397,31 @@ std::shared_ptr<Block> 
create_test_block(std::vector<PrimitiveType> cols, int ro
             block->insert(std::move(type_and_name));
         } break;
         case TYPE_LARGEINT: {
-            auto vec = ColumnInt128::create();
-            auto& data = vec->get_data();
-            for (int i = 0; i < row_num; ++i) {
-                data.push_back(__int128_t(i));
+            if (is_nullable) {
+                auto column_int128 = ColumnInt128::create();
+                auto column_nullable = make_nullable(std::move(column_int128));
+                auto mutable_nullable = std::move(*column_nullable).mutate();
+                for (int i = 0; i < row_num; ++i) {
+                    if (i % 2 == 0) {
+                        mutable_nullable->insert_default();
+                    } else {
+                        
mutable_nullable->insert(Field::create_field<TYPE_LARGEINT>(__int128_t(i)));
+                    }
+                }
+                auto data_type = 
make_nullable(std::make_shared<DataTypeInt128>());
+                ColumnWithTypeAndName 
type_and_name(mutable_nullable->get_ptr(), data_type,
+                                                    col_name);
+                block->insert(std::move(type_and_name));
+            } else {
+                auto vec = ColumnInt128::create();
+                auto& data = vec->get_data();
+                for (int i = 0; i < row_num; ++i) {
+                    data.push_back(__int128_t(i));
+                }
+                DataTypePtr data_type(std::make_shared<DataTypeInt128>());
+                ColumnWithTypeAndName type_and_name(vec->get_ptr(), data_type, 
col_name);
+                block->insert(std::move(type_and_name));
             }
-            DataTypePtr data_type(std::make_shared<DataTypeInt128>());
-            ColumnWithTypeAndName type_and_name(vec->get_ptr(), data_type, 
col_name);
-            block->insert(std::move(type_and_name));
         } break;
         default:
             LOG(FATAL) << "error column type";


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

Reply via email to