Jackie-Jiang commented on a change in pull request #6559:
URL: https://github.com/apache/incubator-pinot/pull/6559#discussion_r573383852



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DictionaryBasedGroupKeyGenerator.java
##########
@@ -831,6 +777,156 @@ private String getGroupKey(IntArray rawKey) {
     return groupKeyBuilder.toString();
   }
 
+  /**
+   * Fast int-to-int hashmap with {@link #INVALID_ID} as the default return 
value.
+   * <p>Different from {@link it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap}, 
this map uses one single array to store
+   * keys and values to reduce the cache miss.
+   */
+  @VisibleForTesting
+  public static class IntGroupIdMap {
+    private static final float LOAD_FACTOR = 0.75f;
+
+    private int[] _keyValueHolder;
+    private int _capacity;
+    private int _mask;
+    private int _maxNumEntries;
+    private int _size;
+
+    public IntGroupIdMap() {
+      _capacity = 1 << 10;
+      int holderSize = _capacity << 1;

Review comment:
       We don't want to start with a too small map, nor a too large map. Small 
map will result in more hash collisions and more resizes. Large map will result 
in bigger memory footprint. A map of capacity 1024 is quite small, but we will 
expand and cache it if we need a larger map. This value does not matter that 
much as long as it is not too large.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



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

Reply via email to