You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by MIkkel Islay <my...@gmail.com> on 2016/12/13 12:48:26 UTC

WindowFunction-extension, WindowedStream apply signature mismatch

(The following is a cross-post of a Stack Overflow question at
https://stackoverflow.com/questions/41105142/windowfunction-extension-does-not-match-windowedstream-apply-signatures
)

Why does the below error occur?

Given this extension to WindowFunction:

  class TestWinFunc extends WindowFunction[Top, Bottom, Long, TimeWindow] {
    override def apply(key: Long,
                       w: TimeWindow,
                       iterable: Iterable[Top],
                       collector: Collector[Bottom]): Unit = {
      collector.collect(Bottom(0.0,0.0,0.0,0.0,1L))
    }
  }

an *apply* transformation on a windowed stream:

    val bottom = inputstream
                .keyBy(_.stamp)
                .window(TumblingEventTimeWindows.of(Time.milliseconds(1)))
                .apply(new TestWinFunc)

yields the following error:

Error:overloaded method value apply with alternatives: [R](function: (Long,
org.apache.flink.streaming.api.windowing.windows.TimeWindow,
Iterable[Flink.ETL.Top], org.apache.flink.util.Collector[R]) =>
Unit)(implicit evidence$4:
org.apache.flink.api.common.typeinfo.TypeInformation[R])org.apache.flink.streaming.api.scala.DataStream[R]
[R](function:
org.apache.flink.streaming.api.scala.function.WindowFunction[Flink.ETL.Top,R,Long,org.apache.flink.streaming.api.windowing.windows.TimeWindow])(implicit
evidence$3:
org.apache.flink.api.common.typeinfo.TypeInformation[R])org.apache.flink.streaming.api.scala.DataStream[R]
cannot be applied to (Flink.ETL.TestWinFunc) .apply(new TestWinFunc)

The 'bottom' val argument to *apply* has type WindowedStream[Top, Long,
TimeWindow].

Flink 1.1.3 / Scala 2.11

Thanks,

Mikkel

Re: WindowFunction-extension, WindowedStream apply signature mismatch

Posted by Aljoscha Krettek <al...@apache.org>.
Hi,
are you using the WindowFunction in
org.apache.flink.streaming.api.scala.function? It's a bit tricky because
there is another WindowFunction in another package.

Cheers,
Aljoscha

On Tue, 13 Dec 2016 at 13:48 MIkkel Islay <my...@gmail.com> wrote:

> (The following is a cross-post of a Stack Overflow question at
> https://stackoverflow.com/questions/41105142/windowfunction-extension-does-not-match-windowedstream-apply-signatures
> )
>
> Why does the below error occur?
>
> Given this extension to WindowFunction:
>
>   class TestWinFunc extends WindowFunction[Top, Bottom, Long, TimeWindow] {
>     override def apply(key: Long,
>                        w: TimeWindow,
>                        iterable: Iterable[Top],
>                        collector: Collector[Bottom]): Unit = {
>       collector.collect(Bottom(0.0,0.0,0.0,0.0,1L))
>     }
>   }
>
> an *apply* transformation on a windowed stream:
>
>     val bottom = inputstream
>                 .keyBy(_.stamp)
>                 .window(TumblingEventTimeWindows.of(Time.milliseconds(1)))
>                 .apply(new TestWinFunc)
>
> yields the following error:
>
> Error:overloaded method value apply with alternatives: [R](function:
> (Long, org.apache.flink.streaming.api.windowing.windows.TimeWindow,
> Iterable[Flink.ETL.Top], org.apache.flink.util.Collector[R]) =>
> Unit)(implicit evidence$4:
> org.apache.flink.api.common.typeinfo.TypeInformation[R])org.apache.flink.streaming.api.scala.DataStream[R]
> [R](function:
> org.apache.flink.streaming.api.scala.function.WindowFunction[Flink.ETL.Top,R,Long,org.apache.flink.streaming.api.windowing.windows.TimeWindow])(implicit
> evidence$3:
> org.apache.flink.api.common.typeinfo.TypeInformation[R])org.apache.flink.streaming.api.scala.DataStream[R]
> cannot be applied to (Flink.ETL.TestWinFunc) .apply(new TestWinFunc)
>
> The 'bottom' val argument to *apply* has type WindowedStream[Top, Long,
> TimeWindow].
>
> Flink 1.1.3 / Scala 2.11
>
> Thanks,
>
> Mikkel
>
>