Java Lambda Expressions

    This document shows how to use lambda expressions and describes current limitations. For a general introduction to the Flink API, please refer to the DataSteam API overview

    Flink can automatically extract the result type information from the implementation of the method signature OUT map(IN value) because is not generic but Integer.

    Unfortunately, functions such as flatMap() with a signature void flatMap(IN value, Collector<OUT> out) are compiled into by the Java compiler. This makes it impossible for Flink to infer the type information for the output type automatically.

    In this case, the type information needs to be specified explicitly, otherwise the output will be treated as type Object which leads to unefficient serialization.

    Similar problems occur when using a map() function with a generic return type. A method signature Tuple2<Integer, Integer> map(Integer value) is erasured to in the example below.