Ordering of Records in Stream

女生的网名这么多〃 提交于 2019-12-01 12:40:27

1) Yes and no. Flink uses so-called Watermarks to track the ordering. This ensures that records can be assigned to the correct windows and windows are not closed until all data is available. However, a strict order is not guaranteed per group (because of parallel incoming data). Between groups, there is no ordering guarantee at all.

2) Basically same answer as for (1).

3) You do not need to use keyBy again. The map/flatMap will be chained by default.

4) See https://ci.apache.org/projects/flink/flink-docs-release-1.0/internals/general_arch.html#the-processes

Concerning Ordering Guarantees

This page gives a good overview and explanation, also of ordering guarantees: https://ci.apache.org/projects/flink/flink-docs-release-1.0/concepts/concepts.html#parallel-dataflows

The Gist is:

Order is maintained within each parallel stream partition. For an explanation of stream partitions, see here: https://ci.apache.org/projects/flink/flink-docs-release-1.0/concepts/concepts.html#parallel-dataflows

For operations like "keyBy()" or "rebalance()" that change the partitioning, the order is maintained per pair of source and target stream partition, meaning per pair of sending and receiving operator.

As Matthias mentioned, if a group (defined by a key, running on one receiving target operator) gets elements from multiple senders, there is no well defined strict ordering of elements. Using concepts like event time, you can impose a meaningful ordering based on the data (the attached timestamps).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!