private DedicatedRows getDedicatedRowsToClear(List<SweepableCellsRow> rows, TimestampsToSweep tsToSweep) { return DedicatedRows.of(rows.stream() .filter(row -> { TargetedSweepMetadata metadata = TargetedSweepMetadata.BYTES_HYDRATOR.hydrateFromBytes(row.getMetadata()); checkState(metadata.dedicatedRow(), "Row not a dedicated row", SafeArg.of("row", row)); return tsToSweep.timestampsDescending().contains(row.getTimestampPartition()); }).collect(Collectors.toList())); }
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); }
private DedicatedRows getDedicatedRowsToClear(List<SweepableCellsRow> rows, TimestampsToSweep tsToSweep) { return DedicatedRows.of(rows.stream() .filter(row -> { TargetedSweepMetadata metadata = TargetedSweepMetadata.BYTES_HYDRATOR.hydrateFromBytes(row.getMetadata()); checkState(metadata.dedicatedRow(), "Row not a dedicated row", SafeArg.of("row", row)); return tsToSweep.timestampsDescending().contains(row.getTimestampPartition()); }).collect(Collectors.toList())); }
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); }