You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by xi...@apache.org on 2020/04/23 18:36:53 UTC

[incubator-pinot] branch master updated: Improve GroupBy query performance by setting initial size for OpenHashMap used in DictionaryBasedGroupKeyGenerator. (#5291)

This is an automated email from the ASF dual-hosted git repository.

xiangfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 62799a3  Improve GroupBy query performance by setting initial size for OpenHashMap used in DictionaryBasedGroupKeyGenerator. (#5291)
62799a3 is described below

commit 62799a32c99615e8d08f0ce9e7f72fe5e666477d
Author: Xiang Fu <fx...@gmail.com>
AuthorDate: Thu Apr 23 11:36:43 2020 -0700

    Improve GroupBy query performance by setting initial size for OpenHashMap used in DictionaryBasedGroupKeyGenerator. (#5291)
---
 .../groupby/DictionaryBasedGroupKeyGenerator.java   | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DictionaryBasedGroupKeyGenerator.java b/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DictionaryBasedGroupKeyGenerator.java
index fc0e55b..e2da862 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DictionaryBasedGroupKeyGenerator.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DictionaryBasedGroupKeyGenerator.java
@@ -109,15 +109,15 @@ public class DictionaryBasedGroupKeyGenerator implements GroupKeyGenerator {
 
     if (longOverflow) {
       _globalGroupIdUpperBound = numGroupsLimit;
-      _rawKeyHolder = new ArrayMapBasedHolder();
+      _rawKeyHolder = new ArrayMapBasedHolder(_globalGroupIdUpperBound);
     } else {
       if (cardinalityProduct > Integer.MAX_VALUE) {
         _globalGroupIdUpperBound = numGroupsLimit;
-        _rawKeyHolder = new LongMapBasedHolder();
+        _rawKeyHolder = new LongMapBasedHolder(_globalGroupIdUpperBound);
       } else {
         _globalGroupIdUpperBound = Math.min((int) cardinalityProduct, numGroupsLimit);
         if (cardinalityProduct > arrayBasedThreshold) {
-          _rawKeyHolder = new IntMapBasedHolder();
+          _rawKeyHolder = new IntMapBasedHolder(_globalGroupIdUpperBound);
         } else {
           _rawKeyHolder = new ArrayBasedHolder();
         }
@@ -259,11 +259,12 @@ public class DictionaryBasedGroupKeyGenerator implements GroupKeyGenerator {
   }
 
   private class IntMapBasedHolder implements RawKeyHolder {
-    private final Int2IntOpenHashMap _rawKeyToGroupIdMap = new Int2IntOpenHashMap();
+    private final Int2IntOpenHashMap _rawKeyToGroupIdMap;
 
     private int _numGroups = 0;
 
-    public IntMapBasedHolder() {
+    public IntMapBasedHolder(int initialSize) {
+      _rawKeyToGroupIdMap = new Int2IntOpenHashMap(initialSize);
       _rawKeyToGroupIdMap.defaultReturnValue(INVALID_ID);
     }
 
@@ -437,11 +438,12 @@ public class DictionaryBasedGroupKeyGenerator implements GroupKeyGenerator {
   }
 
   private class LongMapBasedHolder implements RawKeyHolder {
-    private final Long2IntOpenHashMap _rawKeyToGroupIdMap = new Long2IntOpenHashMap();
+    private final Long2IntOpenHashMap _rawKeyToGroupIdMap;
 
     private int _numGroups = 0;
 
-    public LongMapBasedHolder() {
+    public LongMapBasedHolder(int initialSize) {
+      _rawKeyToGroupIdMap = new Long2IntOpenHashMap(initialSize);
       _rawKeyToGroupIdMap.defaultReturnValue(INVALID_ID);
     }
 
@@ -607,11 +609,12 @@ public class DictionaryBasedGroupKeyGenerator implements GroupKeyGenerator {
   }
 
   private class ArrayMapBasedHolder implements RawKeyHolder {
-    private final Object2IntOpenHashMap<IntArray> _rawKeyToGroupIdMap = new Object2IntOpenHashMap<>();
+    private final Object2IntOpenHashMap<IntArray> _rawKeyToGroupIdMap;
 
     private int _numGroups = 0;
 
-    public ArrayMapBasedHolder() {
+    public ArrayMapBasedHolder(int initialSize) {
+      _rawKeyToGroupIdMap = new Object2IntOpenHashMap<>(initialSize);
       _rawKeyToGroupIdMap.defaultReturnValue(INVALID_ID);
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org