dcapwell commented on code in PR #4228: URL: https://github.com/apache/cassandra/pull/4228#discussion_r2282766462
########## src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java: ########## @@ -589,15 +595,31 @@ public static Map<String, String> validateOptions(Map<String, String> options) t String levelFanoutSize = options.containsKey(LEVEL_FANOUT_SIZE_OPTION) ? options.get(LEVEL_FANOUT_SIZE_OPTION) : String.valueOf(DEFAULT_LEVEL_FANOUT_SIZE); try { - int fanoutSize = Integer.parseInt(levelFanoutSize); + fanoutSize = Integer.parseInt(levelFanoutSize); if (fanoutSize < 1) { throw new ConfigurationException(String.format("%s must be larger than 0, but was %s", LEVEL_FANOUT_SIZE_OPTION, fanoutSize)); } } catch (NumberFormatException ex) { - throw new ConfigurationException(String.format("%s is not a parsable int (base10) for %s", size, LEVEL_FANOUT_SIZE_OPTION), ex); + throw new ConfigurationException(String.format("%s is not a parsable int (base10) for %s", levelFanoutSize, LEVEL_FANOUT_SIZE_OPTION), ex); + } + + // Validate max Bytes for a level + try + { + long maxSSTableSizeInBytes = Math.multiplyExact(ssSize, 1024L * 1024L); // Convert MB to Bytes + BigInteger fanoutPower = BigInteger.valueOf(fanoutSize).pow(MAX_LEVEL_COUNT); Review Comment: the logic that throws is ``` public static long maxBytesForLevel(int level, int levelFanoutSize, long maxSSTableSizeInBytes) { if (level == 0) return 4L * maxSSTableSizeInBytes; double bytes = Math.pow(levelFanoutSize, level) * maxSSTableSizeInBytes; if (bytes > Long.MAX_VALUE) throw new RuntimeException("At most " + Long.MAX_VALUE + " bytes may be in a compaction level; your maxSSTableSize must be absurdly high to compute " + bytes); return (long) bytes; } ``` and ``` // It includes L0, i.e. we support [L0 - L8] levels static final int MAX_LEVEL_COUNT = 9; ``` So max level is 8 for input, so `Math.pow(levelFanoutSize, 8)` is the largest thing we will see, yet this logic currently does `9`, so yeah `9 - 1` makes sense to me. -- 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: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org