assigning stream element to multiple windows of different types

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

assigning stream element to multiple windows of different types

Vlad Podgurschi
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
Reply | Threaded
Open this post in threaded view
|

Re: assigning stream element to multiple windows of different types

Aljoscha Krettek
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 <[hidden email]> 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