Latest.globally()
takes a collection of values and produces the collection containing the single value with the latest implicit timestamp.Latest.perKey()
takes a collection of key value pairs, and returns the latest value for each key, according to the implicit timestamp.For elements with the same timestamp, the output element is arbitrarily selected.
Example: compute the latest value for each session
PCollection input = ...; PCollection sessioned = input .apply(Window.into(Sessions.withGapDuration(Duration.standardMinutes(5))); PCollection latestValues = sessioned.apply(Latest.globally());