如何在Flink中找到两个不连续事件之间的事件时间差异?

huangapple go评论55阅读模式
英文:

How do I find the event time difference between two non consecutive events in Flink?

问题

我想要计算在Apache Flink中两个不连续事件之间的时间差。一个事件包括一个名称和一个时间戳。例如:

E1("A", 时间戳) -> E2("B", 时间戳) -> E3("C", 时间戳)

在这种情况下,我想要计算E3和E1之间的时间戳差异。关于如何在Flink中实现这个功能有什么想法吗?

英文:

I want to calculate the time difference between two non consecutive event in Apache Flink. An Event consists of a name and a timestamp. Ex:

E1("A", timestamp) -> E2("B", timestamp) -> E3("C", timestamp)

In this case I want to calculate the timestamp difference between E3 and E1. Any ideas on how to make it work in Flink?

答案1

得分: 1

因为 E1 和 E3 有不同的键,您需要使用一个非键控窗口(.windowAll()),请参考这个文档。由于通常无法依赖事件的原始顺序被保留,您在自定义的 ProcessWindowFunction 中需要按时间戳对它们进行排序,以能够可靠地计算增量。

英文:

Since E1 & E3 have different keys, you'd need to use a non-keyed window (.windowAll()), see this doc. Since you typically can't rely on the original order of events being preserved, in your custom ProcessWindowFunction you'd have to sort them by timestamp to be able to reliably calculate a delta.

huangapple
  • 本文由 发表于 2023年2月9日 00:52:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75389119.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定