storm滑动窗口

时间:2023-03-09 20:50:33
storm滑动窗口

Window滑动方式:

没有数据不滑动
windowLength:窗口的时间长度/tuple个数
slidingInterval:滑动的时间间隔/tuple个数

withWindow(Duration windowLength)
1.表示每个tuple滑动一次,滑动的窗口的时间长度是windowLength。

withWindow(Duration windowLength, Duration slidingInterval)
2.表示每隔slidingInterval时间,滑动窗口,滑动的窗口的时间长度是windowLength ,没有数据不滑动。

withWindow(Count windowLength, Count slidingInterval)
3.表示每隔slidingInterval的tuple数,滑动窗口,滑动的窗口的tuple个数是windowLength ,没有数据不滑动。

withWindow(Count windowLength)
4.表示每个tuple滑动一次,滑动的窗口的tuple个数是windowLength。

withWindow(Count windowLength, Duration slidingInterval)

5.表示每隔slidingInterval时间,滑动窗口,滑动的窗口的tuple个数是windowLength ,没有数据不滑动。

withWindow(Duration windowLength, Count slidingInterval)
6.表示每隔slidingInterval的tuple数,滑动窗口,滑动的窗口的时间长度是windowLength ,没有数据不滑动。

表示图:例如每5秒滑动一次,滑动窗口大小是10秒

........| e1 e2 | e3 e4 e5 e6 | e7 e8 e9 |...
-5 0 5 10 15 -> time
|<------- w1 -->|
|<---------- w2 ----->|
|<-------------- w3 ---->|

TumblingWindow滑动方式:
withTumblingWindow(BaseWindowedBolt.Count count)
1.表示间隔count个tuple数之后滑动一次窗口

withTumblingWindow(BaseWindowedBolt.Duration duration)

2.表示间隔时长duration之后滑动一次窗口

表示图:每5秒滑动一次窗口

| e1 e2 | e3 e4 e5 e6 | e7 e8 e9 |...
0 5 10 15 -> time
w1 w2 w3