1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| TUMBLE(t, INTERVAL '2' HOUR)滚动,2小时一个窗口 HOP(t, INTERVAL '2' HOUR, INTERVAL '1' HOUR)滑动,每1小时聚合前2小时窗口 SESSION(t,INTERVAL '30' MINUTE)会话,30分钟无响应化为一个窗口
clicks:user, cTime, url SELECT user, TUMBLE_END(cTime, INTERVAL '1' HOURS) AS endT, COUNT(url) as cnt FROM clicks GROUP BY user, TUMBLE(cTime, INTERVAL '1' HOURS)
输出模式 Window按时输出 Group提前输出 输出量 Window只输出一次结果 Group Per Key输出N个结果(Sink压力) 输出流 Window AppendStream Group UpdateStream 状态清理 Window及时清理过期数据 Group状态无限增长 Sink Window均可 Group可更新的结果表
SELECT toAreaId(lon, lat) AS area, TUMBLE_END(rideTime, INTERVAL '5' MINUTE) AS window_end, COUNT(*) AS cnt FROM Rides WHERE isInNYC(lon, lat) and isStart GROUP BY toAreaId(lon, lat), TUMBLE(rideTime, INTERVAL '5' MINUTE) HAVING COUNT(*) >= 5;
|