Flink支持用户自定义 Functions,方法有2个
Ref
1 | https://ci.apache.org/projects/flink/flink-docs-release-1.12/zh/dev/user_defined_functions.html |
- 实现 MapFunction接口
1 | class MyMapFunction implements MapFunction<String, Integer> { |
- 继承 RichMapFunction
1 | class MyMapFunction extends RichMapFunction<String, Integer> { |
累加器和计数器
这个应该和Hadoop和Spark的counter类似,参考
1 | 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 |