PubsubIO.Read 开窗指南

PubsubIO.Read guidance on Windowing

来自 docs(文档是 1.x,尽管我使用的是 2.2):

Note: By default, PubsubIO transforms create unbounded PCollections. After you create a PCollection by using PubsubIO.Read, you should apply a windowing strategy to that PCollection before applying any transforms that group elements, such as GroupByKey or Combine.

  1. 所以如果我不需要使用分组转换,在使用PubsubIO.Read时是否不需要应用window?

  2. 如果我确实使用了分组转换,但没有指定 window,会发生什么情况? PubsubIO.Read?

  3. 默认应用默认 window

默认 windowing 策略是使用所有元素所属的单个全局 window。

如果您确定您的管道不使用分组或聚合,那么您可以使用默认的全局 windows。但是,您可能仍然需要一个 trigger 条件来指定应该从接收器转换中写入数据的时间点。否则,数据将永远累积在全局 window 中,导致您的管道出现卡顿。

Beam 文档在此处提供了有关 windowing 的更多详细信息:https://beam.apache.org/documentation/programming-guide/#windowing