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

morningman pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git

commit 51f7b70507473998c233f6934fae06fd3771d672
Author: morningman <[email protected]>
AuthorDate: Wed Apr 6 10:02:09 2022 +0800

    fix some error on build.sh && fix build fail with clang on runtime_profile 
(#8748)
---
 be/src/util/runtime_profile.cpp |  4 ++--
 be/src/util/runtime_profile.h   | 48 ++++++++++++++++++++---------------------
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/be/src/util/runtime_profile.cpp b/be/src/util/runtime_profile.cpp
index 040e617c65..60bad52ea1 100644
--- a/be/src/util/runtime_profile.cpp
+++ b/be/src/util/runtime_profile.cpp
@@ -41,7 +41,7 @@ static const std::string THREAD_VOLUNTARY_CONTEXT_SWITCHES = 
"VoluntaryContextSw
 static const std::string THREAD_INVOLUNTARY_CONTEXT_SWITCHES = 
"InvoluntaryContextSwitches";
 
 // The root counter name for all top level counters.
-static const std::string ROOT_COUNTER = "";
+static const std::string ROOT_COUNTER;
 
 RuntimeProfile::RuntimeProfile(const std::string& name, bool 
is_averaged_profile)
         : _pool(new ObjectPool()),
@@ -54,7 +54,7 @@ RuntimeProfile::RuntimeProfile(const std::string& name, bool 
is_averaged_profile
     _counter_map["TotalTime"] = &_counter_total_time;
 }
 
-RuntimeProfile::~RuntimeProfile() {}
+RuntimeProfile::~RuntimeProfile() = default;
 
 void RuntimeProfile::merge(RuntimeProfile* other) {
     DCHECK(other != nullptr);
diff --git a/be/src/util/runtime_profile.h b/be/src/util/runtime_profile.h
index 1e9366fd03..8c43637d13 100644
--- a/be/src/util/runtime_profile.h
+++ b/be/src/util/runtime_profile.h
@@ -91,7 +91,7 @@ public:
     class Counter {
     public:
         Counter(TUnit::type type, int64_t value = 0) : _value(value), 
_type(type) {}
-        virtual ~Counter() {}
+        virtual ~Counter() = default;
 
         virtual void update(int64_t delta) {
             //__sync_fetch_and_add(&_value, delta);
@@ -166,7 +166,7 @@ public:
             }
         }
 
-        virtual void set(int64_t v) {
+        void set(int64_t v) override {
             current_value_.store(v);
             UpdateMax(v);
         }
@@ -190,7 +190,7 @@ public:
         AtomicInt64 current_value_;
     };
 
-    typedef std::function<int64_t()> DerivedCounterFunction;
+    using DerivedCounterFunction = std::function<int64_t()>;
 
     // A DerivedCounter also has a name and type, but the value is computed.
     // Do not call Set() and Update().
@@ -199,7 +199,7 @@ public:
         DerivedCounter(TUnit::type type, const DerivedCounterFunction& 
counter_fn)
                 : Counter(type, 0), _counter_fn(counter_fn) {}
 
-        virtual int64_t value() const { return _counter_fn(); }
+        int64_t value() const override { return _counter_fn(); }
 
     private:
         DerivedCounterFunction _counter_fn;
@@ -232,7 +232,7 @@ public:
     // Not thread-safe.
     class EventSequence {
     public:
-        EventSequence() {}
+        EventSequence() = default;
 
         // starts the timer without resetting it.
         void start() { _sw.start(); }
@@ -250,10 +250,10 @@ public:
         int64_t elapsed_time() { return _sw.elapsed_time(); }
 
         // An Event is a <label, timestamp> pair
-        typedef std::pair<std::string, int64_t> Event;
+        using Event = std::pair<std::string, int64_t>;
 
         // An EventList is a sequence of Events, in increasing timestamp order
-        typedef std::vector<Event> EventList;
+        using EventList = std::vector<Event>;
 
         const EventList& events() const { return _events; }
 
@@ -395,7 +395,7 @@ public:
 
     // Function that returns a counter metric.
     // Note: this function should not block (or take a long time).
-    typedef std::function<int64_t()> SampleFn;
+    using SampleFn = std::function<int64_t()>;
 
     // Add a rate counter to the current profile based on src_counter with 
name.
     // The rate counter is updated periodically based on the src counter.
@@ -452,12 +452,12 @@ private:
 
     // Map from counter names to counters.  The profile owns the memory for the
     // counters.
-    typedef std::map<std::string, Counter*> CounterMap;
+    using CounterMap = std::map<std::string, Counter*>;
     CounterMap _counter_map;
 
     // Map from parent counter name to a set of child counter name.
     // All top level counters are the child of "" (root).
-    typedef std::map<std::string, std::set<std::string>> ChildCounterMap;
+    using ChildCounterMap = std::map<std::string, std::set<std::string>>;
     ChildCounterMap _child_counter_map;
 
     // A set of bucket counters registered in this runtime profile.
@@ -469,24 +469,24 @@ private:
     // Child profiles.  Does not own memory.
     // We record children in both a map (to facilitate updates) and a vector
     // (to print things in the order they were registered)
-    typedef std::map<std::string, RuntimeProfile*> ChildMap;
+    using ChildMap = std::map<std::string, RuntimeProfile*>;
     ChildMap _child_map;
     // vector of (profile, indentation flag)
-    typedef std::vector<std::pair<RuntimeProfile*, bool>> ChildVector;
+    using ChildVector = std::vector<std::pair<RuntimeProfile*, bool>>;
     ChildVector _children;
     mutable std::mutex _children_lock; // protects _child_map and _children
 
-    typedef std::map<std::string, std::string> InfoStrings;
+    using InfoStrings = std::map<std::string, std::string>;
     InfoStrings _info_strings;
 
     // Keeps track of the order in which InfoStrings are displayed when printed
-    typedef std::vector<std::string> InfoStringsDisplayOrder;
+    using InfoStringsDisplayOrder = std::vector<std::string>;
     InfoStringsDisplayOrder _info_strings_display_order;
 
     // Protects _info_strings and _info_strings_display_order
     mutable std::mutex _info_strings_lock;
 
-    typedef std::map<std::string, EventSequence*> EventSequenceMap;
+    using EventSequenceMap = std::map<std::string, EventSequence*>;
     EventSequenceMap _event_sequence_map;
     mutable std::mutex _event_sequences_lock;
 
@@ -554,11 +554,11 @@ public:
         }
     }
 
-private:
     // Disable copy constructor and assignment
-    ScopedCounter(const ScopedCounter& counter);
-    ScopedCounter& operator=(const ScopedCounter& counter);
+    ScopedCounter(const ScopedCounter& counter) = delete;
+    ScopedCounter& operator=(const ScopedCounter& counter) = delete;
 
+private:
     int64_t _val;
     RuntimeProfile::Counter* _counter;
 };
@@ -596,11 +596,11 @@ public:
         UpdateCounter();
     }
 
-private:
     // Disable copy constructor and assignment
-    ScopedTimer(const ScopedTimer& timer);
-    ScopedTimer& operator=(const ScopedTimer& timer);
+    ScopedTimer(const ScopedTimer& timer) = delete;
+    ScopedTimer& operator=(const ScopedTimer& timer) = delete;
 
+private:
     T _sw;
     RuntimeProfile::Counter* _counter;
     const bool* _is_cancelled;
@@ -616,11 +616,11 @@ public:
     // Update counter when object is destroyed
     ~ScopedRawTimer() { *_counter += _sw.elapsed_time(); }
 
-private:
     // Disable copy constructor and assignment
-    ScopedRawTimer(const ScopedRawTimer& timer);
-    ScopedRawTimer& operator=(const ScopedRawTimer& timer);
+    ScopedRawTimer(const ScopedRawTimer& timer) = delete;
+    ScopedRawTimer& operator=(const ScopedRawTimer& timer) = delete;
 
+private:
     T _sw;
     C* _counter;
 };


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

Reply via email to