Java Code Examples for org.apache.beam.sdk.values.TypeDescriptors#inputOf()
The following examples show how to use
org.apache.beam.sdk.values.TypeDescriptors#inputOf() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlatMapElements.java From beam with Apache License 2.0 | 5 votes |
/** Like {@link #via(ProcessFunction)}, but allows access to additional context. */ @Experimental(Kind.CONTEXTFUL) public <NewInputT> FlatMapElements<NewInputT, OutputT> via( Contextful<Fn<NewInputT, Iterable<OutputT>>> fn) { return new FlatMapElements<>( fn, fn.getClosure(), TypeDescriptors.inputOf(fn.getClosure()), outputType); }
Example 2
Source File: MapElements.java From beam with Apache License 2.0 | 4 votes |
/** Like {@link #via(ProcessFunction)}, but supports access to context, such as side inputs. */ @Experimental(Kind.CONTEXTFUL) public <NewInputT> MapElements<NewInputT, OutputT> via(Contextful<Fn<NewInputT, OutputT>> fn) { return new MapElements<>( fn, fn.getClosure(), TypeDescriptors.inputOf(fn.getClosure()), outputType); }
Example 3
Source File: FlatMapElements.java From beam with Apache License 2.0 | 2 votes |
/** * For a {@code ProcessFunction<InputT, ? extends Iterable<OutputT>>} {@code fn}, returns a {@link * PTransform} that applies {@code fn} to every element of the input {@code PCollection<InputT>} * and outputs all of the elements to the output {@code PCollection<OutputT>}. * * <p>Example usage: * * <pre>{@code * PCollection<String> words = lines.apply( * FlatMapElements.into(TypeDescriptors.strings()) * .via((String line) -> Arrays.asList(line.split(" "))) * }</pre> */ public <NewInputT> FlatMapElements<NewInputT, OutputT> via( ProcessFunction<NewInputT, ? extends Iterable<OutputT>> fn) { return new FlatMapElements<>( (Contextful) Contextful.fn(fn), fn, TypeDescriptors.inputOf(fn), outputType); }
Example 4
Source File: MapElements.java From beam with Apache License 2.0 | 2 votes |
/** * For a {@code ProcessFunction<InputT, OutputT>} {@code fn} and output type descriptor, returns a * {@code PTransform} that takes an input {@code PCollection<InputT>} and returns a {@code * PCollection<OutputT>} containing {@code fn.apply(v)} for every element {@code v} in the input. * * <p>Example usage: * * <pre>{@code * PCollection<Integer> wordLengths = words.apply( * MapElements.into(TypeDescriptors.integers()) * .via((String word) -> word.length())); * }</pre> */ public <NewInputT> MapElements<NewInputT, OutputT> via(ProcessFunction<NewInputT, OutputT> fn) { return new MapElements<>(Contextful.fn(fn), fn, TypeDescriptors.inputOf(fn), outputType); }