/** * Collects all {@link ExecutionStage}s in this instance. * * @return the {@link ExecutionStage}s */ public Set<ExecutionStage> getStages() { Set<ExecutionStage> seenStages = new HashSet<>(); Queue<ExecutionStage> openStages = new LinkedList<>(this.getStartingStages()); while (!openStages.isEmpty()) { final ExecutionStage stage = openStages.poll(); if (seenStages.add(stage)) { openStages.addAll(stage.getSuccessors()); } } return seenStages; }
private void logStages(ExecutionPlan executionPlan) { if (this.logger.isInfoEnabled()) { StringBuilder sb = new StringBuilder(); Set<ExecutionStage> seenStages = new HashSet<>(); Queue<ExecutionStage> stagedStages = new LinkedList<>(executionPlan.getStartingStages()); ExecutionStage nextStage; while ((nextStage = stagedStages.poll()) != null) { sb.append(nextStage).append(":\n"); nextStage.getPlanAsString(sb, "* "); nextStage.getSuccessors().stream() .filter(seenStages::add) .forEach(stagedStages::add); } this.logger.info("Current execution plan:\n{}", executionPlan.toExtensiveString()); } }
/** * Sets up a {@link Breakpoint} for an {@link ExecutionPlan}. * * @param executionPlan for that the {@link Breakpoint} should be set * @param round {@link TimeMeasurement} to be extended for any interesting time measurements */ private void setUpBreakpoint(ExecutionPlan executionPlan, TimeMeasurement round) { // Set up appropriate Breakpoints. final TimeMeasurement breakpointRound = round.start("Configure Breakpoint"); FixBreakpoint immediateBreakpoint = new FixBreakpoint(); final Set<ExecutionStage> completedStages = this.crossPlatformExecutor.getCompletedStages(); if (completedStages.isEmpty()) { executionPlan.getStartingStages().forEach(immediateBreakpoint::breakAfter); } else { completedStages.stream() .flatMap(stage -> stage.getSuccessors().stream()) .filter(stage -> !completedStages.contains(stage)) .forEach(immediateBreakpoint::breakAfter); } this.crossPlatformExecutor.setBreakpoint(new ConjunctiveBreakpoint( immediateBreakpoint, this.cardinalityBreakpoint, new NoIterationBreakpoint() // Avoid re-optimization inside of loops. )); breakpointRound.stop(); }