本文整理了Java中com.hazelcast.jet.pipeline.Sinks.mapWithUpdating()
方法的一些代码示例,展示了Sinks.mapWithUpdating()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Sinks.mapWithUpdating()
方法的具体详情如下:
包路径:com.hazelcast.jet.pipeline.Sinks
类名称:Sinks
方法名:mapWithUpdating
[英]Convenience for #mapWithUpdating(IMap,DistributedFunction,DistributedBiFunction) with Entry as the input item.
[中]方便使用条目作为输入项进行#MapWithUpdate(IMap、DistributedFunction、DistributedBiFunction)。
代码示例来源:origin: hazelcast/hazelcast-jet
/**
* Convenience for {@link #mapWithUpdating(IMap, DistributedFunction,
* DistributedBiFunction)} with {@link Entry} as the input item.
*/
@Nonnull
public static <K, V, E extends Entry<K, V>> Sink<E> mapWithUpdating(
@Nonnull IMap<? super K, ? super V> map,
@Nonnull DistributedBiFunction<? super V, ? super E, ? extends V> updateFn
) {
return mapWithUpdating(map.getName(), updateFn);
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Nonnull DistributedBiFunction<? super V, ? super T, ? extends V> updateFn
) {
return mapWithUpdating(map.getName(), toKeyFn, updateFn);
代码示例来源:origin: hazelcast/hazelcast-jet-code-samples
/**
* This will take the contents of source map, converts values to the string and
* suffixes the value with {@code odd} if the key is odd and with {@code event} if the key is even.
*/
private static Pipeline mapWithUpdating(String sourceMapName, String sinkMapName) {
Pipeline pipeline = Pipeline.create();
pipeline.drawFrom(Sources.<Integer, Integer>map(sourceMapName))
.map(e -> entry(e.getKey(), String.valueOf(e.getValue())))
.drainTo(
Sinks.mapWithUpdating(
sinkMapName,
(oldValue, item) ->
item.getKey() % 2 == 0
? oldValue + "-even"
: oldValue + "-odd"
)
);
return pipeline;
}
内容来源于网络,如有侵权,请联系作者删除!