|
30 | 30 | import java.util.function.BiPredicate; |
31 | 31 | import java.util.regex.Matcher; |
32 | 32 | import java.util.regex.Pattern; |
| 33 | +import java.util.stream.Collectors; |
33 | 34 |
|
34 | 35 | import com.google.common.annotations.VisibleForTesting; |
35 | 36 | import com.google.common.base.Preconditions; |
@@ -215,14 +216,24 @@ public synchronized CompactionTasks getUserDefinedTasks(Collection<? extends Com |
215 | 216 | /// same effect as compacting all of the sstables in the arena together in one operation. |
216 | 217 | public synchronized List<CompactionAggregate.UnifiedAggregate> getMaximalAggregates() |
217 | 218 | { |
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 | + { |
219 | 230 | // The aggregates are split into arenas by repair status and disk, as well as in non-overlapping sections to |
220 | 231 | // enable some parallelism and efficient use of extra space. The result will be split across shards according to |
221 | 232 | // its density. |
222 | 233 | // Depending on the parallelism, the operation may require up to 100% extra space to complete. |
223 | 234 | List<CompactionAggregate.UnifiedAggregate> aggregates = new ArrayList<>(); |
224 | 235 |
|
225 | | - for (Arena arena : getCompactionArenas(realm.getLiveSSTables(), UnifiedCompactionStrategy::isSuitableForCompaction)) |
| 236 | + for (Arena arena : compactionArenas) |
226 | 237 | { |
227 | 238 | // If possible, we want to issue separate compactions for non-overlapping sets of sstables, to allow |
228 | 239 | // for smaller extra space requirements. However, if the sharding configuration has changed, a major |
|
0 commit comments