Package org.apache.beam.sdk.transforms
Class Latest
java.lang.Object
org.apache.beam.sdk.transforms.Latest
PTransform and Combine.CombineFn for computing the latest element in a PCollection.
 Example: compute the latest value for each session:
 PCollection<Long> input = ...;
 PCollection<Long> sessioned = input
    .apply(Window.<Long>into(Sessions.withGapDuration(Duration.standardMinutes(5)));
 PCollection<Long> latestValues = sessioned.apply(Latest.<Long>globally());
 
 combineFn() can also be used manually, in combination with state and with the Combine transform.
 
For elements with the same timestamp, the element chosen for output is arbitrary.
- 
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Combine.CombineFn<TimestampedValue<T>, ?, T> Returns aCombine.CombineFnthat selects the latest element among its inputs.static <T> PTransform<PCollection<T>, PCollection<T>> globally()Returns aPTransformthat takes as input aPCollection<T>and returns aPCollection<T>whose contents is the latest element according to its event time, or null if there are no elements.static <K,V> PTransform <PCollection<KV<K, V>>, PCollection<KV<K, V>>> perKey()Returns aPTransformthat takes as input aPCollection<KV<K, V>>and returns aPCollection<KV<K, V>>whose contents is the latest element per-key according to its event time. 
- 
Method Details
- 
combineFn
Returns aCombine.CombineFnthat selects the latest element among its inputs. - 
globally
Returns aPTransformthat takes as input aPCollection<T>and returns aPCollection<T>whose contents is the latest element according to its event time, or null if there are no elements.- Type Parameters:
 T- The type of the elements being combined.
 - 
perKey
Returns aPTransformthat takes as input aPCollection<KV<K, V>>and returns aPCollection<KV<K, V>>whose contents is the latest element per-key according to its event time.- Type Parameters:
 K- The key type of the elements being combined.V- The value type of the elements being combined.
 
 -