Re: Window-join DataStream (or KeyedStream) with a broadcast stream
So you are trying to use the same window definition, but you want to aggregate the data in two different ways:
2. Global aggregation
Do you want to use exactly the same aggregation functions? If not, you can just process the events twice:
DataStream<…> events = …;
DataStream<….> keyedEvents = events
.process(f) // instead of process this can be whatever you want, aggregate/apply/reduce/...
DataStream<….> nonKeyedEvents = events
From here you can process keyedEvents and nonKeyedEvents as you prefer.
If yes, if both global and non global aggregation are using similar/the same aggregation function, you could try to use `keyedEvents` as pre-aggregated input for `.windowAll(…)`.
keyedEvents.print() // or further process keyedEvents
DataStream<….> nonKeyedEvents = keyedEvents.windowAll(…).process(f')
But this assumes that the output of your `process(f)` can be re-processed. This second approach can minimise amount of work to be done by the global aggregation. In the first approach, all of the records will have to be processed by a single operator (global aggregation), which can be a performance bottleneck.
> On 24 Nov 2019, at 14:20, natasky <[hidden email]> wrote:
> Hi all,
> I use window aggregation to create a stream of aggregated data per user, per
> some interval.
> Additionally, I use same windows to aggregate system-wide data per the same
> Per user stream: events keyed by user ID -> tumbling window -> aggregation
> System wide stream: events -> tumbling window (windowAll) -> aggregation
> I need to produce a value per user, per interval, that depends on the
> data from that user and the system wide data aggregated for the
> I couldn't find a way to acheive this with Flink's windows. I think can I
> it to work with broadcast, connect and CoProcessFunction - is that the way
> go? How would I handle late events that way?
> - Nathan
> Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/