使用Spark DStreams,我可以这样指定滑动窗口的长度:
val windowedStream = stream.window(Seconds(20))
如何通过结构化流媒体做到这一点?
答案 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()