zl程序教程

您现在的位置是:首页 >  系统

当前栏目

7-6Keyed vs Non-Keyed Windows

Windowsvs Non
2023-09-14 09:14:45 时间

The first thing to specify is whether your stream should be keyed or not. This has to be done before defining the window. Using the keyBy(...) will split your infinite stream into logical keyed streams. If keyBy(...) is not called, your stream is not keyed.

In the case of keyed streams, any attribute of your incoming events can be used as a key (more details here). Having a keyed stream will allow your windowed computation to be performed in parallel by multiple tasks, as each logical keyed stream can be processed independently from the rest. All elements referring to the same key will be sent to the same parallel task.

In case of non-keyed streams, your original stream will not be split into multiple logical streams and all the windowing logic will be performed by a single task, i.e. with parallelism of 1.

keyBy:可以多任务并行执行

not keyBy:只能单任务并行度为1执行