本文介绍了如何使用“处理时间模型"检查流中某个项目的内部flink时间戳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用流到达flink的时间标记流中的数据,以便我可以执行一些计算.我知道使用事件时间模型时可以直接控制它,但是我希望有一些简单的方法来发现在对流进行Window决策时正在使用的Timestamp flink.

I am looking to tag the data in my stream with the time it arrived in flink so that I can perform some calculations. I recognize when using the Event Time Model I would have direct control over that, but I was hoping there was some easy way to discover the Timestamp flink was using when making Window decisions on a stream.

推荐答案

Flink支持三种与时间配合使用的模式:

Flink supports three modes to work with time:

  • 处理时间:相对于每个操作员的当前时间处理事件
  • 事件时间:事件是与手动分配的时间戳相关的过程.
  • 摄取时间:事件是根据Flink摄取事件时自动分配的时间戳进行处理的.
  • Processing Time: Events are processed with respect to the current time of each operator
  • Event Time: Events are processes with respect to a timestamp which was manually assigned.
  • Ingestion Time: Events are processed with respect to a timestamp that is automatically assigned when the event is ingested by Flink.

根据您的描述,您似乎在寻找摄取时间.在内部,摄取时间的传递就像事件时间一样,但是区别在于时间戳是自动分配的(水印是自动生成的).

From your description, it seems that you are looking for Ingestion Time. Internally, ingestion time is handed just like event time, but the difference is that the timestamps are automatically assigned (and watermarks are automatically generated).

通过StreamExecutionEnvironment.setStreamTimeCharacteristic()方法设置时间模式.

The time mode is set via the StreamExecutionEnvironment.setStreamTimeCharacteristic() method.

除了ProcessFunction之外,事件时间和摄取时间时间戳均不提供任何功能. ProcessFunction可以通过Context.timestamp()方法读取ProcessFunction.processElement()中事件的时间戳.

Event time and ingestion time timestamps are not exposed to any function except for the ProcessFunction. A ProcessFunction can read the timestamp of an event in ProcessFunction.processElement() via the Context.timestamp() method.

这篇关于如何使用“处理时间模型"检查流中某个项目的内部flink时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 05:25