You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Elias Levy <fe...@gmail.com> on 2016/04/09 03:53:11 UTC

Access an event's TimeWindow?

Is there an API to access an event's time window?  When you are computing
aggregates over a time window, you usually want to output the window along
with the aggregate.  I could compute the Window on my own, but this seems
like an API that should exist.

Re: Access an event's TimeWindow?

Posted by Aljoscha Krettek <al...@apache.org>.
Hi,
for cases like these there is a family of "apply" methods on WindowedStream
that also take an incremental aggregation function. For example, there is

.apply(ReduceFunction, WindowFunction)

What this will do is incrementally aggregate the contents of the window.
When the window result should be emitted the single aggregated value is
passed to the WindowFunction which also gets meta information, such as the
TimeWindow. There you can emit the window result along with the meta
information.

Cheers,
Aljoscha

On Sat, 9 Apr 2016 at 03:53 Elias Levy <fe...@gmail.com> wrote:

> Is there an API to access an event's time window?  When you are computing
> aggregates over a time window, you usually want to output the window along
> with the aggregate.  I could compute the Window on my own, but this seems
> like an API that should exist.
>