本文整理了Java中com.hazelcast.jet.pipeline.Sinks.mapWithMerging()
方法的一些代码示例,展示了Sinks.mapWithMerging()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Sinks.mapWithMerging()
方法的具体详情如下:
包路径:com.hazelcast.jet.pipeline.Sinks
类名称:Sinks
方法名:mapWithMerging
[英]Convenience for #mapWithMerging(IMap,DistributedFunction,DistributedFunction,DistributedBinaryOperator) with Entry as input item.
[中]方便使用#mapWithMerging(IMap、DistributedFunction、DistributedFunction、DistributedBinaryOperator)将条目作为输入项。
代码示例来源:origin: hazelcast/hazelcast-jet
/**
* Convenience for {@link #mapWithMerging(IMap, DistributedFunction, DistributedFunction,
* DistributedBinaryOperator)} with {@link Entry} as input item.
*/
@Nonnull
public static <K, V, V_IN extends V> Sink<Entry<K, V_IN>> mapWithMerging(
@Nonnull IMap<? super K, V> map,
@Nonnull DistributedBinaryOperator<V> mergeFn
) {
return mapWithMerging(map.getName(), mergeFn);
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Nonnull DistributedBinaryOperator<V> mergeFn
) {
return mapWithMerging(map.getName(), toKeyFn, toValueFn, mergeFn);
代码示例来源:origin: hazelcast/hazelcast-jet-code-samples
/**
* This will take the contents of source map, maps all keys to a key called {@code sum }
* and write it into sink map using an merge function which merges the map values by adding
* old value and new value.
*/
private static Pipeline mapWithMerging(String sourceMapName, String sinkMapName) {
Pipeline pipeline = Pipeline.create();
pipeline.drawFrom(Sources.<Integer, Integer>map(sourceMapName))
.map(e -> entry("sum", e.getValue()))
.drainTo(
Sinks.mapWithMerging(
sinkMapName,
(oldValue, newValue) -> oldValue + newValue
)
);
return pipeline;
}
内容来源于网络,如有侵权,请联系作者删除!