org.apache.cassandra.db.compaction

## Class CompactionController

- java.lang.Object
- - org.apache.cassandra.db.compaction.CompactionController

All Implemented Interfaces:
  java.lang.AutoCloseable

Direct Known Subclasses:
  SSTableSplitter.SplitController, TimeWindowCompactionController

    public class CompactionController
    extends java.lang.Object
    implements java.lang.AutoCloseable

Manage compaction options.

### Field Summary

Fields
`ColumnFamilyStore` `cfs`
`int` `gcBefore`

### Constructor Summary

Constructors
`protected` `CompactionController(ColumnFamilyStore cfs, int maxValue)`
`` `CompactionController(ColumnFamilyStore cfs, java.util.Set<SSTableReader> compacting, int gcBefore)`
`` `CompactionController(ColumnFamilyStore cfs, java.util.Set<SSTableReader> compacting, int gcBefore, com.google.common.util.concurrent.RateLimiter limiter, CompactionParams.TombstoneOption tombstoneOption)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `close()`
`boolean` `compactingRepaired()`
`java.lang.String` `getColumnFamily()`
`java.util.Set<SSTableReader>` `getFullyExpiredSSTables()`
`static java.util.Set<SSTableReader>` `getFullyExpiredSSTables(ColumnFamilyStore cfStore, java.lang.Iterable<SSTableReader> compacting, java.lang.Iterable<SSTableReader> overlapping, int gcBefore)`
`static java.util.Set<SSTableReader>` `getFullyExpiredSSTables(ColumnFamilyStore cfStore, java.lang.Iterable<SSTableReader> compacting, java.lang.Iterable<SSTableReader> overlapping, int gcBefore, boolean ignoreOverlaps)` Finds expired sstables works something like this; 1.
`java.lang.String` `getKeyspace()`
`java.util.function.Predicate<java.lang.Long>` `getPurgeEvaluator(DecoratedKey key)`
`protected boolean` `ignoreOverlaps()` Is overlapped sstables ignored Control whether or not we are taking into account overlapping sstables when looking for fully expired sstables.
`void` `maybeRefreshOverlaps()`
`java.lang.Iterable<UnfilteredRowIterator>` `shadowSources(DecoratedKey key, boolean tombstoneOnly)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### cfs

    public final ColumnFamilyStore cfs

#### gcBefore

    public final int gcBefore

### Constructor Detail

#### CompactionController

    protected CompactionController(ColumnFamilyStore cfs,
                                   int maxValue)

#### CompactionController

    public CompactionController(ColumnFamilyStore cfs,
                                java.util.Set<SSTableReader> compacting,
                                int gcBefore)

#### CompactionController

    public CompactionController(ColumnFamilyStore cfs,
                                java.util.Set<SSTableReader> compacting,
                                int gcBefore,
                                com.google.common.util.concurrent.RateLimiter limiter,
                                CompactionParams.TombstoneOption tombstoneOption)

### Method Detail

#### maybeRefreshOverlaps

    public void maybeRefreshOverlaps()

#### getFullyExpiredSSTables

    public java.util.Set<SSTableReader> getFullyExpiredSSTables()

#### getFullyExpiredSSTables

    public static java.util.Set<SSTableReader> getFullyExpiredSSTables(ColumnFamilyStore cfStore,
                                                                       java.lang.Iterable<SSTableReader> compacting,
                                                                       java.lang.Iterable<SSTableReader> overlapping,
                                                                       int gcBefore,
                                                                       boolean ignoreOverlaps)

Finds expired sstables works something like this; 1. find "global" minTimestamp of overlapping sstables, compacting sstables and memtables containing any non-expired data 2. build a list of fully expired candidates 3. check if the candidates to be dropped actually can be dropped `(maxTimestamp < global minTimestamp)` - if not droppable, remove from candidates 4. return candidates.

Parameters:
  `cfStore` -
  `compacting` - we take the drop-candidates from this set, it is usually the sstables included in the compaction
  `overlapping` - the sstables that overlap the ones in compacting.
  `gcBefore` -
  `ignoreOverlaps` - don't check if data shadows/overlaps any data in other sstables
Returns:

#### getFullyExpiredSSTables

    public static java.util.Set<SSTableReader> getFullyExpiredSSTables(ColumnFamilyStore cfStore,
                                                                       java.lang.Iterable<SSTableReader> compacting,
                                                                       java.lang.Iterable<SSTableReader> overlapping,
                                                                       int gcBefore)

#### getKeyspace

    public java.lang.String getKeyspace()

#### getColumnFamily

    public java.lang.String getColumnFamily()

#### getPurgeEvaluator

    public java.util.function.Predicate<java.lang.Long> getPurgeEvaluator(DecoratedKey key)

Parameters:
  `key` -
Returns:
  a predicate for whether tombstones marked for deletion at the given time for the given partition are purgeable; we calculate this by checking whether the deletion time is less than the min timestamp of all SSTables containing his partition and not participating in the compaction. This means there isn't any data in those sstables that might still need to be suppressed by a tombstone at this timestamp.

#### close

    public void close()

Specified by:
  `close` in interface `java.lang.AutoCloseable`

#### compactingRepaired

    public boolean compactingRepaired()

#### shadowSources

    public java.lang.Iterable<UnfilteredRowIterator> shadowSources(DecoratedKey key,
                                                                   boolean tombstoneOnly)

#### ignoreOverlaps

    protected boolean ignoreOverlaps()

Is overlapped sstables ignored Control whether or not we are taking into account overlapping sstables when looking for fully expired sstables. In order to reduce the amount of work needed, we look for sstables that can be dropped instead of compacted. As a safeguard mechanism, for each time range of data in a sstable, we are checking globally to see if all data of this time range is fully expired before considering to drop the sstable. This strategy can retain for a long time a lot of sstables on disk (see CASSANDRA-13418) so this option control whether or not this check should be ignored.

Returns:
  false by default