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

yiguolei 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 48fcb2a6d17 [fix] remove useless const_cast and explain const_cast(1) 
(#55943)
48fcb2a6d17 is described below

commit 48fcb2a6d1736f43472ca43c6417358e9e640d5b
Author: admiring_xm <[email protected]>
AuthorDate: Tue Nov 18 16:33:19 2025 +0800

    [fix] remove useless const_cast and explain const_cast(1) (#55943)
    
    ### What problem does this PR solve?
     go through whole be/ and find all const_cast
    
    Issue Number: #55057
    
    Problem Summary:
    1. remove useless const_cast
    2. explain why using const_cast does not result in undefined behavior
    3. don't modify some const_cast
        (1) some code in DBUG_EXECUTE_IF or test file
        (2) underlying data structures, such as cow
        (3) const_cast<const T*>
    
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test <!-- At least one of them must be included. -->
        - [ ] Regression test
        - [ ] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [x] No need to test or manual test. Explain why:
    - [ ] This is a refactor/code format and no logic has been changed.
            - [x] Previous test can cover this change.
            - [ ] No code files have been changed.
            - [ ] Other reason <!-- Add your reason?  -->
    
    - Behavior changed:
        - [x] No.
        - [ ] Yes. <!-- Explain the behavior change -->
    
    - Does this need documentation?
        - [x] No.
    - [ ] Yes. <!-- Add document PR link here. eg:
    https://github.com/apache/doris-website/pull/1214 -->
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label <!-- Add branch pick label that this PR
    should merge into -->
---
 be/src/agent/task_worker_pool.cpp                     |  9 +++++++--
 be/src/agent/task_worker_pool.h                       |  2 +-
 be/src/cloud/cloud_meta_mgr.cpp                       | 13 +++++++------
 be/src/cloud/cloud_meta_mgr.h                         |  6 +++---
 be/src/exec/decompressor.cpp                          |  2 +-
 be/src/exec/table_connector.cpp                       |  2 +-
 be/src/exprs/hybrid_set.h                             | 17 ++++++++---------
 be/src/geo/geo_types.cpp                              |  6 +++---
 be/src/geo/geo_types.h                                |  2 +-
 be/src/olap/comparison_predicate.h                    | 18 +++++++-----------
 be/src/olap/in_list_predicate.h                       | 15 ++++++---------
 be/src/runtime/memory/memory_profile.cpp              | 13 ++++++-------
 be/src/runtime/process_profile.h                      |  2 +-
 be/src/runtime/workload_management/resource_context.h |  2 --
 be/src/util/runtime_profile.cpp                       |  6 +++---
 be/src/util/runtime_profile.h                         |  4 ++--
 16 files changed, 57 insertions(+), 62 deletions(-)

diff --git a/be/src/agent/task_worker_pool.cpp 
b/be/src/agent/task_worker_pool.cpp
index 9cf3415f93a..2ee7a21fb27 100644
--- a/be/src/agent/task_worker_pool.cpp
+++ b/be/src/agent/task_worker_pool.cpp
@@ -419,6 +419,8 @@ Status _submit_task(const TAgentTaskRequest& task,
     // TODO(plat1ko): check task request member
 
     // Set the receiving time of task so that we can determine whether it is 
timed out later
+    // exist a path task_worker_pool <- agent_server <- backend_service <- 
BackendService
+    // use the arg BackendService_submit_tasks_args.tasks is not const, so 
modify is ok
     (const_cast<TAgentTaskRequest&>(task)).__set_recv_time(time(nullptr));
     auto st = submit_op(task);
     if (!st.ok()) [[unlikely]] {
@@ -617,7 +619,7 @@ Status PriorTaskWorkerPool::submit_task(const 
TAgentTaskRequest& task) {
     });
 }
 
-Status PriorTaskWorkerPool::submit_high_prior_and_cancel_low(const 
TAgentTaskRequest& task) {
+Status 
PriorTaskWorkerPool::submit_high_prior_and_cancel_low(TAgentTaskRequest& task) {
     const TTaskType::type task_type = task.task_type;
     int64_t signature = task.signature;
     std::string type_str;
@@ -657,7 +659,7 @@ Status 
PriorTaskWorkerPool::submit_high_prior_and_cancel_low(const TAgentTaskReq
     } while (false);
 
     // Set the receiving time of task so that we can determine whether it is 
timed out later
-    (const_cast<TAgentTaskRequest&>(task)).__set_recv_time(time(nullptr));
+    task.__set_recv_time(time(nullptr));
 
     LOG_INFO("successfully submit task").tag("type", 
type_str).tag("signature", signature);
     return Status::OK();
@@ -1926,6 +1928,9 @@ void push_callback(StorageEngine& engine, const 
TAgentTaskRequest& req) {
               << " push_type=" << push_req.push_type;
     std::vector<TTabletInfo> tablet_infos;
 
+    // exist a path task_worker_pool <- agent_server <- backend_service <- 
BackendService
+    // use the arg BackendService_submit_tasks_args.tasks is not const
+    // and push_req will be modify, so modify is ok
     EngineBatchLoadTask engine_task(engine, const_cast<TPushReq&>(push_req), 
&tablet_infos);
     SCOPED_ATTACH_TASK(engine_task.mem_tracker());
     auto status = engine_task.execute();
diff --git a/be/src/agent/task_worker_pool.h b/be/src/agent/task_worker_pool.h
index 98dd0f899ed..300e1daa606 100644
--- a/be/src/agent/task_worker_pool.h
+++ b/be/src/agent/task_worker_pool.h
@@ -88,7 +88,7 @@ public:
 
     Status submit_task(const TAgentTaskRequest& task) override;
 
-    Status submit_high_prior_and_cancel_low(const TAgentTaskRequest& task);
+    Status submit_high_prior_and_cancel_low(TAgentTaskRequest& task);
 
 private:
     void normal_loop();
diff --git a/be/src/cloud/cloud_meta_mgr.cpp b/be/src/cloud/cloud_meta_mgr.cpp
index efa73b0bd81..399d26950c0 100644
--- a/be/src/cloud/cloud_meta_mgr.cpp
+++ b/be/src/cloud/cloud_meta_mgr.cpp
@@ -388,6 +388,7 @@ Status retry_rpc(std::string_view op_name, const Request& 
req, Response* res,
     static_assert(std::is_base_of_v<::google::protobuf::Message, Request>);
     static_assert(std::is_base_of_v<::google::protobuf::Message, Response>);
 
+    // Applies only to the current file, and all req are non-const, but passed 
as const types.
     
const_cast<Request&>(req).set_request_ip(BackendOptions::get_be_endpoint());
 
     int retry_times = 0;
@@ -1931,12 +1932,12 @@ void 
CloudMetaMgr::remove_delete_bitmap_update_lock(int64_t table_id, int64_t lo
     }
 }
 
-void CloudMetaMgr::check_table_size_correctness(const RowsetMeta& rs_meta) {
+void CloudMetaMgr::check_table_size_correctness(RowsetMeta& rs_meta) {
     if (!config::enable_table_size_correctness_check) {
         return;
     }
     int64_t total_segment_size = get_segment_file_size(rs_meta);
-    int64_t total_inverted_index_size = get_inverted_index_file_szie(rs_meta);
+    int64_t total_inverted_index_size = get_inverted_index_file_size(rs_meta);
     if (rs_meta.data_disk_size() != total_segment_size ||
         rs_meta.index_disk_size() != total_inverted_index_size ||
         rs_meta.data_disk_size() + rs_meta.index_disk_size() != 
rs_meta.total_disk_size()) {
@@ -1955,9 +1956,9 @@ void CloudMetaMgr::check_table_size_correctness(const 
RowsetMeta& rs_meta) {
     }
 }
 
-int64_t CloudMetaMgr::get_segment_file_size(const RowsetMeta& rs_meta) {
+int64_t CloudMetaMgr::get_segment_file_size(RowsetMeta& rs_meta) {
     int64_t total_segment_size = 0;
-    const auto fs = const_cast<RowsetMeta&>(rs_meta).fs();
+    const auto fs = rs_meta.fs();
     if (!fs) {
         LOG(WARNING) << "get fs failed, resource_id={}" << 
rs_meta.resource_id();
     }
@@ -1982,9 +1983,9 @@ int64_t CloudMetaMgr::get_segment_file_size(const 
RowsetMeta& rs_meta) {
     return total_segment_size;
 }
 
-int64_t CloudMetaMgr::get_inverted_index_file_szie(const RowsetMeta& rs_meta) {
+int64_t CloudMetaMgr::get_inverted_index_file_size(RowsetMeta& rs_meta) {
     int64_t total_inverted_index_size = 0;
-    const auto fs = const_cast<RowsetMeta&>(rs_meta).fs();
+    const auto fs = rs_meta.fs();
     if (!fs) {
         LOG(WARNING) << "get fs failed, resource_id={}" << 
rs_meta.resource_id();
     }
diff --git a/be/src/cloud/cloud_meta_mgr.h b/be/src/cloud/cloud_meta_mgr.h
index 0fd666d500f..a815c4dc5e5 100644
--- a/be/src/cloud/cloud_meta_mgr.h
+++ b/be/src/cloud/cloud_meta_mgr.h
@@ -191,9 +191,9 @@ private:
                                                GetDeleteBitmapResponse& res,
                                                int64_t bytes_threadhold);
 
-    void check_table_size_correctness(const RowsetMeta& rs_meta);
-    int64_t get_segment_file_size(const RowsetMeta& rs_meta);
-    int64_t get_inverted_index_file_szie(const RowsetMeta& rs_meta);
+    void check_table_size_correctness(RowsetMeta& rs_meta);
+    int64_t get_segment_file_size(RowsetMeta& rs_meta);
+    int64_t get_inverted_index_file_size(RowsetMeta& rs_meta);
 };
 
 } // namespace cloud
diff --git a/be/src/exec/decompressor.cpp b/be/src/exec/decompressor.cpp
index 44893af849c..45270c86792 100644
--- a/be/src/exec/decompressor.cpp
+++ b/be/src/exec/decompressor.cpp
@@ -273,7 +273,7 @@ Status Bzip2Decompressor::decompress(uint8_t* input, 
uint32_t input_len, size_t*
                                      size_t* decompressed_len, bool* 
stream_end,
                                      size_t* more_input_bytes, size_t* 
more_output_bytes) {
     // 1. set input and output
-    _bz_strm.next_in = const_cast<char*>(reinterpret_cast<const char*>(input));
+    _bz_strm.next_in = reinterpret_cast<char*>(input);
     _bz_strm.avail_in = input_len;
     _bz_strm.next_out = reinterpret_cast<char*>(output);
     _bz_strm.avail_out = output_max_len;
diff --git a/be/src/exec/table_connector.cpp b/be/src/exec/table_connector.cpp
index d8c12096da5..3e26429933a 100644
--- a/be/src/exec/table_connector.cpp
+++ b/be/src/exec/table_connector.cpp
@@ -72,7 +72,7 @@ std::u16string TableConnector::utf8_to_u16string(const char* 
first, const char*
     };
     std::unique_ptr<std::remove_pointer_t<iconv_t>, decltype(deleter)> 
convertor(
             iconv_open("UTF-16LE", "UTF-8"), deleter);
-
+    // The `first` variable remains unmodified; `const_cast` is used to adapt 
to third-party functions.
     char* in = const_cast<char*>(first);
     size_t inbytesleft = last - first;
 
diff --git a/be/src/exprs/hybrid_set.h b/be/src/exprs/hybrid_set.h
index f4445276937..e2c29eed82b 100644
--- a/be/src/exprs/hybrid_set.h
+++ b/be/src/exprs/hybrid_set.h
@@ -498,7 +498,7 @@ public:
 
     bool find(const void* data) const override {
         const auto* value = reinterpret_cast<const StringRef*>(data);
-        std::string str_value(const_cast<const char*>(value->data), 
value->size);
+        std::string str_value(value->data, value->size);
         return _set.find(str_value);
     }
 
@@ -565,7 +565,7 @@ public:
         ~Iterator() override = default;
         bool has_next() const override { return !(_begin == _end); }
         const void* get_value() override {
-            _value.data = const_cast<char*>(_begin->data());
+            _value.data = _begin->data();
             _value.size = _begin->length();
             return &_value;
         }
@@ -715,7 +715,6 @@ public:
         const auto& col = assert_cast<const 
doris::vectorized::ColumnString&>(column);
         const auto& offset = col.get_offsets();
         const uint8_t* __restrict data = col.get_chars().data();
-        auto* __restrict cursor = const_cast<uint8_t*>(data);
         const uint8_t* __restrict null_map_data;
         if constexpr (is_nullable) {
             null_map_data = null_map->data();
@@ -729,15 +728,15 @@ public:
         for (size_t i = 0; i < rows; ++i) {
             uint32_t len = offset[i] - offset[i - 1];
             if constexpr (!is_nullable && !is_negative) {
-                result_data[i] = _set.find(StringRef(cursor, len));
+                result_data[i] = _set.find(StringRef(data, len));
             } else if constexpr (!is_nullable && is_negative) {
-                result_data[i] = !_set.find(StringRef(cursor, len));
+                result_data[i] = !_set.find(StringRef(data, len));
             } else if constexpr (is_nullable && !is_negative) {
-                result_data[i] = (!null_map_data[i]) & 
_set.find(StringRef(cursor, len));
+                result_data[i] = (!null_map_data[i]) & 
_set.find(StringRef(data, len));
             } else { // (is_nullable && is_negative)
-                result_data[i] = !((!null_map_data[i]) & 
_set.find(StringRef(cursor, len)));
+                result_data[i] = !((!null_map_data[i]) & 
_set.find(StringRef(data, len)));
             }
-            cursor += len;
+            data += len;
         }
     }
 
@@ -748,7 +747,7 @@ public:
         ~Iterator() override = default;
         bool has_next() const override { return !(_begin == _end); }
         const void* get_value() override {
-            _value.data = const_cast<char*>(_begin->data);
+            _value.data = _begin->data;
             _value.size = _begin->size;
             return &_value;
         }
diff --git a/be/src/geo/geo_types.cpp b/be/src/geo/geo_types.cpp
index 0f7376a58fa..22c48fedc76 100644
--- a/be/src/geo/geo_types.cpp
+++ b/be/src/geo/geo_types.cpp
@@ -779,8 +779,8 @@ int GeoLine::numPoint() const {
     return _polyline->num_vertices();
 }
 
-S2Point* GeoLine::getPoint(int i) const {
-    return const_cast<S2Point*>(&(_polyline->vertex(i)));
+const S2Point* GeoLine::getPoint(int i) const {
+    return &(_polyline->vertex(i));
 }
 
 GeoParseStatus GeoPolygon::from_coords(const GeoCoordinateListList& list) {
@@ -1102,7 +1102,7 @@ int GeoPolygon::numLoops() const {
 }
 
 S2Loop* GeoPolygon::getLoop(int i) const {
-    return const_cast<S2Loop*>(_polygon->loop(i));
+    return _polygon->loop(i);
 }
 
 GeoParseStatus GeoMultiPolygon::from_coords(const 
std::vector<GeoCoordinateListList>& list) {
diff --git a/be/src/geo/geo_types.h b/be/src/geo/geo_types.h
index 1f44fa3deb5..dbc7901f1b3 100644
--- a/be/src/geo/geo_types.h
+++ b/be/src/geo/geo_types.h
@@ -141,7 +141,7 @@ public:
     std::string as_wkt() const override;
 
     int numPoint() const;
-    S2Point* getPoint(int i) const;
+    const S2Point* getPoint(int i) const;
 
 protected:
     void encode(std::string* buf) override;
diff --git a/be/src/olap/comparison_predicate.h 
b/be/src/olap/comparison_predicate.h
index 600be2e60dd..2f2579753bd 100644
--- a/be/src/olap/comparison_predicate.h
+++ b/be/src/olap/comparison_predicate.h
@@ -267,24 +267,20 @@ public:
                 // DecimalV2 using decimal12_t in bloom filter, should convert 
value to decimal12_t
                 if constexpr (Type == PrimitiveType::TYPE_DECIMALV2) {
                     decimal12_t decimal12_t_val(_value.int_value(), 
_value.frac_value());
-                    return bf->test_bytes(
-                            const_cast<char*>(reinterpret_cast<const 
char*>(&decimal12_t_val)),
-                            sizeof(decimal12_t));
+                    return bf->test_bytes(reinterpret_cast<const 
char*>(&decimal12_t_val),
+                                          sizeof(decimal12_t));
                     // Datev1 using uint24_t in bloom filter
                 } else if constexpr (Type == PrimitiveType::TYPE_DATE) {
                     uint24_t date_value(uint32_t(_value.to_olap_date()));
-                    return bf->test_bytes(
-                            const_cast<char*>(reinterpret_cast<const 
char*>(&date_value)),
-                            sizeof(uint24_t));
+                    return bf->test_bytes(reinterpret_cast<const 
char*>(&date_value),
+                                          sizeof(uint24_t));
                     // DatetimeV1 using int64_t in bloom filter
                 } else if constexpr (Type == PrimitiveType::TYPE_DATETIME) {
                     int64_t datetime_value(_value.to_olap_datetime());
-                    return bf->test_bytes(
-                            const_cast<char*>(reinterpret_cast<const 
char*>(&datetime_value)),
-                            sizeof(int64_t));
+                    return bf->test_bytes(reinterpret_cast<const 
char*>(&datetime_value),
+                                          sizeof(int64_t));
                 } else {
-                    return 
bf->test_bytes(const_cast<char*>(reinterpret_cast<const char*>(&_value)),
-                                          sizeof(T));
+                    return bf->test_bytes(reinterpret_cast<const 
char*>(&_value), sizeof(T));
                 }
             }
         } else {
diff --git a/be/src/olap/in_list_predicate.h b/be/src/olap/in_list_predicate.h
index f326098185d..5203a87125e 100644
--- a/be/src/olap/in_list_predicate.h
+++ b/be/src/olap/in_list_predicate.h
@@ -367,26 +367,23 @@ public:
                     // Datev1/DatetimeV1 using VecDatetimeValue in bloom 
filter, NO need to convert.
                     const T* value = (const T*)(iter->get_value());
                     decimal12_t decimal12_t_val(value->int_value(), 
value->frac_value());
-                    if (bf->test_bytes(
-                                const_cast<char*>(reinterpret_cast<const 
char*>(&decimal12_t_val)),
-                                sizeof(decimal12_t))) {
+                    if (bf->test_bytes(reinterpret_cast<const 
char*>(&decimal12_t_val),
+                                       sizeof(decimal12_t))) {
                         return true;
                     }
                 } else if constexpr (Type == PrimitiveType::TYPE_DATE) {
                     const T* value = (const T*)(iter->get_value());
                     uint24_t date_value(uint32_t(value->to_olap_date()));
-                    if (bf->test_bytes(
-                                const_cast<char*>(reinterpret_cast<const 
char*>(&date_value)),
-                                sizeof(uint24_t))) {
+                    if (bf->test_bytes(reinterpret_cast<const 
char*>(&date_value),
+                                       sizeof(uint24_t))) {
                         return true;
                     }
                     // DatetimeV1 using int64_t in bloom filter
                 } else if constexpr (Type == PrimitiveType::TYPE_DATETIME) {
                     const T* value = (const T*)(iter->get_value());
                     int64_t datetime_value(value->to_olap_datetime());
-                    if (bf->test_bytes(
-                                const_cast<char*>(reinterpret_cast<const 
char*>(&datetime_value)),
-                                sizeof(int64_t))) {
+                    if (bf->test_bytes(reinterpret_cast<const 
char*>(&datetime_value),
+                                       sizeof(int64_t))) {
                         return true;
                     }
                 } else {
diff --git a/be/src/runtime/memory/memory_profile.cpp 
b/be/src/runtime/memory/memory_profile.cpp
index 1549cc02fbb..36f9a7d301d 100644
--- a/be/src/runtime/memory/memory_profile.cpp
+++ b/be/src/runtime/memory/memory_profile.cpp
@@ -309,33 +309,32 @@ void MemoryProfile::make_memory_profile(RuntimeProfile* 
profile) const {
 
     RuntimeProfile* memory_overview_profile =
             
memory_profile_snapshot->create_child(_memory_overview_profile->name(), true, 
false);
-    
memory_overview_profile->merge(const_cast<RuntimeProfile*>(_memory_overview_profile.get()));
+    memory_overview_profile->merge(_memory_overview_profile.get());
 
     auto global_memory_version_ptr = _global_memory_profile.get();
     RuntimeProfile* global_memory_profile =
             
memory_profile_snapshot->create_child(global_memory_version_ptr->name(), true, 
false);
-    
global_memory_profile->merge(const_cast<RuntimeProfile*>(global_memory_version_ptr.get()));
+    global_memory_profile->merge(global_memory_version_ptr.get());
 
     auto metadata_memory_version_ptr = _metadata_memory_profile.get();
     RuntimeProfile* metadata_memory_profile =
             
memory_profile_snapshot->create_child(metadata_memory_version_ptr->name(), 
true, false);
-    
metadata_memory_profile->merge(const_cast<RuntimeProfile*>(metadata_memory_version_ptr.get()));
+    metadata_memory_profile->merge(metadata_memory_version_ptr.get());
 
     auto cache_memory_version_ptr = _cache_memory_profile.get();
     RuntimeProfile* cache_memory_profile =
             
memory_profile_snapshot->create_child(cache_memory_version_ptr->name(), true, 
false);
-    
cache_memory_profile->merge(const_cast<RuntimeProfile*>(cache_memory_version_ptr.get()));
+    cache_memory_profile->merge(cache_memory_version_ptr.get());
 
     auto top_memory_tasks_version_ptr = _top_memory_tasks_profile.get();
     RuntimeProfile* top_memory_tasks_profile = 
memory_profile_snapshot->create_child(
             top_memory_tasks_version_ptr->name(), true, false);
-    top_memory_tasks_profile->merge(
-            const_cast<RuntimeProfile*>(top_memory_tasks_version_ptr.get()));
+    top_memory_tasks_profile->merge(top_memory_tasks_version_ptr.get());
 
     auto tasks_memory_version_ptr = _tasks_memory_profile.get();
     RuntimeProfile* tasks_memory_profile =
             
memory_profile_snapshot->create_child(tasks_memory_version_ptr->name(), true, 
false);
-    
tasks_memory_profile->merge(const_cast<RuntimeProfile*>(tasks_memory_version_ptr.get()));
+    tasks_memory_profile->merge(tasks_memory_version_ptr.get());
 }
 
 int64_t MemoryProfile::query_current_usage() {
diff --git a/be/src/runtime/process_profile.h b/be/src/runtime/process_profile.h
index 24b128ab552..aaae064f886 100644
--- a/be/src/runtime/process_profile.h
+++ b/be/src/runtime/process_profile.h
@@ -44,7 +44,7 @@ public:
         std::stringstream ss;
         std::vector<RuntimeProfile*> profiles;
         auto version_ptr = _process_profile.get();
-        auto* process_profile = 
const_cast<doris::RuntimeProfile*>(version_ptr.get());
+        auto* process_profile = version_ptr.get();
         process_profile->get_children(&profiles);
         for (auto* profile : profiles) {
             profile->pretty_print(&ss);
diff --git a/be/src/runtime/workload_management/resource_context.h 
b/be/src/runtime/workload_management/resource_context.h
index 8ef090814ed..5dc69a1067d 100644
--- a/be/src/runtime/workload_management/resource_context.h
+++ b/be/src/runtime/workload_management/resource_context.h
@@ -80,8 +80,6 @@ public:
     }
     void set_workload_group(WorkloadGroupPtr wg) { _workload_group = wg; }
 
-    RuntimeProfile* profile() { return 
const_cast<RuntimeProfile*>(resource_profile_.get().get()); }
-
     void to_thrift_query_statistics(TQueryStatistics* statistics) const;
 
     std::string debug_string() { return 
resource_profile_.get()->pretty_print(); }
diff --git a/be/src/util/runtime_profile.cpp b/be/src/util/runtime_profile.cpp
index 71b1a444f61..42ae738cce8 100644
--- a/be/src/util/runtime_profile.cpp
+++ b/be/src/util/runtime_profile.cpp
@@ -87,7 +87,7 @@ bool RuntimeProfile::Counter::operator==(const Counter& 
other) const {
            _type == other._type && _level == other._level;
 }
 
-void RuntimeProfile::merge(RuntimeProfile* other) {
+void RuntimeProfile::merge(const RuntimeProfile* other) {
     DCHECK(other != nullptr);
 
     // Merge this level
@@ -427,11 +427,11 @@ RuntimeProfile* RuntimeProfile::get_child(std::string 
name) {
     return it->second;
 }
 
-void RuntimeProfile::get_children(std::vector<RuntimeProfile*>* children) {
+void RuntimeProfile::get_children(std::vector<RuntimeProfile*>* children) 
const {
     children->clear();
     std::lock_guard<std::mutex> l(_children_lock);
 
-    for (ChildMap::iterator i = _child_map.begin(); i != _child_map.end(); 
++i) {
+    for (ChildMap::const_iterator i = _child_map.begin(); i != 
_child_map.end(); ++i) {
         children->push_back(i->second);
     }
 }
diff --git a/be/src/util/runtime_profile.h b/be/src/util/runtime_profile.h
index ca5ffcca438..a9ccb0910b6 100644
--- a/be/src/util/runtime_profile.h
+++ b/be/src/util/runtime_profile.h
@@ -504,7 +504,7 @@ public:
     // weren't for locking.
     // Calling this concurrently on two RuntimeProfiles in reverse order 
results in
     // undefined behavior.
-    void merge(RuntimeProfile* src);
+    void merge(const RuntimeProfile* src);
 
     // Updates this profile w/ the thrift profile: behaves like Merge(), except
     // that existing counters are updated rather than added up.
@@ -600,7 +600,7 @@ public:
 
     RuntimeProfile* get_child(std::string name);
 
-    void get_children(std::vector<RuntimeProfile*>* children);
+    void get_children(std::vector<RuntimeProfile*>* children) const;
 
     // Gets all profiles in tree, including this one.
     void get_all_children(std::vector<RuntimeProfile*>* children);


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

Reply via email to