Configure operator based on key

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

Configure operator based on key

Abhinav Sharma
Hi,

Is there some way that I can configure an operator based on the key in a stream?
Eg: If the key is 'abcd', then create a window of size X counts, if the key is 'bfgh', then create a window of size Y counts.

Is this scenario possible in flink

Reply | Threaded
Open this post in threaded view
|

Re: Configure operator based on key

yidan zhao
You can self-define it using keyedStream.window(GlobalWindows.create()).trigger(self-defined-trigger).

Abhinav Sharma <[hidden email]> 于2021年2月21日周日 下午3:57写道:
Hi,

Is there some way that I can configure an operator based on the key in a stream?
Eg: If the key is 'abcd', then create a window of size X counts, if the key is 'bfgh', then create a window of size Y counts.

Is this scenario possible in flink

Reply | Threaded
Open this post in threaded view
|

Re: Configure operator based on key

Abhinav Sharma
Hi Yidan,

Thank you for your reply. I was wondering if there is some way that the process function can kiw which condition fired the trigger.

Eg: If I set trigger to fire when he object associated with key have value 2, 8, 10 (3 conditions for the trigger to fire), then if he process function, I want to operate differently on them.

On Mon, Feb 22, 2021, 11:23 AM yidan zhao <[hidden email]> wrote:
You can self-define it using keyedStream.window(GlobalWindows.create()).trigger(self-defined-trigger).

Abhinav Sharma <[hidden email]> 于2021年2月21日周日 下午3:57写道:
Hi,

Is there some way that I can configure an operator based on the key in a stream?
Eg: If the key is 'abcd', then create a window of size X counts, if the key is 'bfgh', then create a window of size Y counts.

Is this scenario possible in flink

Reply | Threaded
Open this post in threaded view
|

Re: Configure operator based on key

Arvid Heise-4
Hi Abhinav,

I think there is no way and I don't easily see how that could be added. You can however apply the same logic in the trigger also in your process function to detect which case caused the trigger.
If that is expensive to calculate, you might want to do it in a map before entering the window and have a trivial trigger.

input -> map(case detection) -> window (trigger = check if any case has been detected, process function = switch over case)

On Tue, Feb 23, 2021 at 4:05 AM Abhinav Sharma <[hidden email]> wrote:
Hi Yidan,

Thank you for your reply. I was wondering if there is some way that the process function can kiw which condition fired the trigger.

Eg: If I set trigger to fire when he object associated with key have value 2, 8, 10 (3 conditions for the trigger to fire), then if he process function, I want to operate differently on them.

On Mon, Feb 22, 2021, 11:23 AM yidan zhao <[hidden email]> wrote:
You can self-define it using keyedStream.window(GlobalWindows.create()).trigger(self-defined-trigger).

Abhinav Sharma <[hidden email]> 于2021年2月21日周日 下午3:57写道:
Hi,

Is there some way that I can configure an operator based on the key in a stream?
Eg: If the key is 'abcd', then create a window of size X counts, if the key is 'bfgh', then create a window of size Y counts.

Is this scenario possible in flink