/** * Set all of the {@code inputs} as predecessors of the {@code operatorContext} each of the {@code outputs}. * * @param inputs input {@link ChannelInstance}s * @param executionLineageNode in-between {@link ExecutionLineageNode} * @param outputs output {@link ChannelInstance}s * @see #addPredecessor(LazyExecutionLineageNode) */ public static void connectAll(ChannelInstance[] inputs, ExecutionLineageNode executionLineageNode, ChannelInstance[] outputs) { for (ChannelInstance input : inputs) { if (input != null) executionLineageNode.addPredecessor(input.getLineage()); } for (ChannelInstance output : outputs) { if (output != null) output.getLineage().addPredecessor(executionLineageNode); } }
/** * Utility method to forward a {@link JavaChannelInstance} to another. * * @param input that should be forwarded * @param output to that should be forwarded */ static void forward(ChannelInstance input, ChannelInstance output) { // Do the forward. if (output instanceof CollectionChannel.Instance) { ((CollectionChannel.Instance) output).accept(((CollectionChannel.Instance) input).provideCollection()); } else if (output instanceof StreamChannel.Instance) { ((StreamChannel.Instance) output).accept(((JavaChannelInstance) input).provideStream()); } else { throw new RheemException(String.format("Cannot forward %s to %s.", input, output)); } // Manipulate the lineage. output.getLineage().addPredecessor(input.getLineage()); }
/** * Utility method to forward a {@link RddChannel.Instance} to another. * * @param input that should be forwarded * @param output to that should be forwarded */ public void forward(ChannelInstance input, ChannelInstance output) { final RddChannel.Instance rddInput = (RddChannel.Instance) input; final RddChannel.Instance rddOutput = (RddChannel.Instance) output; // Do the forward. assert rddInput.getChannel().getDescriptor() == RddChannel.CACHED_DESCRIPTOR || rddOutput.getChannel().getDescriptor() != RddChannel.CACHED_DESCRIPTOR; rddOutput.accept(rddInput.provideRdd(), this); // Manipulate the lineage. output.getLineage().addPredecessor(input.getLineage()); }
/** * 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; }
probeTable.getOrDefault(keyExtractor1.apply(dataQuantum1), Collections.emptyList()).stream() .map(dataQuantum0 -> new Tuple2<>(dataQuantum0, dataQuantum1))); indexingExecutionLineageNode.addPredecessor(inputs[0].getLineage()); indexingExecutionLineageNode.collectAndMark(executionLineageNodes, producedChannelInstances); probingExecutionLineageNode.addPredecessor(inputs[1].getLineage()); } else { final int expectedNumElements = cardinalityEstimate1 == null ? probeTable.getOrDefault(keyExtractor0.apply(dataQuantum0), Collections.emptyList()).stream() .map(dataQuantum1 -> new Tuple2<>(dataQuantum0, dataQuantum1))); indexingExecutionLineageNode.addPredecessor(inputs[1].getLineage()); indexingExecutionLineageNode.collectAndMark(executionLineageNodes, producedChannelInstances); probingExecutionLineageNode.addPredecessor(inputs[0].getLineage()); outputs[0].getLineage().addPredecessor(probingExecutionLineageNode);
materializedInput = inputs[0]; probingInput = inputs[1]; probingExecutionLineageNode.addPredecessor(materializedInput.getLineage()); materializedInput = inputs[1]; probingInput = inputs[0]; probingExecutionLineageNode.addPredecessor(materializedInput.getLineage()); materializedInput = inputs[0]; probingInput = inputs[1]; indexingExecutionLineageNode.addPredecessor(materializedInput.getLineage()); indexingExecutionLineageNode.collectAndMark(executionLineageNodes, producedChannelInstances); materializedInput = inputs[1]; probingInput = inputs[0]; indexingExecutionLineageNode.addPredecessor(materializedInput.getLineage()); indexingExecutionLineageNode.collectAndMark(executionLineageNodes, producedChannelInstances); probingExecutionLineageNode.addPredecessor(probingInput.getLineage()); output.getLineage().addPredecessor(probingExecutionLineageNode); return new Tuple<>(executionLineageNodes, producedChannelInstances);
@Override public Tuple<Collection<ExecutionLineageNode>, Collection<ChannelInstance>> evaluate( ChannelInstance[] inputs, ChannelInstance[] outputs, JavaExecutor javaExecutor, OptimizationContext.OperatorContext operatorContext) { assert inputs.length == this.getNumInputs(); assert outputs.length == this.getNumOutputs(); String url = this.getInputUrl().trim(); FileSystem fs = FileSystems.getFileSystem(url).orElseThrow( () -> new RheemException(String.format("Cannot access file system of %s.", url)) ); try { final InputStream inputStream = fs.open(url); Stream<String> lines = new BufferedReader(new InputStreamReader(inputStream)).lines(); ((StreamChannel.Instance) outputs[0]).accept(lines); } catch (IOException e) { throw new RheemException(String.format("Reading %s failed.", url), e); } ExecutionLineageNode prepareLineageNode = new ExecutionLineageNode(operatorContext); prepareLineageNode.add(LoadProfileEstimators.createFromSpecification( "rheem.java.textfilesource.load.prepare", javaExecutor.getConfiguration() )); ExecutionLineageNode mainLineageNode = new ExecutionLineageNode(operatorContext); mainLineageNode.add(LoadProfileEstimators.createFromSpecification( "rheem.java.textfilesource.load.main", javaExecutor.getConfiguration() )); outputs[0].getLineage().addPredecessor(mainLineageNode); return prepareLineageNode.collectAndMark(); }
candidateStream = ((JavaChannelInstance) inputs[0]).provideStream(); probingTable = this.createProbingTable(((JavaChannelInstance) inputs[1]).provideStream()); indexingExecutionLineageNode.addPredecessor(inputs[0].getLineage()); probingExecutionLineageNode.addPredecessor(inputs[1].getLineage()); } else { candidateStream = ((JavaChannelInstance) inputs[1]).provideStream(); probingTable = this.createProbingTable(((JavaChannelInstance) inputs[0]).provideStream()); indexingExecutionLineageNode.addPredecessor(inputs[1].getLineage()); probingExecutionLineageNode.addPredecessor(inputs[0].getLineage()); outputs[0].getLineage().addPredecessor(probingExecutionLineageNode);
executionLineageNode.addPredecessor(inputs[CONVERGENCE_INPUT_INDEX].getLineage()); endloop = stoppingCondition.test(convergenceCollection); input = (JavaChannelInstance) inputs[ITERATION_INPUT_INDEX];
executionLineageNode.addPredecessor(inputs[ITERATION_CONVERGENCE_INPUT_INDEX].getLineage()); break; default:
executionLineageNode.addPredecessor(inputs[ITERATION_CONVERGENCE_INPUT_INDEX].getLineage());