The 0.10.0 release introduced API breaking changes. This guide tries to ease the transition from 0.9.x to 0.10.x. It is highly recommended to update to this release as it includes many improvements all over the system.

DataStream API Java Dependency

The flink-streaming-core dependency has been renamed to flink-streaming-java. For the Scala API dependency, nothing has changed.

<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java</artifactId>
<version>0.10.0</version>
</dependency>

DataStream API

Replaced groupBy with keyBy

The groupBy method has been replaced with keyBy, which creates a partitioned stream. Reduce-style operations such as reducesum, or fold work on elements that have the same key. You can replace your old groupBy operations directly keyBy.

Aggregations require a partitioned stream

In 0.9.x it was possible to run a aggregations like countfold, min, minBy, max, maxBy or sum over the entire DataStream without partitioning the stream. This has been removed and you have to partition the stream via keyBy before you can run any of these operations.

Windows

The windowing mechanism has been completely reworked for the 0.10.0 release with support for event time and session windows whereas Flink 0.9.x only supports processing time windows. This is still the default time semantic used in 0.10.0. Check out the DataStream API documentation for an overview of the APIs. The following table gives an overview of how to migrate your windowing code:

 0.9.x0.10.x
Time windows
Tumbling
stream
.groupBy(0)
.window(Time.of(2, TimeUnit.SECONDS))
stream
.keyBy(0)
.timeWindow(Time.of(2, TimeUnit.SECONDS))
Sliding
stream
.groupBy(0)
.window(Time.of(2, TimeUnit.SECONDS))
.every(Time.of(1, TimeUnit.SECONDS))
stream
.keyBy(0)
.timeWindow(Time.of(2, TimeUnit.SECONDS),
Time.of(1, TimeUnit.SECONDS))
Count Windows
Tumbling
stream
.groupBy(0)
.window(Count.of(2)
stream
.keyBy(0)
.countWindow(2)
Sliding
stream
.groupBy(0)
.window(Count.of(2)
.every(Count.of(1))
stream
.keyBy(0)
.countWindow(2, 1)
All Windows (over non-partitioned streams)
Time
stream
.window(Time.of(2, TimeUnit.SECONDS))
stream
.timeWindowAll(Time.of(2, TimeUnit.SECONDS))
Count
stream
.window(Count.of(2))
stream
.countWindowAll(2)

Removed cross operator

The cross operator has been removed.

Added new operations

  • Custom stream partitioning via partitionCustom(Partitioner<K> partitioner, [int field | String field | KeySelector<T, K> keySelector | Keys<T> keys])

 

  • No labels