org.apache.cassandra.db.compaction

## Class LeveledCompactionStrategy

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

- All Implemented Interfaces:
    INotificationConsumer

      public class LeveledCompactionStrategy
      extends AbstractCompactionStrategy
      implements INotificationConsumer

- - ### Field Summary

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

      `cfs, DEFAULT_TOMBSTONE_COMPACTION_INTERVAL, DEFAULT_TOMBSTONE_THRESHOLD, options, TOMBSTONE_COMPACTION_INTERVAL_OPTION, TOMBSTONE_THRESHOLD_OPTION, tombstoneCompactionInterval, tombstoneThreshold`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LeveledCompactionStrategy(ColumnFamilyStore cfs, java.util.Map<java.lang.String,java.lang.String> options)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int[]` | `getAllLevelSize()`
    `int` | `getEstimatedRemainingTasks()`
    `int` | `getLevelSize(int i)`
    `AbstractCompactionTask` | `getMaximalTask(int gcBefore)`
    `long` | `getMaxSSTableSize()`
    `AbstractCompactionTask` | `getNextBackgroundTask(int gcBefore)` the only difference between background and maximal in LCS is that maximal is still allowed (by explicit user request) even when compaction is disabled.
    `java.util.List<ICompactionScanner>` | `getScanners(java.util.Collection<SSTableReader> sstables, Range<Token> range)` Returns a list of KeyScanners given sstables and a range on which to scan.
    `AbstractCompactionTask` | `getUserDefinedTask(java.util.Collection<SSTableReader> sstables, int gcBefore)`
    `void` | `handleNotification(INotification notification, java.lang.Object sender)`
    `void` | `shutdown()` Releases any resources if this strategy is shutdown (when the CFS is reloaded after a schema change).
    `java.lang.String` | `toString()`
    `static java.util.Map<java.lang.String,java.lang.String>` | `validateOptions(java.util.Map<java.lang.String,java.lang.String> options)`

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

      `filterSuspectSSTables, getScanners, worthDroppingTombstones`

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

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

- - ### Constructor Detail

    - #### LeveledCompactionStrategy

          public LeveledCompactionStrategy(ColumnFamilyStore cfs,
                                   java.util.Map<java.lang.String,java.lang.String> options)

  - ### Method Detail

    - #### 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). Default is to do nothing.
      Overrides:
        `shutdown` in class `AbstractCompactionStrategy`

    - #### getLevelSize

          public int getLevelSize(int i)

    - #### getAllLevelSize

          public int[] getAllLevelSize()

    - #### getNextBackgroundTask

          public AbstractCompactionTask getNextBackgroundTask(int gcBefore)

      the only difference between background and maximal in LCS is that maximal is still allowed (by explicit user request) even when compaction is disabled.
      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 AbstractCompactionTask getMaximalTask(int gcBefore)

      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.

    - #### 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

    - #### handleNotification

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

      Specified by:
        `handleNotification` in interface `INotificationConsumer`

    - #### getMaxSSTableSize

          public long getMaxSSTableSize()

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

    - #### getScanners

          public java.util.List<ICompactionScanner> 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`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### validateOptions

          public static java.util.Map<java.lang.String,java.lang.String> validateOptions(java.util.Map<java.lang.String,java.lang.String> options)
                                                                                  throws ConfigurationException

      Throws:
        `ConfigurationException`

Copyright © 2014 The Apache Software Foundation