Background
We want to keep in a Flink operator's state the last n unique id's.
When the n+1 unique id arrives, we want to keep it and drop the oldest unique id in the state. This is in order to avoid an ever-growing state.
We already have a TTL (expiration time) mechanism in place. The size limit is another restriction we're looking to put in place.
Not every element holds a unique id.
Question
Does Flink provide an API that limits the number of elements in the state?
Things tried
- Using
MapStatewith aStateTtlConfiggenerated TTL/expiration mechanism. - Window limited the number of processed elements, but not the number of elements in state.