@Override public void translateNode( Read.Bounded<T> transform, FlinkStreamingTranslationContext context) { PCollection<T> output = context.getOutput(transform); TypeInformation<WindowedValue<T>> outputTypeInfo = context.getTypeInfo(context.getOutput(transform)); DataStream<WindowedValue<T>> source; try { BoundedSourceWrapper<T> sourceWrapper = new BoundedSourceWrapper<>( context.getCurrentTransform().getFullName(), context.getPipelineOptions(), transform.getSource(), context.getExecutionEnvironment().getParallelism()); source = context .getExecutionEnvironment() .addSource(sourceWrapper).name(transform.getName()).returns(outputTypeInfo); } catch (Exception e) { throw new RuntimeException( "Error while translating BoundedSource: " + transform.getSource(), e); } context.setOutputDataStream(output, source); } }
@Override public void translateNode(Read.Bounded<T> transform, FlinkBatchTranslationContext context) { String name = transform.getName(); BoundedSource<T> source = transform.getSource(); PCollection<T> output = context.getOutput(transform); TypeInformation<WindowedValue<T>> typeInformation = context.getTypeInfo(output); DataSource<WindowedValue<T>> dataSource = new DataSource<>( context.getExecutionEnvironment(), new SourceInputFormat<>( context.getCurrentTransform().getFullName(), source, context.getPipelineOptions()), typeInformation, name); context.setOutputDataSet(output, dataSource); } }