【问题标题】:Batch PCollection in Beam/DataflowBeam/Dataflow 中的批量 PCollection
【发布时间】:2017-06-03 20:02:04
【问题描述】:

我在 GCP Dataflow/Apache Beam 中有一个 PCollection。我需要“按 N”组合,而不是一一处理。像grouped(N) 这样的东西。因此,在有界处理的情况下,它将分批按 10 个项目分组,最后一批将剩下的所有项目分组。 这在 Apache Beam 中可行吗?

【问题讨论】:

  • GroupIntoBatchesPTransform 在这里不适用吗?

标签: google-cloud-dataflow apache-beam


【解决方案1】:

编辑,看起来像:Google Dataflow "elementCountExact" aggregation

您应该能够通过将元素分配给全局窗口并使用AfterPane.elementCountAtLeast(N) 来做类似的事情。如果没有足够的元素来触发触发器,您仍然需要考虑怎么办。你可以使用这个:

 Repeatedly.forever(AfterFirst.of(
  AfterPane.elementCountAtLeast(N),
  AfterProcessingTime.pastFirstElementInPane().plusDelayOf(Duration.standardMinutes(X))))

但是您首先应该问自己为什么需要这种启发式方法,可能有更多的惯用方法可以解决您的问题。在Beam’s programming guide 中了解Data-Driven Triggers

【讨论】:

    猜你喜欢
    • 2019-02-09
    • 2018-06-24
    • 1970-01-01
    • 2018-05-22
    • 1970-01-01
    • 2022-12-18
    • 1970-01-01
    • 2022-12-31
    相关资源
    最近更新 更多