[fix](profile) fix double add in aggcounter #27826

This commit is contained in:
Mryange
2023-11-30 21:45:15 +08:00
committed by GitHub
parent 97105e9a16
commit c93b5727b3
2 changed files with 16 additions and 10 deletions

View File

@ -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++;
}

View File

@ -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);