Search in sources :

Example 1 with AggregateTransform

use of com.hazelcast.jet.impl.pipeline.transform.AggregateTransform in project hazelcast by hazelcast.

the class AggBuilder method build.

@Nonnull
@SuppressWarnings({ "unchecked", "rawtypes" })
public <A, R, OUT, OUT_STAGE extends GeneralStage<OUT>> OUT_STAGE build(@Nonnull AggregateOperation<A, R> aggrOp, @Nonnull CreateOutStageFn<OUT, OUT_STAGE> createOutStageFn) {
    AggregateOperation adaptedAggrOp = wDef != null ? ADAPT_TO_JET_EVENT.adaptAggregateOperation(aggrOp) : aggrOp;
    List<Transform> upstreamTransforms = toList(upstreamStages, s -> ((AbstractStage) s).transform);
    final AbstractTransform transform;
    if (wDef != null) {
        transform = new WindowAggregateTransform<>(upstreamTransforms, wDef, adaptedAggrOp);
    } else {
        transform = new AggregateTransform<>(upstreamTransforms, adaptedAggrOp);
    }
    OUT_STAGE attached = createOutStageFn.get(transform, ADAPT_TO_JET_EVENT, pipelineImpl);
    pipelineImpl.connectGeneralStages(upstreamStages, transform);
    return attached;
}
Also used : AbstractTransform(com.hazelcast.jet.impl.pipeline.transform.AbstractTransform) AbstractTransform(com.hazelcast.jet.impl.pipeline.transform.AbstractTransform) Transform(com.hazelcast.jet.impl.pipeline.transform.Transform) AggregateTransform(com.hazelcast.jet.impl.pipeline.transform.AggregateTransform) WindowAggregateTransform(com.hazelcast.jet.impl.pipeline.transform.WindowAggregateTransform) AggregateOperation(com.hazelcast.jet.aggregate.AggregateOperation) Nonnull(javax.annotation.Nonnull)

Example 2 with AggregateTransform

use of com.hazelcast.jet.impl.pipeline.transform.AggregateTransform 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)2 AggregateTransform (com.hazelcast.jet.impl.pipeline.transform.AggregateTransform)2 Transform (com.hazelcast.jet.impl.pipeline.transform.Transform)2 WindowAggregateTransform (com.hazelcast.jet.impl.pipeline.transform.WindowAggregateTransform)2 Nonnull (javax.annotation.Nonnull)2 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 AbstractTransform (com.hazelcast.jet.impl.pipeline.transform.AbstractTransform)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 Nullable (javax.annotation.Nullable)1