当前位置:   article > 正文

【Flink报错】Could not determine TypeInformation for the OutputTag type.

could not determine typeinformation for the outputtag type. the most common

报错信息:

Exception in thread "main" org.apache.flink.api.common.functions.InvalidTypesException: Could not determine TypeInformation for the OutputTag type. The most common reason is forgetting to make the OutputTag an anonymous inner class. It is also not possible to use generic type variables with OutputTags, such as 'Tuple2<A, B>'.at org.apache.flink.util.OutputTag.<init>(OutputTag.java:68)
  • 1

在这里插入图片描述


原因分析:

找不到OutputTag 的类型,是由于泛型擦除导致的,我们可以通过匿名内部类的方式解决这个问题.
在这里插入图片描述


解决方案:

在这里插入图片描述

//定义一个输出标签
        OutputTag<Event> late = new OutputTag<Event>("late");


        SingleOutputStreamOperator<UrlViewCount> result = stream.keyBy(data -> data.url)
                .window(TumblingEventTimeWindows.of(Time.seconds(10)))
                .allowedLateness(Time.minutes(1))
                .sideOutputLateData(late)
                .aggregate(new UrlViewCountAgg(), new UrlViewCountResult());
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

在这里插入图片描述

//定义一个输出标签
        OutputTag<Event> late = new OutputTag<Event>("late"){};


        SingleOutputStreamOperator<UrlViewCount> result = stream.keyBy(data -> data.url)
                .window(TumblingEventTimeWindows.of(Time.seconds(10)))
                .allowedLateness(Time.minutes(1))
                .sideOutputLateData(late)
                .aggregate(new UrlViewCountAgg(), new UrlViewCountResult());
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

只需在代码后面加上大括号即可。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/972511
推荐阅读
相关标签
  

闽ICP备14008679号