@Test public void testTwoCandidates() { long sweepTimestampHigherThanCommitTimestamp = HIGH_COMMIT_TS + 1; CandidateCellForSweeping snd = ImmutableCandidateCellForSweeping.builder() .cell(ANOTHER_CELL) .sortedTimestamps(ImmutableList.of(HIGH_START_TS)) .isLatestValueEmpty(true) .build(); List<CandidateCellForSweeping> candidates = ImmutableList.of(twoCommittedTimestampsForSingleCell().get(0), snd); SweepableCellFilter filter = new SweepableCellFilter( commitTsCache, Sweeper.THOROUGH, sweepTimestampHigherThanCommitTimestamp); BatchOfCellsToSweep result = filter.getCellsToSweep(candidates); assertThat(result.lastCellExamined()).isEqualTo(ANOTHER_CELL); assertThat(result.cells().size()).isEqualTo(2); assertThat(result.numCellTsPairsExamined()).isEqualTo(3L); assertThat(result.cells().get(0).sortedTimestamps()).containsExactly(LOW_START_TS); assertThat(result.cells().get(1).sortedTimestamps()).containsExactly(HIGH_START_TS); }
public BatchOfCellsToSweep getCellsToSweep(List<CandidateCellForSweeping> candidates) { Map<Long, Long> startToCommitTs = commitTsCache.loadBatch(getAllValidTimestamps(candidates)); ImmutableBatchOfCellsToSweep.Builder builder = ImmutableBatchOfCellsToSweep.builder(); long numCellTsPairsExamined = 0; for (CandidateCellForSweeping candidate : candidates) { getCellToSweep(candidate, startToCommitTs).ifPresent(builder::addCells); numCellTsPairsExamined += candidate.sortedTimestamps().size(); } return builder .numCellTsPairsExamined(numCellTsPairsExamined) .lastCellExamined(candidates.get(candidates.size() - 1).cell()) .build(); }
SweepableCellFilter { public BatchOfCellsToSweep getCellsToSweep(List<CandidateCellForSweeping> candidates) { Map<Long, Long> startToCommitTs = commitTsCache.loadBatch(getAllValidTimestamps(candidates)); ImmutableBatchOfCellsToSweep.Builder builder = ImmutableBatchOfCellsToSweep.builder(); long numCellTsPairsExamined = 0; for (CandidateCellForSweeping candidate : candidates) { getCellToSweep(candidate, startToCommitTs).ifPresent(builder::addCells); numCellTsPairsExamined += candidate.sortedTimestamps().size(); } return builder .numCellTsPairsExamined(numCellTsPairsExamined) .lastCellExamined(candidates.get(candidates.size() - 1).cell()) .build(); } }
SweepableCellFilter { public BatchOfCellsToSweep getCellsToSweep(List<CandidateCellForSweeping> candidates) { Map<Long, Long> startToCommitTs = commitTsCache.loadBatch(getAllValidTimestamps(candidates)); ImmutableBatchOfCellsToSweep.Builder builder = ImmutableBatchOfCellsToSweep.builder(); long numCellTsPairsExamined = 0; for (CandidateCellForSweeping candidate : candidates) { getCellToSweep(candidate, startToCommitTs).ifPresent(builder::addCells); numCellTsPairsExamined += candidate.sortedTimestamps().size(); } return builder .numCellTsPairsExamined(numCellTsPairsExamined) .lastCellExamined(candidates.get(candidates.size() - 1).cell()) .build(); } SweepableCellFilter(CommitTsCache commitTsCache, Sweeper sweeper, long sweepTs); }
SweepableCellFilter { public BatchOfCellsToSweep getCellsToSweep(List<CandidateCellForSweeping> candidates) { Map<Long, Long> startToCommitTs = commitTsCache.loadBatch(getAllValidTimestamps(candidates)); ImmutableBatchOfCellsToSweep.Builder builder = ImmutableBatchOfCellsToSweep.builder(); long numCellTsPairsExamined = 0; for (CandidateCellForSweeping candidate : candidates) { getCellToSweep(candidate, startToCommitTs).ifPresent(builder::addCells); numCellTsPairsExamined += candidate.sortedTimestamps().size(); } return builder .numCellTsPairsExamined(numCellTsPairsExamined) .lastCellExamined(candidates.get(candidates.size() - 1).cell()) .build(); } SweepableCellFilter(CommitTsCache commitTsCache, Sweeper sweeper, long sweepTs); BatchOfCellsToSweep getCellsToSweep(List<CandidateCellForSweeping> candidates); }
SweepableCellFilter { public BatchOfCellsToSweep getCellsToSweep(List<CandidateCellForSweeping> candidates) { Map<Long, Long> startToCommitTs = commitTsCache.loadBatch(getAllValidTimestamps(candidates)); ImmutableBatchOfCellsToSweep.Builder builder = ImmutableBatchOfCellsToSweep.builder(); long numCellTsPairsExamined = 0; for (CandidateCellForSweeping candidate : candidates) { getCellToSweep(candidate, startToCommitTs).ifPresent(builder::addCells); numCellTsPairsExamined += candidate.sortedTimestamps().size(); } return builder .numCellTsPairsExamined(numCellTsPairsExamined) .lastCellExamined(candidates.get(candidates.size() - 1).cell()) .build(); } SweepableCellFilter(CommitTsCache commitTsCache, Sweeper sweeper, long sweepTs); BatchOfCellsToSweep getCellsToSweep(List<CandidateCellForSweeping> candidates);  }