public class Max extends Object
PTransforms for computing the maximum of the elements in a PCollection, or the
maximum of the values associated with each key in a PCollection of KVs.
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.<String>integersPerKey());
| Modifier and Type | Method and Description |
|---|---|
static Combine.Globally<Double,Double> |
doublesGlobally()
Returns a
PTransform that takes an input PCollection<Double> and returns a
PCollection<Double> whose contents is the maximum of the input PCollection's
elements, or Double.NEGATIVE_INFINITY if there are no elements. |
static <K> Combine.PerKey<K,Double,Double> |
doublesPerKey()
Returns a
PTransform that takes an input PCollection<KV<K, Double>> and returns
a PCollection<KV<K, Double>> that contains an output element mapping each distinct key
in the input PCollection to the maximum of the values associated with that key in the
input PCollection. |
static <T extends Comparable<? super T>> |
globally()
Returns a
PTransform that takes an input PCollection<T> and returns a PCollection<T> whose contents is the maximum according to the natural ordering of T
of the input PCollection's elements, or null if there are no elements. |
static <T,ComparatorT extends Comparator<? super T> & Serializable> |
globally(ComparatorT comparator)
Returns a
PTransform that takes an input PCollection<T> and returns a PCollection<T> whose contents is the maximum of the input PCollection's elements, or
null if there are no elements. |
static Combine.Globally<Integer,Integer> |
integersGlobally()
Returns a
PTransform that takes an input PCollection<Integer> and returns a
PCollection<Integer> whose contents is the maximum of the input PCollection's
elements, or Integer.MIN_VALUE if there are no elements. |
static <K> Combine.PerKey<K,Integer,Integer> |
integersPerKey()
Returns a
PTransform that takes an input PCollection<KV<K, Integer>> and
returns a PCollection<KV<K, Integer>> that contains an output element mapping each
distinct key in the input PCollection to the maximum of the values associated with that
key in the input PCollection. |
static Combine.Globally<Long,Long> |
longsGlobally()
Returns a
PTransform that takes an input PCollection<Long> and returns a PCollection<Long> whose contents is the maximum of the input PCollection's elements,
or Long.MIN_VALUE if there are no elements. |
static <K> Combine.PerKey<K,Long,Long> |
longsPerKey()
Returns a
PTransform that takes an input PCollection<KV<K, Long>> and returns a
PCollection<KV<K, Long>> that contains an output element mapping each distinct key in
the input PCollection to the maximum of the values associated with that key in the
input PCollection. |
static <K,T extends Comparable<? super T>> |
perKey()
Returns a
PTransform that takes an input PCollection<KV<K, T>> and returns a
PCollection<KV<K, T>> that contains an output element mapping each distinct key in the
input PCollection to the maximum according to the natural ordering of T of the
values associated with that key in the input PCollection. |
static <K,T,ComparatorT extends Comparator<? super T> & Serializable> |
perKey(ComparatorT comparator)
Returns a
PTransform that takes an input PCollection<KV<K, T>> and returns a
PCollection<KV<K, T>> that contains one output element per key mapping each
to the maximum of the values associated with that key in the input PCollection. |
public static Combine.Globally<Integer,Integer> integersGlobally()
PTransform that takes an input PCollection<Integer> and returns a
PCollection<Integer> whose contents is the maximum of the input PCollection's
elements, or Integer.MIN_VALUE if there are no elements.public static <K> Combine.PerKey<K,Integer,Integer> integersPerKey()
PTransform that takes an input PCollection<KV<K, Integer>> and
returns a PCollection<KV<K, Integer>> that contains an output element mapping each
distinct key in the input PCollection to the maximum of the values associated with that
key in the input PCollection.
See Combine.PerKey for how this affects timestamps and windowing.
public static Combine.Globally<Long,Long> longsGlobally()
PTransform that takes an input PCollection<Long> and returns a PCollection<Long> whose contents is the maximum of the input PCollection's elements,
or Long.MIN_VALUE if there are no elements.public static <K> Combine.PerKey<K,Long,Long> longsPerKey()
PTransform that takes an input PCollection<KV<K, Long>> and returns a
PCollection<KV<K, Long>> that contains an output element mapping each distinct key in
the input PCollection to the maximum of the values associated with that key in the
input PCollection.
See Combine.PerKey for how this affects timestamps and windowing.
public static Combine.Globally<Double,Double> doublesGlobally()
PTransform that takes an input PCollection<Double> and returns a
PCollection<Double> whose contents is the maximum of the input PCollection's
elements, or Double.NEGATIVE_INFINITY if there are no elements.public static <K> Combine.PerKey<K,Double,Double> doublesPerKey()
PTransform that takes an input PCollection<KV<K, Double>> and returns
a PCollection<KV<K, Double>> that contains an output element mapping each distinct key
in the input PCollection to the maximum of the values associated with that key in the
input PCollection.
See Combine.PerKey for how this affects timestamps and windowing.
public static <T extends Comparable<? super T>> Combine.Globally<T,T> globally()
PTransform that takes an input PCollection<T> and returns a PCollection<T> whose contents is the maximum according to the natural ordering of T
of the input PCollection's elements, or null if there are no elements.public static <K,T extends Comparable<? super T>> Combine.PerKey<K,T,T> perKey()
PTransform that takes an input PCollection<KV<K, T>> and returns a
PCollection<KV<K, T>> that contains an output element mapping each distinct key in the
input PCollection to the maximum according to the natural ordering of T of the
values associated with that key in the input PCollection.
See Combine.PerKey for how this affects timestamps and windowing.
public static <T,ComparatorT extends Comparator<? super T> & Serializable> Combine.Globally<T,T> globally(ComparatorT comparator)
PTransform that takes an input PCollection<T> and returns a PCollection<T> whose contents is the maximum of the input PCollection's elements, or
null if there are no elements.public static <K,T,ComparatorT extends Comparator<? super T> & Serializable> Combine.PerKey<K,T,T> perKey(ComparatorT comparator)
PTransform that takes an input PCollection<KV<K, T>> and returns a
PCollection<KV<K, T>> that contains one output element per key mapping each
to the maximum of the values associated with that key in the input PCollection.
See Combine.PerKey for how this affects timestamps and windowing.