Flink学习笔记——用户自定义Functions
Flink支持用户自定义 Functions,方法有2个
Ref
https://ci.apache.org/projects/flink/flink-docs-release-1.12/zh/dev/user_defined_functions.html
1. 实现 MapFunction接口
class MyMapFunction implements MapFunction<String, Integer> { public Integer map(String value) { return Integer.parseInt(value); } }; data.map(new MyMapFunction());
2. 继承 RichMapFunction
class MyMapFunction extends RichMapFunction<String, Integer> { public Integer map(String value) { return Integer.parseInt(value); } };
累加器和计数器
这个应该和Hadoop和Spark的counter类似,参考
https://ci.apache.org/projects/flink/flink-docs-release-1.12/zh/dev/user_defined_functions.html#%E7%B4%AF%E5%8A%A0%E5%99%A8%E5%92%8C%E8%AE%A1%E6%95%B0%E5%99%A8
本文只发表于博客园和tonglin0325的博客,作者:tonglin0325,转载请注明原文链接:https://www.cnblogs.com/tonglin0325/p/14145063.html