Transforms for computing the sum of the elements in a collection, or the sum of the values associated with each key in a collection of key-value pairs.
Example 1: get the sum of a
PCollection<Double> input = ...; PCollection<Double> sum = input.apply(Sum.doublesGlobally());
Example 2: calculate the sum of the
Integers associated with each unique key (which is of type
PCollection<KV<String, Integer>> input = ...; PCollection<KV<String, Integer>> sumPerKey = input .apply(Sum.integersPerKey());
- Count counts the number of elements within each aggregation