【问题标题】:Distinct operation on a batch pipeline批处理管道上的不同操作
【发布时间】:2018-12-17 05:57:40
【问题描述】:

来自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 的批处理中另有说明,否则所有元素都是同一窗口的一部分。

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


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-25
      • 2018-05-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多