Skip to content

Commit

Permalink
avoid id mapping for aggregate functions (#1118)
Browse files Browse the repository at this point in the history
For simple aggregate functions the full set of tags are
determined based on the expression. This means we can
avoid mapping the id to a tag map.
  • Loading branch information
brharrington authored Mar 8, 2024
1 parent a0dda8c commit 0195a20
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
Expand Down Expand Up @@ -172,8 +173,13 @@ public EvalPayload eval(long timestamp) {
consolidator.update(timestamp, Double.NaN);
final double v = consolidator.value(timestamp);
if (!Double.isNaN(v)) {
Map<String, String> tags = idMapper.apply(entry.getKey());
tags.putAll(commonTags);
Map<String, String> tags = Collections.emptyMap();
if (!(expr instanceof DataExpr.AggregateFunction)) {
// Aggregation functions only use tags based on the expression. Avoid overhead of
// considering the tags for the data.
tags = idMapper.apply(entry.getKey());
tags.putAll(commonTags);
}
if (delayGaugeAggr && consolidator.isGauge()) {
// When performing a group by, datapoints missing tag used for the grouping
// should be ignored
Expand Down

0 comments on commit 0195a20

Please sign in to comment.