flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Till Rohrmann <trohrm...@apache.org>
Subject Re: Counting tuples within a window in Flink Stream
Date Fri, 26 Feb 2016 09:14:47 GMT
Hi Saiph,

you can do it the following way:

input.keyBy(0).timeWindow(Time.seconds(10)).fold(0, new
FoldFunction<Tuple2<Integer, Integer>, Integer>() {
    @Override
    public Integer fold(Integer integer, Tuple2<Integer, Integer> o)
throws Exception {
        return integer + 1;
    }
});

Cheers,
Till
‚Äč

On Thu, Feb 25, 2016 at 7:58 PM, Saiph Kappa <saiph.kappa@gmail.com> wrote:

> Hi,
>
> In Flink Stream what's the best way of counting the number of tuples
> within a window of 10 seconds? Using a map-reduce task? Asking because in
> spark there is the method rawStream.countByWindow(Seconds(x)).
>
> Thanks.
>

Mime
View raw message