根据元素值后关闭窗口 [英] Close window after based on element value

查看:55
本文介绍了根据元素值后关闭窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当输入元素在DoFn的侧面输出中具有标志值时,是否可以关闭窗口?例如.指示会话关闭的事件会关闭窗口.

Is there a way to close a window when an input element has a flag value in the side output of a DoFn? E.g. event which indicates closing of a session closes the window.

我一直在阅读文档,并且触发器主要基于时间.一个例子将是很好的.

I've been reading the docs, and triggers are time based mostly. An example would be great.

Trigger.OnElementContext.forTrigger(ExecutableTrigger触发器)似乎很有希望,但ExecutableTrigger文档目前非常苗条.

Trigger.OnElementContext.forTrigger(ExecutableTrigger trigger) seems promising but ExecutableTrigger docs are pretty slim at the moment.

推荐答案

我认为这不可用.现在只有一个数据驱动触发器,elementCountAtLeast.

I don't think that this is available. There is only one Data Driven Trigger right now, elementCountAtLeast.

https://cloud.google.com/dataflow/model/triggers#data-driven-triggers

一种解决方法是复制会话窗口功能代码并编写自定义窗口功能.

A work around for this would be to copy the sessions window function code and write a custom window function.

简而言之,您一直将元素分配到同一窗口中,直到看到终止元素为止.然后开始创建一个新窗口.

In short, you keep assigning elements into the same window, until you see your terminating element. Then start creating a new window.

https://github.com/apache/beam/blob/890bc1a23f493b042f8c2de5c042970ce5ddca96/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowinging/Sessions.java#L60

这篇关于根据元素值后关闭窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