org.apache.cassandra.db.compaction

## Class WrappingCompactionStrategy

- java.lang.Object
- - org.apache.cassandra.db.compaction.AbstractCompactionStrategy
  - - org.apache.cassandra.db.compaction.WrappingCompactionStrategy

All Implemented Interfaces:
  INotificationConsumer

    public final class WrappingCompactionStrategy
    extends AbstractCompactionStrategy
    implements INotificationConsumer

### Nested Class Summary

### Nested classes/interfaces inherited from class org.apache.cassandra.db.compaction.AbstractCompactionStrategy

`AbstractCompactionStrategy.ScannerList`

### Field Summary

### Fields inherited from class org.apache.cassandra.db.compaction.AbstractCompactionStrategy

`cfs, COMPACTION_ENABLED, DEFAULT_TOMBSTONE_COMPACTION_INTERVAL, DEFAULT_TOMBSTONE_THRESHOLD, DEFAULT_UNCHECKED_TOMBSTONE_COMPACTION_OPTION, disableTombstoneCompactions, enabled, isActive, options, TOMBSTONE_COMPACTION_INTERVAL_OPTION, TOMBSTONE_THRESHOLD_OPTION, tombstoneCompactionInterval, tombstoneThreshold, UNCHECKED_TOMBSTONE_COMPACTION_OPTION, uncheckedTombstoneCompaction`

### Constructor Summary

