Scarvy Scarvy - 1 month ago 25
Apache Configuration Question

Apache Flink - Error: method apply not applicable for the arguments (WindowFunction)

I am new using Apache Flink. I read data from a Apache Kafka source and need to transform the the DataStream.
In the last step I try to apply a WindowFunction:

DataStream<Tuple8<Double, Double, String, Double, Double, Double, Double, Double>> dataStream =
env
.addSource(new FlinkKafkaConsumer08<>(
parameterTool.getRequired("topic"),
new SimpleStringSchema(),
parameterTool.getProperties()))
.flatMap(new SplitIntoRecordsString())
.flatMap(new SplitIntoTuples())
.keyBy(1)
.countWindow(5)
.apply(new windowApplyFunction());

public class windowApplyFunction implements WindowFunction<
Tuple8<Double, Double, String, Double, Double, Double, Double, Double>,
String,
Double,
Window>{

public void apply(Double key, Window window,
Iterable<Tuple8<Double, Double, String, Double, Double, Double, Double, Double>> values,
Collector<String> out)
throws Exception {
out.collect("MyResult");
}
}


Unfortunately I got the following Error and don't know how to fix it:

The method apply(WindowFunction<Tuple8<Double,Double,String,Double,Double,Double,Double,Double>,R,Tuple,GlobalWindow>) in the type WindowedStream<Tuple8<Double,Double,String,Double,Double,Double,Double,Double>,Tuple,GlobalWindow> is not applicable for the arguments (FlinkManager.windowApplyFunction)


Everything works fine if I replace the apply(new windowApplyFunction()) with a predefined function, e.g. sum(1).

Any Ideas? Thanks!!

Answer

Your WindowFunction should be type of

WindowFunction<
    Tuple8<Double, Double, String, Double, Double, Double, Double, Double>,
    String,
    Double,
    GlobalWindow>

countWindow() returns GlobalWindow type.

Give it a try.