Example 1: get the sum of a PCollection
of Doubles
.
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 String
).
PCollection<KV<String, Integer>> input = ...; PCollection<KV<String, Integer>> sumPerKey = input .apply(Sum.integersPerKey());