You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Lijie Wang (Jira)" <ji...@apache.org> on 2022/11/17 09:36:00 UTC
[jira] [Commented] (FLINK-30048) MapState.remove(UK key) is better to return the old value.
[ https://issues.apache.org/jira/browse/FLINK-30048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17635241#comment-17635241 ]
Lijie Wang commented on FLINK-30048:
------------------------------------
I think it makes sense, but it involves the changs of the public interface. [~Yanfei Lei] , what do you think?
> 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)