package com.coder.flink.restart import org.apache.flink.api.scala._ import org.apache.flink.streaming.api.functions.source.SourceFunction import org.apache.flink.streaming.api.functions.timestamps.BoundedOutOfOrdernessTimestampExtractor import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment} import org.apache.flink.streaming.api.watermark.Watermark import org.apache.flink.streaming.api.windowing.time.Time object WaterMarkDemo { def main(args: Array[String]): Unit = { val env = StreamExecutionEnvironment.getExecutionEnvironment val input = List(("a", 2L, 1), ("b", 2L, 1), ("c", 3L, 1)) env.addSource(new SourceFunction[(String, Long, Int)] { override def run(ctx: SourceFunction.SourceContext[(String, Long, Int)]): Unit = { input.foreach(value => { //固定套路 调用 collectWithTimestamp 指定哪个字段是水印字段 ctx.collectWithTimestamp(value, value._2) ct
Flink,水印的几种简单写法
最新推荐文章于 2024-07-24 16:31:12 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)