Interface FlatMapFunction<T,​O>

  • Type Parameters:
    T - Type of the input elements.
    O - Type of the returned elements.
    All Superinterfaces:
    org.apache.flink.api.common.functions.Function, Serializable
    All Known Implementing Classes:
    BulkIterationBase.TerminationCriterionMapper, RichFlatMapFunction
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @Public
    @FunctionalInterface
    public interface FlatMapFunction<T,​O>
    extends org.apache.flink.api.common.functions.Function, Serializable
    Base interface for flatMap functions. FlatMap functions take elements and transform them, into zero, one, or more elements. Typical applications can be splitting elements, or unnesting lists and arrays. Operations that produce multiple strictly one result element per input element can also use the MapFunction.

    The basic syntax for using a FlatMapFunction is as follows:

    
     DataSet<X> input = ...;
    
     DataSet<Y> result = input.flatMap(new MyFlatMapFunction());
     
    • Method Detail

      • flatMap

        void flatMap​(T value,
                     Collector<O> out)
              throws Exception
        The core method of the FlatMapFunction. Takes an element from the input data set and transforms it into zero, one, or more elements.
        Parameters:
        value - The input value.
        out - The collector for returning result values.
        Throws:
        Exception - This method may throw exceptions. Throwing an exception will cause the operation to fail and may trigger recovery.