com.hazelcast.jet.pipeline.Sinks.mapWithUpdating()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(1.6k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中com.hazelcast.jet.pipeline.Sinks.mapWithUpdating()方法的一些代码示例,展示了Sinks.mapWithUpdating()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Sinks.mapWithUpdating()方法的具体详情如下:
包路径:com.hazelcast.jet.pipeline.Sinks
类名称:Sinks
方法名:mapWithUpdating

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;
}

相关文章