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;
}
Aggregations