You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by ji...@apache.org on 2020/02/10 22:26:22 UTC
[druid] branch master updated: Optimize TimeExtractionTopNAlgorithm
(#9336)
This is an automated email from the ASF dual-hosted git repository.
jihoonson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new ea006dc Optimize TimeExtractionTopNAlgorithm (#9336)
ea006dc is described below
commit ea006dc72a4aea46f49470c4c55d2ca73bcf5677
Author: Suneet Saldanha <44...@users.noreply.github.com>
AuthorDate: Mon Feb 10 14:26:10 2020 -0800
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
---
.../org/apache/druid/query/topn/TimeExtractionTopNAlgorithm.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/processing/src/main/java/org/apache/druid/query/topn/TimeExtractionTopNAlgorithm.java b/processing/src/main/java/org/apache/druid/query/topn/TimeExtractionTopNAlgorithm.java
index a23518a..cee1e3a 100644
--- a/processing/src/main/java/org/apache/druid/query/topn/TimeExtractionTopNAlgorithm.java
+++ b/processing/src/main/java/org/apache/druid/query/topn/TimeExtractionTopNAlgorithm.java
@@ -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();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org