mirror of
https://github.com/apache/druid.git
synced 2025-02-09 03:24:55 +00:00
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()) {
|
while (!cursor.isDone()) {
|
||||||
final Comparable<?> key = dimensionValueConverter.apply(dimSelector.lookupName(dimSelector.getRow().get(0)));
|
final Comparable<?> key = dimensionValueConverter.apply(dimSelector.lookupName(dimSelector.getRow().get(0)));
|
||||||
|
|
||||||
Aggregator[] theAggregators = aggregatesStore.get(key);
|
Aggregator[] theAggregators = aggregatesStore.computeIfAbsent(
|
||||||
if (theAggregators == null) {
|
key,
|
||||||
theAggregators = makeAggregators(cursor, query.getAggregatorSpecs());
|
k -> makeAggregators(cursor, query.getAggregatorSpecs())
|
||||||
aggregatesStore.put(key, theAggregators);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
for (Aggregator aggregator : theAggregators) {
|
for (Aggregator aggregator : theAggregators) {
|
||||||
aggregator.aggregate();
|
aggregator.aggregate();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user