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