Class CompactionIterator
- java.lang.Object
-
- org.apache.cassandra.db.compaction.CompactionInfo.Holder
-
- org.apache.cassandra.db.compaction.CompactionIterator
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.util.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
Constructors Constructor Description CompactionIterator(OperationType type, java.util.List<ISSTableScanner> scanners, AbstractCompactionController controller, long nowInSec, TimeUUID compactionId)
CompactionIterator(OperationType type, java.util.List<ISSTableScanner> scanners, AbstractCompactionController controller, long nowInSec, TimeUUID compactionId, ActiveCompactionsTracker activeCompactions, TopPartitionTracker.Collector topPartitionCollector)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
long
getBytesRead()
CompactionInfo
getCompactionInfo()
long[]
getMergedRowCounts()
long
getTotalSourceCQLRows()
boolean
hasNext()
boolean
isGlobal()
if this compaction involves several/all tables we can safely check globalCompactionsPaused in isStopRequested() belowTableMetadata
metadata()
UnfilteredRowIterator
next()
void
remove()
void
setTargetDirectory(java.lang.String targetDirectory)
java.lang.String
toString()
-
Methods inherited from class org.apache.cassandra.db.compaction.CompactionInfo.Holder
isStopRequested, stop
-
-
-
-
Constructor Detail
-
CompactionIterator
public CompactionIterator(OperationType type, java.util.List<ISSTableScanner> scanners, AbstractCompactionController controller, long nowInSec, TimeUUID compactionId)
-
CompactionIterator
public CompactionIterator(OperationType type, java.util.List<ISSTableScanner> scanners, AbstractCompactionController controller, long nowInSec, TimeUUID compactionId, ActiveCompactionsTracker activeCompactions, TopPartitionTracker.Collector topPartitionCollector)
-
-
Method Detail
-
metadata
public TableMetadata metadata()
- Specified by:
metadata
in interfaceUnfilteredPartitionIterator
-
getCompactionInfo
public CompactionInfo getCompactionInfo()
- Specified by:
getCompactionInfo
in classCompactionInfo.Holder
-
isGlobal
public boolean isGlobal()
Description copied from class:CompactionInfo.Holder
if this compaction involves several/all tables we can safely check globalCompactionsPaused in isStopRequested() below- Specified by:
isGlobal
in classCompactionInfo.Holder
-
setTargetDirectory
public void setTargetDirectory(java.lang.String targetDirectory)
-
getMergedRowCounts
public long[] getMergedRowCounts()
-
getTotalSourceCQLRows
public long getTotalSourceCQLRows()
-
getBytesRead
public long getBytesRead()
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<UnfilteredRowIterator>
-
next
public UnfilteredRowIterator next()
- Specified by:
next
in interfacejava.util.Iterator<UnfilteredRowIterator>
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<UnfilteredRowIterator>
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceBasePartitionIterator<UnfilteredRowIterator>
- Specified by:
close
in interfaceCloseableIterator<UnfilteredRowIterator>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-