osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When does Trigger.clear() get called?


Hi,

Re Q1: The main purpose of the Trigger.clean() method is to remove all custom state of the Trigger. State must be explicitly removed, otherwise the program leaks memory.
Re Q3: If you are using a keyed stream, you need to manually clean up the state by calling State.clear(). If you are using a ProcessFunction, you can do that in processElement() or register a timer and clean up in onTimer().

Best, Fabian

Am So., 14. Okt. 2018 um 06:06 Uhr schrieb Averell <lvhuyen@xxxxxxxxx>:
Hello Hequn,

Thanks for the answers.
Regarding question no.2, I am now clear.
Regarding question no.1, does your answer apply to those custom states as
well? This concern of mine came from Flink's implementation of CountTrigger,
in which a custom state is being cleared explicitly in Trigger.clear():

/       public void clear(W window, TriggerContext ctx) throws Exception {
                ctx.getPartitionedState(stateDesc).clear();
        }
/

My 3rd question was for ordinary, non-windowed keyed streams, where I don't
see in Flink's document any mention of using Trigger, so how can I clear
those streams?

Thank you very much for your help.
Regards,
Averell




--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/