Hi Julian,
we're aware of the issue (https://issues.apache.org/jira/browse/FLINK-3946)
but unfortunately it's not implemented yet. I recently added
ProcessFunction which is somewhat similar to a flatmap but also allows
setting timers. This can be used to set a TTL timer and then call clear()
on the state when the timer fires. This will be release in Flink 1.2.

Cheers,
Aljoscha

On Wed, 30 Nov 2016 at 17:13 Julian Bauß <julian.ba...@gmail.com> wrote:

> Hi everybody,
>
> does Flink offer any automated TTL-functionality for operator state?
> My current solution for deleting state after some time is using a
> SessionWindow which triggers after a timeout and sends messages to stateful
> operators which then call the clear() method on their state.
>
> This is my solution in pseudocode:
>
> sessionEndNotifications =
> dataStream.window(EventTimeSessionWindows.withGap(Time.hours(1)).apply(new
> StateInvalidatorFunction).keyBy(...);
>
> dataStream.connect(sessionEndNotifications)
>           .flatMap(new StatefulFlatMapFunction())
>           .addSink(...);
>
> The StatefulFlatMapFunction calls state.clear() in its flatMap2 function
> when it receives a sessionEndNotification. The flatMap1 function contains
> the actual business logic which is being calculated per event.
>
> I feel like I'm doing this in a roundabout way. Are there better ways of
> doing this?
>
> Best Regards,
>
> Julian
>

Reply via email to