[
https://issues.apache.org/jira/browse/FLINK-32480?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Viktor Feklin updated FLINK-32480:
----------------------------------
Description:
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
was:
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.
> 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)