Flink Window those things --Window small class (Window Assinger type)

1, Window Assinger is doing is
when you decide whether to stream keyby, window is not built, and you also need to specify a window Assinger define how elements are assigned to the window.

2, how to specify window Assinger?
Keyedstream: window (WindowAssigner)
non-keyed STREAMS: WindoWall (WindowAssigner)
action of the window Assinger: responsible for assigning each element passed to one or more windows

With the window Assinger, will create a window to cover all forms of various scenes we need, so do not be too concerned about the classification window itself, you can focus on the classification of window Assinger.

Count-based window: grouping slicing data stream according to the number of elements
Tumbling CountWindow (tumbling window)
Sliding CountWindow (sliding window)

Time-based window: grouping the data stream according to the time slice
Tumbling the Window
Sliding the Window
the Session the Window

注意:Time-based window [start,end)

3, Tumbling Windows- rolling window
3.1, the definition: the data slice the data according to a fixed window length

3.2 Features:
time alignment
window length is fixed
event no overlap

3.3 Application scenario:
BI Statistics (index calculated for each time period)

3.4, Tumbling Windows using
alignment: The default is aligned with epoch (the whole point, aliquot, the second, and the like), the alignment may be changed by the offset parameter

4, Sliding Windows- sliding window
4.1, the definition of: a more generalized form of a fixed window. Sliding window and a fixed window length sliding spacer consisting

4.2 Features:
time alignment
window length is fixed
event overlap

4.3 Application scenario:
monitoring the scene, the statistics for the most recent period of time (recently seeking an interface failure rate 5min to decide whether or not to alarm)

4.4, Sliding Windows using
alignment: The default is aligned with epoch (the whole point, aliquot, the second, and the like), the alignment may be changed by the offset parameter.

. 5, the Session the Windows
5.1, define:
similar session web application, i.e. new data is not received for some time will generate a new window (a fixed gap / gap fun)

5.2 Features:
No alignment
event does not overlap
there is no fixed start and end times

 

5.3 Application scenario:
online user behavior analysis

5.4、Session Windows的使用
5.4.1、Gap
固定gap
动态gap(函数):实现SessionWindowTimeGapExtractor

 

5.4.2、特殊处理方式
session window operator为每个到达的event创建一个新窗口,如果它们之间的距离比定义的间隔更近,则将窗口合并在一起

为了能够合并, session window operator需要合并触发器和合并窗口函数,例如ReduceFunction、AggregateFunction或ProcessWindowFunction (FoldFunction不能合并)

6、Global Windows
6.1、定义:有相同key的所有元素分配给相同的单个全局窗口

6.2、必须指定自定义触发器否则没有任何意义

6.3、注意:不要跟Non-keyed Window搞混,两个不同的角度

Guess you like

Origin www.cnblogs.com/linjiqin/p/12589714.html