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 是框架的核心类,被称为业务逻辑控制 ...
随机推荐
- Mentor_丝印检查——手工绘制丝印线条(标注)到丝印位号距离的检查
http://www.eda365.com/thread-193942-1-1.html 在此之前丝印的检查基本是停留在丝印与阻焊的距离检查,而器件丝印框和手工绘制的线条与器件位号的检查都不到位,据我 ...
- SQlite 学习资料
很有用的开源跨平台数据库,可以作为客户端的小型内存数据库使用,据说它有N多用户(Nokia's Symbian,Mozilla,Abobe,Google,阿里旺旺,飞信,Chrome,FireFo ...
- 梯度提升树GBD
转自 http://blog.csdn.net/u014568921/article/details/49383379 另外一个很容易理解的文章 :http://www.jianshu.com/p/0 ...
- css渐变写法 从左到右渐变三种颜色示例;
background:linear-gradient(to right,#7f06a8,#a02bc2,#7f06a8)
- ES7/ES8 语法学习
作为一个前端开发者,感觉需要学习的东西贼多,ES6刚学会用没多久,又得学习了解ES7/ES8新增的东西,这里是看了大佬们文章的一点点总结以及摘抄的内容,给自己当笔记使用 内容转载自:https://w ...
- minicom 的使用
1.切换到 root 用户. [root@localhost btools]#su - 2. 查找有效的串设备. [root@localhost ~]#cat /proc/devices ... 4 ...
- centos7 sshd 安全设置
ssh 的安全机制 1.SSH之所以能够保证安全,原因在于它采用了非对称加密技术(RSA)加密了所有传输的数据. 2.传统的网络服务程序,如FTP等在网络上用明文传送数据.用户帐号和用户口令,很容 ...
- Eureka备忘
一. 二. 2.2. eureka集群同步集群相关重要的类com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl: 为了保证集群里所有Eur ...
- vue实现curd功能
一.实现效果 二.实现 (一)实现增加用户功能 Vuserlist组件中 <template> <div class="panel panel-default"& ...
- ThreadLocal知识点
ThreadLocal是什么 ThreadLocal 表面上看他是和多线程,线程同步有关的一个工具类,但其实他与线程同步机制无关.线程同步机制是多个线程共享同一个变量,而ThreadLocal是为每个 ...