带有合成时间戳的 Spark 窗口函数? [英] Spark window function with synthetic timestamp?

查看:71
本文介绍了带有合成时间戳的 Spark 窗口函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个包含记录的数据文件,其中每条记录都有一个时间戳,如下所示:

Say I have a datafile with records where each record has a timestamp, like this:

foo,bar,blaz,timestamp1
foo,flibble,baz,timestamp2
bleh,foo,gnarly,timestamp3
...

我想使用 Spark 以需要使用 window() 函数的方式处理它.有什么方法可以读取这些记录,并将每个记录放入 DStream 中,以便 window() 函数使用的时间戳由我的代码显式提供(在这种情况下基于解析输入记录中的时间戳字段))?

and I want to process this using Spark, in a way that requires using the window() function. Is there any way to read these records, and get each one into the DStream so that the timestamp that will be used by the window() function is provided by my code explicitly (based on parsing the timestamp field in the input records in this case)?

推荐答案

否,默认 Spark 处理基于系统时间.如果您想使用事件时间构建窗口.建议你使用updateStateByKey"函数来处理更新函数内部的逻辑.

No, the default Spark processing is based on the system time. And if you want to build the window using the event time. I suggest you use up "updateStateByKey" function to handle the logic inside the update function.

这篇关于带有合成时间戳的 Spark 窗口函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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