Managed Keyed state update

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

Managed Keyed state update

Alexey Trenikhun
Let’s say I have Managed Keyed state - MapState<String,Tuple2<String,String>> x, I initialize for state for “k0” - x.put(“k0”, new Tuple2<>(“a”, “b”)); 
Later  I retried state Tuple2<String,String> v = x.get(“k0”); and change value: v.f0=“U”;, does it make state ‘dirty’? In other words, do I need to call x.put(“k0”, v) again or change will be saved by checkpoint anyway because value was changed?

Alexey 
Reply | Threaded
Open this post in threaded view
|

Re: Managed Keyed state update

Renjie Liu
Hi, Alexey:
It depends on the state backend you use. If you use heap memory backend, then you don't need to do put again.
However, if you use rocksdb state backend, then you need to do the put again so that it will be saved by the checkpoint.

On Tue, Aug 14, 2018 at 4:58 AM Alexey Trenikhun <[hidden email]> wrote:
Let’s say I have Managed Keyed state - MapState<String,Tuple2<String,String>> x, I initialize for state for “k0” - x.put(“k0”, new Tuple2<>(“a”, “b”)); 
Later  I retried state Tuple2<String,String> v = x.get(“k0”); and change value: v.f0=“U”;, does it make state ‘dirty’? In other words, do I need to call x.put(“k0”, v) again or change will be saved by checkpoint anyway because value was changed?

Alexey 
--
Liu, Renjie
Software Engineer, MVAD
Reply | Threaded
Open this post in threaded view
|

Re: Managed Keyed state update

Alexey Trenikhun
Clear. Thank you

 

From: Renjie Liu <[hidden email]>
Sent: Monday, August 13, 2018 4:33 PM
To: Alexey Trenikhun
Cc: [hidden email]
Subject: Re: Managed Keyed state update
 
Hi, Alexey:
It depends on the state backend you use. If you use heap memory backend, then you don't need to do put again.
However, if you use rocksdb state backend, then you need to do the put again so that it will be saved by the checkpoint.

On Tue, Aug 14, 2018 at 4:58 AM Alexey Trenikhun <[hidden email]> wrote:
Let’s say I have Managed Keyed state - MapState<String,Tuple2<String,String>> x, I initialize for state for “k0” - x.put(“k0”, new Tuple2<>(“a”, “b”)); 
Later  I retried state Tuple2<String,String> v = x.get(“k0”); and change value: v.f0=“U”;, does it make state ‘dirty’? In other words, do I need to call x.put(“k0”, v) again or change will be saved by checkpoint anyway because value was changed?

Alexey 
--
Liu, Renjie
Software Engineer, MVAD
Reply | Threaded
Open this post in threaded view
|

Re: Managed Keyed state update

Fabian Hueske-2
Hi,

It is recommended to always call update().

State modifications by modifying objects is only possible because the heap based backends do not serialize or copy records to avoid additional costs.
Hence, this is rather a side effect than a provided API. As soon as you change the state backend, state modifications might be lost if you do not call update().

Best, Fabian

2018-08-14 2:07 GMT+02:00 Alexey Trenikhun <[hidden email]>:
Clear. Thank you

 

From: Renjie Liu <[hidden email]>
Sent: Monday, August 13, 2018 4:33 PM
To: Alexey Trenikhun
Cc: [hidden email]
Subject: Re: Managed Keyed state update
 
Hi, Alexey:
It depends on the state backend you use. If you use heap memory backend, then you don't need to do put again.
However, if you use rocksdb state backend, then you need to do the put again so that it will be saved by the checkpoint.

On Tue, Aug 14, 2018 at 4:58 AM Alexey Trenikhun <[hidden email]> wrote:
Let’s say I have Managed Keyed state - MapState<String,Tuple2<String,String>> x, I initialize for state for “k0” - x.put(“k0”, new Tuple2<>(“a”, “b”)); 
Later  I retried state Tuple2<String,String> v = x.get(“k0”); and change value: v.f0=“U”;, does it make state ‘dirty’? In other words, do I need to call x.put(“k0”, v) again or change will be saved by checkpoint anyway because value was changed?

Alexey 
--
Liu, Renjie
Software Engineer, MVAD