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

zhangstar333 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 74b3cdc4aa1 [chore](compile) fix some file complie warning error 
(#55567)
74b3cdc4aa1 is described below

commit 74b3cdc4aa116a4f5b46ff49c7ef7a929346bc83
Author: zhangstar333 <[email protected]>
AuthorDate: Wed Sep 3 18:27:25 2025 +0800

    [chore](compile) fix some file complie warning error (#55567)
    
    ### What problem does this PR solve?
     fix some file complie warning error
---
 be/src/util/jni-util.cpp                           |   9 +-
 be/src/util/tdigest.h                              | 102 ++++++++++++---------
 be/src/util/uid_util.cpp                           |   7 +-
 be/src/util/url_parser.cpp                         |   5 +-
 .../aggregate_function_percentile.h                |  10 +-
 5 files changed, 76 insertions(+), 57 deletions(-)

diff --git a/be/src/util/jni-util.cpp b/be/src/util/jni-util.cpp
index 6eb895f505d..55e95cb431c 100644
--- a/be/src/util/jni-util.cpp
+++ b/be/src/util/jni-util.cpp
@@ -22,11 +22,9 @@
 #include <jni.h>
 #include <jni_md.h>
 
-#include <algorithm>
 #include <cstdlib>
 #include <filesystem>
 #include <iterator>
-#include <limits>
 #include <memory>
 #include <mutex>
 #include <sstream>
@@ -34,6 +32,7 @@
 #include <vector>
 
 #include "absl/strings/substitute.h"
+#include "common/cast_set.h"
 #include "common/config.h"
 #include "util/doris_metrics.h"
 #include "util/jni_native_method.h"
@@ -42,7 +41,7 @@
 using std::string;
 
 namespace doris {
-
+#include "common/compile_check_begin.h"
 namespace {
 JavaVM* g_vm;
 [[maybe_unused]] std::once_flag g_vm_once;
@@ -146,7 +145,7 @@ const std::string GetKerb5ConfPath() {
         JavaVMInitArgs vm_args;
         vm_args.version = JNI_VERSION_1_8;
         vm_args.options = jvm_options.get();
-        vm_args.nOptions = options.size();
+        vm_args.nOptions = cast_set<int>(options.size());
         // Set it to JNI_FALSE because JNI_TRUE will let JVM ignore the max 
size config.
         vm_args.ignoreUnrecognized = JNI_FALSE;
 
@@ -660,5 +659,5 @@ Status JniUtil::Init() {
     DorisMetrics::instance()->init_jvm_metrics(env);
     return Status::OK();
 }
-
+#include "common/compile_check_end.h"
 } // namespace doris
diff --git a/be/src/util/tdigest.h b/be/src/util/tdigest.h
index 30f07ae45c2..5dad6d5bac9 100644
--- a/be/src/util/tdigest.h
+++ b/be/src/util/tdigest.h
@@ -55,10 +55,9 @@
 
 #include "common/factory_creator.h"
 #include "common/logging.h"
-#include "udf/udf.h"
-#include "util/debug_util.h"
 
 namespace doris {
+#include "common/compile_check_begin.h"
 
 using Value = float;
 using Weight = float;
@@ -106,7 +105,7 @@ struct CentroidList {
 
 class CentroidListComparator {
 public:
-    CentroidListComparator() {}
+    CentroidListComparator() = default;
 
     bool operator()(const CentroidList& left, const CentroidList& right) const 
{
         return left.iter->mean() > right.iter->mean();
@@ -125,7 +124,7 @@ class TDigest {
 
     class TDigestComparator {
     public:
-        TDigestComparator() {}
+        TDigestComparator() = default;
 
         bool operator()(const TDigest* left, const TDigest* right) const {
             return left->totalSize() > right->totalSize();
@@ -230,7 +229,7 @@ public:
 
             size_t totalSize = 0;
             while (!pq.empty()) {
-                auto td = pq.top();
+                const auto* td = pq.top();
                 batch.push_back(td);
                 pq.pop();
                 totalSize += td->totalSize();
@@ -258,7 +257,9 @@ public:
 
     // return the cdf on the t-digest
     Value cdf(Value x) {
-        if (haveUnprocessed() || isDirty()) process();
+        if (haveUnprocessed() || isDirty()) {
+            process();
+        }
         return cdfProcessed(x);
     }
 
@@ -312,7 +313,8 @@ public:
 
                 // note that this is different than mean(0) > _min ... this 
guarantees interpolation works
                 if (mean(0) - _min > 0) {
-                    return (x - _min) / (mean(0) - _min) * weight(0) / 
_processed_weight / 2.0;
+                    return static_cast<Value>((x - _min) / (mean(0) - _min) * 
weight(0) /
+                                              _processed_weight / 2.0);
                 } else {
                     return 0;
                 }
@@ -324,8 +326,9 @@ public:
                               << " _max " << _max << " mean(n - 1) " << mean(n 
- 1) << " x " << x;
 
                 if (_max - mean(n - 1) > 0) {
-                    return 1.0 - (_max - x) / (_max - mean(n - 1)) * weight(n 
- 1) /
-                                         _processed_weight / 2.0;
+                    return static_cast<Value>(1.0 - (_max - x) / (_max - 
mean(n - 1)) *
+                                                            weight(n - 1) / 
_processed_weight /
+                                                            2.0);
                 } else {
                     return 1;
                 }
@@ -349,7 +352,9 @@ public:
 
     // this returns a quantile on the t-digest
     Value quantile(Value q) {
-        if (haveUnprocessed() || isDirty()) process();
+        if (haveUnprocessed() || isDirty()) {
+            process();
+        }
         return quantileProcessed(q);
     }
 
@@ -379,12 +384,13 @@ public:
         // at the boundaries, we return _min or _max
         if (index <= weight(0) / 2.0) {
             DCHECK_GT(weight(0), 0);
-            return _min + 2.0 * index / weight(0) * (mean(0) - _min);
+            return static_cast<Value>(_min + 2.0 * index / weight(0) * 
(mean(0) - _min));
         }
 
         auto iter = std::lower_bound(_cumulative.cbegin(), _cumulative.cend(), 
index);
 
-        if (iter + 1 != _cumulative.cend()) {
+        if (iter != _cumulative.cend() && iter != _cumulative.cbegin() &&
+            iter + 1 != _cumulative.cend()) {
             auto i = std::distance(_cumulative.cbegin(), iter);
             auto z1 = index - *(iter - 1);
             auto z2 = *(iter)-index;
@@ -395,8 +401,8 @@ public:
         DCHECK_LE(index, _processed_weight);
         DCHECK_GE(index, _processed_weight - weight(n - 1) / 2.0);
 
-        auto z1 = index - _processed_weight - weight(n - 1) / 2.0;
-        auto z2 = weight(n - 1) / 2 - z1;
+        auto z1 = static_cast<Value>(index - _processed_weight - weight(n - 1) 
/ 2.0);
+        auto z2 = static_cast<Value>(weight(n - 1) / 2 - z1);
         return weightedAverage(mean(n - 1), z1, _max, z2);
     }
 
@@ -412,7 +418,7 @@ public:
         if (std::isnan(x)) {
             return false;
         }
-        _unprocessed.push_back(Centroid(x, w));
+        _unprocessed.emplace_back(x, w);
         _unprocessed_weight += w;
         processIfNecessary();
         return true;
@@ -424,7 +430,9 @@ public:
             const size_t diff = std::distance(iter, end);
             const size_t room = _max_unprocessed - _unprocessed.size();
             auto mid = iter + std::min(diff, room);
-            while (iter != mid) _unprocessed.push_back(*(iter++));
+            while (iter != mid) {
+                _unprocessed.push_back(*(iter++));
+            }
             if (_unprocessed.size() >= _max_unprocessed) {
                 process();
             }
@@ -432,9 +440,10 @@ public:
     }
 
     uint32_t serialized_size() {
-        return sizeof(uint32_t) + sizeof(Value) * 5 + sizeof(Index) * 2 + 
sizeof(uint32_t) * 3 +
-               _processed.size() * sizeof(Centroid) + _unprocessed.size() * 
sizeof(Centroid) +
-               _cumulative.size() * sizeof(Weight);
+        return static_cast<uint32_t>(sizeof(uint32_t) + sizeof(Value) * 5 + 
sizeof(Index) * 2 +
+                                     sizeof(uint32_t) * 3 + _processed.size() 
* sizeof(Centroid) +
+                                     _unprocessed.size() * sizeof(Centroid) +
+                                     _cumulative.size() * sizeof(Weight));
     }
 
     size_t serialize(uint8_t* writer) {
@@ -457,7 +466,7 @@ public:
         memcpy(writer, &_unprocessed_weight, sizeof(Value));
         writer += sizeof(Value);
 
-        uint32_t size = _processed.size();
+        auto size = static_cast<uint32_t>(_processed.size());
         memcpy(writer, &size, sizeof(uint32_t));
         writer += sizeof(uint32_t);
         for (int i = 0; i < size; i++) {
@@ -465,7 +474,7 @@ public:
             writer += sizeof(Centroid);
         }
 
-        size = _unprocessed.size();
+        size = static_cast<uint32_t>(_unprocessed.size());
         memcpy(writer, &size, sizeof(uint32_t));
         writer += sizeof(uint32_t);
         //TODO(weixiang): may be once memcpy is enough!
@@ -474,7 +483,7 @@ public:
             writer += sizeof(Centroid);
         }
 
-        size = _cumulative.size();
+        size = static_cast<uint32_t>(_cumulative.size());
         memcpy(writer, &size, sizeof(uint32_t));
         writer += sizeof(uint32_t);
         for (int i = 0; i < size; i++) {
@@ -550,22 +559,24 @@ private:
     std::vector<Weight> _cumulative;
 
     // return mean of i-th centroid
-    Value mean(int i) const noexcept { return _processed[i].mean(); }
+    Value mean(int64_t i) const noexcept { return _processed[i].mean(); }
 
     // return weight of i-th centroid
-    Weight weight(int i) const noexcept { return _processed[i].weight(); }
+    Weight weight(int64_t i) const noexcept { return _processed[i].weight(); }
 
     // append all unprocessed centroids into current unprocessed vector
     void mergeUnprocessed(const std::vector<const TDigest*>& tdigests) {
-        if (tdigests.size() == 0) return;
+        if (tdigests.size() == 0) {
+            return;
+        }
 
         size_t total = _unprocessed.size();
-        for (auto& td : tdigests) {
+        for (const auto& td : tdigests) {
             total += td->_unprocessed.size();
         }
 
         _unprocessed.reserve(total);
-        for (auto& td : tdigests) {
+        for (const auto& td : tdigests) {
             _unprocessed.insert(_unprocessed.end(), td->_unprocessed.cbegin(),
                                 td->_unprocessed.cend());
             _unprocessed_weight += td->_unprocessed_weight;
@@ -574,12 +585,14 @@ private:
 
     // merge all processed centroids together into a single sorted vector
     void mergeProcessed(const std::vector<const TDigest*>& tdigests) {
-        if (tdigests.size() == 0) return;
+        if (tdigests.size() == 0) {
+            return;
+        }
 
         size_t total = 0;
         CentroidListQueue pq(CentroidListComparator {});
-        for (auto& td : tdigests) {
-            auto& sorted = td->_processed;
+        for (const auto& td : tdigests) {
+            const auto& sorted = td->_processed;
             auto size = sorted.size();
             if (size > 0) {
                 pq.push(CentroidList(sorted));
@@ -587,7 +600,9 @@ private:
                 _processed_weight += td->_processed_weight;
             }
         }
-        if (total == 0) return;
+        if (total == 0) {
+            return;
+        }
 
         if (_processed.size() > 0) {
             pq.push(CentroidList(_processed));
@@ -602,7 +617,9 @@ private:
             auto best = pq.top();
             pq.pop();
             sorted.push_back(*(best.iter));
-            if (best.advance()) pq.push(best);
+            if (best.advance()) {
+                pq.push(best);
+            }
         }
         _processed = std::move(sorted);
         if (_processed.size() > 0) {
@@ -621,10 +638,10 @@ private:
         const auto n = _processed.size();
         _cumulative.clear();
         _cumulative.reserve(n + 1);
-        auto previous = 0.0;
+        Weight previous = 0.0;
         for (Index i = 0; i < n; i++) {
-            auto current = weight(i);
-            auto halfCurrent = current / 2.0;
+            Weight current = weight(i);
+            auto halfCurrent = static_cast<Weight>(current / 2.0);
             _cumulative.push_back(previous + halfCurrent);
             previous = previous + current;
         }
@@ -654,14 +671,14 @@ private:
 
         auto end = _unprocessed.end();
         for (auto iter = _unprocessed.cbegin() + 1; iter < end; iter++) {
-            auto& centroid = *iter;
+            const auto& centroid = *iter;
             Weight projectedW = wSoFar + centroid.weight();
             if (projectedW <= wLimit) {
                 wSoFar = projectedW;
                 (_processed.end() - 1)->add(centroid);
             } else {
                 auto k1 = integratedLocation(wSoFar / _processed_weight);
-                wLimit = _processed_weight * integratedQ(k1 + 1.0);
+                wLimit = _processed_weight * integratedQ(static_cast<Value>(k1 
+ 1.0));
                 wSoFar += centroid.weight();
                 _processed.emplace_back(centroid);
             }
@@ -674,8 +691,6 @@ private:
         updateCumulative();
     }
 
-    int checkWeights() { return checkWeights(_processed, _processed_weight); }
-
     size_t checkWeights(const std::vector<Centroid>& sorted, Value total) {
         size_t badWeight = 0;
         auto k1 = 0.0;
@@ -683,7 +698,7 @@ private:
         for (auto iter = sorted.cbegin(); iter != sorted.cend(); iter++) {
             auto w = iter->weight();
             auto dq = w / total;
-            auto k2 = integratedLocation(q + dq);
+            auto k2 = integratedLocation(static_cast<Value>(q + dq));
             if (k2 - k1 > 1 && w != 1) {
                 VLOG_CRITICAL << "Oversize centroid at " << 
std::distance(sorted.cbegin(), iter)
                               << " k1 " << k1 << " k2 " << k2 << " dk " << (k2 
- k1) << " w " << w
@@ -721,11 +736,12 @@ private:
     * @return The centroid scale value corresponding to q.
     */
     Value integratedLocation(Value q) const {
-        return _compression * (std::asin(2.0 * q - 1.0) + M_PI / 2) / M_PI;
+        return static_cast<Value>(_compression * (std::asin(2.0 * q - 1.0) + 
M_PI / 2) / M_PI);
     }
 
     Value integratedQ(Value k) const {
-        return (std::sin(std::min(k, _compression) * M_PI / _compression - 
M_PI / 2) + 1) / 2;
+        return static_cast<Value>(
+                (std::sin(std::min(k, _compression) * M_PI / _compression - 
M_PI / 2) + 1) / 2);
     }
 
     /**
@@ -773,5 +789,5 @@ private:
         return previousMean * previousWeight + nextMean * nextWeight;
     }
 };
-
+#include "common/compile_check_end.h"
 } // namespace doris
diff --git a/be/src/util/uid_util.cpp b/be/src/util/uid_util.cpp
index fb767f09bd7..e5254fffae2 100644
--- a/be/src/util/uid_util.cpp
+++ b/be/src/util/uid_util.cpp
@@ -24,12 +24,13 @@
 
 #include <cstdlib>
 
+#include "common/cast_set.h"
 #include "util/hash_util.hpp"
 
 namespace doris {
-
+#include "common/compile_check_begin.h"
 size_t UniqueId::hash(size_t seed) const {
-    return doris::HashUtil::hash(this, sizeof(*this), seed);
+    return doris::HashUtil::hash(this, sizeof(*this), 
cast_set<uint32_t>(seed));
 }
 
 std::size_t hash_value(const doris::TUniqueId& id) {
@@ -80,5 +81,5 @@ bool parse_id(const std::string& s, TUniqueId* id) {
     *colon = ':';
     return valid;
 }
-
+#include "common/compile_check_end.h"
 } // namespace doris
diff --git a/be/src/util/url_parser.cpp b/be/src/util/url_parser.cpp
index a0bdd153e6b..c51291fd15f 100644
--- a/be/src/util/url_parser.cpp
+++ b/be/src/util/url_parser.cpp
@@ -27,7 +27,7 @@
 #include "vec/common/string_ref.h"
 
 namespace doris {
-
+#include "common/compile_check_begin.h"
 const StringRef UrlParser::_s_url_authority(const_cast<char*>("AUTHORITY"), 9);
 const StringRef UrlParser::_s_url_file(const_cast<char*>("FILE"), 4);
 const StringRef UrlParser::_s_url_host(const_cast<char*>("HOST"), 4);
@@ -402,7 +402,7 @@ StringRef UrlParser::extract_url(StringRef url, StringRef 
name) {
             // invalid url. like: k1&k2=bb
             continue;
         }
-        int32_t key_len = key_url.size;
+        auto key_len = key_url.size;
         auto key = key_url.substring(0, eq_pod);
         if (name == key) {
             return key_url.substring(eq_pod + 1, key_len - eq_pod - 1);
@@ -410,4 +410,5 @@ StringRef UrlParser::extract_url(StringRef url, StringRef 
name) {
     }
     return result;
 }
+#include "common/compile_check_end.h"
 } // namespace doris
diff --git a/be/src/vec/aggregate_functions/aggregate_function_percentile.h 
b/be/src/vec/aggregate_functions/aggregate_function_percentile.h
index 1578ec43a1c..f398dbebdc3 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_percentile.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_percentile.h
@@ -61,7 +61,7 @@ struct PercentileApproxState {
     PercentileApproxState() = default;
     ~PercentileApproxState() = default;
 
-    void init(double quantile, double compression = 10000) {
+    void init(double quantile, float compression = 10000) {
         if (!init_flag) {
             
//https://doris.apache.org/zh-CN/sql-reference/sql-functions/aggregate-functions/percentile_approx.html#description
             //The compression parameter setting range is [2048, 10000].
@@ -152,7 +152,7 @@ struct PercentileApproxState {
     bool init_flag = false;
     std::unique_ptr<TDigest> digest;
     double target_quantile = INIT_QUANTILE;
-    double compressions = 10000;
+    float compressions = 10000;
 };
 
 class AggregateFunctionPercentileApprox
@@ -230,7 +230,8 @@ public:
         const auto& compression =
                 assert_cast<const ColumnFloat64&, 
TypeCheckOnRelease::DISABLE>(*columns[2]);
 
-        this->data(place).init(quantile.get_element(0), 
compression.get_element(0));
+        this->data(place).init(quantile.get_element(0),
+                               static_cast<float>(compression.get_element(0)));
         this->data(place).add(sources.get_element(row_num));
     }
 
@@ -302,7 +303,8 @@ public:
         const auto& compression =
                 assert_cast<const ColumnFloat64&, 
TypeCheckOnRelease::DISABLE>(*columns[3]);
 
-        this->data(place).init(quantile.get_element(0), 
compression.get_element(0));
+        this->data(place).init(quantile.get_element(0),
+                               static_cast<float>(compression.get_element(0)));
         this->data(place).add_with_weight(sources.get_element(row_num),
                                           weight.get_element(row_num));
     }


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

Reply via email to