use of org.apache.cassandra.io.sstable.format.SSTableReadsListener in project cassandra by apache.
the class PartitionRangeReadCommand method queryStorage.
@VisibleForTesting
public UnfilteredPartitionIterator queryStorage(final ColumnFamilyStore cfs, ReadExecutionController controller) {
ColumnFamilyStore.ViewFragment view = cfs.select(View.selectLive(dataRange().keyRange()));
Tracing.trace("Executing seq scan across {} sstables for {}", view.sstables.size(), dataRange().keyRange().getString(metadata().partitionKeyType));
// fetch data from current memtable, historical memtables, and SSTables in the correct order.
InputCollector<UnfilteredPartitionIterator> inputCollector = iteratorsForRange(view, controller);
try {
for (Memtable memtable : view.memtables) {
// We close on exception and on closing the result returned by this method
@SuppressWarnings("resource") Memtable.MemtableUnfilteredPartitionIterator iter = memtable.makePartitionIterator(columnFilter(), dataRange());
controller.updateMinOldestUnrepairedTombstone(iter.getMinLocalDeletionTime());
inputCollector.addMemtableIterator(RTBoundValidator.validate(iter, RTBoundValidator.Stage.MEMTABLE, false));
}
SSTableReadsListener readCountUpdater = newReadCountUpdater();
for (SSTableReader sstable : view.sstables) {
// We close on exception and on closing the result returned by this method
@SuppressWarnings("resource") UnfilteredPartitionIterator iter = sstable.getScanner(columnFilter(), dataRange(), readCountUpdater);
inputCollector.addSSTableIterator(sstable, RTBoundValidator.validate(iter, RTBoundValidator.Stage.SSTABLE, false));
if (!sstable.isRepaired())
controller.updateMinOldestUnrepairedTombstone(sstable.getMinLocalDeletionTime());
}
// iterators can be empty for offline tools
if (inputCollector.isEmpty())
return EmptyIterators.unfilteredPartition(metadata());
return checkCacheFilter(UnfilteredPartitionIterators.mergeLazily(inputCollector.finalizeIterators(cfs, nowInSec(), controller.oldestUnrepairedTombstone())), cfs);
} catch (RuntimeException | Error e) {
try {
inputCollector.close();
} catch (Exception e1) {
e.addSuppressed(e1);
}
throw e;
}
}
Aggregations