/** * Creates a new instance. * * @param inputSlots see {@link #inputSlots} * @param borderInputSlots see {@link #borderInputSlots} * @param sourceOperators see {@link #sourceOperators} * @param configuration see {@link #configuration} */ private Builder(Collection<InputSlot<?>> inputSlots, Collection<InputSlot<?>> borderInputSlots, Collection<Operator> sourceOperators, Configuration configuration) { this.inputSlots = inputSlots; this.borderInputSlots = RheemCollections.asSet(borderInputSlots); this.configuration = configuration; this.sourceOperators = sourceOperators; }
private StageExecution(ExecutionStage stage, OptimizationContext optimizationContext, ExecutionState executionState) { this.executionState = executionState; this.optimizationContext = optimizationContext; // Initialize the readyActivators. assert !stage.getStartTasks().isEmpty() : String.format("No start tasks for %s.", stage); stage.getStartTasks().forEach(this::scheduleStartTask); // Initialize the terminalTasks. this.terminalTasks = RheemCollections.asSet(stage.getTerminalTasks()); }
/** * Gather all available {@link PlanTransformation}s from the {@link #configuration}. */ private Collection<PlanTransformation> gatherTransformations() { final Set<Platform> platforms = RheemCollections.asSet(this.configuration.getPlatformProvider().provideAll()); return this.configuration.getMappingProvider().provideAll().stream() .flatMap(mapping -> mapping.getTransformations().stream()) .filter(t -> t.getTargetPlatforms().isEmpty() || platforms.containsAll(t.getTargetPlatforms())) .collect(Collectors.toList()); }
/** * Find the supported {@link ChannelDescriptor}s for the given {@link InputSlot}. If the latter is a * "loop invariant" {@link InputSlot}, then require to only reusable {@link ChannelDescriptor}. * * @param input for which supported {@link ChannelDescriptor}s are requested * @return all eligible {@link ChannelDescriptor}s */ private Set<ChannelDescriptor> resolveSupportedChannels(final InputSlot<?> input) { final Channel existingChannel = this.existingDestinationChannels.get(input); if (existingChannel != null) { return Collections.singleton(existingChannel.getDescriptor()); } final ExecutionOperator owner = (ExecutionOperator) input.getOwner(); final List<ChannelDescriptor> supportedInputChannels = owner.getSupportedInputChannels(input.getIndex()); if (input.isLoopInvariant()) { // Loop input is needed in several iterations and must therefore be reusable. return supportedInputChannels.stream().filter(ChannelDescriptor::isReusable).collect(Collectors.toSet()); } else { return RheemCollections.asSet(supportedInputChannels); } }
/** * For each given instance, group the {@link #planImplementations} by their {@link ExecutionOperator} for the * associated {@link InputSlot}. * * @param enumerations a mapping from {@link InputSlot}s to {@link PlanEnumeration}s that request this input * @return a {@link List} with an element for each {@code enumerations} entry; each entry groups the * {@link PlanImplementation}s of the {@link PlanEnumeration} that share the same {@link ExecutionOperator}s for * the requested {@link InputSlot} */ private static List<MultiMap<Set<InputSlot<?>>, PlanImplementation>> groupImplementationsByInput( Map<InputSlot<?>, PlanEnumeration> enumerations) { // Prepare a collector for the results. List<MultiMap<Set<InputSlot<?>>, PlanImplementation>> targetPlanGroupList = new ArrayList<>(enumerations.size()); // Go over all PlanEnumerations. for (Map.Entry<InputSlot<?>, PlanEnumeration> entry : enumerations.entrySet()) { // Extract the requested InputSlot and the associated PlanEnumeration requesting it. final InputSlot<?> requestedInput = entry.getKey(); final PlanEnumeration targetEnumeration = entry.getValue(); MultiMap<Set<InputSlot<?>>, PlanImplementation> targetPlanGroups = new MultiMap<>(); for (PlanImplementation planImpl : targetEnumeration.getPlanImplementations()) { final Collection<InputSlot<?>> openInput = planImpl.findExecutionOperatorInputs(requestedInput); targetPlanGroups.putSingle(RheemCollections.asSet(openInput), planImpl); } targetPlanGroupList.add(targetPlanGroups); } return targetPlanGroupList; }
/** * Creates a new instance. */ ConcatenationDescriptor(OutputSlot<?> output, List<InputSlot<?>> inputs) { // Find the ExecutionOperator's corresponding OutputSlot along with the nested PlanImplementation. OutputSlot<?> execOutput = null; PlanImplementation execOutputPlanImplementation = null; if (output != null) { Collection<Tuple<OutputSlot<?>, PlanImplementation>> execOpOutputsWithContext = PlanImplementation.this.findExecutionOperatorOutputWithContext(output); final Tuple<OutputSlot<?>, PlanImplementation> execOpOutputWithCtx = RheemCollections.getSingleOrNull(execOpOutputsWithContext); assert execOpOutputsWithContext != null : String.format("No outputs found for %s.", output); execOutput = execOpOutputWithCtx.field0; execOutputPlanImplementation = execOpOutputWithCtx.field1; } // Find the ExecutionOperators' corresponding InputSlots. List<Set<InputSlot<?>>> execInputs = new ArrayList<>(inputs.size()); for (InputSlot<?> input : inputs) { if (input == null) { execInputs.add(null); } else { execInputs.add(RheemCollections.asSet(PlanImplementation.this.findExecutionOperatorInputs(input))); } } this.groupDescriptor = new ConcatenationGroupDescriptor(execOutput, execInputs); this.execOutputPlanImplementation = execOutputPlanImplementation; }