Source:
<code>private int sweepBatch(TableReference tableRef, List<CellToSweep> batch, RunType runType, int deleteBatchSize) { int numberOfSweptCells = 0; Multimap<Cell, Long> currentBatch = ArrayListMultimap.create(); List<Cell> currentBatchSentinels = Lists.newArrayList(); for (CellToSweep cell : batch) { if (cell.needsSentinel()) { currentBatchSentinels.add(cell.cell()); } <START> if (currentBatch.size() + cell.sortedTimestamps().size() < deleteBatchSize) { <END> currentBatch.putAll(cell.cell(), TDecorators.wrap(cell.sortedTimestamps())); continue; } TLongList remainingCellTimestamps = cell.sortedTimestamps(); while (currentBatch.size() + remainingCellTimestamps.size() >= deleteBatchSize) { int numberOfTimestampsForThisBatch = deleteBatchSize - currentBatch.size(); TLongList timestampsForThisBatch = remainingCellTimestamps.subList(0, numberOfTimestampsForThisBatch); currentBatch.putAll(cell.cell(), TDecorators.wrap(timestampsForThisBatch)); if (runType == RunType.FULL) { cellsSweeper.sweepCells(tableRef, currentBatch, currentBatchSentinels); } numberOfSweptCells += currentBatch.size(); currentBatch = ArrayListMultimap.create(); currentBatchSentinels = Lists.newArrayList(); remainingCellTimestamps = remainingCellTimestamps.subList( numberOfTimestampsForThisBatch, remainingCellTimestamps.size()); } currentBatch.putAll(cell.cell(), TDecorators.wrap(remainingCellTimestamps)); } if (!currentBatch.isEmpty() && runType == RunType.FULL) { cellsSweeper.sweepCells(tableRef, currentBatch, currentBatchSentinels); } numberOfSweptCells += currentBatch.size(); return numberOfSweptCells; }</code><technical_language>I a larger number for maximum batch size, e.g. 2 * deleteBatchSize discussed before. partitioning code return batches deleteBatchSize (cell, ts) pairs, want batch broken delete() calls</technical_language>

Target:
private int sweepBatch(TableReference tableRef, List<CellToSweep> batch, RunType runType, int deleteBatchSize) { int numberOfSweptCells = 0; Multimap<Cell, Long> currentBatch = ArrayListMultimap.create(); List<Cell> currentBatchSentinels = Lists.newArrayList(); for (CellToSweep cell : batch) { if (cell.needsSentinel()) { currentBatchSentinels.add(cell.cell()); } List<Long> currentCellTimestamps = TDecorators.wrap(cell.sortedTimestamps()); if (currentBatch.size() + currentCellTimestamps.size() < deleteBatchSize) { currentBatch.putAll(cell.cell(), currentCellTimestamps); continue; } while (currentBatch.size() + currentCellTimestamps.size() >= deleteBatchSize) { int numberOfTimestampsForThisBatch = deleteBatchSize - currentBatch.size(); currentBatch.putAll(cell.cell(), currentCellTimestamps.subList(0, numberOfTimestampsForThisBatch)); if (runType == RunType.FULL) { cellsSweeper.sweepCells(tableRef, currentBatch, currentBatchSentinels); } numberOfSweptCells += currentBatch.size(); currentBatch.clear(); currentBatchSentinels.clear(); currentCellTimestamps = currentCellTimestamps.subList( numberOfTimestampsForThisBatch, currentCellTimestamps.size()); } currentBatch.putAll(cell.cell(), currentCellTimestamps); } if (!currentBatch.isEmpty() && runType == RunType.FULL) { cellsSweeper.sweepCells(tableRef, currentBatch, currentBatchSentinels); } numberOfSweptCells += currentBatch.size(); return numberOfSweptCells; }