/** * Returns a new {@link SweepResults} representing cumulative results from this instance and {@code other}. * The operation is commutative. */ public SweepResults accumulateWith(SweepResults other) { return SweepResults.builder() .nextStartRow(maxRowOptional(getNextStartRow(), other.getNextStartRow())) .cellTsPairsExamined(getCellTsPairsExamined() + other.getCellTsPairsExamined()) .staleValuesDeleted(getStaleValuesDeleted() + other.getStaleValuesDeleted()) .minSweptTimestamp(Math.min(getMinSweptTimestamp(), other.getMinSweptTimestamp())) .timeInMillis(getTimeInMillis() + other.getTimeInMillis()) .timeSweepStarted(Math.min(getTimeSweepStarted(), other.getTimeSweepStarted())) .build(); }
.build(), startRow); assertEquals(ts, results.getMinSweptTimestamp()); assertArrayEquals(startRow, results.getPreviousStartRow().orElse(null)); totalStaleValuesDeleted += results.getStaleValuesDeleted();
private void saveIntermediateSweepResults(TableToSweep tableToSweep, SweepResults results) { Preconditions.checkArgument(results.getNextStartRow().isPresent(), "Next start row should be present when saving intermediate results!"); txManager.runTaskWithRetry((TxTask) tx -> { if (!tableToSweep.hasPreviousProgress()) { // This is the first set of results being written for this table. sweepPriorityStore.update( tx, tableToSweep.getTableRef(), ImmutableUpdateSweepPriority.builder().newWriteCount(0L).build()); } SweepProgress newProgress = ImmutableSweepProgress.builder() .tableRef(tableToSweep.getTableRef()) .staleValuesDeleted(results.getStaleValuesDeleted()) .cellTsPairsExamined(results.getCellTsPairsExamined()) //noinspection OptionalGetWithoutIsPresent // covered by precondition above .startRow(results.getNextStartRow().get()) .startColumn(PtBytes.toBytes("unused")) .minimumSweptTimestamp(results.getMinSweptTimestamp()) .timeInMillis(results.getTimeInMillis()) .startTimeInMillis(results.getTimeSweepStarted()) .build(); sweepProgressStore.saveProgress(newProgress); return null; }); }
private void saveFinalSweepResults(TableToSweep tableToSweep, SweepResults finalSweepResults) { txManager.runTaskWithRetry((TxTask) tx -> { ImmutableUpdateSweepPriority.Builder update = ImmutableUpdateSweepPriority.builder() .newStaleValuesDeleted(finalSweepResults.getStaleValuesDeleted()) .newCellTsPairsExamined(finalSweepResults.getCellTsPairsExamined()) .newLastSweepTimeMillis(wallClock.getTimeMillis()) .newMinimumSweptTimestamp(finalSweepResults.getMinSweptTimestamp()); if (!tableToSweep.hasPreviousProgress()) { // This is the first (and only) set of results being written for this table. update.newWriteCount(0L); } sweepPriorityStore.update(tx, tableToSweep.getTableRef(), update.build()); return null; }); }
private void logSweepPerformance(TableReference tableRef, byte[] startRow, SweepResults results) { log.info("Analyzed {} cell+timestamp pairs" + " from table {}" + " starting at row {}" + " and deleted {} stale values" + " in {} ms" + " up to timestamp {}.", SafeArg.of("cellTs pairs examined", results.getCellTsPairsExamined()), LoggingArgs.tableRef("tableRef", tableRef), UnsafeArg.of("startRow", startRowToHex(startRow)), SafeArg.of("cellTs pairs deleted", results.getStaleValuesDeleted()), SafeArg.of("time taken", results.getTimeInMillis()), SafeArg.of("last swept timestamp", results.getMinSweptTimestamp())); SweepPerformanceResults performanceResults = SweepPerformanceResults.builder() .sweepResults(results) .tableName(tableRef.getQualifiedName()) .elapsedMillis(results.getTimeInMillis()) .build(); sweepPerfLogger.logSweepResults(performanceResults); }
/** * Returns a new {@link SweepResults} representing cumulative results from this instance and {@code other}. * The operation is commutative. */ public SweepResults accumulateWith(SweepResults other) { return SweepResults.builder() .nextStartRow(maxRowOptional(getNextStartRow(), other.getNextStartRow())) .cellTsPairsExamined(getCellTsPairsExamined() + other.getCellTsPairsExamined()) .staleValuesDeleted(getStaleValuesDeleted() + other.getStaleValuesDeleted()) .minSweptTimestamp(Math.min(getMinSweptTimestamp(), other.getMinSweptTimestamp())) .timeInMillis(getTimeInMillis() + other.getTimeInMillis()) .timeSweepStarted(Math.min(getTimeSweepStarted(), other.getTimeSweepStarted())) .build(); }
.build(), startRow); assertEquals(ts, results.getMinSweptTimestamp()); assertArrayEquals(startRow, results.getPreviousStartRow().orElse(null)); totalStaleValuesDeleted += results.getStaleValuesDeleted();
private void saveFinalSweepResults(TableToSweep tableToSweep, SweepResults finalSweepResults) { txManager.runTaskWithRetry((TxTask) tx -> { ImmutableUpdateSweepPriority.Builder update = ImmutableUpdateSweepPriority.builder() .newStaleValuesDeleted(finalSweepResults.getStaleValuesDeleted()) .newCellTsPairsExamined(finalSweepResults.getCellTsPairsExamined()) .newLastSweepTimeMillis(wallClock.getTimeMillis()) .newMinimumSweptTimestamp(finalSweepResults.getMinSweptTimestamp()); if (!tableToSweep.hasPreviousProgress()) { // This is the first (and only) set of results being written for this table. update.newWriteCount(0L); } sweepPriorityStore.update(tx, tableToSweep.getTableRef(), update.build()); return null; }); }
private void saveIntermediateSweepResults(TableToSweep tableToSweep, SweepResults results) { Preconditions.checkArgument(results.getNextStartRow().isPresent(), "Next start row should be present when saving intermediate results!"); txManager.runTaskWithRetry((TxTask) tx -> { if (!tableToSweep.hasPreviousProgress()) { // This is the first set of results being written for this table. sweepPriorityStore.update( tx, tableToSweep.getTableRef(), ImmutableUpdateSweepPriority.builder().newWriteCount(0L).build()); } SweepProgress newProgress = ImmutableSweepProgress.builder() .tableRef(tableToSweep.getTableRef()) .staleValuesDeleted(results.getStaleValuesDeleted()) .cellTsPairsExamined(results.getCellTsPairsExamined()) //noinspection OptionalGetWithoutIsPresent // covered by precondition above .startRow(results.getNextStartRow().get()) .startColumn(PtBytes.toBytes("unused")) .minimumSweptTimestamp(results.getMinSweptTimestamp()) .timeInMillis(results.getTimeInMillis()) .startTimeInMillis(results.getTimeSweepStarted()) .build(); sweepProgressStore.saveProgress(newProgress); return null; }); }
private void logSweepPerformance(TableReference tableRef, byte[] startRow, SweepResults results) { log.info("Analyzed {} cell+timestamp pairs" + " from table {}" + " starting at row {}" + " and deleted {} stale values" + " in {} ms" + " up to timestamp {}.", SafeArg.of("cellTs pairs examined", results.getCellTsPairsExamined()), LoggingArgs.tableRef("tableRef", tableRef), UnsafeArg.of("startRow", startRowToHex(startRow)), SafeArg.of("cellTs pairs deleted", results.getStaleValuesDeleted()), SafeArg.of("time taken", results.getTimeInMillis()), SafeArg.of("last swept timestamp", results.getMinSweptTimestamp())); SweepPerformanceResults performanceResults = SweepPerformanceResults.builder() .sweepResults(results) .tableName(tableRef.getQualifiedName()) .elapsedMillis(results.getTimeInMillis()) .build(); sweepPerfLogger.logSweepResults(performanceResults); }