@Nonnull private static ContextFactory<SentimentAnalyzer> sentimentAnalyzerContext() { return ContextFactory .withCreateFn(jet -> new SentimentAnalyzer()) .shareLocally(); }
/** * Returns a factory that provides an {@link IMapJet} as the context. This * is useful if you are enriching an event stream with the data stored in * the Hazelcast Jet cluster. Unlike in a {@code hashJoin} transformation, * the data in the map can change while the job is running so you can keep * the enriching dataset up-to-date. * <p> * Instead of using this factory, you can call {@link * GeneralStage#mapUsingIMapAsync(IMap, DistributedBiFunction)} or {@link * GeneralStageWithKey#mapUsingIMapAsync(IMap, DistributedBiFunction)}. * <p> * If you plan to use a sync method on the map, call {@link * ContextFactory#nonCooperative()} on the returned factory. * * @param mapName name of the map used as context * @param <K> key type * @param <V> value type * @return the context factory */ @Nonnull public static <K, V> ContextFactory<IMapJet<K, V>> iMapContext(@Nonnull String mapName) { return ContextFactory .withCreateFn(jet -> jet.<K, V>getMap(mapName)) .shareLocally(); }