Package org.apache.beam.sdk.transforms
Class Min
- java.lang.Object
-
- org.apache.beam.sdk.transforms.Min
-
public class Min extends java.lang.Object
PTransform
s for computing the minimum of the elements in aPCollection
, or the minimum of the values associated with each key in aPCollection
ofKV
s.Example 1: get the minimum of a
PCollection
ofDouble
s.PCollection<Double> input = ...; PCollection<Double> min = input.apply(Min.doublesGlobally());
Example 2: calculate the minimum of the
Integer
s associated with each unique key (which is of typeString
).PCollection<KV<String, Integer>> input = ...; PCollection<KV<String, Integer>> minPerKey = input .apply(Min.<String>integersPerKey());
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Combine.Globally<java.lang.Double,java.lang.Double>
doublesGlobally()
Returns aPTransform
that takes an inputPCollection<Double>
and returns aPCollection<Double>
whose contents is the minimum of the inputPCollection
's elements, orDouble.POSITIVE_INFINITY
if there are no elements.static <K> Combine.PerKey<K,java.lang.Double,java.lang.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 minimum of the values associated with that key in the inputPCollection
.static <T extends java.lang.Comparable<? super T>>
Combine.Globally<T,T>globally()
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
whose contents is the minimum according to the natural ordering ofT
of the inputPCollection
's elements, ornull
if there are no elements.static <T,ComparatorT extends java.util.Comparator<? super T> & java.io.Serializable>
Combine.Globally<T,T>globally(ComparatorT comparator)
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
whose contents is the minimum of the inputPCollection
's elements, ornull
if there are no elements.static Combine.Globally<java.lang.Integer,java.lang.Integer>
integersGlobally()
Returns aPTransform
that takes an inputPCollection<Integer>
and returns aPCollection<Integer>
whose contents is a single value that is the minimum of the inputPCollection
's elements, orInteger.MAX_VALUE
if there are no elements.static <K> Combine.PerKey<K,java.lang.Integer,java.lang.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 minimum of the values associated with that key in the inputPCollection
.static Combine.Globally<java.lang.Long,java.lang.Long>
longsGlobally()
Returns aPTransform
that takes an inputPCollection<Long>
and returns aPCollection<Long>
whose contents is the minimum of the inputPCollection
's elements, orLong.MAX_VALUE
if there are no elements.static <K> Combine.PerKey<K,java.lang.Long,java.lang.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 minimum of the values associated with that key in the inputPCollection
.static <T extends java.lang.Comparable<? super T>>
Combine.BinaryCombineFn<T>naturalOrder()
static <T extends java.lang.Comparable<? super T>>
Combine.BinaryCombineFn<T>naturalOrder(T identity)
static <T,ComparatorT extends java.util.Comparator<? super T> & java.io.Serializable>
Combine.BinaryCombineFn<T>of(ComparatorT comparator)
ACombineFn
that computes the minimum of a collection of elements of typeT
using an arbitraryComparator
, useful as an argument toCombine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
orCombine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
.static <T,ComparatorT extends java.util.Comparator<? super T> & java.io.Serializable>
Combine.BinaryCombineFn<T>of(T identity, ComparatorT comparator)
ACombineFn
that computes the minimum of a collection of elements of typeT
using an arbitraryComparator
and anidentity
, useful as an argument toCombine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
orCombine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
.static Combine.BinaryCombineDoubleFn
ofDoubles()
ACombineFn
that computes the minimum of a collection ofDouble
s, useful as an argument toCombine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
orCombine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
.static Combine.BinaryCombineIntegerFn
ofIntegers()
ACombineFn
that computes the minimum of a collection ofInteger
s, useful as an argument toCombine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
orCombine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
.static Combine.BinaryCombineLongFn
ofLongs()
ACombineFn
that computes the minimum of a collection ofLong
s, useful as an argument toCombine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
orCombine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
.static <K,T extends java.lang.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 minimum according to the natural ordering ofT
of the values associated with that key in the inputPCollection
.static <K,T,ComparatorT extends java.util.Comparator<? super T> & java.io.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 minimum of the values associated with that key in the inputPCollection
.
-
-
-
Method Detail
-
integersGlobally
public static Combine.Globally<java.lang.Integer,java.lang.Integer> integersGlobally()
Returns aPTransform
that takes an inputPCollection<Integer>
and returns aPCollection<Integer>
whose contents is a single value that is the minimum of the inputPCollection
's elements, orInteger.MAX_VALUE
if there are no elements.
-
integersPerKey
public static <K> Combine.PerKey<K,java.lang.Integer,java.lang.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 minimum 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<java.lang.Long,java.lang.Long> longsGlobally()
Returns aPTransform
that takes an inputPCollection<Long>
and returns aPCollection<Long>
whose contents is the minimum of the inputPCollection
's elements, orLong.MAX_VALUE
if there are no elements.
-
longsPerKey
public static <K> Combine.PerKey<K,java.lang.Long,java.lang.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 minimum 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<java.lang.Double,java.lang.Double> doublesGlobally()
Returns aPTransform
that takes an inputPCollection<Double>
and returns aPCollection<Double>
whose contents is the minimum of the inputPCollection
's elements, orDouble.POSITIVE_INFINITY
if there are no elements.
-
doublesPerKey
public static <K> Combine.PerKey<K,java.lang.Double,java.lang.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 minimum of the values associated with that key in the inputPCollection
.See
Combine.PerKey
for how this affects timestamps and windowing.
-
ofIntegers
public static Combine.BinaryCombineIntegerFn ofIntegers()
ACombineFn
that computes the minimum of a collection ofInteger
s, useful as an argument toCombine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
orCombine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
.
-
ofLongs
public static Combine.BinaryCombineLongFn ofLongs()
ACombineFn
that computes the minimum of a collection ofLong
s, useful as an argument toCombine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
orCombine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
.
-
ofDoubles
public static Combine.BinaryCombineDoubleFn ofDoubles()
ACombineFn
that computes the minimum of a collection ofDouble
s, useful as an argument toCombine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
orCombine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
.
-
of
public static <T,ComparatorT extends java.util.Comparator<? super T> & java.io.Serializable> Combine.BinaryCombineFn<T> of(T identity, ComparatorT comparator)
ACombineFn
that computes the minimum of a collection of elements of typeT
using an arbitraryComparator
and anidentity
, useful as an argument toCombine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
orCombine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
.- Type Parameters:
T
- the type of the values being compared
-
of
public static <T,ComparatorT extends java.util.Comparator<? super T> & java.io.Serializable> Combine.BinaryCombineFn<T> of(ComparatorT comparator)
ACombineFn
that computes the minimum of a collection of elements of typeT
using an arbitraryComparator
, useful as an argument toCombine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
orCombine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>)
.- Type Parameters:
T
- the type of the values being compared
-
naturalOrder
public static <T extends java.lang.Comparable<? super T>> Combine.BinaryCombineFn<T> naturalOrder(T identity)
-
naturalOrder
public static <T extends java.lang.Comparable<? super T>> Combine.BinaryCombineFn<T> naturalOrder()
-
globally
public static <T extends java.lang.Comparable<? super T>> Combine.Globally<T,T> globally()
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
whose contents is the minimum according to the natural ordering ofT
of the inputPCollection
's elements, ornull
if there are no elements.
-
perKey
public static <K,T extends java.lang.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 minimum 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 java.util.Comparator<? super T> & java.io.Serializable> Combine.Globally<T,T> globally(ComparatorT comparator)
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
whose contents is the minimum of the inputPCollection
's elements, ornull
if there are no elements.
-
perKey
public static <K,T,ComparatorT extends java.util.Comparator<? super T> & java.io.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 minimum of the values associated with that key in the inputPCollection
.See
Combine.PerKey
for how this affects timestamps and windowing.
-
-