K - the type of the keys in the input PCollection and the values in the output
PCollectionV - the type of the values in the input PCollection and the keys in the output
PCollectionpublic class KvSwap<K,V> extends PTransform<PCollection<KV<K,V>>,PCollection<KV<V,K>>>
KvSwap<K, V> takes a PCollection<KV<K, V>> and returns a PCollection<KV<V,
K>>, where all the keys and values have been swapped.
Example of use:
PCollection<String, Long> wordsToCounts = ...;
PCollection<Long, String> countsToWords =
wordToCounts.apply(KvSwap.<String, Long>create());
Each output element has the same timestamp and is in the same windows as its corresponding
input element, and the output PCollection has the same WindowFn associated with it as the input.
name, resourceHints| Modifier and Type | Method and Description |
|---|---|
static <K,V> KvSwap<K,V> |
create()
Returns a
KvSwap<K, V> PTransform. |
PCollection<KV<V,K>> |
expand(PCollection<KV<K,V>> in)
Override this method to specify how this
PTransform should be expanded on the given
InputT. |
compose, compose, getAdditionalInputs, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setResourceHints, toString, validate, validatepublic static <K,V> KvSwap<K,V> create()
KvSwap<K, V> PTransform.K - the type of the keys in the input PCollection and the values in the output
PCollectionV - the type of the values in the input PCollection and the keys in the output
PCollectionpublic PCollection<KV<V,K>> expand(PCollection<KV<K,V>> in)
PTransformPTransform should be expanded on the given
InputT.
NOTE: This method should not be called directly. Instead apply the PTransform should
be applied to the InputT using the apply method.
Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
expand in class PTransform<PCollection<KV<K,V>>,PCollection<KV<V,K>>>