private WriteBatch getBatchOfWrites(SweepableCellsRow row, PeekingIterator<Map.Entry<Cell, Value>> resultIterator, long sweepTs) { WriteBatch writeBatch = new WriteBatch(); while (resultIterator.hasNext() && writeBatch.writesByStartTs.size() < SweepQueueUtils.SWEEP_BATCH_SIZE) { Map.Entry<Cell, Value> entry = resultIterator.next(); SweepableCellsTable.SweepableCellsColumn col = computeColumn(entry); long startTs = getTimestamp(row, col); if (knownToBeCommittedAfterSweepTs(startTs, sweepTs)) { writeBatch.add(ImmutableList.of(getWriteInfo(startTs, entry.getValue()))); return writeBatch; } writeBatch.merge(getWrites(row, col, entry.getValue())); } // there may be entries remaining with the same start timestamp as the last processed one. If that is the case // we want to include these ones as well. This is OK since there are at most MAX_CELLS_GENERIC - 1 of them. while (resultIterator.hasNext()) { Map.Entry<Cell, Value> entry = resultIterator.peek(); SweepableCellsTable.SweepableCellsColumn col = computeColumn(entry); long timestamp = getTimestamp(row, col); if (writeBatch.writesByStartTs.containsKey(timestamp)) { writeBatch.merge(getWrites(row, col, entry.getValue())); resultIterator.next(); } else { break; } } return writeBatch; }
private WriteBatch getBatchOfWrites(SweepableCellsRow row, PeekingIterator<Map.Entry<Cell, Value>> resultIterator, long sweepTs) { WriteBatch writeBatch = new WriteBatch(); while (resultIterator.hasNext() && writeBatch.writesByStartTs.size() < SweepQueueUtils.SWEEP_BATCH_SIZE) { Map.Entry<Cell, Value> entry = resultIterator.next(); SweepableCellsTable.SweepableCellsColumn col = computeColumn(entry); long startTs = getTimestamp(row, col); if (knownToBeCommittedAfterSweepTs(startTs, sweepTs)) { writeBatch.add(ImmutableList.of(getWriteInfo(startTs, entry.getValue()))); return writeBatch; } writeBatch.merge(getWrites(row, col, entry.getValue())); } // there may be entries remaining with the same start timestamp as the last processed one. If that is the case // we want to include these ones as well. This is OK since there are at most MAX_CELLS_GENERIC - 1 of them. while (resultIterator.hasNext()) { Map.Entry<Cell, Value> entry = resultIterator.peek(); SweepableCellsTable.SweepableCellsColumn col = computeColumn(entry); long timestamp = getTimestamp(row, col); if (writeBatch.writesByStartTs.containsKey(timestamp)) { writeBatch.merge(getWrites(row, col, entry.getValue())); resultIterator.next(); } else { break; } } return writeBatch; }