Search in sources :

Example 1 with WindowResultFunction

use of com.hazelcast.jet.function.WindowResultFunction 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)1 Tag (com.hazelcast.jet.datamodel.Tag)1 Tag.tag (com.hazelcast.jet.datamodel.Tag.tag)1 WindowResultFunction (com.hazelcast.jet.function.WindowResultFunction)1 DONT_ADAPT (com.hazelcast.jet.impl.pipeline.ComputeStageImplBase.DONT_ADAPT)1 ComputeStageImplBase.ensureJetEvents (com.hazelcast.jet.impl.pipeline.ComputeStageImplBase.ensureJetEvents)1 JetEventFunctionAdapter.adaptAggregateOperation (com.hazelcast.jet.impl.pipeline.JetEventFunctionAdapter.adaptAggregateOperation)1 AggregateTransform (com.hazelcast.jet.impl.pipeline.transform.AggregateTransform)1 Transform (com.hazelcast.jet.impl.pipeline.transform.Transform)1 WindowAggregateTransform (com.hazelcast.jet.impl.pipeline.transform.WindowAggregateTransform)1 GeneralStage (com.hazelcast.jet.pipeline.GeneralStage)1 WindowDefinition (com.hazelcast.jet.pipeline.WindowDefinition)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Collectors.toList (java.util.stream.Collectors.toList)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1