You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by ゞ野蠻遊戲χ <zh...@vip.qq.com> on 2020/07/18 12:30:00 UTC

How do I trigger clear custom state in ProcessWindowsFunction

Dear all:


How do I clear custom state in ProcessWindowsFunction? Because there is no onTimer method in ProcessAllWindowFunction.


Thanks
Jiazhi

Re: How do I trigger clear custom state in ProcessWindowsFunction

Posted by David Anderson <da...@alpinegizmo.com>.
ProcessWindowFunction#process is passed a Context object that contains

  public abstract KeyedStateStore windowState();
  public abstract KeyedStateStore globalState();

which are available for you to use for custom state. Whatever you store in
windowState is scoped to a window, and is cleared when that window is
cleared (this is only useful for windows that may have multiple firings).
On the other hand, state that you create in globalState is retained
indefinitely. If you have an unbounded key space with keys that become
stale (such as sessionIds), you will want to use state TTL [1] on the state
descriptor(s) to arrange for its eventual deletion.

[1]
https://ci.apache.org/projects/flink/flink-docs-stable/dev/stream/state/state.html#state-time-to-live-ttl

Regards,
David

On Sat, Jul 18, 2020 at 2:30 PM ゞ野蠻遊戲χ <zh...@vip.qq.com> wrote:

> Dear all:
>
> How do I clear custom state in ProcessWindowsFunction? Because there is no
> onTimer method in ProcessAllWindowFunction.
>
> Thanks
> Jiazhi
>