## org.apache.cassandra.db.compaction
Class AbstractCompactionStrategy

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

Direct Known Subclasses:
  LeveledCompactionStrategy, SizeTieredCompactionStrategy

    public abstract class AbstractCompactionStrategy

extends java.lang.Object

Pluggable compaction strategy determines how SSTables get merged. There are two main goals: - perform background compaction constantly as needed; this typically makes a tradeoff between i/o done by compaction, and merging done at read time. - perform a full (maximum possible) compaction if requested by the user

Field Summary
`protected ColumnFamilyStore` `cfs`
`protected java.util.Map<java.lang.String,java.lang.String>` `options`

Constructor Summary
`protected` `AbstractCompactionStrategy(ColumnFamilyStore cfs, java.util.Map<java.lang.String,java.lang.String> options)`

Method Summary
`abstract java.util.List<AbstractCompactionTask>` `getBackgroundTasks(int gcBefore)`
`abstract int` `getEstimatedRemainingTasks()`
`abstract java.util.List<AbstractCompactionTask>` `getMaximalTasks(int gcBefore)`
`abstract long` `getMaxSSTableSize()`
`java.util.Map<java.lang.String,java.lang.String>` `getOptions()`
`abstract AbstractCompactionTask` `getUserDefinedTask(java.util.Collection<SSTableReader> sstables, int gcBefore)`
`abstract boolean` `isKeyExistenceExpensive(java.util.Set<? extends SSTable> sstablesToIgnore)`
`void` `shutdown()` Releases any resources if this strategy is shutdown (when the CFS is reloaded after a schema change).

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### cfs

    protected final ColumnFamilyStore cfs

### options

    protected final java.util.Map<java.lang.String,java.lang.String> options

Constructor Detail

### AbstractCompactionStrategy

    protected AbstractCompactionStrategy(ColumnFamilyStore cfs,
                                         java.util.Map<java.lang.String,java.lang.String> options)

Method Detail

### getOptions

    public java.util.Map<java.lang.String,java.lang.String> getOptions()

### shutdown

    public void shutdown()

  Releases any resources if this strategy is shutdown (when the CFS is reloaded after a schema change). Default is to do nothing.

### getBackgroundTasks

    public abstract java.util.List<AbstractCompactionTask> getBackgroundTasks(int gcBefore)

  Parameters:
    `gcBefore` - throw away tombstones older than this
  Returns:
    a list of compaction tasks that should run in the background to get the sstable count down to desired parameters. Will not be null, but may be empty.

### getMaximalTasks

    public abstract java.util.List<AbstractCompactionTask> getMaximalTasks(int gcBefore)

  Parameters:
    `gcBefore` - throw away tombstones older than this
  Returns:
    a list of compaction tasks that should be run to compact this columnfamilystore as much as possible. Will not be null, but may be empty.

### getUserDefinedTask

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

  Parameters:
    `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.)

### getEstimatedRemainingTasks

    public abstract int getEstimatedRemainingTasks()

  Returns:
    the number of background tasks estimated to still be needed for this columnfamilystore

### getMaxSSTableSize

    public abstract long getMaxSSTableSize()

  Returns:
    size in bytes of the largest sstables for this strategy

### isKeyExistenceExpensive

    public abstract boolean isKeyExistenceExpensive(java.util.Set<? extends SSTable> sstablesToIgnore)

  Returns:
    true if checking for whether a key exists, ignoring @param sstablesToIgnore, is going to be expensive

Copyright © 2012 The Apache Software Foundation