Why ListState of flink don't support update?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Why ListState of flink don't support update?

yunfan123
If I want to update the list.
I have to do two steps:
listState.clear()
for (Element e : myList) {
    listState.add(e);
}

Why not I update the state by:
listState.update(myList) ?
Reply | Threaded
Open this post in threaded view
|

Re: Why ListState of flink don't support update?

Stefan Richter
Hi,

this is because the list state is intended to be append only. The underlying reason is that this allows certain optimizations in the underlying datastructures. For example, a list state for the RocksDB backend can make use of RocksDB’s merge operator and does not require a full rewrite to the DB on appends.

If you need to have a list that supports this, you could use a value state of type list or use a map state where you map from list-index -> element.

Best,
Stefan

> Am 17.08.2017 um 06:07 schrieb yunfan123 <[hidden email]>:
>
> If I want to update the list.
> I have to do two steps:
> listState.clear()
> for (Element e : myList) {
>    listState.add(e);
> }
>
> Why not I update the state by:
> listState.update(myList) ?
>
>
>
> --
> View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Why-ListState-of-flink-don-t-support-update-tp14957.html
> Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Why ListState of flink don't support update?

Stefan Richter
In reply to this post by yunfan123
Having a second look, I think what you are suggesting is just a change to the API, so that should work but it is not there. You could open a Jira to suggest this.

> Am 17.08.2017 um 06:07 schrieb yunfan123 <[hidden email]>:
>
> If I want to update the list.
> I have to do two steps:
> listState.clear()
> for (Element e : myList) {
>    listState.add(e);
> }
>
> Why not I update the state by:
> listState.update(myList) ?
>
>
>
> --
> View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Why-ListState-of-flink-don-t-support-update-tp14957.html
> Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.