use of org.apache.cassandra.io.sstable.ISSTableScanner in project cassandra by apache.
the class GcCompactionTest method count.
int count(SSTableReader reader, Function<Unfiltered, Integer> predicate, Function<UnfilteredRowIterator, Integer> partitionPredicate) {
int instances = 0;
try (ISSTableScanner partitions = reader.getScanner()) {
while (partitions.hasNext()) {
try (UnfilteredRowIterator iter = partitions.next()) {
instances += partitionPredicate.apply(iter);
while (iter.hasNext()) {
Unfiltered atom = iter.next();
instances += predicate.apply(atom);
}
}
}
}
return instances;
}
use of org.apache.cassandra.io.sstable.ISSTableScanner in project cassandra by apache.
the class CompactionIteratorTest method iterate.
private void iterate(Unfiltered... unfiltereds) {
ColumnFamilyStore cfs = getCurrentColumnFamilyStore();
DecoratedKey key = cfs.getPartitioner().decorateKey(ByteBufferUtil.bytes("key"));
try (CompactionController controller = new CompactionController(cfs, Integer.MAX_VALUE);
UnfilteredRowIterator rows = rows(cfs.metadata(), key, false, unfiltereds);
ISSTableScanner scanner = new Scanner(Collections.singletonList(rows));
CompactionIterator iter = new CompactionIterator(OperationType.COMPACTION, Collections.singletonList(scanner), controller, FBUtilities.nowInSeconds(), null)) {
while (iter.hasNext()) {
try (UnfilteredRowIterator partition = iter.next()) {
partition.forEachRemaining(u -> {
});
}
}
}
}
use of org.apache.cassandra.io.sstable.ISSTableScanner in project cassandra by apache.
the class CompactionsCQLTest method assertTombstones.
private void assertTombstones(SSTableReader sstable, boolean expectTS) {
boolean foundTombstone = false;
try (ISSTableScanner scanner = sstable.getScanner()) {
while (scanner.hasNext()) {
try (UnfilteredRowIterator iter = scanner.next()) {
if (!iter.partitionLevelDeletion().isLive())
foundTombstone = true;
while (iter.hasNext()) {
Unfiltered unfiltered = iter.next();
assertTrue(unfiltered instanceof Row);
for (Cell<?> c : ((Row) unfiltered).cells()) {
if (c.isTombstone())
foundTombstone = true;
}
}
}
}
}
assertEquals(expectTS, foundTombstone);
}
use of org.apache.cassandra.io.sstable.ISSTableScanner in project cassandra by apache.
the class CompactionStrategyManager method maybeGetScanners.
/**
* Create ISSTableScanners from the given sstables
*
* Delegates the call to the compaction strategies to allow LCS to create a scanner
* @param sstables
* @param ranges
* @return
*/
@SuppressWarnings("resource")
public AbstractCompactionStrategy.ScannerList maybeGetScanners(Collection<SSTableReader> sstables, Collection<Range<Token>> ranges) {
maybeReloadDiskBoundaries();
List<ISSTableScanner> scanners = new ArrayList<>(sstables.size());
readLock.lock();
try {
List<GroupedSSTableContainer> sstableGroups = groupSSTables(sstables);
for (int i = 0; i < holders.size(); i++) {
AbstractStrategyHolder holder = holders.get(i);
GroupedSSTableContainer group = sstableGroups.get(i);
scanners.addAll(holder.getScanners(group, ranges));
}
} catch (PendingRepairManager.IllegalSSTableArgumentException e) {
ISSTableScanner.closeAllAndPropagate(scanners, new ConcurrentModificationException(e));
} finally {
readLock.unlock();
}
return new AbstractCompactionStrategy.ScannerList(scanners);
}
use of org.apache.cassandra.io.sstable.ISSTableScanner in project cassandra by apache.
the class GcCompactionTest method count.
int count(SSTableReader reader, ToIntFunction<Unfiltered> predicate, ToIntFunction<UnfilteredRowIterator> partitionPredicate) {
int instances = 0;
try (ISSTableScanner partitions = reader.getScanner()) {
while (partitions.hasNext()) {
try (UnfilteredRowIterator iter = partitions.next()) {
instances += partitionPredicate.applyAsInt(iter);
while (iter.hasNext()) {
Unfiltered atom = iter.next();
instances += predicate.applyAsInt(atom);
}
}
}
}
return instances;
}
Aggregations