layout: section title: “Max” permalink: /documentation/transforms/java/aggregation/max/ section_menu: section-menu/documentation.html
Max
Examples
Example 1: get the maximum of a PCollection
of Doubles
.
PCollection<Double> input = ...;
PCollection<Double> max = input.apply(Max.doublesGlobally());
Example 2: calculate the maximum of the Integers
associated with each unique key (which is of type String
).
PCollection<KV<String, Integer>> input = ...;
PCollection<KV<String, Integer>> maxPerKey = input
.apply(Max.integersPerKey());
Related transforms
- [Min]({{ site.baseurl }}/documentation/transforms/java/aggregation/min) for computing minimum values in a collection
- [Mean]({{ site.baseurl }}/documentation/transforms/java/aggregation/mean) for computing the arithmetic mean of the elements in a collection
- [Combine]({{ site.baseurl }}/documentation/transforms/java/aggregation/combine) for combining all values associated with a key to a single result