Class Deduplicate
PTransform
s which deduplicate input records over a time domain and threshold.
Values in different windows will not be considered duplicates of each other. Deduplication is
best effort.
Two values of type T
are compared for equality not by regular Java Object.equals(java.lang.Object)
, but instead by first encoding each of the elements using the
PCollection
's Coder
, and then comparing the encoded bytes. This admits efficient
parallel evaluation.
These PTransforms are different then Distinct
since Distinct
guarantees
uniqueness of values within a PCollection
but may support a narrower set of windowing strategies
or may delay when output is
produced.
The durations specified may impose memory and/or storage requirements within a runner and care might need to be used to ensure that the deduplication time limit is long enough to remove duplicates but short enough to not cause performance problems within a runner. Each runner may provide an optimized implementation of their choice using the deduplication time domain and threshold specified.
Does not preserve any order the input PCollection might have had.
Example of use:
PCollection<String> words = ...;
PCollection<String> deduplicatedWords =
words.apply(Deduplicate.<String>values());
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Deduplicates keyed values using the key over a specified time domain and threshold.static final class
Deduplicates values over a specified time domain and threshold.static final class
APTransform
that uses aSerializableFunction
to obtain a representative value for each input element used for deduplication. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Duration
The default duration is 10 mins.static final TimeDomain
The default is theprocessing time domain
. -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> Deduplicate.KeyedValues <K, V> Returns a deduplication transform that deduplicates keyed values using the key for up to 10 mins within theprocessing time domain
.static <T> Deduplicate.Values
<T> values()
Returns a deduplication transform that deduplicates values for up to 10 mins within theprocessing time domain
.static <T,
IdT> Deduplicate.WithRepresentativeValues <T, IdT> withRepresentativeValueFn
(SerializableFunction<T, IdT> representativeValueFn) Returns a deduplication transform that deduplicates values using the supplied representative value for up to 10 mins within theprocessing time domain
.
-
Field Details
-
DEFAULT_TIME_DOMAIN
The default is theprocessing time domain
. -
DEFAULT_DURATION
The default duration is 10 mins.
-
-
Method Details
-
values
Returns a deduplication transform that deduplicates values for up to 10 mins within theprocessing time domain
. -
keyedValues
Returns a deduplication transform that deduplicates keyed values using the key for up to 10 mins within theprocessing time domain
. -
withRepresentativeValueFn
public static <T,IdT> Deduplicate.WithRepresentativeValues<T,IdT> withRepresentativeValueFn(SerializableFunction<T, IdT> representativeValueFn) Returns a deduplication transform that deduplicates values using the supplied representative value for up to 10 mins within theprocessing time domain
.
-