Hi,Nick
Normally you could not iterate all the keyed states, but the
`BroadCastState` & `applyTokeyedState` could do that.
For example, before you get the broadcast side elements you might choose to
cache the non-broadcast element to the keyed state. After the broadcast
elements arrive you need to use `applyTokeyedState`[1] to iterate all the
elements you "cached" in the keyed state and do your business logic.

[1]
https://ci.apache.org/projects/flink/flink-docs-release-1.12/dev/stream/state/broadcast_state.html

Best,
Guowei


On Mon, Jan 25, 2021 at 12:59 PM Nick Bendtner <buggi...@gmail.com> wrote:

> Thanks Guowei. Another question I have is, what is the use of a broadcast
> state when I can update a map state or value state inside of the process
> broadcast element method and use that state to do a lookup in the process
> element method like this example
>
> https://stackoverflow.com/questions/58307154/initialize-the-content-of-a-mapstate
>
>
> Best,
> Nick
> On Sun, Jan 24, 2021 at 9:23 PM Guowei Ma <guowei....@gmail.com> wrote:
>
>> Hi, Nick
>>   You might need to handle it yourself If you have to process an element
>> only after you get the broadcast state.
>>   For example, you could “cache” the element to the state and handle it
>> when the element from the broadcast side elements are arrived. Specially if
>> you are using the `KeyedBroadcastProcessFunction` you could use the
>> `applyToKeyedState` to access the element you cache before.
>>
>> Best,
>> Guowei
>>
>>
>> On Mon, Jan 25, 2021 at 10:24 AM Nick Bendtner <buggi...@gmail.com>
>> wrote:
>>
>>> Hi guys,
>>> What is the way to initialize broadcast state(say with default values)
>>> before the first element shows up in the broadcasting stream? I do a lookup
>>> on the broadcast state to process transactions which come from another
>>> stream. The problem is the broadcast state is empty until the first element
>>> shows up.
>>>
>>>
>>> Best,
>>> Nick.
>>>
>>

Reply via email to