我是 GCP Dataflow 的新手,只是想了解是否有任何方法可以打印 PCollection 的所有值。
Pipeline p = Pipeline.create(options);
PCollection<String> lines = p.apply("ReadLines", TextIO.read().from(options.getInputFile()));
在这里,我想打印并检查行中可用的所有值(PCollection)
同样,想在以下操作后访问单词中的所有值
PCollection<String> words = lines.apply(
FlatMapElements.into(TypeDescriptors.strings())
.via((String line) -> Arrays.asList(line.split(" "))));
最佳答案
在你的主函数中
p.apply("ReadLines", TextIO.read().from(options.getInputFile()))
.apply("Print",ParDo.of(new PrintElementFn()))
编写静态类
private static class PrintElementFn extends DoFn<String,Void>{
@ProcessElement
public void processElement(@Element String input){
System.out.println(input);
}
}
关于google-cloud-platform - GCP数据流: print PCollection data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64048360/