KSQL跳频窗口:仅访问最旧的子窗口 [英] KSQL Hopping Window : accessing only oldest subwindow

查看:60
本文介绍了KSQL跳频窗口:仅访问最旧的子窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用看起来像这样的查询来跟踪特定字段的滚动总和:

I am tracking the rolling sum of a particular field by using a query which looks something like this :

SELECT id, SUM(quantity) AS quantity from stream \
WINDOW HOPPING (SIZE 1 MINUTE, ADVANCE BY 10 SECONDS) \
GROUP BY id;

现在,对于每个输入的滴答声,似乎我会返回以下六个时间段的6个不同的汇总值:

Now, for every input tick, it seems to return me 6 different aggregated values I guess which are for the following time periods :

[start, start+60] seconds
[start+10, start+60] seconds
[start+20, start+60] seconds
[start+30, start+60] seconds
[start+40, start+60] seconds
[start+50, start+60] seconds

如果我感兴趣的话,每次进入的每个滴答声都只会获得[start,start + 60]秒的结果.总之,只有那样吗?

What if I am interested is only getting the [start, start+60] seconds result for every tick that comes in. Is there anyway to get ONLY that?

推荐答案

由于您指定了一个跳跃窗口,因此每个记录都属于多个窗口,并且在处理记录时需要更新所有窗口.仅更新一个窗口将是不正确的,并且结果将是错误的.

Because you specify a hopping window, each record falls into multiple windows and all windows need to be updated when processing a record. Updating only one window would be incorrect and the result would be wrong.

比较有关跳窗的Kafka Streams文档(Kafka Streams是KSQL的内部运行时引擎): https://docs.confluent.io/current/streams/developer-guide/dsl-api.html#hopping-time-windows

Compare the Kafka Streams docs about hopping windows (Kafka Streams is KSQL's internal runtime engine): https://docs.confluent.io/current/streams/developer-guide/dsl-api.html#hopping-time-windows

更新

Kafka Streams通过KIP-450(

Kafka Streams is adding proper sliding window support via KIP-450 (https://cwiki.apache.org/confluence/display/KAFKA/KIP-450%3A+Sliding+Window+Aggregations+in+the+DSL). This should allow to add sliding window to ksqlDB later, too.

这篇关于KSQL跳频窗口:仅访问最旧的子窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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