You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/05/27 08:32:47 UTC

[GitHub] [ignite] tkalkirill commented on a diff in pull request #10045: IGNITE-17043 Shrink GridHandleTable on clear

tkalkirill commented on code in PR #10045:
URL: https://github.com/apache/ignite/pull/10045#discussion_r883392640


##########
modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java:
##########
@@ -107,6 +120,10 @@ public int lookup(Object obj) {
      * Resets table to its initial (empty) state.
      */
     public void clear() {
+        if (size < objs.length) {
+            shrink();

Review Comment:
   ```suggestion
               shrink();
               
               retrun;
   ```



##########
modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java:
##########
@@ -181,6 +198,24 @@ private void growEntries() {
         objs = newObjs;
     }
 
+    /**
+     * Tries to gradually shrink hash table by factor of two when it's cleared.
+     */
+    private void shrink() {
+        int newLen = objs.length;
+
+        if (newLen > initCap) {
+            int shrinked = (newLen - 1) / 2;
+            if (shrinked >= size)
+                newLen = shrinked;

Review Comment:
   ```suggestion
               int shrinked = newLen / 2;
               
               if (shrinked >= size)
                   newLen = shrinked;
   ```



-- 
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: notifications-unsubscribe@ignite.apache.org

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