use of org.apache.flink.table.connector.ParallelismProvider in project flink by apache.
the class CommonExecSink method deriveSinkParallelism.
/**
* Returns the parallelism of sink operator, it assumes the sink runtime provider implements
* {@link ParallelismProvider}. It returns parallelism defined in {@link ParallelismProvider} if
* the parallelism is provided, otherwise it uses parallelism of input transformation.
*/
private int deriveSinkParallelism(Transformation<RowData> inputTransform, SinkRuntimeProvider runtimeProvider) {
final int inputParallelism = inputTransform.getParallelism();
if (!(runtimeProvider instanceof ParallelismProvider)) {
return inputParallelism;
}
final ParallelismProvider parallelismProvider = (ParallelismProvider) runtimeProvider;
return parallelismProvider.getParallelism().map(sinkParallelism -> {
if (sinkParallelism <= 0) {
throw new TableException(String.format("Invalid configured parallelism %s for table '%s'.", sinkParallelism, tableSinkSpec.getContextResolvedTable().getIdentifier().asSummaryString()));
}
return sinkParallelism;
}).orElse(inputParallelism);
}
Aggregations