Search in sources :

Example 1 with AbstractTransform

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

the class GrAggBuilder method buildStream.

public <A, R> StreamStage<KeyedWindowResult<K, R>> buildStream(@Nonnull AggregateOperation<A, ? extends R> aggrOp) {
    List<Transform> upstreamTransforms = toList(upstreamStages, s -> s.transform);
    FunctionAdapter fnAdapter = ADAPT_TO_JET_EVENT;
    // Casts in this expression are a workaround for JDK 8 compiler bug:
    @SuppressWarnings("unchecked") List<FunctionEx<?, ? extends K>> adaptedKeyFns = toList(keyFns, fn -> fnAdapter.adaptKeyFn((FunctionEx) fn));
    AbstractTransform transform = new WindowGroupTransform<K, R>(upstreamTransforms, wDef, adaptedKeyFns, fnAdapter.adaptAggregateOperation(aggrOp));
    pipelineImpl.connect(upstreamStages, transform);
    return new StreamStageImpl<>(transform, fnAdapter, pipelineImpl);
}
Also used : AbstractTransform(com.hazelcast.jet.impl.pipeline.transform.AbstractTransform) BiFunctionEx(com.hazelcast.function.BiFunctionEx) FunctionEx(com.hazelcast.function.FunctionEx) WindowGroupTransform(com.hazelcast.jet.impl.pipeline.transform.WindowGroupTransform) GroupTransform(com.hazelcast.jet.impl.pipeline.transform.GroupTransform) AbstractTransform(com.hazelcast.jet.impl.pipeline.transform.AbstractTransform) Transform(com.hazelcast.jet.impl.pipeline.transform.Transform) WindowGroupTransform(com.hazelcast.jet.impl.pipeline.transform.WindowGroupTransform)

Example 2 with AbstractTransform

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

the class GrAggBuilder method buildBatch.

public <A, R, OUT> BatchStage<OUT> buildBatch(@Nonnull AggregateOperation<A, ? extends R> aggrOp, @Nonnull BiFunctionEx<? super K, ? super R, OUT> mapToOutputFn) {
    checkSerializable(mapToOutputFn, "mapToOutputFn");
    List<Transform> upstreamTransforms = toList(upstreamStages, s -> s.transform);
    AbstractTransform transform = new GroupTransform<>(upstreamTransforms, keyFns, aggrOp, mapToOutputFn);
    pipelineImpl.connect(upstreamStages, transform);
    return new BatchStageImpl<>(transform, pipelineImpl);
}
Also used : AbstractTransform(com.hazelcast.jet.impl.pipeline.transform.AbstractTransform) WindowGroupTransform(com.hazelcast.jet.impl.pipeline.transform.WindowGroupTransform) GroupTransform(com.hazelcast.jet.impl.pipeline.transform.GroupTransform) WindowGroupTransform(com.hazelcast.jet.impl.pipeline.transform.WindowGroupTransform) GroupTransform(com.hazelcast.jet.impl.pipeline.transform.GroupTransform) AbstractTransform(com.hazelcast.jet.impl.pipeline.transform.AbstractTransform) Transform(com.hazelcast.jet.impl.pipeline.transform.Transform)

Example 3 with AbstractTransform

use of com.hazelcast.jet.impl.pipeline.transform.AbstractTransform 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)

Aggregations

AbstractTransform (com.hazelcast.jet.impl.pipeline.transform.AbstractTransform)3 Transform (com.hazelcast.jet.impl.pipeline.transform.Transform)3 GroupTransform (com.hazelcast.jet.impl.pipeline.transform.GroupTransform)2 WindowGroupTransform (com.hazelcast.jet.impl.pipeline.transform.WindowGroupTransform)2 BiFunctionEx (com.hazelcast.function.BiFunctionEx)1 FunctionEx (com.hazelcast.function.FunctionEx)1 AggregateOperation (com.hazelcast.jet.aggregate.AggregateOperation)1 AggregateTransform (com.hazelcast.jet.impl.pipeline.transform.AggregateTransform)1 WindowAggregateTransform (com.hazelcast.jet.impl.pipeline.transform.WindowAggregateTransform)1 Nonnull (javax.annotation.Nonnull)1