【问题标题】:Hazelcast Jet IMap remove entryHazelcast Jet IMap 删除条目
【发布时间】:2020-08-15 21:47:02
【问题描述】:

我已阅读 Hazelcast Jet 的文档。

我已经看到可以在 IMap 接收器中添加/更新条目。 但我没有看到如何从 IMap 中删除条目。

有什么办法吗?

【问题讨论】:

    标签: hazelcast-imap hazelcast-jet


    【解决方案1】:

    参见Sinks.mapWithMerging,来自 JavaDoc:

        /**
         * Returns a sink that uses the supplied functions to extract the key
         * and value with which to update a Hazelcast {@code IMap}. If the map
         * already contains the key, it applies the given {@code mergeFn} to
         * resolve the existing and the proposed value into the value to use. If
         * the value comes out as {@code null}, it removes the key from the map.
         * Expressed as code, the sink performs the equivalent of the following for
         * each item:
         * <pre>
         * K key = toKeyFn.apply(item);
         * V oldValue = map.get(key);
         * V newValue = toValueFn.apply(item);
         * V resolved = (oldValue == null)
         *            ? newValue
                      : mergeFn.apply(oldValue, newValue);
         * if (value == null)
         *     map.remove(key);
         * else
         *     map.put(key, value);
         * </pre>
    ...
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多