赞
踩
每个并行的任务实例下有各自的累加器,获取最终值时会把各个并行任务的累加器的值求和。(一个并行度对应一个累加器)
版本: flink1.9.2 java1.8
map并行度1:
- package Counter;
-
- import org.apache.flink.api.common.JobExecutionResult;
- import org.apache.flink.api.common.accumulators.IntCounter;
- import org.apache.flink.api.common.functions.RichMapFunction;
- import org.apache.flink.configuration.Configuration;
- import org.apache.flink.streaming.api.datastream.DataStream;
- import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
-
- /**
- * @Author you guess
- * @Date 2020/6/25 12:30
- * @Version 1.0
- * @Desc
- */
- public class CounterTest1 {
-
- public static void main(String[] args) throws Exception {
- //获取执行环境
- final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
-
- //数据来源
- DataStream<String> source1 = env.fromElements("a", "b&#
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。