批处理管道上的不同操作

Distinct operation on a batch pipeline

来自apache doc on DistinctDistinct<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 的批处理中另有说明,否则所有元素都是相同的 window.

的一部分

这意味着线性管道中的 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())

是的,它适用于所有元素。基本上,在不同操作之后的阶段已经开始处理时没有问题。 distinct 操作只需要抑制重复,但可以处理元素的第一个观察值。

请查看 implementation 以了解其内部工作原理,因为它基本上由一个简单的 Combine.perKey 操作组成,没有聚合任何值。