package com.mischen.it;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
/**
* @ClassName Flink01_TransForm_Map_Anonymous
* @Description 得到一个新的数据流: 新的流的元素是原来流的元素的平方
* @Author mischen
* @Date 2021/6/29 0029 9:36
* @Version 1.0
**/
public class Flink01_TransForm_Map_Anonymous {
public static void main(String[] args) throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env
.fromElements(1, 2, 3, 4, 5)
.map(new MyMapFunction())
.print();
env.execute();
}
public static class MyMapFunction implements MapFunction<Integer, Integer> {
@Override
public Integer map(Integer value) throws Exception {
return value * value;
}
}
}
Flink编程(静态内部类)
最新推荐文章于 2024-06-19 16:13:48 发布