You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Abhinav Sharma <ab...@gmail.com> on 2021/02/21 07:56:59 UTC

Configure operator based on key

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

Re: Configure operator based on key

Posted by Arvid Heise <ar...@apache.org>.
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 <ab...@gmail.com>
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 <hi...@gmail.com> wrote:
>
>> You can self-define it using keyedStream.window(GlobalWindows.create()
>> ).trigger(self-defined-trigger).
>>
>> Abhinav Sharma <ab...@gmail.com> 于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
>>>
>>>

Re: Configure operator based on key

Posted by Abhinav Sharma <ab...@gmail.com>.
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 <hi...@gmail.com> wrote:

> You can self-define it using keyedStream.window(GlobalWindows.create()
> ).trigger(self-defined-trigger).
>
> Abhinav Sharma <ab...@gmail.com> 于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
>>
>>

Re: Configure operator based on key

Posted by yidan zhao <hi...@gmail.com>.
You can self-define it using keyedStream.window(GlobalWindows.create()
).trigger(self-defined-trigger).

Abhinav Sharma <ab...@gmail.com> 于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
>
>