Constructors
Constructor and Description
`WrappingCompactionStrategy(ColumnFamilyStore cfs)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `addSSTable(SSTableReader added)`
`void` `disable()`
`void` `enable()`
`java.util.List<SSTableReader>` `filterSSTablesForReads(java.util.List<SSTableReader> sstables)`
`AbstractCompactionTask` `getCompactionTask(LifecycleTransaction txn, int gcBefore, long maxSSTableBytes)`
`int` `getEstimatedRemainingTasks()`
`java.util.Collection<AbstractCompactionTask>` `getMaximalTask(int gcBefore, boolean splitOutput)`
`long` `getMaxSSTableBytes()`
`java.lang.String` `getName()`
`AbstractCompactionTask` `getNextBackgroundTask(int gcBefore)`
`AbstractCompactionStrategy.ScannerList` `getScanners(java.util.Collection<SSTableReader> sstables, Range<Token> range)` Returns a list of KeyScanners given sstables and a range on which to scan.
`int[]` `getSSTableCountPerLevel()`
`int` `getUnleveledSSTables()`
`AbstractCompactionTask` `getUserDefinedTask(java.util.Collection<SSTableReader> sstables, int gcBefore)`
`java.util.List<AbstractCompactionStrategy>` `getWrappedStrategies()`
`java.util.Collection<java.util.Collection<SSTableReader>>` `groupSSTablesForAntiCompaction(java.util.Collection<SSTableReader> sstablesToGroup)` Method for grouping similar SSTables together, This will be used by anti-compaction to determine which SSTables should be anitcompacted as a group.
`void` `handleNotification(INotification notification, java.lang.Object sender)`
`void` `maybeReloadCompactionStrategy(CFMetaData metadata)`
`void` `reloadCompactionStrategy(CFMetaData metadata)`
`void` `removeSSTable(SSTableReader sstable)`
`void` `replaceSSTables(java.util.Collection<SSTableReader> removed, java.util.Collection<SSTableReader> added)`
`void` `setNewLocalCompactionStrategy(java.lang.Class<? extends AbstractCompactionStrategy> compactionStrategyClass, java.util.Map<java.lang.String,java.lang.String> options)`
`boolean` `shouldDefragment()`
`void` `shutdown()` Releases any resources if this strategy is shutdown (when the CFS is reloaded after a schema change).
`void` `startup()` Performs any extra initialization required
`static int[]` `sumArrays(int[] a, int[] b)`

### Methods inherited from class org.apache.cassandra.db.compaction.AbstractCompactionStrategy

`filterSuspectSSTables, getMemtableReservedSize, getScanners, isAffectedByMeteredFlusher, isEnabled, pause, replaceFlushed, resume, shouldBeEnabled, validateOptions, worthDroppingTombstones`

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

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

### Constructor Detail

#### WrappingCompactionStrategy

    public WrappingCompactionStrategy(ColumnFamilyStore cfs)

### Method Detail

#### getNextBackgroundTask

    public AbstractCompactionTask getNextBackgroundTask(int gcBefore)

Specified by:
  `getNextBackgroundTask` in class `AbstractCompactionStrategy`
Parameters:
  `gcBefore` - throw away tombstones older than this
Returns:
  the next background/minor compaction task to run; null if nothing to do. Is responsible for marking its sstables as compaction-pending.

#### getMaximalTask

    public java.util.Collection<AbstractCompactionTask> getMaximalTask(int gcBefore,
                                                                       boolean splitOutput)

Specified by:
  `getMaximalTask` in class `AbstractCompactionStrategy`
Parameters:
  `gcBefore` - throw away tombstones older than this
Returns:
  a compaction task that should be run to compact this columnfamilystore as much as possible. Null if nothing to do. Is responsible for marking its sstables as compaction-pending.

#### getCompactionTask

    public AbstractCompactionTask getCompactionTask(LifecycleTransaction txn,
                                                    int gcBefore,
                                                    long maxSSTableBytes)

Overrides:
  `getCompactionTask` in class `AbstractCompactionStrategy`

#### getUserDefinedTask

    public AbstractCompactionTask getUserDefinedTask(java.util.Collection<SSTableReader> sstables,
                                                     int gcBefore)

Specified by:
  `getUserDefinedTask` in class `AbstractCompactionStrategy`
Parameters:
  `sstables` - SSTables to compact. Must be marked as compacting.
  `gcBefore` - throw away tombstones older than this
Returns:
  a compaction task corresponding to the requested sstables. Will not be null. (Will throw if user requests an invalid compaction.) Is responsible for marking its sstables as compaction-pending.

#### getEstimatedRemainingTasks

    public int getEstimatedRemainingTasks()

Specified by:
  `getEstimatedRemainingTasks` in class `AbstractCompactionStrategy`
Returns:
  the number of background tasks estimated to still be needed for this columnfamilystore

#### getMaxSSTableBytes

    public long getMaxSSTableBytes()

Specified by:
  `getMaxSSTableBytes` in class `AbstractCompactionStrategy`
Returns:
  size in bytes of the largest sstables for this strategy

#### maybeReloadCompactionStrategy

    public void maybeReloadCompactionStrategy(CFMetaData metadata)

#### reloadCompactionStrategy

    public void reloadCompactionStrategy(CFMetaData metadata)

#### getUnleveledSSTables

    public int getUnleveledSSTables()

#### getSSTableCountPerLevel

    public int[] getSSTableCountPerLevel()

#### sumArrays

    public static int[] sumArrays(int[] a,
                                  int[] b)

#### shouldDefragment

    public boolean shouldDefragment()

Overrides:
  `shouldDefragment` in class `AbstractCompactionStrategy`

#### getName

    public java.lang.String getName()

Overrides:
  `getName` in class `AbstractCompactionStrategy`

#### replaceSSTables

    public void replaceSSTables(java.util.Collection<SSTableReader> removed,
                                java.util.Collection<SSTableReader> added)

Overrides:
  `replaceSSTables` in class `AbstractCompactionStrategy`

#### addSSTable

    public void addSSTable(SSTableReader added)

Specified by:
  `addSSTable` in class `AbstractCompactionStrategy`

#### removeSSTable

    public void removeSSTable(SSTableReader sstable)

Specified by:
  `removeSSTable` in class `AbstractCompactionStrategy`

#### handleNotification

    public void handleNotification(INotification notification,
                                   java.lang.Object sender)

Specified by:
  `handleNotification` in interface `INotificationConsumer`

#### filterSSTablesForReads

    public java.util.List<SSTableReader> filterSSTablesForReads(java.util.List<SSTableReader> sstables)

Overrides:
  `filterSSTablesForReads` in class `AbstractCompactionStrategy`
Returns:
  a subset of the suggested sstables that are relevant for read requests.

#### startup

    public void startup()

Description copied from class: `AbstractCompactionStrategy`
Performs any extra initialization required

Overrides:
  `startup` in class `AbstractCompactionStrategy`

#### shutdown

    public void shutdown()

Description copied from class: `AbstractCompactionStrategy`
Releases any resources if this strategy is shutdown (when the CFS is reloaded after a schema change).

Overrides:
  `shutdown` in class `AbstractCompactionStrategy`

#### enable

    public void enable()

Overrides:
  `enable` in class `AbstractCompactionStrategy`

#### disable

    public void disable()

Overrides:
  `disable` in class `AbstractCompactionStrategy`

#### getScanners

    public AbstractCompactionStrategy.ScannerList getScanners(java.util.Collection<SSTableReader> sstables,
                                                              Range<Token> range)

Description copied from class: `AbstractCompactionStrategy`
Returns a list of KeyScanners given sstables and a range on which to scan. The default implementation simply grab one SSTableScanner per-sstable, but overriding this method allow for a more memory efficient solution if we know the sstable don't overlap (see LeveledCompactionStrategy for instance).

Overrides:
  `getScanners` in class `AbstractCompactionStrategy`

#### groupSSTablesForAntiCompaction

    public java.util.Collection<java.util.Collection<SSTableReader>> groupSSTablesForAntiCompaction(java.util.Collection<SSTableReader> sstablesToGroup)

Description copied from class: `AbstractCompactionStrategy`
Method for grouping similar SSTables together, This will be used by anti-compaction to determine which SSTables should be anitcompacted as a group. If a given compaction strategy creates sstables which cannot be merged due to some constraint it must override this method.

Overrides:
  `groupSSTablesForAntiCompaction` in class `AbstractCompactionStrategy`

#### getWrappedStrategies

    public java.util.List<AbstractCompactionStrategy> getWrappedStrategies()

#### setNewLocalCompactionStrategy

    public void setNewLocalCompactionStrategy(java.lang.Class<? extends AbstractCompactionStrategy> compactionStrategyClass,
                                              java.util.Map<java.lang.String,java.lang.String> options)