WindowOperations
来源:互联网 发布:i.t是什么牌子 知乎 编辑:程序博客网 时间:2024/05/19 23:13
在SparkStreaming中提供了window操作,通过window操作,操作者可以对一个滑动的窗口内的数据进行转换操作,如下图所示:
如上图所示,这个窗口每次在DStream上进行滑动,这里存在两个变量
1、window length 窗口长度
2、slid length 窗口滑动长度
这里的长度均是以batchinterval为单位,因此以上两个参数均需要时batchinterval的整数倍。
示例如下:
// Reduce last 30 seconds of data, every 10 secondsval windowedWordCounts = pairs.reduceByKeyAndWindow((a:Int,b:Int) => (a + b), Seconds(30), Seconds(10))
窗口大小为30S,每隔10S窗口滑动一次。通俗地解释就是,每隔10s统计前30s内的数据。
以下是一些window操作中常用的算子:
spark.default.parallelism
) to do the grouping. You can pass an optional numTasks
argument to set a different number of tasks.reduceByKeyAndWindow(func, invFunc,windowLength, slideInterval, [numTasks])A more efficient version of the above reduceByKeyAndWindow()
where the reduce value of each window is calculated incrementally using the reduce values of the previous window. This is done by reducing the new data that enters the sliding window, and “inverse reducing” the old data that leaves the window. An example would be that of “adding” and “subtracting” counts of keys as the window slides. However, it is applicable only to “invertible reduce functions”, that is, those reduce functions which have a corresponding “inverse reduce” function (taken as parameterinvFunc). Like in reduceByKeyAndWindow
, the number of reduce tasks is configurable through an optional argument. Note that checkpointing must be enabled for using this operation.
reduceByKeyAndWindow
, the number of reduce tasks is configurable through an optional argument.- WindowOperations
- ucosII 笔记
- C语言模拟多态
- iOS之自定义AlertView的传参问题
- Ububntu下tftp服务搭建
- 如何在Ubuntu下编译Chromium for Android
- WindowOperations
- Java运行报错:Error: Could not find or load main class
- 目标检测
- Android 特效库 - 视觉滚动
- 编译原理NFA确定化
- ceph中radosgw的put object代码走读
- JSPatch热修复的使用的那些深坑
- 【USACO】2002 Feb Cow Cycling 奶牛赛车
- SIP应答消息状态码与功能