T - the type of the elements of the input and output
PCollectionspublic class First<T> extends PTransform<PCollection<T>,PCollection<T>>
First<T> takes a PCollection<T> and a limit, and
produces a new PCollection<T> containing up to limit
elements of the input PCollection.
If the input and output PCollections are ordered, then
First will select the first elements, otherwise it will
select any elements.
If limit is less than or equal to the size of the input
PCollection, then all the input's elements will be selected.
All of the elements of the output PCollection should fit into
main memory of a single worker machine. This operation does not
run in parallel.
Example of use:
PCollection<String> input = ...;
PCollection<String> output = input.apply(First.<String>of(100));
name| Modifier and Type | Method and Description |
|---|---|
PCollection<T> |
apply(PCollection<T> in)
Applies this
PTransform on the given Input, and returns its
Output. |
static <T> First<T> |
of(long limit)
Returns a
First<T> PTransform. |
finishSpecifying, getCoderRegistry, getDefaultName, getDefaultOutputCoder, getDefaultOutputCoder, getInput, getKindString, getName, getOutput, getPipeline, setName, setPipeline, toString, withNamepublic static <T> First<T> of(long limit)
First<T> PTransform.T - the type of the elements of the input and output
PCollectionslimit - the numer of elements to take from the inputpublic PCollection<T> apply(PCollection<T> in)
PTransformPTransform on the given Input, and returns its
Output.
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).
The default implementation throws an exception. A derived class must
either implement apply, or else each runner must supply a custom
implementation via
PipelineRunner.apply(com.google.cloud.dataflow.sdk.transforms.PTransform<Input, Output>, Input).
apply in class PTransform<PCollection<T>,PCollection<T>>