Google Cloud Dataflow SDK for Java, version 1.9.1
Class Max
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.transforms.Max
-
public class Max extends Object
PTransform
s for computing the maximum of the elements in aPCollection
, or the maximum of the values associated with each key in aPCollection
ofKV
s.Example 1: get the maximum of a
PCollection
ofDouble
s.PCollection<Double> input = ...; PCollection<Double> max = input.apply(Max.doublesGlobally());
Example 2: calculate the maximum of the
Integer
s associated with each unique key (which is of typeString
).PCollection<KV<String, Integer>> input = ...; PCollection<KV<String, Integer>> maxPerKey = input .apply(Max.<String>integersPerKey());
-
-
Nested Class Summary
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static Combine.Globally<Double,Double>
doublesGlobally()
Returns aPTransform
that takes an inputPCollection<Double>
and returns aPCollection<Double>
whose contents is the maximum of the inputPCollection
's elements, orDouble.NEGATIVE_INFINITY
if there are no elements.static <K> Combine.PerKey<K,Double,Double>
doublesPerKey()
Returns aPTransform
that takes an inputPCollection<KV<K, Double>>
and returns aPCollection<KV<K, Double>>
that contains an output element mapping each distinct key in the inputPCollection
to the maximum of the values associated with that key in the inputPCollection
.static <T extends Comparable<? super T>>
Combine.Globally<T,T>globally()
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
whose contents is the maximum according to the natural ordering ofT
of the inputPCollection
's elements, ornull
if there are no elements.static <T,ComparatorT extends Comparator<? super T> & Serializable>
Combine.Globally<T,T>globally(ComparatorT comparator)
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
whose contents is the maximum of the inputPCollection
's elements, ornull
if there are no elements.static Combine.Globally<Integer,Integer>
integersGlobally()
Returns aPTransform
that takes an inputPCollection<Integer>
and returns aPCollection<Integer>
whose contents is the maximum of the inputPCollection
's elements, orInteger.MIN_VALUE
if there are no elements.static <K> Combine.PerKey<K,Integer,Integer>
integersPerKey()
Returns aPTransform
that takes an inputPCollection<KV<K, Integer>>
and returns aPCollection<KV<K, Integer>>
that contains an output element mapping each distinct key in the inputPCollection
to the maximum of the values associated with that key in the inputPCollection
.static Combine.Globally<Long,Long>
longsGlobally()
Returns aPTransform
that takes an inputPCollection<Long>
and returns aPCollection<Long>
whose contents is the maximum of the inputPCollection
's elements, orLong.MIN_VALUE
if there are no elements.static <K> Combine.PerKey<K,Long,Long>
longsPerKey()
Returns aPTransform
that takes an inputPCollection<KV<K, Long>>
and returns aPCollection<KV<K, Long>>
that contains an output element mapping each distinct key in the inputPCollection
to the maximum of the values associated with that key in the inputPCollection
.static <K,T extends Comparable<? super T>>
Combine.PerKey<K,T,T>perKey()
Returns aPTransform
that takes an inputPCollection<KV<K, T>>
and returns aPCollection<KV<K, T>>
that contains an output element mapping each distinct key in the inputPCollection
to the maximum according to the natural ordering ofT
of the values associated with that key in the inputPCollection
.static <K,T,ComparatorT extends Comparator<? super T> & Serializable>
Combine.PerKey<K,T,T>perKey(ComparatorT comparator)
Returns aPTransform
that takes an inputPCollection<KV<K, T>>
and returns aPCollection<KV<K, T>>
that contains one output element per key mapping each to the maximum of the values associated with that key in the inputPCollection
.
-
-
-
Method Detail
-
integersGlobally
public static Combine.Globally<Integer,Integer> integersGlobally()
Returns aPTransform
that takes an inputPCollection<Integer>
and returns aPCollection<Integer>
whose contents is the maximum of the inputPCollection
's elements, orInteger.MIN_VALUE
if there are no elements.
-
integersPerKey
public static <K> Combine.PerKey<K,Integer,Integer> integersPerKey()
Returns aPTransform
that takes an inputPCollection<KV<K, Integer>>
and returns aPCollection<KV<K, Integer>>
that contains an output element mapping each distinct key in the inputPCollection
to the maximum of the values associated with that key in the inputPCollection
.See
Combine.PerKey
for how this affects timestamps and windowing.
-
longsGlobally
public static Combine.Globally<Long,Long> longsGlobally()
Returns aPTransform
that takes an inputPCollection<Long>
and returns aPCollection<Long>
whose contents is the maximum of the inputPCollection
's elements, orLong.MIN_VALUE
if there are no elements.
-
longsPerKey
public static <K> Combine.PerKey<K,Long,Long> longsPerKey()
Returns aPTransform
that takes an inputPCollection<KV<K, Long>>
and returns aPCollection<KV<K, Long>>
that contains an output element mapping each distinct key in the inputPCollection
to the maximum of the values associated with that key in the inputPCollection
.See
Combine.PerKey
for how this affects timestamps and windowing.
-
doublesGlobally
public static Combine.Globally<Double,Double> doublesGlobally()
Returns aPTransform
that takes an inputPCollection<Double>
and returns aPCollection<Double>
whose contents is the maximum of the inputPCollection
's elements, orDouble.NEGATIVE_INFINITY
if there are no elements.
-
doublesPerKey
public static <K> Combine.PerKey<K,Double,Double> doublesPerKey()
Returns aPTransform
that takes an inputPCollection<KV<K, Double>>
and returns aPCollection<KV<K, Double>>
that contains an output element mapping each distinct key in the inputPCollection
to the maximum of the values associated with that key in the inputPCollection
.See
Combine.PerKey
for how this affects timestamps and windowing.
-
globally
public static <T extends Comparable<? super T>> Combine.Globally<T,T> globally()
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
whose contents is the maximum according to the natural ordering ofT
of the inputPCollection
's elements, ornull
if there are no elements.
-
perKey
public static <K,T extends Comparable<? super T>> Combine.PerKey<K,T,T> perKey()
Returns aPTransform
that takes an inputPCollection<KV<K, T>>
and returns aPCollection<KV<K, T>>
that contains an output element mapping each distinct key in the inputPCollection
to the maximum according to the natural ordering ofT
of the values associated with that key in the inputPCollection
.See
Combine.PerKey
for how this affects timestamps and windowing.
-
globally
public static <T,ComparatorT extends Comparator<? super T> & Serializable> Combine.Globally<T,T> globally(ComparatorT comparator)
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
whose contents is the maximum of the inputPCollection
's elements, ornull
if there are no elements.
-
perKey
public static <K,T,ComparatorT extends Comparator<? super T> & Serializable> Combine.PerKey<K,T,T> perKey(ComparatorT comparator)
Returns aPTransform
that takes an inputPCollection<KV<K, T>>
and returns aPCollection<KV<K, T>>
that contains one output element per key mapping each to the maximum of the values associated with that key in the inputPCollection
.See
Combine.PerKey
for how this affects timestamps and windowing.
-
-