Class LeveledCompactionStrategy
java.lang.Object
org.apache.cassandra.db.compaction.AbstractCompactionStrategy
org.apache.cassandra.db.compaction.LeveledCompactionStrategy
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.cassandra.db.compaction.AbstractCompactionStrategy
AbstractCompactionStrategy.ScannerList -
Field Summary
FieldsFields 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
ConstructorsConstructorDescriptionLeveledCompactionStrategy(ColumnFamilyStore cfs, Map<String, String> options) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSSTable(SSTableReader added) Adds sstable, note that implementations must handle duplicate notifications here (added already being in the compaction strategy)voidaddSSTables(Iterable<SSTableReader> sstables) Adds sstables, note that implementations must handle duplicate notifications here (added already being in the compaction strategy)int[]long[]getCompactionTask(LifecycleTransaction txn, long gcBefore, long maxSSTableBytes) intintintgetLevelSize(int i) getMaximalTask(long gcBefore, boolean splitOutput) longgetNextBackgroundTask(long 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.getScanners(Collection<SSTableReader> sstables, Collection<Range<Token>> ranges) Returns a list of KeyScanners given sstables and a range on which to scan.protected Set<SSTableReader>Returns the sstables managed by this strategy instancegetUserDefinedTask(Collection<SSTableReader> sstables, long gcBefore) groupSSTablesForAntiCompaction(Collection<SSTableReader> ssTablesToGroup) Leveled compaction strategy has guarantees on the data contained within each level so we have to make sure we only create groups of SSTables with members from the same level.voidmetadataChanged(StatsMetadata oldMetadata, SSTableReader sstable) Called when the metadata has changed for an sstable - for example if the level changed Not called when repair status changes (which is also metadata), because this results in the sstable getting removed from the compaction strategy instance.voidremoveSSTable(SSTableReader sstable) Removes sstable from the strategy, implementations must be able to handle the sstable having already been removed.voidreplaceSSTables(Collection<SSTableReader> removed, Collection<SSTableReader> added) Replaces sstables in the compaction strategy Note that implementations must be able to handle duplicate notifications here (that removed are already gone and added have already been added)voidstartup()Performs any extra initialization requiredtoString()validateOptions(Map<String, String> options) Methods inherited from class org.apache.cassandra.db.compaction.AbstractCompactionStrategy
createSSTableMultiWriter, filterSuspectSSTables, getDirectories, getName, getScanners, getScanners, pause, removeSSTables, resume, shutdown, supportsEarlyOpen, worthDroppingTombstones
-
Field Details
-
DEFAULT_LEVEL_FANOUT_SIZE
public static final int DEFAULT_LEVEL_FANOUT_SIZE- See Also:
-
-
Constructor Details
-
LeveledCompactionStrategy
-
-
Method Details
-
getLevelSize
public int getLevelSize(int i) -
getAllLevelSize
public int[] getAllLevelSize() -
getAllLevelSizeBytes
public long[] getAllLevelSizeBytes() -
startup
public void startup()Description copied from class:AbstractCompactionStrategyPerforms any extra initialization required- Overrides:
startupin classAbstractCompactionStrategy
-
getNextBackgroundTask
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:
getNextBackgroundTaskin 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
- Specified by:
getMaximalTaskin 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
- Specified by:
getUserDefinedTaskin 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.
-
getCompactionTask
public AbstractCompactionTask getCompactionTask(LifecycleTransaction txn, long gcBefore, long maxSSTableBytes) - Overrides:
getCompactionTaskin classAbstractCompactionStrategy
-
groupSSTablesForAntiCompaction
public Collection<Collection<SSTableReader>> groupSSTablesForAntiCompaction(Collection<SSTableReader> ssTablesToGroup) Leveled compaction strategy has guarantees on the data contained within each level so we have to make sure we only create groups of SSTables with members from the same level. This way we won't end up creating invalid sstables during anti-compaction.- Overrides:
groupSSTablesForAntiCompactionin classAbstractCompactionStrategy- Parameters:
ssTablesToGroup-- Returns:
- Groups of sstables from the same level
-
getEstimatedRemainingTasks
public int getEstimatedRemainingTasks()- Specified by:
getEstimatedRemainingTasksin classAbstractCompactionStrategy- Returns:
- the number of background tasks estimated to still be needed for this columnfamilystore
-
getMaxSSTableBytes
public long getMaxSSTableBytes()- Specified by:
getMaxSSTableBytesin classAbstractCompactionStrategy- Returns:
- size in bytes of the largest sstables for this strategy
-
getLevelFanoutSize
public int getLevelFanoutSize() -
getScanners
public AbstractCompactionStrategy.ScannerList getScanners(Collection<SSTableReader> sstables, Collection<Range<Token>> ranges) Description copied from class:AbstractCompactionStrategyReturns 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:
getScannersin classAbstractCompactionStrategy
-
replaceSSTables
Description copied from class:AbstractCompactionStrategyReplaces sstables in the compaction strategy Note that implementations must be able to handle duplicate notifications here (that removed are already gone and added have already been added)- Overrides:
replaceSSTablesin classAbstractCompactionStrategy
-
metadataChanged
Description copied from class:AbstractCompactionStrategyCalled when the metadata has changed for an sstable - for example if the level changed Not called when repair status changes (which is also metadata), because this results in the sstable getting removed from the compaction strategy instance.- Overrides:
metadataChangedin classAbstractCompactionStrategy
-
addSSTables
Description copied from class:AbstractCompactionStrategyAdds sstables, note that implementations must handle duplicate notifications here (added already being in the compaction strategy)- Overrides:
addSSTablesin classAbstractCompactionStrategy
-
addSSTable
Description copied from class:AbstractCompactionStrategyAdds sstable, note that implementations must handle duplicate notifications here (added already being in the compaction strategy)- Specified by:
addSSTablein classAbstractCompactionStrategy
-
removeSSTable
Description copied from class:AbstractCompactionStrategyRemoves sstable from the strategy, implementations must be able to handle the sstable having already been removed.- Specified by:
removeSSTablein classAbstractCompactionStrategy
-
getSSTables
Description copied from class:AbstractCompactionStrategyReturns the sstables managed by this strategy instance- Specified by:
getSSTablesin classAbstractCompactionStrategy
-
toString
-
strategyLogger
- Overrides:
strategyLoggerin classAbstractCompactionStrategy
-
validateOptions
public static Map<String,String> validateOptions(Map<String, String> options) throws ConfigurationException- Throws:
ConfigurationException
-