Class InferableFunction<InputT,OutputT>
- java.lang.Object
-
- org.apache.beam.sdk.transforms.InferableFunction<InputT,OutputT>
-
- All Implemented Interfaces:
java.io.Serializable
,HasDisplayData
,ProcessFunction<InputT,OutputT>
- Direct Known Subclasses:
SimpleFunction
public abstract class InferableFunction<InputT,OutputT> extends java.lang.Object implements ProcessFunction<InputT,OutputT>, HasDisplayData
AProcessFunction
which is not a functional interface. Concrete subclasses allow us to infer type information, which in turn aidsCoder
inference.See
SimpleFunction
for providing robust type information where aSerializableFunction
is required.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
InferableFunction()
protected
InferableFunction(ProcessFunction<InputT,OutputT> fn)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description OutputT
apply(InputT input)
Returns the result of invoking this function on the given input.static <InputT,OutputT>
InferableFunction<InputT,OutputT>fromProcessFunctionWithOutputType(ProcessFunction<InputT,OutputT> fn, TypeDescriptor<OutputT> outputType)
TypeDescriptor<InputT>
getInputTypeDescriptor()
Returns aTypeDescriptor
capturing what is known statically about the input type of thisInferableFunction
instance's most-derived class.TypeDescriptor<OutputT>
getOutputTypeDescriptor()
Returns aTypeDescriptor
capturing what is known statically about the output type of thisInferableFunction
instance's most-derived class.void
populateDisplayData(DisplayData.Builder builder)
Register display data for the given transform or component.
-
-
-
Constructor Detail
-
InferableFunction
protected InferableFunction()
-
InferableFunction
protected InferableFunction(ProcessFunction<InputT,OutputT> fn)
-
-
Method Detail
-
apply
public OutputT apply(InputT input) throws java.lang.Exception
Description copied from interface:ProcessFunction
Returns the result of invoking this function on the given input.- Specified by:
apply
in interfaceProcessFunction<InputT,OutputT>
- Throws:
java.lang.Exception
-
fromProcessFunctionWithOutputType
public static <InputT,OutputT> InferableFunction<InputT,OutputT> fromProcessFunctionWithOutputType(ProcessFunction<InputT,OutputT> fn, TypeDescriptor<OutputT> outputType)
-
getInputTypeDescriptor
public TypeDescriptor<InputT> getInputTypeDescriptor()
Returns aTypeDescriptor
capturing what is known statically about the input type of thisInferableFunction
instance's most-derived class.See
getOutputTypeDescriptor()
for more discussion.
-
getOutputTypeDescriptor
public TypeDescriptor<OutputT> getOutputTypeDescriptor()
Returns aTypeDescriptor
capturing what is known statically about the output type of thisInferableFunction
instance's most-derived class.In the normal case of a concrete
InferableFunction
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 outputCoder<OutputT>
for the outputPCollection<OutputT>
.
-
populateDisplayData
public void populateDisplayData(DisplayData.Builder builder)
Register display data for the given transform or component.populateDisplayData(DisplayData.Builder)
is invoked by Pipeline runners to collect display data viaDisplayData.from(HasDisplayData)
. Implementations may callsuper.populateDisplayData(builder)
in order to register display data in the current namespace, but should otherwise usesubcomponent.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.
- Specified by:
populateDisplayData
in interfaceHasDisplayData
- Parameters:
builder
- The builder to populate with display data.- See Also:
HasDisplayData
-
-