Flink 报错:The generic type parameters of 'Tuple2' are missing. In many cases lambda methods don't provide enough information for automatic type extraction when Java generics are involved


针对flink中的算子为什么要返回指定的类型,不然的话报错比如(Tuple,KeyBy)

函数的输入i和输出参数的类型map()无需声明,因为它们是Java编译器推断的。有的则使Flink无法自动推断输出类型的类型信息。

常见报错信息:

org.apache.flink.api.common.functions.InvalidTypesException: The generic type parameters of 'Collector' are missing.
    In many cases lambda methods don't provide enough information for automatic type extraction when Java generics are involved.
    An easy workaround is to use an (anonymous) class instead that implements the 'org.apache.flink.api.common.functions.FlatMapFunction' interface.
    Otherwise the type has to be specified explicitly using type information.

 

参考官网:

https://ci.apache.org/projects/flink/flink-docs-stable/dev/java_lambdas.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM