【发布时间】:2018-12-17 05:57:40
【问题描述】:
来自apache doc on Distinct:Distinct<T> takes a PCollection<T> and returns a PCollection<T> that has all distinct elements of the input. Thus, each element is unique within each window.
此外,如果我没记错的话,除非在 Dataflow 2.5.0 的批处理中另有说明,否则所有元素都是同一窗口的一部分。
这意味着线性管道中的Distinct 阶段将适用于所有元素。但是,我观察到Distinct 之后的阶段可能在Distinct 阶段完成之前已经开始处理(=某些元素尚未完成)。更重要的是,Distinct 阶段似乎只需要很少的计算能力(如在可视化 console.cloud.google.com/dataflow/jobsDetail/... 上所见),这是出乎意料的,因为在数百万个输入中查找重复项似乎对我来说就像一个后续任务。
所以我的问题如下:带有批处理的线性管道上的Distinct 阶段确实适用于批处理的所有元素吗?我错过了什么吗?
一个示例管道:
Pipeline p = Pipeline.create(options);
p.apply("Stuff", ParDo.of(new Stuff())
.apply(Distinct.<String>create())
.apply("OtherStuff", ParDo.of(new OtherStuff())
【问题讨论】:
标签: java google-cloud-dataflow apache-beam distinct-values