use of org.apache.flink.table.runtime.generated.GeneratedWatermarkGenerator in project flink by apache.
the class StreamExecWatermarkAssigner method translateToPlanInternal.
@SuppressWarnings("unchecked")
@Override
protected Transformation<RowData> translateToPlanInternal(PlannerBase planner, ExecNodeConfig config) {
final ExecEdge inputEdge = getInputEdges().get(0);
final Transformation<RowData> inputTransform = (Transformation<RowData>) inputEdge.translateToPlan(planner);
final GeneratedWatermarkGenerator watermarkGenerator = WatermarkGeneratorCodeGenerator.generateWatermarkGenerator(config.getTableConfig(), (RowType) inputEdge.getOutputType(), watermarkExpr, JavaScalaConversionUtil.toScala(Optional.empty()));
final long idleTimeout = config.get(ExecutionConfigOptions.TABLE_EXEC_SOURCE_IDLE_TIMEOUT).toMillis();
final WatermarkAssignerOperatorFactory operatorFactory = new WatermarkAssignerOperatorFactory(rowtimeFieldIndex, idleTimeout, watermarkGenerator);
return ExecNodeUtil.createOneInputTransformation(inputTransform, createTransformationMeta(WATERMARK_ASSIGNER_TRANSFORMATION, config), operatorFactory, InternalTypeInfo.of(getOutputType()), inputTransform.getParallelism());
}
use of org.apache.flink.table.runtime.generated.GeneratedWatermarkGenerator in project flink by apache.
the class WatermarkPushDownSpec method apply.
@Override
public void apply(DynamicTableSource tableSource, SourceAbilityContext context) {
if (tableSource instanceof SupportsWatermarkPushDown) {
GeneratedWatermarkGenerator generatedWatermarkGenerator = WatermarkGeneratorCodeGenerator.generateWatermarkGenerator(context.getTableConfig(), context.getSourceRowType(), watermarkExpr, Option.apply("context"));
Configuration configuration = context.getTableConfig().getConfiguration();
WatermarkGeneratorSupplier<RowData> supplier = new GeneratedWatermarkGeneratorSupplier(configuration, generatedWatermarkGenerator);
WatermarkStrategy<RowData> watermarkStrategy = WatermarkStrategy.forGenerator(supplier);
if (idleTimeoutMillis > 0) {
watermarkStrategy = watermarkStrategy.withIdleness(Duration.ofMillis(idleTimeoutMillis));
}
((SupportsWatermarkPushDown) tableSource).applyWatermark(watermarkStrategy);
} else {
throw new TableException(String.format("%s does not support SupportsWatermarkPushDown.", tableSource.getClass().getName()));
}
}
Aggregations