You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Vlad Podgurschi <vl...@podgurschi.org> on 2016/05/09 03:45:18 UTC

assigning stream element to multiple windows of different types

Hello,

Is it possible to assign one record of a stream to multiple windows of
different types, like so:


class MultiAssigner extends WindowAssigner[Record, ReportWindow] {

  override def assignWindows(i: Record, timestamp: Long) =
    asJavaCollection(
      List(
        W1(i.d1, i.d2, i.d3),
        W2(i.d1, i.d2, i.d4),
        W3(i.d1, i.d2, i.d5, i.d6)
      )
    )

  override def getWindowSerializer(executionConfig: ExecutionConfig) = {
    W1Serializer    //    <-----  how to specify multiple serializers???
  }
}


Here ReportWindow is the base class of W1, W2 and W3.

Thanks,
Vlad

Re: assigning stream element to multiple windows of different types

Posted by Aljoscha Krettek <al...@apache.org>.
Hi,
I think it should (theoretically) work. You would have to provide a custom
serializer that can serialize/deserialize your different window subclasses.
Also, you will probably have to provide a Trigger that can deal with the
different types of windows.

Cheers,
Aljoscha

On Mon, 9 May 2016 at 05:45 Vlad Podgurschi <vl...@podgurschi.org> wrote:

> Hello,
>
> Is it possible to assign one record of a stream to multiple windows of
> different types, like so:
>
>
> class MultiAssigner extends WindowAssigner[Record, ReportWindow] {
>
>   override def assignWindows(i: Record, timestamp: Long) =
>     asJavaCollection(
>       List(
>         W1(i.d1, i.d2, i.d3),
>         W2(i.d1, i.d2, i.d4),
>         W3(i.d1, i.d2, i.d5, i.d6)
>       )
>     )
>
>   override def getWindowSerializer(executionConfig: ExecutionConfig) = {
>     W1Serializer    //    <-----  how to specify multiple serializers???
>   }
> }
>
>
> Here ReportWindow is the base class of W1, W2 and W3.
>
> Thanks,
> Vlad
>