mirror of https://github.com/apache/druid.git
Optimize TimeExtractionTopNAlgorithm (#9336)
When the time extraction Top N algorithm is looking for aggregators, it makes 2 calls to hashCode on the key. Use Map#computeIfAbsent instead so that the hashCode is calculated only once
This commit is contained in:
parent
51d7864935
commit
ea006dc72a
|
@ -98,11 +98,10 @@ public class TimeExtractionTopNAlgorithm extends BaseTopNAlgorithm<int[], Map<Co
|
|||
while (!cursor.isDone()) {
|
||||
final Comparable<?> key = dimensionValueConverter.apply(dimSelector.lookupName(dimSelector.getRow().get(0)));
|
||||
|
||||
Aggregator[] theAggregators = aggregatesStore.get(key);
|
||||
if (theAggregators == null) {
|
||||
theAggregators = makeAggregators(cursor, query.getAggregatorSpecs());
|
||||
aggregatesStore.put(key, theAggregators);
|
||||
}
|
||||
Aggregator[] theAggregators = aggregatesStore.computeIfAbsent(
|
||||
key,
|
||||
k -> makeAggregators(cursor, query.getAggregatorSpecs())
|
||||
);
|
||||
|
||||
for (Aggregator aggregator : theAggregators) {
|
||||
aggregator.aggregate();
|
||||
|
|
Loading…
Reference in New Issue