Diese Nutzung ist ein nicht arbeiten versuchen Flink für die Verwendung fach mit scala anonymer Funktion:Wie flink Falzfunktion in scala
val myFoldFunction = (x: Double, t:(Double,String,String)) => x + t._1
env.readFileStream(...).
...
.groupBy(1)
.fold(0.0, myFoldFunction : Function2[Double, (Double,String,String), Double])
Es kompiliert gut, aber bei der Ausführung, erhalte ich eine „Typ Löschung Ausgabe“ (siehe unten). In Java ist das in Ordnung, aber natürlich ausführlicher. Ich mag die prägnanten und klaren Lambdas. Wie kann ich das in Scala tun?
Caused by: org.apache.flink.api.common.functions.InvalidTypesException:
Type of TypeVariable 'R' in 'public org.apache.flink.streaming.api.scala.DataStream org.apache.flink.streaming.api.scala.DataStream.fold(java.lang.Object,scala.Function2,org.apache.flink.api.common.typeinfo.TypeInformation,scala.reflect.ClassTag)' could not be determined.
This is most likely a type erasure problem.
The type extraction currently supports types with generic variables only in cases where all variables in the return type can be deduced from the input type(s).