Spark结构化流中的窗口长度

时间:2018-10-10 16:32:02

标签: scala apache-spark spark-structured-streaming

使用Spark DStreams,我可以这样指定滑动窗口的长度:

val windowedStream = stream.window(Seconds(20))

如何通过结构化流媒体做到这一点?

1 个答案:

答案 0 :(得分:1)

看看事件时间文档的窗口操作:https://spark.apache.org/docs/latest/structured-streaming-programming-guide.html#window-operations-on-event-time

示例:

val windowedCounts = words.groupBy(window($"timestamp", "10 minutes", "5 minutes"),$"word").count()