apache beam 流式传输和同时处理多个文件和窗口连接?

apache beam streaming and processing multiple files at same time and windowed joins?

我刚看完这篇文章

https://medium.com/bb-tutorials-and-thoughts/how-to-create-a-streaming-job-on-gcp-dataflow-a71b9a28e432

我在这里真正想念的是,如果我删除 50 个文件,并且这是一个如文章所说的流式传输作业(始终有效),那么输出不会是所有文件的窗口连接吗?

如果不是,它会是什么样子以及如何变成窗口连接?我正在尝试获得我的两个世界的头像

任何人都可以阐明那篇文章以及会发生什么变化吗?

我还阅读了一些关于 'Bounded PCollections' 的内容。在那种情况下,也许不需要开窗,因为在流内部它有点像一批,直到我们处理了整个 Pcollection,我们才不会进入下一阶段?也许如果文章使用的是有界 pcollcation,那么所有输入文件都与输出文件 1 对 1 映射?

如何从函数内部判断我是从有界集合还是无界集合接收数据?还有其他方法可以告诉我吗?在 apache 束流作业中甚至可以进行有界集合吗?

我会尽量回答你的一些问题。

What I am truly missing here though is if I drop 50 files and this is a streaming job like the article says(always live), then won't the output be a windowed join of all the files?

输入(源)和输出(汇)没有直接联系。所以这取决于你在管道中做什么。 TextIO.watchForNewFiles 是一种流式源转换,它不断观察给定的文件位置并不断读取新闻文件并输出从此类文件中读取的行。因此,此步骤的输出将是一个 PCollection<String>,即从此类文件中读取的流式文本行。

接下来设置窗口化,这决定了您的数据将如何捆绑到 Windows。对于此管道,他们选择使用 FixedWindows 的 1 分钟。时间戳将是观察文件的时间。

接收器转换应用于管道的末端(有时接收器也会产生输出,因此它可能不是真正的末端)。在这种情况下,他们选择 TextIO.write() 将输入 PCollection<String> 中的字符串行写入输出文本文件。

因此,输出是否包含来自所有输入文件的数据取决于您的输入文件是如何处理的,以及它们是如何在管道中捆绑到 Windows 中的。

I also read something about 'Bounded PCollections'. In that case, perhaps windowing is not needed as inside the stream it is sort of like a batch of until we have the entire Pcollection processed, we do not move to the next stage? Perhaps if the article is using bounded pcollcation, then all input files map 1 to 1 with output files?

您可以在流式管道中使用有界输入。在流式管道中,进度通过 watermark 函数进行跟踪。如果您使用有界输入(例如,有界源),水印只会从 0 到无穷大,而不是逐渐前进。因此,您的管道可能只是结束而不是等待更多数据。

How can one tell from inside a function if I am receiving data from a bounded or unbounded collection? Is there some other way I can tell that? Is bounded collections even possible in apache beam streaming job?

我上面说的肯定是可以的。如果您有权访问输入 PCollection,则可以使用 isBounded function to determine if it is bounded. See here 作为示例。扩展 PTransforms 时(因此在作业提交期间),您可以访问输入 PCollections。我不相信你可以在运行时访问它。