Flink from entry to real fragrance (13. Definition of time semantics)

Before watermark, let me talk about the concept of time. There are various time windows in https://blog.51cto.com/mapengfei/2554577. In actual production, which time is the window generated? When did the incident occur? Time to enter the flink program? It is still the time when flink starts processing
Flink provides a set of design solutions
settings that can be set directly in the code env

    val env = StreamExecutionEnvironment.getExecutionEnvironment

//    env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime)  //以事件时间作为窗口聚合
//env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime)   //以数据进入flink的时间作为窗口时间
//    env.setStreamTimeCharacteristic(TimeCharacteristic.ProcessingTime) //以Flink实际处理时间作为窗口时间

Time semantics

Flink from entry to real fragrance (13. Definition of time semantics)

It can only be said that in different scenarios, there are usage scenarios at each time, and the specific implementation is based on the actual situation.

Set in code

We can call the setStreamCharacteristic method on the execution environment directly in the code to set the
specific time of the stream's time characteristics , and also need to extract the timestamp from the data.
If you want to use the event time, you also need to set which field and Format, otherwise flink doesn’t know which field you use

val env = StreamExecutionEnvironment.getExecutionEnvironment
//Add time characteristics to each stream created by env from the moment of call
env.setStreamTimeCharcteristic(TimeCharacteristic.EventTime)

Guess you like

Origin blog.51cto.com/mapengfei/2554583