/** * Attaches a {@link #mapUsingContextAsync} stage where the context is a * Hazelcast {@code IMap} with the supplied name. The mapping function will * receive it as the first argument. * <p> * The operations on {@link IMap} typically return Hazelcast's custom * {@link com.hazelcast.core.ICompletableFuture}, not the standard {@link * java.util.concurrent.CompletableFuture}. Use {@link * Util#toCompletableFuture(ICompletableFuture)} to convert them. * <p> * See also {@link GeneralStageWithKey#mapUsingIMapAsync}. * * @param mapName name of the {@code IMap} * @param mapFn the mapping function * @param <K> type of the key in the {@code IMap} * @param <V> type of the value in the {@code IMap} * @param <R> type of the output item * @return the newly attached stage */ @Nonnull default <K, V, R> GeneralStage<R> mapUsingIMapAsync( @Nonnull String mapName, @Nonnull DistributedBiFunction<? super IMap<K, V>, ? super T, ? extends CompletableFuture<R>> mapFn ) { return mapUsingContextAsync(ContextFactories.iMapContext(mapName), mapFn); }
/** * 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))); }
.mapUsingContext(ContextFactories.<TrendKey, Double>iMapContext("trends"), (trendMap, cc) -> { int[] counts = new int[NUM_PREDICTIONS];