Search in sources :

Example 1 with LegacySourceTransformation

use of org.apache.flink.streaming.api.transformations.LegacySourceTransformation in project flink by apache.

the class CommonExecTableSourceScan method createSourceFunctionTransformation.

/**
 * Adopted from {@link StreamExecutionEnvironment#addSource(SourceFunction, String,
 * TypeInformation)} but with custom {@link Boundedness}.
 */
protected Transformation<RowData> createSourceFunctionTransformation(StreamExecutionEnvironment env, SourceFunction<RowData> function, boolean isBounded, String operatorName, TypeInformation<RowData> outputTypeInfo) {
    env.clean(function);
    final int parallelism;
    if (function instanceof ParallelSourceFunction) {
        parallelism = env.getParallelism();
    } else {
        parallelism = 1;
    }
    final Boundedness boundedness;
    if (isBounded) {
        boundedness = Boundedness.BOUNDED;
    } else {
        boundedness = Boundedness.CONTINUOUS_UNBOUNDED;
    }
    final StreamSource<RowData, ?> sourceOperator = new StreamSource<>(function, !isBounded);
    return new LegacySourceTransformation<>(operatorName, sourceOperator, outputTypeInfo, parallelism, boundedness);
}
Also used : RowData(org.apache.flink.table.data.RowData) Boundedness(org.apache.flink.api.connector.source.Boundedness) StreamSource(org.apache.flink.streaming.api.operators.StreamSource) ParallelSourceFunction(org.apache.flink.streaming.api.functions.source.ParallelSourceFunction) LegacySourceTransformation(org.apache.flink.streaming.api.transformations.LegacySourceTransformation)

Aggregations

Boundedness (org.apache.flink.api.connector.source.Boundedness)1 ParallelSourceFunction (org.apache.flink.streaming.api.functions.source.ParallelSourceFunction)1 StreamSource (org.apache.flink.streaming.api.operators.StreamSource)1 LegacySourceTransformation (org.apache.flink.streaming.api.transformations.LegacySourceTransformation)1 RowData (org.apache.flink.table.data.RowData)1