Access an event's TimeWindow?

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

Access an event's TimeWindow?

Elias Levy
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.
Reply | Threaded
Open this post in threaded view
|

Re: Access an event's TimeWindow?

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