/** * Define a function that reduces all values related to one key into one result object. * The function is not combinable - i.e. partial results cannot be made up before shuffle. * To get better performance use {@link #combineBy} method. * * @param <OUT> type of output element * * @param reducer function that reduces all values into one output object * * @return next builder to complete the setup of the {@link ReduceByKey} operator */ default <OUT> SortableDatasetBuilder4<IN, KEY, VALUE, OUT> reduceBy( ReduceFunction<VALUE, OUT> reducer) { return reduceBy((Stream<VALUE> in, Collector<OUT> ctx) -> { ctx.collect(reducer.apply(in)); }); }
/** * Define a function that reduces all values related to one key into one result object. * The function is not combinable - i.e. partial results cannot be made up before shuffle. * To get better performance use {@link #combineBy} method. * * @param <OUT> type of output element * * @param reducer function that reduces all values into one output object * * @return next builder to complete the setup of the {@link ReduceByKey} operator */ default <OUT> SortableDatasetBuilder4<IN, KEY, VALUE, OUT> reduceBy( ReduceFunction<VALUE, OUT> reducer) { return reduceBy((Stream<VALUE> in, Collector<OUT> ctx) -> { ctx.collect(reducer.apply(in)); }); }
/** * Define a function that reduces all values related to one key into one result object. * The function is combinable (associative and commutative) so it can be used to * compute partial results before shuffle. * * @param reducer function that reduces all values into one output object * @return next builder to complete the setup of the {@link ReduceByKey} operator */ default DatasetBuilder4<IN, KEY, VALUE, VALUE> combineBy( CombinableReduceFunction<VALUE> reducer) { return reduceBy(toReduceFunctor(reducer)); }
/** * Define a function that reduces all values related to one key into one result object. * The function is combinable (associative and commutative) so it can be used to * compute partial results before shuffle. * * @param reducer function that reduces all values into one output object * @return next builder to complete the setup of the {@link ReduceByKey} operator */ default DatasetBuilder4<IN, KEY, VALUE, VALUE> combineBy( CombinableReduceFunction<VALUE> reducer) { return reduceBy(toReduceFunctor(reducer)); }