Flink中的 richfunction 有一点小作用
发布时间
阅读量:
阅读量
①参数传递
所有由用户自行设定的函数均可转化为richfunction形式,例如在构建map operator时,需创建一个内部类并完成其map方法的定义:
data.map (new MapFunction<String, Integer>() {
public Integer map(String value) { return Integer.parseInt(value); }
});
接下来,我们能够将该过程转化为RichMapFunction的实现形式:
data.map (new RichMapFunction<String, Integer>() {
public Integer map(String value) { return Integer.parseInt(value); }
});
此外,RichFuction不仅保留了MapFuction原有的功能,还新增了open、close、getRuntimeContext以及setRuntimeContext等方法。这些新增的功能可以用于实现函数的参数化(即参数传递),支持本地状态的创建与管
全部评论 (0)
还没有任何评论哟~
