public void transform(KEY key, VALUE value) throws Exception { KeyValue<KEY, VALUE> input = new KeyValue<>(key, value); transformExecutor.runOneIteration(input); }
/** * Create a transform executor for the specified pipeline. Will instantiate and initialize all sources, * transforms, and sinks in the pipeline. * * @param pipeline the pipeline to create a transform executor for * @param outputWriter writes output records to the mapreduce context * @return executor for the pipeline * @throws InstantiationException if there was an error instantiating a plugin * @throws Exception if there was an error initializing a plugin */ public <KEY_OUT, VAL_OUT> PipeTransformExecutor<T> create(PipelinePhase pipeline, OutputWriter<KEY_OUT, VAL_OUT> outputWriter) throws Exception { // populate the pipe stages in reverse topological order to ensure that an output is always created before its // input. this will allow us to setup all outputs for a stage when we get to it. List<String> traversalOrder = pipeline.getDag().getTopologicalOrder(); Collections.reverse(traversalOrder); Map<String, PipeStage> pipeStages = new HashMap<>(); for (String stageName : traversalOrder) { pipeStages.put(stageName, getPipeStage(pipeline, stageName, pipeStages, outputWriter)); } // sourceStageName will be null in reducers, so need to handle that case Set<String> startingPoints = (sourceStageName == null) ? pipeline.getSources() : Sets.newHashSet(sourceStageName); return new PipeTransformExecutor<>(pipeStages, startingPoints); }