You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-zh@flink.apache.org by 赵一旦 <hi...@gmail.com> on 2020/11/29 04:16:52 UTC

Flink的富函数类中重新声明接口方法的目的是什么

如题,事例如下。

public interface MapFunction<T, O> extends Function, Serializable {

   /**
    * The mapping method. Takes an element from the input data set and
transforms
    * it into exactly one element.
    *
    * @param value The input value.
    * @return The transformed value
    *
    * @throws Exception This method may throw exceptions. Throwing an
exception will cause the operation
    *                   to fail and may trigger recovery.
    */
   O map(T value) throws Exception;
}


public abstract class RichMapFunction<IN, OUT> extends
AbstractRichFunction implements MapFunction<IN, OUT> {

   private static final long serialVersionUID = 1L;

   @Override
   public abstract OUT map(IN value) throws Exception;
}


如上,为什么要把map函数重新声明呢?

貌似所有的富函数类和对应接口都是这样,这有什么用处吗?