nikhilkumawat03 commented on code in PR #4228:
URL: https://github.com/apache/cassandra/pull/4228#discussion_r2191405866
##########
src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java:
##########
@@ -600,6 +605,19 @@ public static Map<String, String>
validateOptions(Map<String, String> options) t
throw new ConfigurationException(String.format("%s is not a
parsable int (base10) for %s", size, LEVEL_FANOUT_SIZE_OPTION), ex);
}
+ // Validate max Bytes for a level
+ try {
+ long maxSSTableSizeInBytes = Math.multiplyExact(ssSize, 1024L *
1024L); // Convert MB to Bytes
+ double maxBytes = Math.pow(fanoutSize, MAX_LEVEL_COUNT) *
maxSSTableSizeInBytes;
+ if (Double.isInfinite(maxBytes) || maxBytes > Long.MAX_VALUE)
Review Comment:
I agree that double’s limited precision could lead to inaccuracies. To
address this, I’ve updated the code to use BigInteger for exact integer
arithmetic, which eliminates precision loss for this calculation.
Since the inputs (fanoutSize, ssSize, MAX_LEVEL_COUNT) and the result are
all integers, BigInteger is sufficient and avoids the overhead of BigDecimal’s
decimal handling.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]