背景
在flink的窗口函数运用中,window和windowAll方法总是会引起混淆,特别是结合上GlobalWindow的组合时,更是如此,本文就来梳理下他们的区别和常见用法
window和windowAll的区别
window是KeyStream数据流的方法,其并行度是任意的,也就是最大可以和分组key的数量相同
windowAll是DataStream数据流的方法,其并行度只能是1,也就是所有的元素都会被聚合到一个算子任务上,性能极差
GlobalWindows.create()是一个全局的窗口分配器,
它的作用和TimeWindow或CountWindow一样,都是对元素进行窗口分配,不同点在于GlobalWindows把分区内所有的元素分配到同一个窗口,并且不会触发计算,
而TimeWindow或CountWindow会基于时间或者元素个数对元素进行窗口的分配,并且满足条件就会触发计算
以下是示意图:

GlobalWindows+KeyedStream常见用法如下:
WindowedStream<Integer, Integer, GlobalWindow> keyedWindowedStream = keyedStream.window(GlobalWindows.create()).trigger(PurgingTrigger.of(CountTrigger.of(10)));
GlobalWindows+DataStream常见用法如下:
AllWindowedStream<Integer, GlobalWindow> allWindowedStream = dataStream.windowAll(GlobalWindows.create()).trigger(PurgingTrigger.of(CountTrigger.of(10)));
![[Linux版本Debian系统]安装cuda 和对应的cudnn以cuda 12.0为例](https://img-blog.csdnimg.cn/8dc2005cc7104af4a6e54310a0158187.png)




![23111705[含文档+PPT+源码等]计算机毕业设计SSM框架美妆商城全套电商购物](https://img-blog.csdnimg.cn/img_convert/3f4a538d4cb3350799e45d2a2ffed4fe.png)












