Search code examples
javaapache-flink

Incompatible Java Data Type


I'm building a Stream Processor using Apache Flink.

Simply put, I have no idea why this line:

SingleOutputStreamOperator<VideoAdEvent> windowedStream = videoAdEventDataStream
    .windowAll(TumblingEventTimeWindows.of(Time.seconds(5)));

throws me this exception when I compile

Compilation failure
[ERROR] incompatible types: no instance(s) of type variable(s) W exist so that org.apache.flink.streaming.api.datastream.AllWindowedStream<com.test.flink.videoadsinfluxsink.VideoAdEvent,W> conforms to org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator<com.test.flink.videoadsinfluxsink.VideoAdEvent>

Am I supposed to pass in W as an argument like: SingleOutputStreamOperator<VideoAdEvent, W> ? This seems to also throw me an issue


Solution

  • windowAll doesn't return a stream. Normally you would also specify how the window is to be processed, by calling reduce, aggregate, apply, or process on the result of windowAll, and in doing so, supply an appropriate function for processing the window's contents.

    If you really want to capture the result of windowAll for some reason, it returns an AllWindowedStream<T, W extends Window>, so you would do that like this:

    AllWindowedStream<VideoAdEvent, TumblingEventTimeWindow> windowedStream ...