private boolean checkForLoopHead(ExecutionStage executionStage) { return executionStage.getAllTasks().stream().anyMatch(this::isLoopHead); }
/** * Retrieves the {@link ExecutionStage} that contains the {@link LoopHeadOperator} of this instance. * * @return the loop head {@link ExecutionStage} */ public ExecutionStage getLoopHead() { if (this.headStageCache == null) { this.allStages.stream() .flatMap(executionStage -> executionStage.getAllTasks().stream()) .forEach(this::update); } assert this.headStageCache != null : String.format("No ExecutionStageLoop head for %s.", this.loopSubplan); return this.headStageCache; }
@Override public void applyTo(ExecutionStage stage) { stage.getAllTasks().stream() .flatMap(task -> Arrays.stream(task.getOutputChannels())) .forEach(Channel::markForInstrumentation); } }
/** * Collects all {@link ExecutionTask}s of this instance. * * @return the {@link ExecutionTask}s */ public Set<ExecutionTask> collectAllTasks() { Set<ExecutionTask> allTasks = new HashSet<>(); for (ExecutionStage stage : this.getStages()) { allTasks.addAll(stage.getAllTasks()); } return allTasks; }
/** * @return all {@link Channel}s of this instance that connect to other {@link ExecutionStage}s */ public Collection<Channel> getOutboundChannels() { return this.getAllTasks().stream() .flatMap( task -> Arrays.stream(task.getOutputChannels()).filter(Channel::isBetweenStages) ).collect(Collectors.toList()); }
/** * @return all {@link Channel}s of this instance that connect from other {@link ExecutionStage}s */ public Collection<Channel> getInboundChannels() { return this.getAllTasks().stream() .flatMap(task -> Arrays.stream(task.getInputChannels()).filter( channel -> channel.getProducer().getStage() != this ) ).collect(Collectors.toList()); }
/** * Retrieves the {@link LoopHeadOperator} {@link ExecutionTask} in this instance. This instance must be a * loop head. * * @return the {@link LoopHeadOperator} {@link ExecutionTask} * @see #isLoopHead() */ public ExecutionTask getLoopHeadTask() { assert this.isLoopHead(); return RheemCollections.getSingle(this.getAllTasks()); }
.flatMap(stage -> stage.getAllTasks().stream()) .collect(Collectors.toSet());
assert this.stage.getAllTasks().size() == 1 : String.format("Loop head stage looks like this:\n%s", this.stage.getPlanAsString("! "));