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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
cfs
protected final ColumnFamilyStore cfs
options
protected final java.util.Map<java.lang.String,java.lang.String> options
AbstractCompactionStrategy
protected AbstractCompactionStrategy(ColumnFamilyStore cfs,
java.util.Map<java.lang.String,java.lang.String> options)
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.
getNextBackgroundTask
public abstract AbstractCompactionTask getNextBackgroundTask(int gcBefore)
- Parameters:
gcBefore
- throw away tombstones older than this
- Returns:
- the next background/minor compaction task to run; null if nothing to do.
getMaximalTask
public abstract AbstractCompactionTask getMaximalTask(int gcBefore)
- 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.
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
filterSuspectSSTables
public static java.util.List<SSTableReader> filterSuspectSSTables(java.util.Collection<SSTableReader> originalCandidates)
- Filters SSTables that are to be blacklisted from the given collection
- Parameters:
originalCandidates
- The collection to check for blacklisted SSTables
- Returns:
- list of the SSTables with blacklisted ones filtered out
getScanners
public java.util.List<ICompactionScanner> getScanners(java.util.Collection<SSTableReader> sstables,
Range<Token> range)
throws java.io.IOException
- 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).
- Throws:
java.io.IOException
getScanners
public java.util.List<ICompactionScanner> getScanners(java.util.Collection<SSTableReader> toCompact)
throws java.io.IOException
- Throws:
java.io.IOException
Copyright © 2012 The Apache Software Foundation