public class ReducerMergeFunctionWrapper extends Object implements MergeFunctionWrapper<KeyValue>
MergeFunction
s which works like a reducer.
A reducer is a type of function. If there is only one input the result is equal to that input; Otherwise the result is calculated by merging all the inputs in some way.
This wrapper optimize the wrapped MergeFunction
. If there is only one input, the input
will be stored and the inner merge function will not be called, thus saving some computing time.
Constructor and Description |
---|
ReducerMergeFunctionWrapper(MergeFunction<KeyValue> mergeFunction) |
Modifier and Type | Method and Description |
---|---|
void |
add(KeyValue kv)
Adds the given
KeyValue to the MergeFunction helper. |
KeyValue |
getResult()
Get current value of the
MergeFunction helper. |
void |
reset()
Resets the
MergeFunction helper to its default state. |
public ReducerMergeFunctionWrapper(MergeFunction<KeyValue> mergeFunction)
public void reset()
MergeFunction
helper to its default state.reset
in interface MergeFunctionWrapper<KeyValue>
public void add(KeyValue kv)
KeyValue
to the MergeFunction
helper.add
in interface MergeFunctionWrapper<KeyValue>
public KeyValue getResult()
MergeFunction
helper.getResult
in interface MergeFunctionWrapper<KeyValue>
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.