【问题标题】:Window length in Spark Structured StreamingSpark 结构化流中的窗口长度
【发布时间】:2018-10-11 13:34:28
【问题描述】:

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

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

如何使用结构化流来做到这一点?

【问题讨论】:

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


    【解决方案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()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-09
      • 2019-10-23
      • 2021-11-11
      • 2017-05-04
      • 2020-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多