public static Tuple<OutputSlot<?>, OptimizationContext> createConcatenationKey( OutputSlot<?> outputSlot, OptimizationContext optimizationContext) { return new Tuple<>(outputSlot, optimizationContext); }
public static Tuple<Operator, OptimizationContext> createKey(Operator operator, OptimizationContext optimizationContext) { return new Tuple<>(operator, optimizationContext); }
public OperatorAlternativeCardinalityPusher(final OperatorAlternative operatorAlternative, final Configuration configuration ) { super(operatorAlternative); this.alternativeTraversals = operatorAlternative.getAlternatives().stream() .map(alternative -> { final CardinalityEstimationTraversal traversal = CardinalityEstimationTraversal.createPushTraversal(alternative, configuration); return new Tuple<>(alternative, traversal); }) .collect(Collectors.toList()); }
public LoopHeadAlternativeCardinalityPusher( final LoopHeadAlternative loopHeadAlternative, Collection<InputSlot<?>> relevantInputSlots, Collection<OutputSlot<?>> relevantOutputSlots, BiFunction<OperatorAlternative.Alternative, Configuration, CardinalityPusher> pusherRetriever, final Configuration configuration ) { super(Slot.toIndices(relevantInputSlots), Slot.toIndices(relevantOutputSlots)); this.alternativePushers = loopHeadAlternative.getAlternatives().stream() .map(alternative -> { final CardinalityPusher alternativePusher = pusherRetriever.apply(alternative, configuration); return new Tuple<>(alternative, alternativePusher); }) .collect(Collectors.toList()); }
/** * Extracts the interesting properties of a {@link PlanImplementation}. * * @param implementation whose interesting properties are requested * @return the interesting properties of the given {@code implementation} */ private static Tuple<Set<Platform>, Collection<ExecutionOperator>> getInterestingProperties(PlanImplementation implementation) { return new Tuple<>( implementation.getUtilizedPlatforms(), implementation.getInterfaceOperators() ); }
/** * Models lazy execution by not marking any {@link LazyExecutionLineageNode}s. * * @param inputs the input {@link ChannelInstance}s * @param outputs the output {@link ChannelInstance}s * @param operatorContext the executed {@link OptimizationContext.OperatorContext} * @return the executed {@link OptimizationContext.OperatorContext} and produced {@link ChannelInstance}s */ static Tuple<Collection<ExecutionLineageNode>, Collection<ChannelInstance>> modelLazyExecution(ChannelInstance[] inputs, ChannelInstance[] outputs, OptimizationContext.OperatorContext operatorContext) { final ExecutionLineageNode executionLineageNode = new ExecutionLineageNode(operatorContext); executionLineageNode.addAtomicExecutionFromOperatorContext(); LazyExecutionLineageNode.connectAll(inputs, executionLineageNode, outputs); return new Tuple<>(Collections.emptyList(), Collections.emptyList()); }
/** * Collect and mark all unmarked {@link LazyExecutionLineageNode}s in this instance. * * @param executionLineageCollector collects the unmarked {@link ExecutionLineageNode} * @param channelInstanceCollector collects the {@link ChannelInstance} in the unmarked {@link LazyExecutionLineageNode}s * @return the two collectors */ public Tuple<Collection<ExecutionLineageNode>, Collection<ChannelInstance>> collectAndMark( Collection<ExecutionLineageNode> executionLineageCollector, Collection<ChannelInstance> channelInstanceCollector ) { return this.traverseAndMark( new Tuple<>(executionLineageCollector, channelInstanceCollector), new CollectingAggregator() ); }
instance.servingOutputSlots.add(new Tuple<>(outputSlot, inputSlot));
channelDescriptors = new HashSet<>(channelDescriptors); channelDescriptors.removeIf(channelDescriptor -> !channelDescriptor.isReusable()); kernelDestChannelDescriptorSetsToIndicesUpdates.add(new Tuple<>(channelDescriptors, indices));
final List<InputSlot<?>> occupiedInputs = escapedOutput.getOccupiedSlots(); if (occupiedInputs.isEmpty()) { escapedInstance.servingOutputSlots.add(new Tuple<>(escapedOutput, null)); } else { for (InputSlot inputSlot : occupiedInputs) { escapedInstance.servingOutputSlots.add(new Tuple<>(escapedOutput, inputSlot));
@Override public ExecutionStage toExecutionStage() { final Iterator<ExecutionTask> iterator = this.allTasks.iterator(); final LoopSubplan loop = iterator.next().getOperator().getInnermostLoop(); assert Iterators.allMatch(iterator, task -> task.getOperator().getInnermostLoop() == loop, true ) : String.format("There are different loops in the stage with the tasks %s.", this.allTasks.stream() .map(task -> new Tuple<>(task, task.getOperator().getInnermostLoop())) .collect(Collectors.toList()) ); ExecutionStageLoop executionStageLoop = null; if (loop != null) { executionStageLoop = StageAssignmentTraversal.this.stageLoops.computeIfAbsent(loop, ExecutionStageLoop::new); } final ExecutionStage executionStage = this.platformExecution.createStage(executionStageLoop, this.sequenceNumber); for (ExecutionTask task : this.allTasks) { executionStage.addTask(task); if (this.checkIfStartTask(task)) { executionStage.markAsStartTask(task); } if (this.checkIfTerminalTask(task)) { executionStage.markAsTerminalTask(task); } } assert !executionStage.getTerminalTasks().isEmpty() : String.format("No terminal tasks among %s.", this.allTasks); return executionStage; }
/** * Models eager execution by marking all {@link LazyExecutionLineageNode}s as executed and collecting all marked ones. * * @param inputs the input {@link ChannelInstance}s * @param outputs the output {@link ChannelInstance}s * @param operatorContext the executed {@link OptimizationContext.OperatorContext} * @return the executed {@link OptimizationContext.OperatorContext} and produced {@link ChannelInstance}s */ static Tuple<Collection<ExecutionLineageNode>, Collection<ChannelInstance>> modelEagerExecution( ChannelInstance[] inputs, ChannelInstance[] outputs, OptimizationContext.OperatorContext operatorContext) { final ExecutionLineageNode executionLineageNode = new ExecutionLineageNode(operatorContext); executionLineageNode.addAtomicExecutionFromOperatorContext(); LazyExecutionLineageNode.connectAll(inputs, executionLineageNode, outputs); final Tuple<Collection<ExecutionLineageNode>, Collection<ChannelInstance>> collectors; if (outputs.length == 0) { collectors = executionLineageNode.collectAndMark(); } else { collectors = new Tuple<>(new LinkedList<>(), new LinkedList<>()); for (ChannelInstance output : outputs) { output.getLineage().collectAndMark(collectors.getField0(), collectors.getField1()); } } return collectors; }
/** * 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; }
return Collections.singleton(new Tuple<>(someOutput, this));
outputs[0].getLineage().addPredecessor(probingExecutionLineageNode); return new Tuple<>(executionLineageNodes, producedChannelInstances);
return new Tuple<>(Arrays.asList(outputChannelInstances), partialExecution);
for (OutputSlot<?> loopOutput : loop.getAllOutputs()) { if (loopOutput.getOccupiedSlots().isEmpty()) { this.loopEnumeration.getServingOutputSlots().add(new Tuple<>(loopOutput, null)); } else { for (InputSlot<?> input : loopOutput.getOccupiedSlots()) { this.loopEnumeration.getServingOutputSlots().add(new Tuple<>(loopOutput, input));
return new Tuple<>(executionLineageNodes, producedChannelInstances);
return new Tuple<>(Arrays.asList(outputChannelInstances), partialExecution);
return new Tuple<>(executionLineageNodes, producedChannelInstances);