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 是框架的核心类,被称为业务逻辑控制 ...
随机推荐
- apach hadoop2.6 集群利用Phoenix 4.6-hbase 批量导入并自动创建索引
基础环境: 1.安装apach 版本hadoop2.6 2.部署hbase1.0.0 3.下载phoenix-4.6.0-HBase-1.0.下载地址(http://mirror.nus.edu.sg ...
- Centos 能ping通域名和公网ip但是网站不能够打开,服务器拒绝了请求。打开80端口解决。
博客搬迁,给你带来的不便,敬请谅解! http://www.suanliutudousi.com/2017/10/29/centos-%E8%83%BDping%E9%80%9A%E5%9F%9F%E ...
- axios以form-data形式的传递参数遇到的坑
axios默认的Content-type是application/json;charset=UTF-8,如果想要以表单的形式传递参数,只要修改{headers:{'Content-Type':'app ...
- C# WinfForm 控件之dev电子表格 SpreadSheet
网上找了一些资料可是不得入门 只能再回过头来看demos 看了一点 例子大多继承自SpreadsheetRibbonTutorialControlBase 这个类,它又继承自SpreadSheetTu ...
- 2019牛客国庆集训派对day7 A 2016
链接:https://ac.nowcoder.com/acm/problem/52800来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K ...
- 天道神诀--samba和NFS部署
samba yum -y install samba samba-client rpm -qa |grep samba service smb start(445端口) service nmb sta ...
- 2018-12-21-微软最具价值专家-MVP-如何获得-Resharper-的免费功能
title author date CreateTime categories 微软最具价值专家 MVP 如何获得 Resharper 的免费功能 lindexi 2018-12-21 11:29:0 ...
- @Conditional系列注解例子
1. @Conditional 说明:指定的Condition实现类,matches方法返回true则注入bean,false则不注入 @Configuration public class Bean ...
- kubeadm生成的token重新获取
当你的token忘了或者过期,解决办法如下: 1.先获取token #如果过期可先执行此命令kubeadm token create #重新生成token#列出tokenkubeadm token l ...
- BCZM : 1.15
数独 解法一:广度优先搜索. 解法二:先填满中间矩阵,其他区域通过矩阵置换求出.