@Override public Iterable<OutputType> call(Iterator<InputType> it) throws Exception { List<OutputType> out = new ArrayList<>(); while (it.hasNext()) { final Iterable<OutputType> mappedPartition = this.function.apply(Iterators.wrapWithIterable(it)); for (OutputType dataQuantum : mappedPartition) { out.add(dataQuantum); } } return out; } }
@Override public Iterable<OutputType> call(Iterator<InputType> it) throws Exception { this.impl.open(executionContext); List<OutputType> out = new ArrayList<>(); while (it.hasNext()) { final Iterable<OutputType> mappedPartition = this.impl.apply(Iterators.wrapWithIterable(it)); for (OutputType dataQuantum : mappedPartition) { out.add(dataQuantum); } } return out; } }
@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(); final Function<Iterable<InputType>, Iterable<OutputType>> function = javaExecutor.getCompiler().compile(this.functionDescriptor); JavaExecutor.openFunction(this, function, inputs, operatorContext); final Iterable<OutputType> outputDataQuanta = function.apply(Iterators.wrapWithIterable(((JavaChannelInstance) inputs[0]).<InputType>provideStream().iterator())); ((StreamChannel.Instance) outputs[0]).accept(StreamSupport.stream( Spliterators.spliteratorUnknownSize( outputDataQuanta.iterator(), Spliterator.ORDERED), false )); return ExecutionOperator.modelLazyExecution(inputs, outputs, operatorContext); }