[ 
https://issues.apache.org/jira/browse/FLINK-32480?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17754403#comment-17754403
 ] 

Kezhu Wang commented on FLINK-32480:
------------------------------------

Flink never provide such a guarantee. The "Expected behavior" listed in 
description requires Flink to store all its state in JVM memory which is 
apparently unrealistic. If you want to check equal values, you should override 
"equals" method.

> Keyed State always returns new value instance
> ---------------------------------------------
>
>                 Key: FLINK-32480
>                 URL: https://issues.apache.org/jira/browse/FLINK-32480
>             Project: Flink
>          Issue Type: Bug
>          Components: API / State Processor
>    Affects Versions: 1.14.6
>            Reporter: Viktor Feklin
>            Priority: Major
>
> I create ValueState with default value. Then i access value in the map 
> function (multiple times with the same partition key).
> Expected behavior:
>  * First call to value() should return new instance
>  * Second call to value should return instance created in first call (just 
> like Map#computeIfAbsent)
> Actual dehavior:
>  * every call to value() return new instance until we manualy set it with 
> update() function.
> According to source code - we can call update only once to assign value to 
> current key. But from the user poin of view - it happends to call update() 
> every time - because i do not know if value was already asigned or just 
> created.
> ----------------------------
> Currently my code looks like:
> {code:java}
> List<Integer> context = contextState.value();
> contextState.update(context); {code}
> May be there is some logic for immutable objects, but for mutable objects it 
> looks awkward
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to