private Optional<TableToSweep> attemptToChooseTable(SweepPriorityOverrideConfig overrideConfig) { List<TableReference> priorityTableRefs = overrideConfig.priorityTablesAsList().stream() .map(TableReference::createFromFullyQualifiedName) .collect(Collectors.toList()); // If there are multiple priority tables, we don't want to consistently use the same ordering. // It is true that this operation is O(list length) while an O(min(list length, cluster size)) algorithm // exists, but the priority table reference list is expected to be small. Collections.shuffle(priorityTableRefs); return attemptToChooseTableFromPrioritisedList(priorityTableRefs, "it is on the sweep priority list"); }
public Optional<TableToSweep> getNextTableToSweep( Transaction tx, long conservativeSweepTimestamp, SweepPriorityOverrideConfig overrideConfig) { if (!overrideConfig.priorityTables().isEmpty()) { Optional<TableToSweep> maybeChosenTable = attemptToChooseTable(overrideConfig); if (maybeChosenTable.isPresent()) { return maybeChosenTable; } } Map<TableReference, Double> scores = calculator.calculateSweepPriorityScores(tx, conservativeSweepTimestamp); Map<TableReference, Double> tablesWithNonZeroPriority = getTablesToBeConsideredForSweepAndScores(overrideConfig, scores); if (tablesWithNonZeroPriority.isEmpty()) { return logDecision(Optional.empty(), scores, overrideConfig); } List<TableReference> tablesOrderedByPriority = orderTablesByPriority(tablesWithNonZeroPriority); Optional<TableToSweep> chosenTable = attemptToChooseTableFromPrioritisedList(tablesOrderedByPriority, "it has a high priority score"); return logDecision(chosenTable, scores, overrideConfig); }
private Optional<TableToSweep> attemptToChooseTable(SweepPriorityOverrideConfig overrideConfig) { List<TableReference> priorityTableRefs = overrideConfig.priorityTablesAsList().stream() .map(TableReference::createFromFullyQualifiedName) .collect(Collectors.toList()); // If there are multiple priority tables, we don't want to consistently use the same ordering. // It is true that this operation is O(list length) while an O(min(list length, cluster size)) algorithm // exists, but the priority table reference list is expected to be small. Collections.shuffle(priorityTableRefs); return attemptToChooseTableFromPrioritisedList(priorityTableRefs, "it is on the sweep priority list"); }
public Optional<TableToSweep> getNextTableToSweep( Transaction tx, long conservativeSweepTimestamp, SweepPriorityOverrideConfig overrideConfig) { if (!overrideConfig.priorityTables().isEmpty()) { Optional<TableToSweep> maybeChosenTable = attemptToChooseTable(overrideConfig); if (maybeChosenTable.isPresent()) { return maybeChosenTable; } } Map<TableReference, Double> scores = calculator.calculateSweepPriorityScores(tx, conservativeSweepTimestamp); Map<TableReference, Double> tablesWithNonZeroPriority = getTablesToBeConsideredForSweepAndScores(overrideConfig, scores); if (tablesWithNonZeroPriority.isEmpty()) { return logDecision(Optional.empty(), scores, overrideConfig); } List<TableReference> tablesOrderedByPriority = orderTablesByPriority(tablesWithNonZeroPriority); Optional<TableToSweep> chosenTable = attemptToChooseTableFromPrioritisedList(tablesOrderedByPriority, "it has a high priority score"); return logDecision(chosenTable, scores, overrideConfig); }