IN - Type of the elements that this function processes.OUT - The type of the elements returned by the user-defined function.public abstract class RichGroupReduceFunction<IN,OUT> extends AbstractRichFunction implements GroupReduceFunction<IN,OUT>, GroupCombineFunction<IN,IN>
GroupReduceFunction. As a RichFunction, it gives access to the
RuntimeContext and provides setup and teardown methods:
RichFunction.open(org.apache.flink.configuration.Configuration) and
RichFunction.close().| Modifier and Type | Class and Description |
|---|---|
static interface |
RichGroupReduceFunction.Combinable
This annotation can be added to classes that extend
RichGroupReduceFunction, in oder to mark
them as "combinable". |
| Constructor and Description |
|---|
RichGroupReduceFunction() |
| Modifier and Type | Method and Description |
|---|---|
void |
combine(Iterable<IN> values,
Collector<IN> out)
The combine methods pre-reduces elements.
|
abstract void |
reduce(Iterable<IN> values,
Collector<OUT> out)
The reduce method.
|
close, getIterationRuntimeContext, getRuntimeContext, open, setRuntimeContextpublic abstract void reduce(Iterable<IN> values, Collector<OUT> out) throws Exception
GroupReduceFunctionreduce in interface GroupReduceFunction<IN,OUT>values - All records that belong to the given input key.out - The collector to hand results to.Exception - This method may throw exceptions. Throwing an exception will cause the operation
to fail and may trigger recovery.public void combine(Iterable<IN> values, Collector<IN> out) throws Exception
This method is only ever invoked when the subclass of RichGroupReduceFunction
adds the RichGroupReduceFunction.Combinable annotation, or if the combinable flag is set when defining
the reduceGroup operation via
org.apache.flink.api.java.operators.GroupReduceOperator#setCombinable(boolean).
Since the reduce function will be called on the result of this method, it is important that this
method returns the same data type as it consumes. By default, this method only calls the
reduce(Iterable, Collector) method. If the behavior in the pre-reducing is different
from the final reduce function (for example because the reduce function changes the data type),
this method must be overwritten, or the execution will fail.
combine in interface GroupCombineFunction<IN,IN>values - The iterator returning the group of values to be reduced.out - The collector to emit the returned values.Exception - This method may throw exceptions. Throwing an exception will cause the operation
to fail and may trigger recovery.Copyright © 2014–2016 The Apache Software Foundation. All rights reserved.