com.google.cloud.dataflow.sdk.transforms

## Class FlatMapElements<InputT,OutputT>

- java.lang.Object
- - com.google.cloud.dataflow.sdk.transforms.PTransform<PCollection<InputT>,PCollection<OutputT>>
  - - com.google.cloud.dataflow.sdk.transforms.FlatMapElements<InputT,OutputT>

All Implemented Interfaces:
  HasDisplayData, Serializable

    public class FlatMapElements<InputT,OutputT>
    extends PTransform<PCollection<InputT>,PCollection<OutputT>>

`PTransform`s for mapping a simple function that returns iterables over the elements of a `PCollection` and merging the results.

See Also:
  Serialized Form

### Nested Class Summary

Nested Classes
`static class` `FlatMapElements.MissingOutputTypeDescriptor<InputT,OutputT>` An intermediate builder for a `FlatMapElements` transform.

### Field Summary

### Fields inherited from class com.google.cloud.dataflow.sdk.transforms.PTransform

`name`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`PCollection<OutputT>` `apply(PCollection<InputT> input)` Applies this `PTransform` on the given `InputT`, and returns its `Output`.
`static <InputT,OutputT> FlatMapElements.MissingOutputTypeDescriptor<InputT,OutputT>` `via(SerializableFunction<InputT,? extends Iterable<OutputT>> fn)` For a `SerializableFunction<InputT, ? extends Iterable<OutputT>>` `fn`, returns a `PTransform` that applies `fn` to every element of the input `PCollection<InputT>` and outputs all of the elements to the output `PCollection<OutputT>`.
`static <InputT,OutputT> FlatMapElements<InputT,OutputT>` `via(SimpleFunction<InputT,? extends Iterable<OutputT>> fn)` For a `SimpleFunction<InputT, ? extends Iterable<OutputT>>` `fn`, return a `PTransform` that applies `fn` to every element of the input `PCollection<InputT>` and outputs all of the elements to the output `PCollection<OutputT>`.

### Methods inherited from class com.google.cloud.dataflow.sdk.transforms.PTransform

`getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, populateDisplayData, toString, validate`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Method Detail

#### via

    public static <InputT,OutputT> FlatMapElements.MissingOutputTypeDescriptor<InputT,OutputT> via(SerializableFunction<InputT,? extends Iterable<OutputT>> fn)

For a `SerializableFunction<InputT, ? extends Iterable<OutputT>>` `fn`, returns a `PTransform` that applies `fn` to every element of the input `PCollection<InputT>` and outputs all of the elements to the output `PCollection<OutputT>`.

Example of use in Java 8:

     PCollection<String> words = lines.apply(
         FlatMapElements.via((String line) -> Arrays.asList(line.split(" ")))
             .withOutputType(new TypeDescriptor<String>(){});

In Java 7, the overload `via(SimpleFunction)` is more concise as the output type descriptor need not be provided.

#### via

    public static <InputT,OutputT> FlatMapElements<InputT,OutputT> via(SimpleFunction<InputT,? extends Iterable<OutputT>> fn)

For a `SimpleFunction<InputT, ? extends Iterable<OutputT>>` `fn`, return a `PTransform` that applies `fn` to every element of the input `PCollection<InputT>` and outputs all of the elements to the output `PCollection<OutputT>`.

This overload is intended primarily for use in Java 7. In Java 8, the overload `via(SerializableFunction)` supports use of lambda for greater concision.

Example of use in Java 7:

     PCollection<String> lines = ...;
     PCollection<String> words = lines.apply(FlatMapElements.via(
         new SimpleFunction<String, List<String>>() {
           public Integer apply(String line) {
             return Arrays.asList(line.split(" "));
           }
         });

To use a Java 8 lambda, see `via(SerializableFunction)`.

#### apply

    public PCollection<OutputT> apply(PCollection<InputT> input)

Description copied from class: `PTransform`
Applies this `PTransform` on the given `InputT`, 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<InputT, OutputT>, InputT)`.

Overrides:
  `apply` in class `PTransform<PCollection<InputT>,PCollection<OutputT>>`