sparkStreaming的transformation和action详解
- Transformations
- Window Operations
- Join Operations
- Output Operations
一、Transformations
|
1
|
val b = a.map(func) |
|
1
|
val linesNew = lines.map(lines => lines + "_NEW" ) |

2、flatMap(func)
|
1
|
val b = a.flatMap(func) |
|
1
|
val words = lines.flatMap(_.split( " " )) |

3、 filter(func)
|
1
|
val b = a.filter(func) |

4、union(otherStream)
|
1
2
3
4
5
6
7
|
val wordsOne = words.map(_ + "_one" )val wordsTwo = words.map(_ + "_two" )val unionWords = wordsOne.union(wordsTwo)wordsOne.print()wordsTwo.print()unionWords.print() |

5、count()
|
1
|
val wordsCount = words.count() |

6、reduce(func)
|
1
|
val reduceWords = words.reduce(_ + "-" + _) |

7、countByValue()
|
1
|
val countByValueWords = words.countByValue() |

8、reduceByKey(func, [numTasks])
|
1
2
|
val pairs = words.map(word => (word , 1))val wordCounts = pairs.reduceByKey(_ + _) |

9、join(otherStream, [numTasks])
|
1
2
3
|
val wordsOne = words.map(word => (word , word + "_one" ))val wordsTwo = words.map(word => (word , word + "_two" ))val joinWords = wordsOne.join(wordsTwo) |

10、cogroup(otherStream, [numTasks])

11、transform(func)
1、window(windowLength, slideInterval)
|
1
|
val windowWords = words.window(Seconds( 3 ), Seconds( 1)) |

2、 countByWindow(windowLength,slideInterval)
|
1
|
val windowWords = words.countByWindow(Seconds( 3 ), Seconds( 1)) |

3、 reduceByWindow(func, windowLength,slideInterval)
|
1
|
val windowWords = words.reduceByWindow(_ + "-" + _, Seconds( 3) , Seconds( 1 )) |

4、 reduceByKeyAndWindow(func,windowLength, slideInterval, [numTasks])
|
1
|
val windowWords = pairs.reduceByKeyAndWindow((a:Int , b:Int) => (a + b) , Seconds(3 ) , Seconds( 1 )) |

5、 reduceByKeyAndWindow(func, invFunc,windowLength, slideInterval, [numTasks])
|
1
|
val windowWords = pairs.reduceByKeyAndWindow((a: Int, b:Int ) => (a + b) , (a:Int, b: Int) => (a - b) , Seconds( 3 ), Seconds( 1 )) |


6、 countByValueAndWindow(windowLength,slideInterval, [numTasks])
|
1
|
val windowWords = words.countByValueAndWindow(Seconds( 3 ), Seconds( 1))[/align] |

1、DStream对象之间的Join
2、DStream和dataset之间的join
四、Output Operations
1、print()
|
1
2
|
val words = lines.flatMap(_.split(" "))words.print() |

2、saveAsTextFiles(prefix, [suffix])
|
1
|
lines.saveAsTextFiles("satf", ".txt")[/align][align=left] |


