August 2017
Beginner to intermediate
284 pages
6h 51m
English
Trident provides a feature to apply multiple aggregators to the same input stream, and this process is called aggregator chaining. Here is a piece of code that shows how we can use aggregator chaining:
mystream.chainedAgg()
.partitionAggregate(new Fields("b"), new Average(), new Fields("average"))
.partitionAggregate(new Fields("b"), new Sum(), new Fields("sum"))
.chainEnd();
We have applied the Average() and Sum() aggregators to each partition. The output of chainedAgg() contains a single tuple corresponding to each input partition. The output tuple contains two fields, sum and average.
The following diagram shows how aggregator chaining works:
Read now
Unlock full access