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 是框架的核心类,被称为业务逻辑控制 ...
随机推荐
- python re模块使用
re.findall() 查找字符 从字符串中找出符合模式的字符序列:findall(模式(正则表达式),目标字符串), 返回值为list类型,list元素为匹配出的各个字符串如: import re ...
- jenkins在pipline中运行后台命令
需求 在jenkin中启动java程序或者python程序的时候,希望程序在后台执行,并在jenkins构建完成之后继续执行.在工作中有两个地方我碰到了这种需求 在shell script输入框中pi ...
- IdentityServer4认证服务器集成Identity&配置持久化数据库
文章简介 asp.net core的空Web项目集成相关dll和页面文件配置IdnetityServer4认证服务器 Ids4集成Identity Ids4配置持久化到数据库 写在最前面,此文章不详细 ...
- 第十一篇 session和cookie自动登录机制
session和cookie的作用和区别可以在网上查到,这里简单说下,我们使用的http协议本身是种无状态的协议,就是说web服务器接收到浏览器的请求,会直接返回相应内容,并不会检查是哪个浏览器,即浏 ...
- 监控数据库SqlServer
监控数据库的连接数select COUNT( * ) from master.dbo.sysprocesses select COUNT( * ) from master.dbo.sysprocess ...
- usb-host与外设通信(三)
4.与设备之间的通信 和USB设备通信可以是同步的或者是异步的,无论是哪一种情况,你都应该创建一个新的线程来处理数据传输,这样才不会使UI线程出现阻塞.与设备建立适宜的通信,你需要获得该设备一个合适的 ...
- ttytype - 终端设备映射的默认终端类型
DESCRIPTION(描述) /etc/ttytype 文件把termcap/terminfo中的终端类型名与tty行关联起来.每行包括一种终端类型,后面跟着空格,然后是tty名(不带 /dev/ ...
- 使用 SpringBoot 配置发送邮件功能
1.使用 SpringBoot 配置发送邮件功能 项目总体结构 用户表设计 SET FOREIGN_KEY_CHECKS=0; CREATE DATABASE sample; USE sample; ...
- photoshop钢笔工具简单记录
1. 移动锚点 Ctrl + 左键 2. 增加.删除锚点 左键(显示+.-) 3. 直线曲线相互转换 Alt + 左键(注意提示) 默认情况下为直线,按住Alt鼠标左键点击目标锚点,目标锚点两边的直线 ...
- java----int,string 转化为long
String: 1.返回Long包装类型: String str = "aaa"; long l = Long.parseLong([str]); 2.返回long基本数据类型: ...