You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by yunfan123 <yu...@foxmail.com> on 2017/08/17 04:07:37 UTC

Why ListState of flink don't support update?

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.

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

Posted by Stefan Richter <s....@data-artisans.com>.
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 <yu...@foxmail.com>:
> 
> 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.


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

Posted by Stefan Richter <s....@data-artisans.com>.
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 <yu...@foxmail.com>:
> 
> 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.