/** * Attaches a stage that co-aggregates the data from this and the supplied * stage by performing a separate aggregate operation on each and emitting * a {@link Tuple2} with their results. * <p> * The returned stage emits a single item. * * @param aggrOp0 aggregate operation to perform on this stage * @param stage1 the other stage * @param aggrOp1 aggregate operation to perform on the other stage * @param <T1> type of the items in the other stage * @param <R0> type of the aggregated result for this stage * @param <R1> type of the aggregated result for the other stage */ @Nonnull default <T1, R0, R1> BatchStage<Tuple2<R0, R1>> aggregate2( @Nonnull AggregateOperation1<? super T, ?, ? extends R0> aggrOp0, @Nonnull BatchStage<T1> stage1, @Nonnull AggregateOperation1<? super T1, ?, ? extends R1> aggrOp1 ) { return aggregate2(stage1, aggregateOperation2(aggrOp0, aggrOp1, Tuple2::tuple2)); }
/** * Attaches a stage that co-aggregates the data from this and the supplied * stage by performing a separate aggregate operation on each and then * passing both results to {@code mapToOutputFn}, which transforms them * into the final output. * <p> * The returned stage emits a single item. * * @param aggrOp0 aggregate operation to perform on this stage * @param stage1 the other stage * @param aggrOp1 aggregate operation to perform on the other stage * @param mapToOutputFn function to apply to the aggregated results * @param <T1> type of the items in the other stage * @param <R0> type of the aggregated result for this stage * @param <R1> type of the aggregated result for the other stage * @param <OUT> the output item type */ @Nonnull default <T1, R0, R1, OUT> BatchStage<OUT> aggregate2( @Nonnull AggregateOperation1<? super T, ?, ? extends R0> aggrOp0, @Nonnull BatchStage<T1> stage1, @Nonnull AggregateOperation1<? super T1, ?, ? extends R1> aggrOp1, @Nonnull DistributedBiFunction<? super R0, ? super R1, ? extends OUT> mapToOutputFn ) { return aggregate2(stage1, aggregateOperation2(aggrOp0, aggrOp1, mapToOutputFn)); }