@Override public String toString() { return String.format("%s[%s->%s]", this.getClass().getSimpleName(), this.getProducer() == null ? this.getProducerSlot() : this.getProducer(), this.getConsumers()); }
@Override public void update(Channel sourceChannel, Channel targetChannel, Collection<OptimizationContext> optimizationContexts, CardinalityEstimate cardinality) { ExecutionTask conversionTask = targetChannel.getProducer(); this.setCardinalityAndTimeEstimates(sourceChannel, optimizationContexts, cardinality, conversionTask); }
/** * @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()); }
/** * Creates a new, hierarchical instance. Mimes the {@code original}'s properties except for the {@link #consumers}. * * @param original the original instance whose properties will be mimed */ protected Channel(Channel original) { this.descriptor = original.getDescriptor(); this.original = original.getOriginal(); assert this.original == null || !this.original.isCopy(); this.producer = original.getProducer(); this.producerSlot = original.getProducerSlot(); }
/** * Checks if <i>all</i> input {@link Channel}s of the given {@code task} are outbound w.r.t. to the * {@link InterimStage}. */ private boolean checkIfStartTask(ExecutionTask task) { for (Channel channel : task.getInputChannels()) { if (this.checkIfFeedbackChannel(task, channel)) continue; final ExecutionTask producer = channel.getProducer(); if (this.equals(StageAssignmentTraversal.this.assignedInterimStages.get(producer))) { return false; } } return true; }
Channel targetChannel = junction.getTargetChannel(destIndex); while (targetChannel != sourceChannel) { final ExecutionTask producer = targetChannel.getProducer(); producer.getOperator().setContainer(sourceLoop); assert producer.getNumInputChannels() == 1 : String.format(
/** * Scrap any consumer {@link ExecutionTask}s and sibling {@link Channel}s that are not within the given * {@link ExecutionStage}s. * * @return whether consumer {@link ExecutionTask}s have been removed */ public boolean retain(Set<ExecutionStage> retainableStages) { boolean isConsumersRemoved = this.consumers.removeIf(consumer -> !retainableStages.contains(consumer.getStage())); this.removeSiblingsWhere((sibling) -> !retainableStages.contains(sibling.getProducer().getStage())); return isConsumersRemoved; }
/** * Finds the single input {@link Channel} of the given {@code channel}'s producing {@link ExecutionTask}. * * @param channel whose predecessor is requested * @return the preceeding {@link Channel} */ public static Channel getPredecessorChannel(Channel channel) { final ExecutionTask producer = channel.getProducer(); assert producer != null && producer.getNumInputChannels() == 1; return producer.getInputChannel(0); }
/** * Handle the upstream neighbors of the given {@code task} by expanding the {@code expandableStage} if possible. */ private void expandUpstream(ExecutionTask task, InterimStage expandableStage) { for (Channel channel : task.getInputChannels()) { if (!this.shouldVisitProducerOf(channel)) continue; final ExecutionTask producer = channel.getProducer(); assert producer != null; final InterimStage assignedStage = this.assignedInterimStages.get(producer); if (assignedStage == null) { this.handleTaskWithoutPlatformExecution(producer, /*channel.isExecutionBreaker() ? null : */expandableStage); } } }
for (Channel channel : task.getInputChannels()) { if (task.isFeedbackInput(channel)) continue; final ExecutionTask producer = channel.getProducer(); if (tasks.remove(producer)) { stagedTasks.add(producer);
/** * Checks whether the given {@link Channel} is inside of a {@link ExecutionStageLoop}. * * @param channel the said {@link Channel} * @return whether the {@link Channel} is in a {@link ExecutionStageLoop} */ private static boolean checkIfIsInLoopChannel(Channel channel) { final ExecutionStageLoop producerLoop = channel.getProducer().getStage().getLoop(); return producerLoop != null && channel.getConsumers().stream().anyMatch( consumer -> consumer.getStage().getLoop() == producerLoop ); }
final ExecutionTask producer = inputChannel.getProducer(); assert inputChannel.getProducer() != null; stagedTasks.add(inputChannel.getProducer());
final ExecutionTask predecessor = channel.getProducer(); this.assembleExecutionPlan(finalStages, executionStage, predecessor, visitedTasks);
/** * The given instance should build upon the open {@link Channel}s of this instance. Then, this instance will be * expanded with the content of the given instance. * * @param expansion extends this instance, but they are not overlapping */ public void expand(ExecutionPlan expansion) { for (Channel openChannel : expansion.getOpenInputChannels()) { openChannel.mergeIntoOriginal(); final Channel original = openChannel.getOriginal(); final ExecutionStage producerStage = original.getProducer().getStage(); assert producerStage != null : String.format("No stage found for %s.", original.getProducer()); for (ExecutionTask consumer : original.getConsumers()) { final ExecutionStage consumerStage = consumer.getStage(); assert consumerStage != null : String.format("No stage found for %s.", consumer); // Equal stages possible on "partially open" Channels. if (producerStage != consumerStage) { producerStage.addSuccessor(consumerStage); } } } }
/** * Checks if the given {@link Channel} (inbound to {@link #stage}), is entering an {@link ExecutionStageLoop} * when serving the {@link #stage}. * * @param inboundChannel {@link Channel} that is inbound to {@link #stage} and that might be a {@link ExecutionStageLoop} input * @return whether the {@link Channel} is a {@link ExecutionStageLoop} input, i.e., it is not produced in an {@link ExecutionStageLoop} * while this {@link #stage} is part of a {@link ExecutionStageLoop} */ private boolean checkIfIsLoopInput(Channel inboundChannel) { // NB: This code assumes no nested loops. return this.stage.getLoop() != null && this.stage.getLoop() != inboundChannel.getProducer().getStage().getLoop(); }
/** * Tells whether the given constellation of producing and consuming {@link ExecutionTask}, linked by the * {@link Channel} can be handled within a single {@link PlatformExecution} of this {@link Platform} * * @param producerTask an {@link ExecutionTask} running on this {@link Platform} * @param channel links the {@code producerTask} and {@code consumerTask} * @param consumerTask an {@link ExecutionTask} running on this {@link Platform} * @return whether the {@link ExecutionTask}s can be executed in a single {@link PlatformExecution} */ public boolean isSinglePlatformExecutionPossible(ExecutionTask producerTask, Channel channel, ExecutionTask consumerTask) { assert producerTask.getOperator().getPlatform() == this; assert consumerTask.getOperator().getPlatform() == this; assert channel.getProducer() == producerTask; assert channel.getConsumers().contains(consumerTask); // Overwrite as necessary. return true; }
/** * Determine the {@link ExecutionStageLoop} the given {@link Channel} belongs to. * * @param channel the {@link Channel} * @return the {@link ExecutionStageLoop} or {@code null} if none */ private static ExecutionStageLoop getExecutionStageLoop(Channel channel) { final ExecutionStage producerStage = channel.getProducer().getStage(); if (producerStage.getLoop() == null) return null; final OutputSlot<?> output = channel.getProducer().getOutputSlotFor(channel); if (output != null && output.getOwner().isLoopHead() && ((LoopHeadOperator) output.getOwner()).getFinalLoopOutputs().contains(output)) { return null; } return producerStage.getLoop(); }
/** * Determine the producing {@link OutputSlot} of this {@link Channel} that lies within a {@link RheemPlan}. * We follow non-RheemPlan {@link ExecutionOperator}s because they should merely forward data. */ public static OutputSlot<?> findRheemPlanOutputSlotFor(Channel openChannel) { OutputSlot<?> producerOutput = null; Channel tracedChannel = openChannel; do { final ExecutionTask producer = tracedChannel.getProducer(); final ExecutionOperator producerOperator = producer.getOperator(); if (!producerOperator.isAuxiliary()) { producerOutput = producer.getOutputSlotFor(tracedChannel); } else { assert producer.getNumInputChannels() == 1; tracedChannel = producer.getInputChannel(0); } } while (producerOutput == null); return producerOutput; }
final ExecutionTask producer = newChannel.getProducer(); final ExecutionOperator conversionOperator = producer.getOperator(); conversionOperator.setName(String.format(