public class RichCombineToGroupCombineWrapper<IN,OUT,F extends RichGroupReduceFunction<IN,OUT> & CombineFunction<IN,IN>> extends RichGroupCombineFunction<IN,IN> implements GroupReduceFunction<IN,OUT>
CombineFunction
and GroupReduceFunction
interfaces and makes it look like a function that implements GroupCombineFunction
and GroupReduceFunction
to the runtime.Constructor and Description |
---|
RichCombineToGroupCombineWrapper(F wrappedFunction) |
Modifier and Type | Method and Description |
---|---|
void |
combine(Iterable<IN> values,
Collector<IN> out)
The combine method, called (potentially multiple timed) with subgroups of elements.
|
void |
open(OpenContext openContext)
Initialization method for the function.
|
void |
reduce(Iterable<IN> values,
Collector<OUT> out)
The reduce method.
|
close, getIterationRuntimeContext, getRuntimeContext, setRuntimeContext
public RichCombineToGroupCombineWrapper(F wrappedFunction)
public void open(OpenContext openContext) throws Exception
RichFunction
The openContext object passed to the function can be used for configuration and initialization. The openContext contains some necessary information that were configured on the function in the program composition.
public class MyFilter extends RichFilterFunction<String> {
private String searchString;
public void open(OpenContext openContext) {
// initialize the value of searchString
}
public boolean filter(String value) {
return value.equals(searchString);
}
}
open
in interface RichFunction
open
in class AbstractRichFunction
openContext
- The context containing information about the context in which the function
is opened.Exception
- Implementations may forward exceptions, which are caught by the runtime.
When the runtime catches an exception, it aborts the task and lets the fail-over logic
decide whether to retry the task execution.public void combine(Iterable<IN> values, Collector<IN> out) throws Exception
GroupCombineFunction
combine
in interface GroupCombineFunction<IN,IN>
combine
in class RichGroupCombineFunction<IN,IN>
values
- The elements to be combined.out
- The collector to use to return values from the function.Exception
- The function may throw Exceptions, which will cause the program to cancel,
and may trigger the recovery logic.public void reduce(Iterable<IN> values, Collector<OUT> out) throws Exception
GroupReduceFunction
reduce
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.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.