diff --git a/src/java/org/apache/cassandra/db/compaction/UnifiedCompactionStrategy.java b/src/java/org/apache/cassandra/db/compaction/UnifiedCompactionStrategy.java index 13ff07dc6e56..bf1db0746120 100644 --- a/src/java/org/apache/cassandra/db/compaction/UnifiedCompactionStrategy.java +++ b/src/java/org/apache/cassandra/db/compaction/UnifiedCompactionStrategy.java @@ -581,9 +581,12 @@ public ShardingStats(Collection sstables, Range sstables, Range= 0.0, "Density must be non-negative, but was %s", density); + Preconditions.checkNotNull(shardManager, "shardManager must not be null"); + Preconditions.checkNotNull(controller, "controller must not be null"); + + int shardCountForDensity = controller.getNumShards(density * shardManager.shardSetCoverage()); + int coveredShardCount = shardManager.coveredShardCount(this.min, this.max, shardCountForDensity); + return new ShardingStats( + this.min, + this.max, + this.totalOnDiskSize, + this.overheadToDataRatio, + this.uniqueKeyRatio, + density, + shardCountForDensity, + coveredShardCount + ); + } } /// Get and store the sharding stats for a given aggregate