Class FromElementsGeneratorFunction<OUT>
- java.lang.Object
-
- org.apache.flink.connector.datagen.functions.FromElementsGeneratorFunction<OUT>
-
- Type Parameters:
OUT
- The type of elements returned by this function.
- All Implemented Interfaces:
Serializable
,Function
,GeneratorFunction<Long,OUT>
,OutputTypeConfigurable<OUT>
@Internal public class FromElementsGeneratorFunction<OUT> extends Object implements GeneratorFunction<Long,OUT>, OutputTypeConfigurable<OUT>
A stream generator function that returns a sequence of elements.This generator function serializes the elements using Flink's type information. That way, any object transport using Java serialization will not be affected by the serializability of the elements.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FromElementsGeneratorFunction(TypeInformation<OUT> typeInfo, ExecutionConfig config, Iterable<OUT> elements)
FromElementsGeneratorFunction(TypeInformation<OUT> typeInfo, OUT... elements)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <OUT> void
checkIterable(Iterable<OUT> elements, Class<?> viewedAs)
Verifies that all elements in the iterable are non-null, and are of the given class, or a subclass thereof.TypeSerializer<OUT>
getSerializer()
OUT
map(Long nextIndex)
void
open(SourceReaderContext readerContext)
Initialization method for the function.void
setOutputType(TypeInformation<OUT> outTypeInfo, ExecutionConfig executionConfig)
Is called by theorg.apache.flink.streaming.api.graph.StreamGraph#addOperator(Integer, String, StreamOperator, TypeInformation, TypeInformation, String)
method when theorg.apache.flink.streaming.api.graph.StreamGraph
is generated.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.connector.datagen.source.GeneratorFunction
close
-
-
-
-
Constructor Detail
-
FromElementsGeneratorFunction
@SafeVarargs public FromElementsGeneratorFunction(TypeInformation<OUT> typeInfo, OUT... elements)
-
FromElementsGeneratorFunction
public FromElementsGeneratorFunction(TypeInformation<OUT> typeInfo, ExecutionConfig config, Iterable<OUT> elements)
-
-
Method Detail
-
getSerializer
@VisibleForTesting @Nullable public TypeSerializer<OUT> getSerializer()
-
open
public void open(SourceReaderContext readerContext) throws Exception
Description copied from interface:GeneratorFunction
Initialization method for the function. It is called once before the actual data mapping methods.- Specified by:
open
in interfaceGeneratorFunction<Long,OUT>
- Throws:
Exception
-
map
public OUT map(Long nextIndex) throws Exception
- Specified by:
map
in interfaceGeneratorFunction<Long,OUT>
- Throws:
Exception
-
setOutputType
public void setOutputType(TypeInformation<OUT> outTypeInfo, ExecutionConfig executionConfig)
Description copied from interface:OutputTypeConfigurable
Is called by theorg.apache.flink.streaming.api.graph.StreamGraph#addOperator(Integer, String, StreamOperator, TypeInformation, TypeInformation, String)
method when theorg.apache.flink.streaming.api.graph.StreamGraph
is generated. The method is called with the outputTypeInformation
which is also used for theorg.apache.flink.streaming.runtime.tasks.StreamTask
output serializer.- Specified by:
setOutputType
in interfaceOutputTypeConfigurable<OUT>
- Parameters:
outTypeInfo
- Output type information of theorg.apache.flink.streaming.runtime.tasks.StreamTask
executionConfig
- Execution configuration
-
checkIterable
public static <OUT> void checkIterable(Iterable<OUT> elements, Class<?> viewedAs)
Verifies that all elements in the iterable are non-null, and are of the given class, or a subclass thereof.- Type Parameters:
OUT
- The generic type of the iterable to be checked.- Parameters:
elements
- The iterable to check.viewedAs
- The class to which the elements must be assignable to.
-
-