[
https://issues.apache.org/jira/browse/FLINK-30048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17635320#comment-17635320
]
Hangxiang Yu commented on FLINK-30048:
--------------------------------------
For RocksDBStateBackend, 'Remove' just add a delete flag to writebuffer, it's
very fast.
If we want to return the old value, RocksDBStateBackend has to call get firstly
which is not necessary and make 'Remove' slower.
For HashMapStateBackend, I think benefits are limited because they are memory
operations.
Considering the consistency of interface, I prefer to leave the interface as it
is.
> MapState.remove(UK key) is better to return the old value.
> ----------------------------------------------------------
>
> Key: FLINK-30048
> URL: https://issues.apache.org/jira/browse/FLINK-30048
> Project: Flink
> Issue Type: Improvement
> Components: API / DataStream, Runtime / State Backends
> Reporter: xljtswf
> Priority: Major
>
> Hi all:
> I found the MapState.remove(UK key) just returns nothing, and the Java Map
> Interface returns the old value associated with the key.
> Consider the flollowing example from the Learn Flink Event-driven Application
> [链接标题|https://nightlies.apache.org/flink/flink-docs-release-1.16/docs/learn-flink/event_driven/#the-ontimer-method]
> ,
> we want to get the value with the timestamp and then delete the timestamp,
> with current inplement, we must first call mapState.get(key),then call
> mapState.remove(key). it will search the key 2 times, I think it is not
> necessary. If mapState.remove(key) can return the old value, then we can just
> call mapState.remove(key) and get the old value and save the unnecessary 2nd
> search in the map.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)