【问题标题】:Is it possible to efficiently convert PCollection list to PCollection (just values from the list)?是否可以有效地将 PCollection 列表转换为 PCollection(只是列表中的值)?
【发布时间】:2021-01-28 09:45:36
【问题描述】:

我知道可以使用 ParDo 函数直接从列表中生成元素,但是还有其他直接或更有效的方法吗?

【问题讨论】:

  • 也许您可以添加一些上下文、您的一些代码以及您尝试过的内容以及预期行为和实际行为之间的区别,以便我们为您提供帮助

标签: python mapreduce apache-beam


【解决方案1】:

按照official Documentation,您可以使用Flatten 方法来合并PCollection。 the Beam Programming Guide 中提供了示例。

# Flatten takes a tuple of PCollection objects.
# Returns a single PCollection that contains all of the elements in the PCollection objects in that tuple.

merged = (
    (pcoll1, pcoll2, pcoll3)
    # A list of tuples can be "piped" directly into a Flatten transform.
    | beam.Flatten())

【讨论】:

  • PCollection 列表不同于不同 PCollection 的元组。它是一个常规的 PCollection 对象。
  • @PartheshSoni 到目前为止你尝试过什么?
猜你喜欢
  • 2021-05-15
  • 1970-01-01
  • 1970-01-01
  • 2022-12-31
  • 1970-01-01
  • 2021-12-14
  • 1970-01-01
  • 1970-01-01
  • 2021-03-23
相关资源
最近更新 更多