3、saveAsObjectFiles(prefix, [suffix])
实验略过,可参考前面一个操作。
4、saveAsHadoopFiles(prefix, [suffix])
5、foreachRDD(func)
sparkStreaming的transformation和action详解的更多相关文章
- (七)Transformation和action详解-Java&Python版Spark
Transformation和action详解 视频教程: 1.优酷 2.YouTube 什么是算子 算子是RDD中定义的函数,可以对RDD中的数据进行转换和操作. 算子分类: 具体: 1.Value ...
- Spring MVC 学习总结(三)——请求处理方法Action详解
Spring MVC中每个控制器中可以定义多个请求处理方法,我们把这种请求处理方法简称为Action,每个请求处理方法可以有多个不同的参数,以及一个多种类型的返回结果. 一.Action参数类型 如果 ...
- Struts2学习笔记(三)——Action详解
Action是用于处理请求操作的,它是由StrutsPrepareAndExceuteFilter分发过来的. 1.Action的创建方式 1) POJO类(PlainOldJavaObjects简单 ...
- Struts2 配置Action详解
Struts2的核心功能是action,对于开发人员来说,使用Struts2主要就是编写action,action类通常都要实现com.opensymphony.xwork2.Action接口,并实 ...
- vuex 源码分析(五) action 详解
action类似于mutation,不同的是Action提交的是mutation,而不是直接变更状态,而且action里可以包含任意异步操作,每个mutation的参数1是一个对象,可以包含如下六个属 ...
- Odoo中的五种Action详解
转载请注明原文地址:https://www.cnblogs.com/ygj0930/p/10826232.html Odoo中的五种action都是继承自ir.actions.actions模型实现的 ...
- Struts 2 配置Action详解_java - JAVA
文章来源:嗨学网 敏而好学论坛www.piaodoo.com 欢迎大家相互学习 实现了Action处理类之后,就可以在struts.xml中配置该Action,从而让Struts 2框架知道哪个Act ...
- 转载 Struts2的配置 struts.xml Action详解
在学习struts的时候,我们一定要掌握struts2的工作原理.只有当我们明确了在struts2框架的内部架构的实现过程,在配置整个struts 的框架时,可以很好的进行逻辑上的配置.接下来我就先简 ...
- Action详解
简介 Action 是用于处理请求操作的,它是由 StrutsPrepareAndExecuteFilter 分发过来的. 在 Struts2 框架中,Action 是框架的核心类,被称为业务逻辑控制 ...
随机推荐
- Http协议中get和post的区别 转载https://www.cnblogs.com/lexiaofei/p/http.html
get(默认值)是通过URL传递表单值,数据追加在action属性后面. post传递的表单值是隐藏到http报文体中,url中看不到. get是通过url传递表单值,post通过url看不到表单域的 ...
- 函数的四种调用模式.上下文调用.call.apply
闭包:函数就是一个闭包,一个封闭的作用域; 返回函数,要返回多个函数就用一个对象封装一下, 立即执行函数+return 回调函数 JS动态创建的DOM,不会被搜索引 ...
- MarkDown 快速开始 基础教学
# MarkDown 快速上手 # > [源代码](https://www.cnblogs.com/qiyuexin/p/9932941.html) > by qyx@2018/11/07 ...
- Linux环境变量永久设置方法(zsh)
1.之前一直使用:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./home/46005/cuda-9.0/lib64/来设置cuda库路径变量 -----临时的,当 ...
- 进程共享变量#pragma data_seg用法
#pragma data_seg介绍 用#pragma data_seg建立一个新的数据段并定义共享数据,其具体格式为: #pragma data_seg ("shareddata" ...
- Mysql 命令行下建立存储过程
建立存储过程的sql如下: CREATE PROCEDURE proc_variable () BEGIN DECLARE dec_var_ VARCHAR(100); DECLARE rep_nu ...
- 树上倍增 hdu 2586
参考博客: 代码: #include<stdio.h> #include<iostream> #include<algorithm> #include<mat ...
- beforeEach的深入研究,及beforeEach和beforeRouteEnter区别?
之前一直困惑它俩的区别,也没找到合适的文档,直到有天看到一篇博客,一起来学习下: 之前是在created钩子函数里面,发现这是在今天当前页面之后了.先回顾一下钩子函数beforeEach const ...
- JavaScript小实例-文字跑马灯效果
我们常常能看到显示屏上字体的滚动以及手机弹幕等,下面所示代码就是一个简易的文字跑马灯的效果: <!DOCTYPE html> <html> <head lang=&quo ...
- Django项目从新建到运行
返回主目录:Django框架 内容目录: 一.安装之前 二.Django安装 三.创建项目 四.配置 一.安装之前 安装django之前你需要注意的几个事项: 1.版本问题 建议使用1.11.11左右 ...