C
- the user-defined context object typepublic final class ContextFactory<C> extends Object implements Serializable
You can use the context factory from these Pipeline API methods:
GeneralStage.mapUsingContext(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.DistributedBiFunction<? super C, ? super T, ? extends R>)
GeneralStage.filterUsingContext(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.DistributedBiPredicate<? super C, ? super T>)
GeneralStage.flatMapUsingContext(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.DistributedBiFunction<? super C, ? super T, ? extends com.hazelcast.jet.Traverser<? extends R>>)
GeneralStageWithKey.mapUsingContext(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.DistributedTriFunction<? super C, ? super K, ? super T, ? extends R>)
GeneralStageWithKey.filterUsingContext(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.DistributedTriPredicate<? super C, ? super K, ? super T>)
GeneralStageWithKey.flatMapUsingContext(com.hazelcast.jet.pipeline.ContextFactory<C>, com.hazelcast.jet.function.DistributedTriFunction<? super C, ? super K, ? super T, ? extends com.hazelcast.jet.Traverser<? extends R>>)
Modifier and Type | Method and Description |
---|---|
DistributedFunction<JetInstance,? extends C> |
createFn()
Returns the create-function.
|
DistributedConsumer<? super C> |
destroyFn()
Returns the destroy-function.
|
boolean |
isCooperative()
Returns the
isCooperative flag. |
boolean |
isSharedLocally()
Returns the
isSharedLocally flag. |
ContextFactory<C> |
nonCooperative()
Returns a copy of this
ContextFactory with the
isCooperative flag set to false . |
ContextFactory<C> |
shareLocally()
Returns a copy of this
ContextFactory with the
shareLocally flag set. |
static <C> ContextFactory<C> |
withCreateFn(DistributedFunction<JetInstance,? extends C> createContextFn)
Creates a new
ContextFactory with the given create-function. |
ContextFactory<C> |
withDestroyFn(DistributedConsumer<? super C> destroyFn)
Returns a copy of this
ContextFactory with the destroy-function
replaced with the given function. |
@Nonnull public static <C> ContextFactory<C> withCreateFn(@Nonnull DistributedFunction<JetInstance,? extends C> createContextFn)
ContextFactory
with the given create-function.C
- the user-defined context object typecreateContextFn
- the function to create new context object, given
a JetInstance@Nonnull public ContextFactory<C> withDestroyFn(@Nonnull DistributedConsumer<? super C> destroyFn)
ContextFactory
with the destroy-function
replaced with the given function.
The destroy function is called at the end of the job to destroy all created context objects.
destroyFn
- the function to destroy user-defined context@Nonnull public ContextFactory<C> nonCooperative()
ContextFactory
with the
isCooperative flag set to false
. The context factory is
cooperative by default. Call this method if your transform function
doesn't follow the cooperative
processor contract.isCooperative
flag set
to false
.@Nonnull public ContextFactory<C> shareLocally()
ContextFactory
with the
shareLocally flag set. If the pipeline doesn't have grouping,
there will be:
isSharedLocally
flag set.@Nonnull public DistributedFunction<JetInstance,? extends C> createFn()
@Nonnull public DistributedConsumer<? super C> destroyFn()
public boolean isCooperative()
isCooperative
flag.public boolean isSharedLocally()
isSharedLocally
flag.Copyright © 2018 Hazelcast, Inc.. All rights reserved.