You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Abdul Salam Shaikh <ab...@gmail.com> on 2016/11/21 01:07:19 UTC

Regarding dividing the streams using keyby

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*

Re: Regarding dividing the streams using keyby

Posted by Fabian Hueske <fh...@gmail.com>.
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 <ab...@gmail.com>:

> 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*
>
>