Class SizeTieredCompactionStrategy
- java.lang.Object
-
- org.apache.cassandra.db.compaction.AbstractCompactionStrategy
-
- org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy
-
public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.cassandra.db.compaction.AbstractCompactionStrategy
AbstractCompactionStrategy.ScannerList
-
-
Field Summary
Fields Modifier and Type Field Description protected int
estimatedRemainingTasks
protected SizeTieredCompactionStrategyOptions
sizeTieredOptions
protected java.util.Set<SSTableReader>
sstables
-
Fields inherited from class org.apache.cassandra.db.compaction.AbstractCompactionStrategy
cfs, COMPACTION_ENABLED, DEFAULT_LOG_ALL_OPTION, DEFAULT_TOMBSTONE_COMPACTION_INTERVAL, DEFAULT_TOMBSTONE_THRESHOLD, DEFAULT_UNCHECKED_TOMBSTONE_COMPACTION_OPTION, disableTombstoneCompactions, isActive, LOG_ALL_OPTION, logAll, ONLY_PURGE_REPAIRED_TOMBSTONES, options, TOMBSTONE_COMPACTION_INTERVAL_OPTION, TOMBSTONE_THRESHOLD_OPTION, tombstoneCompactionInterval, tombstoneThreshold, UNCHECKED_TOMBSTONE_COMPACTION_OPTION, uncheckedTombstoneCompaction
-
-
Constructor Summary
Constructors Constructor Description SizeTieredCompactionStrategy(ColumnFamilyStore cfs, java.util.Map<java.lang.String,java.lang.String> options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSSTable(SSTableReader added)
Adds sstable, note that implementations must handle duplicate notifications here (added already being in the compaction strategy)static java.util.List<Pair<SSTableReader,java.lang.Long>>
createSSTableAndLengthPairs(java.lang.Iterable<SSTableReader> sstables)
static <T> java.util.List<java.util.List<T>>
getBuckets(java.util.Collection<Pair<T,java.lang.Long>> files, double bucketHigh, double bucketLow, long minSSTableSize)
static int
getEstimatedCompactionsByTasks(ColumnFamilyStore cfs, java.util.List<java.util.List<SSTableReader>> tasks)
int
getEstimatedRemainingTasks()
java.util.Collection<AbstractCompactionTask>
getMaximalTask(long gcBefore, boolean splitOutput)
long
getMaxSSTableBytes()
AbstractCompactionTask
getNextBackgroundTask(long gcBefore)
protected java.util.Set<SSTableReader>
getSSTables()
Returns the sstables managed by this strategy instanceAbstractCompactionTask
getUserDefinedTask(java.util.Collection<SSTableReader> sstables, long gcBefore)
static java.util.List<SSTableReader>
mostInterestingBucket(java.util.List<java.util.List<SSTableReader>> buckets, int minThreshold, int maxThreshold)
void
removeSSTable(SSTableReader sstable)
Removes sstable from the strategy, implementations must be able to handle the sstable having already been removed.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
addSSTables, createSSTableMultiWriter, filterSuspectSSTables, getCompactionTask, getDirectories, getName, getScanners, getScanners, getScanners, groupSSTablesForAntiCompaction, metadataChanged, pause, removeSSTables, replaceSSTables, resume, shutdown, startup, strategyLogger, supportsEarlyOpen, worthDroppingTombstones
-
-
-
-
Field Detail
-
sizeTieredOptions
protected SizeTieredCompactionStrategyOptions sizeTieredOptions
-
estimatedRemainingTasks
protected volatile int estimatedRemainingTasks
-
sstables
protected final java.util.Set<SSTableReader> sstables
-
-
Constructor Detail
-
SizeTieredCompactionStrategy
public SizeTieredCompactionStrategy(ColumnFamilyStore cfs, java.util.Map<java.lang.String,java.lang.String> options)
-
-
Method Detail
-
mostInterestingBucket
public static java.util.List<SSTableReader> mostInterestingBucket(java.util.List<java.util.List<SSTableReader>> buckets, int minThreshold, int maxThreshold)
- Parameters:
buckets
- list of buckets from which to return the most interesting, where "interesting" is the total hotness for readsminThreshold
- minimum number of sstables in a bucket to qualify as interestingmaxThreshold
- maximum number of sstables to compact at once (the returned bucket will be trimmed down to this)- Returns:
- a bucket (list) of sstables to compact
-
getNextBackgroundTask
public AbstractCompactionTask getNextBackgroundTask(long gcBefore)
- Specified by:
getNextBackgroundTask
in classAbstractCompactionStrategy
- 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(long gcBefore, boolean splitOutput)
- Specified by:
getMaximalTask
in classAbstractCompactionStrategy
- 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, long gcBefore)
- Specified by:
getUserDefinedTask
in classAbstractCompactionStrategy
- 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 classAbstractCompactionStrategy
- Returns:
- the number of background tasks estimated to still be needed for this columnfamilystore
-
createSSTableAndLengthPairs
public static java.util.List<Pair<SSTableReader,java.lang.Long>> createSSTableAndLengthPairs(java.lang.Iterable<SSTableReader> sstables)
-
getBuckets
public static <T> java.util.List<java.util.List<T>> getBuckets(java.util.Collection<Pair<T,java.lang.Long>> files, double bucketHigh, double bucketLow, long minSSTableSize)
-
getEstimatedCompactionsByTasks
public static int getEstimatedCompactionsByTasks(ColumnFamilyStore cfs, java.util.List<java.util.List<SSTableReader>> tasks)
-
getMaxSSTableBytes
public long getMaxSSTableBytes()
- Specified by:
getMaxSSTableBytes
in classAbstractCompactionStrategy
- Returns:
- size in bytes of the largest sstables for this strategy
-
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
-
addSSTable
public void addSSTable(SSTableReader added)
Description copied from class:AbstractCompactionStrategy
Adds sstable, note that implementations must handle duplicate notifications here (added already being in the compaction strategy)- Specified by:
addSSTable
in classAbstractCompactionStrategy
-
removeSSTable
public void removeSSTable(SSTableReader sstable)
Description copied from class:AbstractCompactionStrategy
Removes sstable from the strategy, implementations must be able to handle the sstable having already been removed.- Specified by:
removeSSTable
in classAbstractCompactionStrategy
-
getSSTables
protected java.util.Set<SSTableReader> getSSTables()
Description copied from class:AbstractCompactionStrategy
Returns the sstables managed by this strategy instance- Specified by:
getSSTables
in classAbstractCompactionStrategy
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-