Package com.hazelcast.jet.aggregate
Interface AggregateOperation2<T0,T1,A,R>
-
- Type Parameters:
T0
- the type of item in stream-0T1
- the type of item in stream-1A
- the type of the accumulatorR
- the type of the aggregation result
- All Superinterfaces:
AggregateOperation<A,R>
,java.io.Serializable
public interface AggregateOperation2<T0,T1,A,R> extends AggregateOperation<A,R>
Specialization ofAggregateOperation
(refer to its extensive documentation) to the "arity-2" case with two data streams being aggregated over.AggregateOperations
contains factories for the built-in implementations and you can create your own using the aggregate operation builder.This example constructs an operation that sums up
long
values from two streams:AggregateOperation2<Long, Long, LongAccumulator, Long> aggrOp = AggregateOperation .withCreate(LongAccumulator::new) .<Long>andAccumulate0(LongAccumulator::add) .<Long>andAccumulate1(LongAccumulator::add) .andFinish(LongAccumulator::get);
All the functions must be stateless and cooperative.
- Since:
- Jet 3.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BiConsumerEx<? super A,? super T0>
accumulateFn0()
A primitive that updates the accumulator state to account for a new item coming from stream-0.BiConsumerEx<? super A,? super T1>
accumulateFn1()
A primitive that updates the accumulator state to account for a new item coming from stream-1.<R_NEW> AggregateOperation2<T0,T1,A,R_NEW>
andThen(FunctionEx<? super R,? extends R_NEW> thenFn)
Returns a copy of this aggregate operation, but with theexport
andfinish
primitives composed with the suppliedthenFn
.<T0_NEW> AggregateOperation2<T0_NEW,T1,A,R>
withAccumulateFn0(BiConsumerEx<? super A,? super T0_NEW> newAccFn0)
Returns a copy of this aggregate operation, but with theaccumulate
primitive at index 0 replaced with the one supplied here.<T1_NEW> AggregateOperation2<T0,T1_NEW,A,R>
withAccumulateFn1(BiConsumerEx<? super A,? super T1_NEW> newAccFn1)
Returns a copy of this aggregate operation, but with theaccumulate
primitive at index 1 replaced with the one supplied here.AggregateOperation2<T0,T1,A,A>
withIdentityFinish()
Returns a copy of this aggregate operation, but with thefinish
primitive replaced with the identity function.-
Methods inherited from interface com.hazelcast.jet.aggregate.AggregateOperation
accumulateFn, accumulateFn, arity, combineFn, createFn, deductFn, exportFn, finishFn, withAccumulateFns, withCombiningAccumulateFn
-
-
-
-
Method Detail
-
accumulateFn0
@Nonnull BiConsumerEx<? super A,? super T0> accumulateFn0()
A primitive that updates the accumulator state to account for a new item coming from stream-0.The consumer must be stateless and cooperative.
-
accumulateFn1
@Nonnull BiConsumerEx<? super A,? super T1> accumulateFn1()
A primitive that updates the accumulator state to account for a new item coming from stream-1.The consumer must be stateless and cooperative.
-
withAccumulateFn0
@Nonnull <T0_NEW> AggregateOperation2<T0_NEW,T1,A,R> withAccumulateFn0(@Nonnull BiConsumerEx<? super A,? super T0_NEW> newAccFn0)
Returns a copy of this aggregate operation, but with theaccumulate
primitive at index 0 replaced with the one supplied here.The consumer must be stateless and cooperative.
-
withAccumulateFn1
@Nonnull <T1_NEW> AggregateOperation2<T0,T1_NEW,A,R> withAccumulateFn1(@Nonnull BiConsumerEx<? super A,? super T1_NEW> newAccFn1)
Returns a copy of this aggregate operation, but with theaccumulate
primitive at index 1 replaced with the one supplied here.The consumer must be stateless and cooperative.
-
withIdentityFinish
@Nonnull AggregateOperation2<T0,T1,A,A> withIdentityFinish()
Description copied from interface:AggregateOperation
Returns a copy of this aggregate operation, but with thefinish
primitive replaced with the identity function. It will return the accumulator object as-is. The returned aggregate operation does not support theexport
primitive.- Specified by:
withIdentityFinish
in interfaceAggregateOperation<T0,T1>
-
andThen
@Nonnull <R_NEW> AggregateOperation2<T0,T1,A,R_NEW> andThen(FunctionEx<? super R,? extends R_NEW> thenFn)
Description copied from interface:AggregateOperation
Returns a copy of this aggregate operation, but with theexport
andfinish
primitives composed with the suppliedthenFn
. This replacesexportFn
withexportFn.andThen(thenFn)
, same forfinishFn
. The main use case is to transform the result of an existing (library-provided) aggregate operation.The given function must be stateless and cooperative.
- Specified by:
andThen
in interfaceAggregateOperation<T0,T1>
- Type Parameters:
R_NEW
- the type of the returned aggregate operation's result- Parameters:
thenFn
- the function to apply to the results ofexport
andfinish
primitives
-
-