accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] milleruntime commented on a change in pull request #1002: Fix implicit casts of numbers & int multiplication
Date Fri, 01 Mar 2019 17:50:53 GMT
milleruntime commented on a change in pull request #1002: Fix implicit casts of numbers &
int multiplication
URL: https://github.com/apache/accumulo/pull/1002#discussion_r261697745
 
 

 ##########
 File path: core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCache.java
 ##########
 @@ -674,9 +678,9 @@ public long heapSize() {
   }
 
   public static long calculateOverhead(long maxSize, long blockSize, int concurrency) {
-    return CACHE_FIXED_OVERHEAD + ClassSize.CONCURRENT_HASHMAP
-        + ((int) Math.ceil(maxSize * 1.2 / blockSize) * ClassSize.CONCURRENT_HASHMAP_ENTRY)
-        + (concurrency * ClassSize.CONCURRENT_HASHMAP_SEGMENT);
+    long entryPart = Math.round(maxSize * 1.2 / blockSize) * CONCURRENT_HASHMAP_ENTRY;
+    long segmentPart = (long) concurrency * CONCURRENT_HASHMAP_SEGMENT;
+    return CACHE_FIXED_OVERHEAD + CONCURRENT_HASHMAP + entryPart + segmentPart;
 
 Review comment:
   I broke this calculation into multiple lines to make it easier to read/understand.  I then
replaced the `Math.ceil()` with `Math.round()` since it returns the proper type that we need.
 All of the `ClassSize.CONCURRENT` constants are small int types but `concurrency` could be
larger so I casted that to a long.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

Mime
View raw message