You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@orc.apache.org by GitBox <gi...@apache.org> on 2021/07/17 23:52:49 UTC

[GitHub] [orc] belugabehr commented on a change in pull request #751: ORC-848: Recycle Internal Buffer in StringHashTableDictionary

belugabehr commented on a change in pull request #751:
URL: https://github.com/apache/orc/pull/751#discussion_r671757568



##########
File path: java/core/src/java/org/apache/orc/impl/StringHashTableDictionary.java
##########
@@ -75,18 +75,19 @@ public StringHashTableDictionary(int initialCapacity, float loadFactor) {
     this.capacity = initialCapacity;
     this.loadFactor = loadFactor;
     this.keyOffsets = new DynamicIntArray(initialCapacity);
-    initHashBuckets(initialCapacity);
+    initHashBuckets(false);
     this.threshold = (int)Math.min(initialCapacity * loadFactor, MAX_ARRAY_SIZE + 1);
   }
 
-  private void initHashBuckets(int capacity) {
-    DynamicIntArray[] buckets = new DynamicIntArray[capacity];
-    for (int i = 0; i < capacity; i++) {
+  private void initHashBuckets(final boolean reinit) {
+    final DynamicIntArray[] newBuckets =
+        (reinit) ? this.hashBuckets : new DynamicIntArray[this.capacity];
+    for (int i = 0; i < this.capacity; i++) {
       // We don't need large bucket: If we have more than a handful of collisions,
       // then the table is too small or the function isn't good.
-      buckets[i] = createBucket();
+      newBuckets[i] = createBucket();

Review comment:
       Hello. Thanks for the review. The purpose of this patch is to preserve the `buckets` array since this method simply repopulates the contents. There's no reason to throw away a 4KB array to simply replace it with a new one .




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

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