之前一直对窗口操作不太理解。认为spark streaming本身已经是分片计算,还需要窗口操作干啥。

窗口操作最为简单易懂的场景就是,在M时间间隔计算一次N时间内的热搜。当M=N的时候,就像上述所说,窗口操作本身没什么优势;但当在M!=N的时候,窗口计算优势就体现出来了。

之前用storm的窗口计算,实在是麻烦。而spark streaming则要简单许多。

借用官网提供的图以及例子:

streaming窗口操作

 

 

简来说就是10秒钟计算30秒内的单词数。

两个参数
window length - The duration of the window (3 in the figure). -> N sliding interval - The interval at which the window operation is performed (2 in the figure). -> M

在每一次十秒分别输入:

1:

sdf sdfsd sdf

2:

sdf sdfsd sdf

3:

sdf sdfsd sdf
sdf sdfsd sdf 234
输入

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
  • 2021-08-27
  • 2022-01-16
  • 2021-08-13
  • 2021-06-10
猜你喜欢
  • 2021-04-08
  • 2021-07-24
  • 2021-12-21
  • 2022-12-23
  • 2021-09-16
  • 2021-10-30
  • 2021-09-02
相关资源
相似解决方案