private synchronized int doEvict(Transaction transaction) throws IOException {
final byte[] stopRow = QueueEntryRow.getStopRowForTransaction(queueRowPrefix, transaction);
Row row;
List<byte[]> rowsToDelete = Lists.newArrayList();
// the scan must be non-transactional in order to see the state columns (which have latest timestamp)
Scanner scanner = core.scan(queueRowPrefix, stopRow, null, null, Transaction.ALL_VISIBLE_LATEST);
try {
while ((row = scanner.next()) != null) {
int processed = 0;
for (Map.Entry<byte[], byte[]> entry : row.getColumns().entrySet()) {
// is it a state column for a consumer instance?
if (!QueueEntryRow.isStateColumn(entry.getKey())) {
continue;
}
// is the write pointer of this state committed w.r.t. the current transaction, and is it processed?
if (QueueEntryRow.isCommittedProcessed(entry.getValue(), transaction)) {
++processed;
}
}
if (processed >= numGroups) {
rowsToDelete.add(row.getRow());
}
}
} finally {
scanner.close();
}
if (!rowsToDelete.isEmpty()) {
core.deleteRows(rowsToDelete);
LOG.trace("Evicted {} entries from queue {}", rowsToDelete.size(), name);
} else {