public abstract class SimpleFunction<InputT,OutputT> extends java.lang.Object implements SerializableFunction<InputT,OutputT>, HasDisplayData
SerializableFunction
which is not a functional interface. Concrete subclasses
allow us to infer type information, which in turn aids Coder
inference.Modifier | Constructor and Description |
---|---|
protected |
SimpleFunction() |
protected |
SimpleFunction(SerializableFunction<InputT,OutputT> fn) |
Modifier and Type | Method and Description |
---|---|
OutputT |
apply(InputT input)
Returns the result of invoking this function on the given input.
|
static <InputT,OutputT> |
fromSerializableFunctionWithOutputType(SerializableFunction<InputT,OutputT> fn,
TypeDescriptor<OutputT> outputType) |
TypeDescriptor<InputT> |
getInputTypeDescriptor()
Returns a
TypeDescriptor capturing what is known statically about the input type of
this SimpleFunction instance's most-derived class. |
TypeDescriptor<OutputT> |
getOutputTypeDescriptor()
Returns a
TypeDescriptor capturing what is known statically about the output type of
this SimpleFunction instance's most-derived class. |
void |
populateDisplayData(DisplayData.Builder builder)
Register display data for the given transform or component.
|
protected SimpleFunction()
protected SimpleFunction(SerializableFunction<InputT,OutputT> fn)
public OutputT apply(InputT input)
SerializableFunction
apply
in interface SerializableFunction<InputT,OutputT>
public static <InputT,OutputT> SimpleFunction<InputT,OutputT> fromSerializableFunctionWithOutputType(SerializableFunction<InputT,OutputT> fn, TypeDescriptor<OutputT> outputType)
public TypeDescriptor<InputT> getInputTypeDescriptor()
TypeDescriptor
capturing what is known statically about the input type of
this SimpleFunction
instance's most-derived class.
See getOutputTypeDescriptor()
for more discussion.
public TypeDescriptor<OutputT> getOutputTypeDescriptor()
TypeDescriptor
capturing what is known statically about the output type of
this SimpleFunction
instance's most-derived class.
In the normal case of a concrete SimpleFunction
subclass with no generic type
parameters of its own (including anonymous inner classes), this will be a complete non-generic
type, which is good for choosing a default output Coder<OutputT>
for the output PCollection<OutputT>
.
public void populateDisplayData(DisplayData.Builder builder)
populateDisplayData(DisplayData.Builder)
is invoked by Pipeline runners to collect
display data via DisplayData.from(HasDisplayData)
. Implementations may call super.populateDisplayData(builder)
in order to register display data in the current namespace,
but should otherwise use subcomponent.populateDisplayData(builder)
to use the namespace
of the subcomponent.
By default, does not register any display data. Implementors may override this method to provide their own display data.
populateDisplayData
in interface HasDisplayData
builder
- The builder to populate with display data.HasDisplayData