private void doTestLargerTable(boolean checkIfLatestValueIsEmpty) { TestDataBuilder builder = new TestDataBuilder(); List<Cell> expectedCells = Lists.newArrayList(); for (int rowNum = 1; rowNum <= 50; ++rowNum) { for (int colNum = 1; colNum <= rowNum; ++colNum) { expectedCells.add(cell(rowNum, colNum)); for (int ts = 0; ts < 1 + (colNum % 4); ++ts) { builder.put(rowNum, colNum, 10 + ts); } } } assertEquals((1 + 50) * 50 / 2, expectedCells.size()); builder.store(); List<CandidateCellForSweeping> candidates = getAllCandidates( ImmutableCandidateCellForSweepingRequest.builder() .startRowInclusive(PtBytes.EMPTY_BYTE_ARRAY) .maxTimestampExclusive(40L) .shouldCheckIfLatestValueIsEmpty(checkIfLatestValueIsEmpty) .shouldDeleteGarbageCollectionSentinels(false) .batchSizeHint(1) .build()); assertEquals(expectedCells, candidates.stream().map(CandidateCellForSweeping::cell).collect(Collectors.toList())); }
private int fullTableScan(TableReference tableRef, KeyValueService kvs, int numCellsExpected, boolean thorough) { CandidateCellForSweepingRequest request = ImmutableCandidateCellForSweepingRequest.builder() .startRowInclusive(PtBytes.EMPTY_BYTE_ARRAY) .batchSizeHint(1000) .maxTimestampExclusive(Long.MAX_VALUE) .shouldCheckIfLatestValueIsEmpty(thorough) .shouldDeleteGarbageCollectionSentinels(thorough) .build(); try (ClosableIterator<List<CandidateCellForSweeping>> iter = kvs.getCandidateCellsForSweeping( tableRef, request)) { int numCandidates = Iterators.size(Iterators.concat(Iterators.transform(iter, List::iterator))); Preconditions.checkState(numCandidates == numCellsExpected, "Number of candidates %s != %s", numCandidates, numCellsExpected); return numCandidates; } } }
CandidateCellForSweepingRequest request = ImmutableCandidateCellForSweepingRequest.builder() .startRowInclusive(startRow) .batchSizeHint(batchConfig.candidateBatchSize()) .maxTimestampExclusive(sweepTs) .shouldCheckIfLatestValueIsEmpty(sweeper.shouldSweepLastCommitted())
CandidateCellForSweepingRequest request = ImmutableCandidateCellForSweepingRequest.builder() .startRowInclusive(startRow) .batchSizeHint(batchConfig.candidateBatchSize()) .maxTimestampExclusive(sweepTs) .shouldCheckIfLatestValueIsEmpty(sweeper.shouldSweepLastCommitted())
private void doTestLargerTable(boolean checkIfLatestValueIsEmpty) { TestDataBuilder builder = new TestDataBuilder(); List<Cell> expectedCells = Lists.newArrayList(); for (int rowNum = 1; rowNum <= 50; ++rowNum) { for (int colNum = 1; colNum <= rowNum; ++colNum) { expectedCells.add(cell(rowNum, colNum)); for (int ts = 0; ts < 1 + (colNum % 4); ++ts) { builder.put(rowNum, colNum, 10 + ts); } } } assertEquals((1 + 50) * 50 / 2, expectedCells.size()); builder.store(); List<CandidateCellForSweeping> candidates = getAllCandidates( ImmutableCandidateCellForSweepingRequest.builder() .startRowInclusive(PtBytes.EMPTY_BYTE_ARRAY) .maxTimestampExclusive(40L) .shouldCheckIfLatestValueIsEmpty(checkIfLatestValueIsEmpty) .shouldDeleteGarbageCollectionSentinels(false) .batchSizeHint(1) .build()); assertEquals(expectedCells, candidates.stream().map(CandidateCellForSweeping::cell).collect(Collectors.toList())); }
protected static CandidateCellForSweepingRequest thoroughRequest(byte[] startRow, long sweepTs, int batchSizeHint) { return ImmutableCandidateCellForSweepingRequest.builder() .startRowInclusive(startRow) .maxTimestampExclusive(sweepTs) .shouldCheckIfLatestValueIsEmpty(true) .shouldDeleteGarbageCollectionSentinels(true) .batchSizeHint(batchSizeHint) .build(); }
protected static CandidateCellForSweepingRequest conservativeRequest(byte[] startRow, long sweepTs, int batchSizeHint) { return ImmutableCandidateCellForSweepingRequest.builder() .startRowInclusive(startRow) .maxTimestampExclusive(sweepTs) .shouldCheckIfLatestValueIsEmpty(false) .shouldDeleteGarbageCollectionSentinels(false) .batchSizeHint(batchSizeHint) .build(); }
protected static CandidateCellForSweepingRequest thoroughRequest(byte[] startRow, long sweepTs, int batchSizeHint) { return ImmutableCandidateCellForSweepingRequest.builder() .startRowInclusive(startRow) .maxTimestampExclusive(sweepTs) .shouldCheckIfLatestValueIsEmpty(true) .shouldDeleteGarbageCollectionSentinels(true) .batchSizeHint(batchSizeHint) .build(); }
protected static CandidateCellForSweepingRequest conservativeRequest(byte[] startRow, long sweepTs, int batchSizeHint) { return ImmutableCandidateCellForSweepingRequest.builder() .startRowInclusive(startRow) .maxTimestampExclusive(sweepTs) .shouldCheckIfLatestValueIsEmpty(false) .shouldDeleteGarbageCollectionSentinels(false) .batchSizeHint(batchSizeHint) .build(); }