/** * Attaches a {@link #mapUsingContextAsync} stage where the context is a * Hazelcast {@code IMap} with the supplied name. Jet will use the * specified {@linkplain #keyFn() key function} to retrieve the value from * the map and pass it to the mapping function you supply, as the second * argument. * <p> * This stage is similar to {@link GeneralStage#mapUsingIMapAsync(String, * DistributedBiFunction) stageWithoutKey.mapUsingIMap()}, but here Jet * knows the key and uses it to partition and distribute the input in order * to achieve data locality. The value it fetches from the {@code IMap} is * stored on the cluster member where the processing takes place. However, * if the map doesn't use the default partitioning strategy, the data * locality will be broken. * * @param mapName name of the {@code IMap} * @param mapFn the mapping function * @param <V> type of the value in the {@code IMap} * @param <R> type of the output item * @return the newly attached stage */ @Nonnull default <V, R> GeneralStage<R> mapUsingIMapAsync( @Nonnull String mapName, @Nonnull DistributedBiFunction<? super T, ? super V, ? extends R> mapFn ) { return mapUsingContextAsync(ContextFactories.<K, V>iMapContext(mapName), (map, key, item) -> toCompletableFuture(map.getAsync(key)).thenApply(value -> mapFn.apply(item, value))); }