[fix](profile) fix double add in aggcounter #27826
This commit is contained in:
@ -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++;
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user