You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by "xljtswf (Jira)" <ji...@apache.org> on 2022/11/17 02:43:00 UTC

[jira] [Created] (FLINK-30048) MapState.remove(UK key) is better to return the old value.

xljtswf created FLINK-30048:
-------------------------------

             Summary: 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
            Reporter: xljtswf


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)