Class CompactionIterator
java.lang.Object
org.apache.cassandra.db.compaction.CompactionInfo.Holder
org.apache.cassandra.db.compaction.CompactionIterator
- All Implemented Interfaces:
AutoCloseable,Iterator<UnfilteredRowIterator>,BasePartitionIterator<UnfilteredRowIterator>,UnfilteredPartitionIterator,CloseableIterator<UnfilteredRowIterator>
public class CompactionIterator
extends CompactionInfo.Holder
implements UnfilteredPartitionIterator
Merge multiple iterators over the content of sstable into a "compacted" iterator.
On top of the actual merging the source iterators, this class:
- purge gc-able tombstones if possible (see PurgeIterator below).
- update 2ndary indexes if necessary (as we don't read-before-write on index updates, index entries are not deleted on deletion of the base table data, which is ok because we'll fix index inconsistency on reads. This however mean that potentially obsolete index entries could be kept a long time for data that is not read often, so compaction "pro-actively" fix such index entries. This is mainly an optimization).
- invalidate cached partitions that are empty post-compaction. This avoids keeping partitions with only purgable tombstones in the row cache.
- keep tracks of the compaction progress.
-
Constructor Summary
ConstructorsConstructorDescriptionCompactionIterator(OperationType type, List<ISSTableScanner> scanners, AbstractCompactionController controller, long nowInSec, TimeUUID compactionId) CompactionIterator(OperationType type, List<ISSTableScanner> scanners, AbstractCompactionController controller, long nowInSec, TimeUUID compactionId, ActiveCompactionsTracker activeCompactions, TopPartitionTracker.Collector topPartitionCollector) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()longlong[]longbooleanhasNext()booleanisGlobal()if this compaction involves several/all tables we can safely check globalCompactionsPaused in isStopRequested() belowmetadata()next()voidremove()voidsetTargetDirectory(String targetDirectory) toString()Methods inherited from class org.apache.cassandra.db.compaction.CompactionInfo.Holder
isStopRequested, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
CompactionIterator
public CompactionIterator(OperationType type, List<ISSTableScanner> scanners, AbstractCompactionController controller, long nowInSec, TimeUUID compactionId) -
CompactionIterator
public CompactionIterator(OperationType type, List<ISSTableScanner> scanners, AbstractCompactionController controller, long nowInSec, TimeUUID compactionId, ActiveCompactionsTracker activeCompactions, TopPartitionTracker.Collector topPartitionCollector)
-
-
Method Details
-
metadata
- Specified by:
metadatain interfaceUnfilteredPartitionIterator
-
getCompactionInfo
- Specified by:
getCompactionInfoin classCompactionInfo.Holder
-
isGlobal
public boolean isGlobal()Description copied from class:CompactionInfo.Holderif this compaction involves several/all tables we can safely check globalCompactionsPaused in isStopRequested() below- Specified by:
isGlobalin classCompactionInfo.Holder
-
setTargetDirectory
-
getMergedRowCounts
public long[] getMergedRowCounts() -
getTotalSourceCQLRows
public long getTotalSourceCQLRows() -
getBytesRead
public long getBytesRead() -
hasNext
public boolean hasNext()- Specified by:
hasNextin interfaceIterator<UnfilteredRowIterator>
-
next
- Specified by:
nextin interfaceIterator<UnfilteredRowIterator>
-
remove
public void remove()- Specified by:
removein interfaceIterator<UnfilteredRowIterator>
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceBasePartitionIterator<UnfilteredRowIterator>- Specified by:
closein interfaceCloseableIterator<UnfilteredRowIterator>
-
toString
-