import org.apache.flink.util.Collector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
-
@author will
-
@email zq2599@gmail.com
-
@date 2020-11-11 09:48
-
@description 功能介绍
*/
public class AddTwoSourceValue extends AbstractCoProcessFunctionExecutor {
private static final Logger logger = LoggerFactory.getLogger(AddTwoSourceValue.class);
@Override
protected CoProcessFunction<Tuple2<String, Integer>, Tuple2<String, Integer>, Tuple2<String, Integer>> getCoProcessFunctionInstance() {
return new CoProcessFunction<Tuple2<String, Integer>, Tuple2<String, Integer>, Tuple2<String, Integer>>() {
// 某个key在processElement1中存入的状态
private ValueState state1;
// 某个key在processElement2中存入的状态
private ValueState state2;<

本文详细介绍了如何使用Flink的CoProcessFunction进行状态处理,通过实例展示了如何处理来自两个源的数据并进行融合。关键点包括:当key不确定先出现在哪个源时,将值保存在相应状态中,以及数据处理完后清理状态。文章还提供了验证步骤以帮助读者理解其工作原理。
最低0.47元/天 解锁文章
780

被折叠的 条评论
为什么被折叠?



