TargetedSweeper implements MultiTableSweepQueueWriter, BackgroundSweeper { @VisibleForTesting long processShard(ShardAndStrategy shardAndStrategy) { long maxTsExclusive = Sweeper.of(shardAndStrategy).getSweepTimestamp(timestampsSupplier); return sweepNextBatch(shardAndStrategy, maxTsExclusive); } private  TargetedSweeper(MetricsManager metricsManager,
            Supplier<TargetedSweepRuntimeConfig> runtime,
            TargetedSweepInstallConfig install,
            List<Follower> followers); static TargetedSweeper createUninitialized(MetricsManager metrics,
            Supplier<TargetedSweepRuntimeConfig> runtime,
            TargetedSweepInstallConfig install,
            List<Follower> followers); static TargetedSweeper createUninitializedForTest(MetricsManager metricsManager,
            Supplier<TargetedSweepRuntimeConfig> runtime); static TargetedSweeper createUninitializedForTest(Supplier<Integer> shards); @Override void initialize(TransactionManager txManager); void initializeWithoutRunning(TransactionManager txManager); void initializeWithoutRunning(
            SpecialTimestampsSupplier timestamps,
            TimelockService timelockService,
            KeyValueService kvs,
            TransactionService transaction,
            TargetedSweepFollower follower); @Override void runInBackground(); @Override void enqueue(List<WriteInfo> writes); @SuppressWarnings("checkstyle:RegexpMultiline") // Suppress VisibleForTesting warning @VisibleForTesting long sweepNextBatch(ShardAndStrategy shardStrategy, long maxTsExclusive); @Override void close(); @Override void shutdown();  }
@Test public void sweepOnlyOneFinePartitionByDefault() { enqueueWriteCommitted(TABLE_CONS, LOW_TS); enqueueTombstone(TABLE_CONS, LOW_TS + 2); enqueueWriteCommitted(TABLE_CONS, LOW_TS + 4); enqueueTombstone(TABLE_CONS, LOW_TS + 6); enqueueWriteCommitted(TABLE_CONS, LOW_TS + 8); enqueueWriteCommitted(TABLE_CONS, maxTsForFinePartition(0) + 1); sweepQueue.processShard(ShardAndStrategy.conservative(CONS_SHARD)); assertTestValueEnqueuedAtGivenTimestampStillPresent(TABLE_CONS, maxTsForFinePartition(0) + 1); }
@Test public void enableAutoTuningSweepsMultipleFinePartitions() { enableAutoTuning = true; enqueueWriteCommitted(TABLE_CONS, LOW_TS); enqueueTombstone(TABLE_CONS, LOW_TS + 2); enqueueWriteCommitted(TABLE_CONS, LOW_TS + 4); enqueueTombstone(TABLE_CONS, LOW_TS + 6); enqueueWriteCommitted(TABLE_CONS, LOW_TS + 8); enqueueWriteCommitted(TABLE_CONS, maxTsForFinePartition(0) + 1); enqueueTombstone(TABLE_CONS, maxTsForFinePartition(0) + 2); sweepQueue.processShard(ShardAndStrategy.conservative(CONS_SHARD)); assertReadAtTimestampReturnsSentinel(TABLE_CONS, maxTsForFinePartition(0) + 1); }