Skip to content

Commit e401420

Browse files
jasonstackdjatnieks
authored andcommitted
CNDB-12459: add API to get major compaction tasks for given sstables (#1570)
1 parent e7690cf commit e401420

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/java/org/apache/cassandra/db/compaction/UnifiedCompactionStrategy.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.function.BiPredicate;
3131
import java.util.regex.Matcher;
3232
import java.util.regex.Pattern;
33+
import java.util.stream.Collectors;
3334

3435
import com.google.common.annotations.VisibleForTesting;
3536
import com.google.common.base.Preconditions;
@@ -215,14 +216,24 @@ public synchronized CompactionTasks getUserDefinedTasks(Collection<? extends Com
215216
/// same effect as compacting all of the sstables in the arena together in one operation.
216217
public synchronized List<CompactionAggregate.UnifiedAggregate> getMaximalAggregates()
217218
{
218-
maybeUpdateSelector();
219+
return getMaximalAggregates(realm.getLiveSSTables());
220+
}
221+
222+
public synchronized List<CompactionAggregate.UnifiedAggregate> getMaximalAggregates(Collection<? extends CompactionSSTable> sstables)
223+
{
224+
maybeUpdateSelector(); // must be called before computing compaction arenas
225+
return getMaximalAggregatesWithArenas(getCompactionArenas(sstables, UnifiedCompactionStrategy::isSuitableForCompaction));
226+
}
227+
228+
private synchronized List<CompactionAggregate.UnifiedAggregate> getMaximalAggregatesWithArenas(Collection<Arena> compactionArenas)
229+
{
219230
// The aggregates are split into arenas by repair status and disk, as well as in non-overlapping sections to
220231
// enable some parallelism and efficient use of extra space. The result will be split across shards according to
221232
// its density.
222233
// Depending on the parallelism, the operation may require up to 100% extra space to complete.
223234
List<CompactionAggregate.UnifiedAggregate> aggregates = new ArrayList<>();
224235

225-
for (Arena arena : getCompactionArenas(realm.getLiveSSTables(), UnifiedCompactionStrategy::isSuitableForCompaction))
236+
for (Arena arena : compactionArenas)
226237
{
227238
// If possible, we want to issue separate compactions for non-overlapping sets of sstables, to allow
228239
// for smaller extra space requirements. However, if the sharding configuration has changed, a major

0 commit comments

Comments
 (0)