/** * Creates the final {@link PlanEnumeration} by <ol> * <li>escaping all terminal operations (in {@link #completedEnumerations}) from {@link #enumeratedAlternative} and</li> * <li>joining them.</li> * </ol> * The result is stored in {@link #resultReference}. Note the outcome might be {@code null} if the traversed plan * did not allow to construct a valid {@link PlanEnumeration}. */ private void constructResultEnumeration() { final PlanEnumeration resultEnumeration = RheemCollections.getSingleOrNull(this.completedEnumerations); this.resultReference = new AtomicReference<>(resultEnumeration); }
/** * Retrieves the single(!) {@link Operator} that is <i>immediately</i> encased by this instance. * * @return the encased {@link Operator}s */ default Operator getContainedOperator() { return RheemCollections.getSingleOrNull(this.getContainedOperators()); }
/** * Find the {@link Operator} in this instance by their name. * * @param name the name of the {@link Operator}s * @return the matching {@link Operator} or {@code null} if none * @throws RheemException if there is more than one such {@link Operator} */ public Operator collectTopLevelOperatorByName(String name) throws RheemException{ return RheemCollections.getSingleOrNull(this.collectTopLevelOperatorsByName(name)); }
/** * 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; }
final OutputSlot<?> newOutput = RheemCollections.getSingleOrNull( (Collection<OutputSlot<?>>) oldToNewSlotMapping .getOrCreateDownstreamMapping()
/** * Groups all {@link #planImplementations} by their {@link ExecutionOperator}s' {@link OutputSlot}s for the * {@code output}. Additionally preserves the very (nested) {@link PlanImplementation} in that {@code output} resides. * * @param output a (possibly top-level) {@link OutputSlot} that should be connected * @return a mapping that represents each element {@link #planImplementations} by a key value pair * {@code (implementing OutputSlots -> (PlanImplementation, nested PlanImplementation)} */ private MultiMap<OutputSlot<?>, Tuple<PlanImplementation, PlanImplementation>> groupImplementationsByOutput(OutputSlot<?> output) { // Sort the PlanEnumerations by their respective open InputSlot or OutputSlot. final MultiMap<OutputSlot<?>, Tuple<PlanImplementation, PlanImplementation>> basePlanGroups = new MultiMap<>(); // Find and validate implementing OutputSlots. for (PlanImplementation basePlanImplementation : this.getPlanImplementations()) { final Collection<Tuple<OutputSlot<?>, PlanImplementation>> execOpOutputsWithContext = basePlanImplementation.findExecutionOperatorOutputWithContext(output); final Tuple<OutputSlot<?>, PlanImplementation> execOpOutputWithCtx = RheemCollections.getSingleOrNull(execOpOutputsWithContext); assert execOpOutputsWithContext != null && !execOpOutputsWithContext.isEmpty() : String.format("No outputs found for %s.", output); basePlanGroups.putSingle( execOpOutputWithCtx.getField0(), new Tuple<>(basePlanImplementation, execOpOutputWithCtx.getField1()) ); } return basePlanGroups; }