SweepBatch getNextBatchToSweep(ShardAndStrategy shardStrategy, long lastSweptTs, long sweepTs) { return sweepableTimestamps.nextSweepableTimestampPartition(shardStrategy, lastSweptTs, sweepTs) .map(fine -> sweepableCells.getBatchForPartition(shardStrategy, fine, lastSweptTs, sweepTs)) .orElse(SweepBatch.of(ImmutableList.of(), DedicatedRows.of(ImmutableList.of()), sweepTs - 1L)); } }
SweepBatch getBatchForPartition(ShardAndStrategy shardStrategy, long partitionFine, long minTsExclusive, long sweepTs) { SweepableCellsRow row = computeRow(partitionFine, shardStrategy); RowColumnRangeIterator resultIterator = getRowColumnRange(row, partitionFine, minTsExclusive, sweepTs); PeekingIterator<Map.Entry<Cell, Value>> peekingResultIterator = Iterators.peekingIterator(resultIterator); WriteBatch writeBatch = getBatchOfWrites(row, peekingResultIterator, sweepTs); Multimap<Long, WriteInfo> writesByStartTs = writeBatch.writesByStartTs; maybeMetrics.ifPresent(metrics -> metrics.updateEntriesRead(shardStrategy, writesByStartTs.size())); log.debug("Read {} entries from the sweep queue.", SafeArg.of("number", writesByStartTs.size())); TimestampsToSweep tsToSweep = getTimestampsToSweepDescendingAndCleanupAborted( shardStrategy, minTsExclusive, sweepTs, writesByStartTs); Collection<WriteInfo> writes = getWritesToSweep(writesByStartTs, tsToSweep.timestampsDescending()); DedicatedRows filteredDedicatedRows = getDedicatedRowsToClear(writeBatch.dedicatedRows, tsToSweep); long lastSweptTs = getLastSweptTs(tsToSweep, peekingResultIterator, partitionFine, sweepTs); return SweepBatch.of(writes, filteredDedicatedRows, lastSweptTs); }
SweepBatch getNextBatchToSweep(ShardAndStrategy shardStrategy, long lastSweptTs, long sweepTs) { return sweepableTimestamps.nextSweepableTimestampPartition(shardStrategy, lastSweptTs, sweepTs) .map(fine -> sweepableCells.getBatchForPartition(shardStrategy, fine, lastSweptTs, sweepTs)) .orElse(SweepBatch.of(ImmutableList.of(), DedicatedRows.of(ImmutableList.of()), sweepTs - 1L)); } }
SweepBatch getBatchForPartition(ShardAndStrategy shardStrategy, long partitionFine, long minTsExclusive, long sweepTs) { SweepableCellsRow row = computeRow(partitionFine, shardStrategy); RowColumnRangeIterator resultIterator = getRowColumnRange(row, partitionFine, minTsExclusive, sweepTs); PeekingIterator<Map.Entry<Cell, Value>> peekingResultIterator = Iterators.peekingIterator(resultIterator); WriteBatch writeBatch = getBatchOfWrites(row, peekingResultIterator, sweepTs); Multimap<Long, WriteInfo> writesByStartTs = writeBatch.writesByStartTs; maybeMetrics.ifPresent(metrics -> metrics.updateEntriesRead(shardStrategy, writesByStartTs.size())); log.debug("Read {} entries from the sweep queue.", SafeArg.of("number", writesByStartTs.size())); TimestampsToSweep tsToSweep = getTimestampsToSweepDescendingAndCleanupAborted( shardStrategy, minTsExclusive, sweepTs, writesByStartTs); Collection<WriteInfo> writes = getWritesToSweep(writesByStartTs, tsToSweep.timestampsDescending()); DedicatedRows filteredDedicatedRows = getDedicatedRowsToClear(writeBatch.dedicatedRows, tsToSweep); long lastSweptTs = getLastSweptTs(tsToSweep, peekingResultIterator, partitionFine, sweepTs); return SweepBatch.of(writes, filteredDedicatedRows, lastSweptTs); }