如何使用处理时间模型检查流中项目的内部 flink 时间戳? [英] How can I inspect the internal flink timestamp for an item in a stream using the Processing Time Model?

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

问题描述

我希望用它在 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 时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