此代码运行良好:
.keyBy(value -> value.getSessionUid())
但是这个
.keyBy(LogItem::getSessionUid)
抛出异常:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at org.apache.flink.api.java.typeutils.TypeExtractor.getUnaryOperatorReturnType(TypeExtractor.java:294)
at org.apache.flink.api.java.typeutils.TypeExtractor.getKeySelectorTypes(TypeExtractor.java:253)
at org.apache.flink.api.java.typeutils.TypeExtractor.getKeySelectorTypes(TypeExtractor.java:246)
at org.apache.flink.streaming.api.datastream.KeyedStream.<init>(KeyedStream.java:87)
at org.apache.flink.streaming.api.datastream.DataStream.keyBy(DataStream.java:241)
at streamer_sessions_aggregator.StreamerSessionAggregator.runFlow(StreamerSessionAggregator.java:40)
at streamer_sessions_aggregator.Main.main(Main.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
据我所知,ApacheFlink 1.0.0现在不支持引用方法。正确的
Flink目前不支持引用方法。以下是JIRA添加对它的支持:https://issues.apache.org/jira/browse/FLINK-3138