Database Reference
In-Depth Information
["c", 8]
Partition 2:
["e", 1]
["d", 9]
["d", 10]
The output will be as follows:
Partition 0:
[3]
Partition 1:
[11]
Partition 2:
[20]
CombinerAggregator
The implementation of this interface provided by the Trident API returns a single tuple
with a single field as an output; internally, it executes an init function on each input tuple
and then after that it combines the values until only one value is left, which is returned as
an output. If the combiner functions encounter a partition that doesn't have any value, "0"
is emitted.
Here is the interface definition and its contracts:
public interface CombinerAggregator<T> extends Serializable
{
T init(TridentTuple tuple);
T combine(T val1, T val2);
T zero();
}
The following is the implementation for the count functionality:
public class myCount implements CombinerAggregator<Long> {
public Long init(TridentTuple mytuple) {
return 1L;
}
public Long combine(Long val1, Long val2) {
return val1 + val2;
Search WWH ::




Custom Search