Search in sources :

Example 11 with AggregateOperation

use of com.hazelcast.jet.aggregate.AggregateOperation in project hazelcast-jet by hazelcast.

the class AggBuilder method build.

@Nonnull
@SuppressWarnings("unchecked")
public <A, R, OUT, OUT_STAGE extends GeneralStage<OUT>> OUT_STAGE build(@Nonnull AggregateOperation<A, R> aggrOp, @Nonnull CreateOutStageFn<OUT, OUT_STAGE> createOutStageFn, @Nullable WindowResultFunction<? super R, ? extends OUT> mapToOutputFn) {
    AggregateOperation adaptedAggrOp = wDef != null ? adaptAggregateOperation(aggrOp) : aggrOp;
    List<Transform> upstreamTransforms = upstreamStages.stream().map(s -> ((AbstractStage) s).transform).collect(toList());
    final Transform transform;
    if (wDef != null) {
        requireNonNull(mapToOutputFn, "wDef != null but mapToOutputFn == null");
        transform = new WindowAggregateTransform<>(upstreamTransforms, wDef, adaptedAggrOp, mapToOutputFn);
    } else {
        transform = new AggregateTransform<>(upstreamTransforms, adaptedAggrOp);
    }
    OUT_STAGE attached = createOutStageFn.get(transform, DONT_ADAPT, pipelineImpl);
    pipelineImpl.connect(upstreamTransforms, transform);
    return attached;
}
Also used : GeneralStage(com.hazelcast.jet.pipeline.GeneralStage) DONT_ADAPT(com.hazelcast.jet.impl.pipeline.ComputeStageImplBase.DONT_ADAPT) WindowDefinition(com.hazelcast.jet.pipeline.WindowDefinition) JetEventFunctionAdapter.adaptAggregateOperation(com.hazelcast.jet.impl.pipeline.JetEventFunctionAdapter.adaptAggregateOperation) Tag(com.hazelcast.jet.datamodel.Tag) Transform(com.hazelcast.jet.impl.pipeline.transform.Transform) ArrayList(java.util.ArrayList) Tag.tag(com.hazelcast.jet.datamodel.Tag.tag) List(java.util.List) ComputeStageImplBase.ensureJetEvents(com.hazelcast.jet.impl.pipeline.ComputeStageImplBase.ensureJetEvents) Collectors.toList(java.util.stream.Collectors.toList) AggregateOperation(com.hazelcast.jet.aggregate.AggregateOperation) Objects.requireNonNull(java.util.Objects.requireNonNull) WindowResultFunction(com.hazelcast.jet.function.WindowResultFunction) Nonnull(javax.annotation.Nonnull) AggregateTransform(com.hazelcast.jet.impl.pipeline.transform.AggregateTransform) WindowAggregateTransform(com.hazelcast.jet.impl.pipeline.transform.WindowAggregateTransform) Nullable(javax.annotation.Nullable) Transform(com.hazelcast.jet.impl.pipeline.transform.Transform) AggregateTransform(com.hazelcast.jet.impl.pipeline.transform.AggregateTransform) WindowAggregateTransform(com.hazelcast.jet.impl.pipeline.transform.WindowAggregateTransform) JetEventFunctionAdapter.adaptAggregateOperation(com.hazelcast.jet.impl.pipeline.JetEventFunctionAdapter.adaptAggregateOperation) AggregateOperation(com.hazelcast.jet.aggregate.AggregateOperation) Nonnull(javax.annotation.Nonnull)

Aggregations

AggregateOperation (com.hazelcast.jet.aggregate.AggregateOperation)11 List (java.util.List)10 FunctionEx (com.hazelcast.function.FunctionEx)7 Tag (com.hazelcast.jet.datamodel.Tag)7 ArrayList (java.util.ArrayList)7 Collections.singletonList (java.util.Collections.singletonList)7 BiFunctionEx (com.hazelcast.function.BiFunctionEx)6 Collections.emptyList (java.util.Collections.emptyList)6 Nonnull (javax.annotation.Nonnull)5 Util.entry (com.hazelcast.jet.Util.entry)4 LongAccumulator (com.hazelcast.jet.accumulator.LongAccumulator)4 AggregateOperation1 (com.hazelcast.jet.aggregate.AggregateOperation1)4 AggregateOperations (com.hazelcast.jet.aggregate.AggregateOperations)4 AggregateOperations.coAggregateOperationBuilder (com.hazelcast.jet.aggregate.AggregateOperations.coAggregateOperationBuilder)4 CoAggregateOperationBuilder (com.hazelcast.jet.aggregate.CoAggregateOperationBuilder)4 DAG (com.hazelcast.jet.core.DAG)4 Edge (com.hazelcast.jet.core.Edge)4 Address (com.hazelcast.cluster.Address)3 ComparatorEx (com.hazelcast.function.ComparatorEx)3 ComparatorEx.comparingInt (com.hazelcast.function.ComparatorEx.comparingInt)3