You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/09/14 04:50:54 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #29744: [SPARK-32872][CORE] Prevent BytesToBytesMap at MAX_CAPACITY from exceeding growth threshold

cloud-fan commented on a change in pull request #29744:
URL: https://github.com/apache/spark/pull/29744#discussion_r487650024



##########
File path: core/src/main/java/org/apache/spark/unsafe/map/BytesToBytesMap.java
##########
@@ -816,6 +816,12 @@ public boolean append(Object kbase, long koff, int klen, Object vbase, long voff
           } catch (SparkOutOfMemoryError oom) {
             canGrowArray = false;
           }
+        } else if (numKeys >= growthThreshold && longArray.size() / 2 >= MAX_CAPACITY) {

Review comment:
       it should be more readable to combine the common condition:
   ```
   // The map has reached its growth threshold, try to grow it
   if (numKeys >= growthThreshold) {
     // We use two array entries per key ...
     if (longArray.size() / 2 < MAX_CAPACITY) {
        ...
     } else {
       // It's already at MAX_CAPACITY and cannot grow ...
       canGrowArray = false;
     }
   }
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org