Regarding dividing the streams using keyby

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

Regarding dividing the streams using keyby

Abdul Salam Shaikh
I am trying to creating a keyed stream which collects events in a window using :

 DataStream<Tuple4<String, String, String, Long>> windowedStream = 
                jsonToTuple.keyBy(0)
                            .window(GlobalWindows.create())
                            .trigger(new WindowCustomTrigger())
                            .apply(new WindowCrossingCalculator());

Is it possible to further create a keyed stream from this already created keyedStream using some other field for the keyBy function ?  

--
Thanks & Regards,

Abdul Salam Shaikh

Reply | Threaded
Open this post in threaded view
|

Re: Regarding dividing the streams using keyby

Fabian Hueske-2
Hi,

the result of a window operation on a KeyedStream is a regular DataStream.
So, you would need to call keyBy() on the result again if you'd like to have a KeyedStream.
You can also key a stream by two or more attributes:

 DataStream<Tuple4<String, String, String, Long>> windowedStream =
                jsonToTuple.keyBy(0,1,3)  // keys be first, second, and forth attribute

Does this answer your question?

Best, Fabian

2016-11-21 2:07 GMT+01:00 Abdul Salam Shaikh <[hidden email]>:
I am trying to creating a keyed stream which collects events in a window using :

 DataStream<Tuple4<String, String, String, Long>> windowedStream = 
                jsonToTuple.keyBy(0)
                            .window(GlobalWindows.create())
                            .trigger(new WindowCustomTrigger())
                            .apply(new WindowCrossingCalculator());

Is it possible to further create a keyed stream from this already created keyedStream using some other field for the keyBy function ?  

--
Thanks & Regards,

Abdul Salam Shaikh