java - Apache 光束窗口:考虑延迟数据但只发出一个窗格
问题描述
当水印在窗口结束后达到 x 分钟时,我想发出一个窗格。这让我确保我处理了一些迟到的数据,但仍然只发出一个窗格。我目前在java中工作。
目前我找不到解决这个问题的适当方法。当水印到达窗口末尾时,我可以发出一个窗格,但随后会丢弃任何迟到的数据。我可以在窗口末尾发出窗格,然后在收到迟到的数据时再次发出,但是在这种情况下,我不会发出单个窗格。
我目前有类似这样的代码:
.triggering(
// This is going to emit the pane, but I don't want emit the pane yet!
AfterWatermark.pastEndOfWindow()
// This is going to emit panes each time I receive late data, however
// I would like to only emit one pane at the end of the allowedLateness
).withAllowedLateness(allowedLateness).accumulatingFiredPanes())
如果仍然存在混淆,我只想在水印通过allowedLateness
.
解决方案
谢谢 Guillem,最后我用你的答案找到了这个非常有用的链接,里面有很多 apache 梁示例。由此我想出了以下解决方案:
// We first specify to never emit any panes
.triggering(Never.ever())
// We then specify to fire always when closing the window. This will emit a
// single final pane at the end of allowedLateness
.withAllowedLateness(allowedLateness, Window.ClosingBehavior.FIRE_ALWAYS)
.discardingFiredPanes())
推荐阅读
- c# - Mongo DB C#如何更新很多字段并忽略一些字段
- shell - 如何在 Fish Shell 中使用 EOF 和 curl?
- java - 我想在 mysql 中使用 jdatechooser 在 java 中插入和更新日期
- javascript - 如何使用javascript触发添加输入事件监听器?
- next.js - NextJs 未使用的 Javascript
- r - 如何使用 ggplot 的 geom_smooth 突出显示图形的一部分?
- typescript - 打字稿递归类型退出条件
- sql - 使用点坐标查询最近的项目
- ruby-on-rails - 如何在 ActiveRecord 上创建子模型条件
- python - 我无法导入 Pytorch