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 c93b5727b30 [fix](profile) fix double add in aggcounter #27826
c93b5727b30 is described below
commit c93b5727b303823789a2be432dec4dc7d108274b
Author: Mryange <[email protected]>
AuthorDate: Thu Nov 30 21:45:15 2023 +0800
[fix](profile) fix double add in aggcounter #27826
---
.../org/apache/doris/common/util/AggCounter.java | 24 ++++++++++++++--------
.../apache/doris/common/util/RuntimeProfile.java | 2 +-
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/util/AggCounter.java
b/fe/fe-core/src/main/java/org/apache/doris/common/util/AggCounter.java
index ed8f91533fb..d7eb7184954 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/AggCounter.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/AggCounter.java
@@ -26,18 +26,24 @@ public class AggCounter extends Counter {
Counter min;
int number;
- public AggCounter(org.apache.doris.thrift.TUnit type, long value) {
- super(type, value);
- max = new Counter(type, value);
- sum = new Counter(type, value);
- min = new Counter(type, value);
- number = 1;
+ public AggCounter(org.apache.doris.thrift.TUnit type) {
+ super(type, 0);
+ max = new Counter(type, 0);
+ sum = new Counter(type, 0);
+ min = new Counter(type, 0);
+ number = 0;
}
public void addCounter(Counter counter) {
- max.maxValue(counter);
- sum.addValue(counter);
- min.minValue(counter);
+ if (number == 0) {
+ max.setValue(counter.getValue());
+ sum.setValue(counter.getValue());
+ min.setValue(counter.getValue());
+ } else {
+ max.maxValue(counter);
+ sum.addValue(counter);
+ min.minValue(counter);
+ }
number++;
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java
b/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java
index 432171e9ce2..41e3738f0a0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java
@@ -494,7 +494,7 @@ public class RuntimeProfile {
mergeCounters(childCounterName, profiles, simpleProfile);
if (counter.getLevel() == 1) {
Counter oldCounter =
profiles.get(0).counterMap.get(childCounterName);
- AggCounter aggCounter = new AggCounter(oldCounter.getType(),
oldCounter.getValue());
+ AggCounter aggCounter = new AggCounter(oldCounter.getType());
for (RuntimeProfile profile : profiles) {
Counter orgCounter =
profile.counterMap.get(childCounterName);
aggCounter.addCounter(orgCounter);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]