watermark

A, watermark

  flink each record will have received a Watermark, calculated as a current received eventTime- maximum delay time, the window function to the received message satisfies a condition will trigger operation window, so the absence of the condition to enter the message window will not be calculated.

  Window trigger conditions is calculated: 1, watermark time> = window_end_time; 2, the data in the [window_start_time, window_end_time) in.

  

  // Specify processing time according eventtime 
   env.setStreamTimeCharacteristic (TimeCharacteristic.EventTime) 
    Val Stream = env.fromElements (( . 1 , " A " ), ( 2 , " B " ), ( . 3 , " B " ), ( 3000 , " C " )). assignTimestampsAndWatermarks (
 // specified interval of 1 second 
      new new BoundedOutOfOrdernessTimestampExtractor [(Int, String)] (Time.seconds ( . 1 )) {
         // the specified field as EventTime 
        the override def extractTimestamp(element: (Int, String)): Long = {
          element._1.toLong
        }
      }
    )
    val result = stream.keyBy(1).window(
//eventtimewindow
      TumblingEventTimeWindows.of(Time.seconds(1))
    ).sum(0)

 

Guess you like

Origin www.cnblogs.com/csyusu/p/11448311.html