Google Cloud Dataflow SDK for Java, version 1.9.1
Class Flatten
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.transforms.Flatten
-
public class Flatten extends Object
Flatten<T>
takes multiplePCollection<T>
s bundled into aPCollectionList<T>
and returns a singlePCollection<T>
containing all the elements in all the inputPCollection
s. The name "Flatten" suggests taking a list of lists and flattening them into a single list.Example of use:
PCollection<String> pc1 = ...; PCollection<String> pc2 = ...; PCollection<String> pc3 = ...; PCollectionList<String> pcs = PCollectionList.of(pc1).and(pc2).and(pc3); PCollection<String> merged = pcs.apply(Flatten.<String>pCollections());
By default, the
Coder
of the outputPCollection
is the same as theCoder
of the firstPCollection
in the inputPCollectionList
(if thePCollectionList
is non-empty).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
Flatten.FlattenIterables<T>
FlattenIterables<T>
takes aPCollection<Iterable<T>>
and returns aPCollection<T>
that contains all the elements from each iterable.static class
Flatten.FlattenPCollectionList<T>
APTransform
that flattens aPCollectionList
into aPCollection
containing all the elements of all thePCollection
s in its input.
-
Constructor Summary
Constructors Constructor and Description Flatten()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static <T> Flatten.FlattenIterables<T>
iterables()
Returns aPTransform
that takes aPCollection<Iterable<T>>
and returns aPCollection<T>
containing all the elements from all theIterable
s.static <T> Flatten.FlattenPCollectionList<T>
pCollections()
Returns aPTransform
that flattens aPCollectionList
into aPCollection
containing all the elements of all thePCollection
s in its input.
-
-
-
Method Detail
-
pCollections
public static <T> Flatten.FlattenPCollectionList<T> pCollections()
Returns aPTransform
that flattens aPCollectionList
into aPCollection
containing all the elements of all thePCollection
s in its input.All inputs must have equal
WindowFn
s. The output elements ofFlatten<T>
are in the same windows and have the same timestamps as their corresponding input elements. The outputPCollection
will have the sameWindowFn
as all of the inputs.- Type Parameters:
T
- the type of the elements in the input and outputPCollection
s.
-
iterables
public static <T> Flatten.FlattenIterables<T> iterables()
Returns aPTransform
that takes aPCollection<Iterable<T>>
and returns aPCollection<T>
containing all the elements from all theIterable
s.Example of use:
PCollection<Iterable<Integer>> pcOfIterables = ...; PCollection<Integer> pc = pcOfIterables.apply(Flatten.<Integer>iterables());
By default, the output
PCollection
encodes its elements using the sameCoder
that the input uses for the elements in itsIterable
.- Type Parameters:
T
- the type of the elements of the inputIterable
and the outputPCollection
-
-