針對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
