如何解决Hazelcast Jet IMap删除条目
我已经阅读了Hazelcast Jet的文档。
我已经看到可以在IMap接收器中添加/更新条目。 但是我从没见过从IMap删除条目的方法。
有办法吗?
解决方法
请参见来自JavaDoc的Sinks.mapWithMerging
:
/**
* 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>
...
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。