map、mapPartitions、mapValues、mapWith、flatMap、flatMapWith、flatMapValues
来源:互联网 发布:Mac大括号怎么打 编辑:程序博客网 时间:2024/06/05 08:19
Spark API 详解/大白话解释 之 map、mapPartitions、mapValues、mapWith、flatMap、flatMapWith、flatMapValues
http://blog.csdn.net/guotong1988/article/details/50555185
map(function)
map是对RDD中的每个元素都执行一个指定的函数来产生一个新的RDD。任何原RDD中的元素在新RDD中都有且只有一个元素与之对应。
举例:
- 1
- 2
- 3
- 4
- 5
- 6
- 1
- 2
- 3
- 4
- 5
- 6
当然map也可以把Key变成Key-Value对
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
mapPartitions(function)
map()的输入函数是应用于RDD中每个元素,而mapPartitions()的输入函数是应用于每个分区
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
mapValues(function)
原RDD中的Key保持不变,与新的Value一起组成新的RDD中的元素。因此,该函数只适用于元素为KV对的RDD。
- 1
- 2
- 3
- 1
- 2
- 3
//"x" + _ + "x"
等同于everyInput =>"x" + everyInput + "x"
//结果
Array(
(3,xdogx),
(5,xtigerx),
(4,xlionx),
(3,xcatx),
(7,xpantherx),
(5,xeaglex)
)
mapWith和flatMapWith
感觉用得不多,参考http://blog.csdn.net/jewes/article/details/39896301
flatMap(function)
与map类似,区别是原RDD中的元素经map处理后只能生成一个元素,而原RDD中的元素经flatmap处理后可生成多个元素
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
flatMapValues(function)
- map、mapPartitions、mapValues、mapWith、flatMap、flatMapWith、flatMapValues
- Spark API 详解/大白话解释 之 map、mapPartitions、mapValues、mapWith、flatMap、flatMapWith、flatMapValues
- Spark API 详解/大白话解释 之 map、mapPartitions、mapValues、mapWith、flatMap、flatMapWith、flatMapValues
- spark:map mapPartitions flatmap
- spark:map mapPartitions flatmap
- spark map flatMap flatMapToPair mapPartitions 的区别和用途
- Spark RDD中Transformation的map、flatMap、mapPartitions、glom详解
- spark 的transformations之map,flatMap,mapPartitions,mapPartitionsWithIndex的用法
- spark map flatMap flatMapToPair mapPartitions 的区别和用途
- 第45课 Spark 2.0实战之Dataset:map、flatMap、mapPartitions、dropDuplicate、coalesce、repartition等
- SparkRDD学习之map ,flatmap,mappartitions,glom,union,cartesian,groupby,filter,distinct,subtract代码
- RDD键值转换操作(1)–partitionBy、mapValues、flatMapValues
- 3.3 Spark RDD 键值转换操作1-partitionBy、mapValues、flatMapValues
- flatMap Map
- Spark算子:RDD键值转换操作(1)–partitionBy、mapValues、flatMapValues
- Spark算子:RDD键值转换操作(1)–partitionBy、mapValues、flatMapValues
- Spark算子:RDD键值转换操作(1)–partitionBy、mapValues、flatMapValues
- Optimize map performamce with mapPartitions
- 使用洋铭SE-500HD切换台进行多机位切换画面现场直播搭建详解教程
- SSM中集成memcache缓存
- delphi指针函数
- Python下opencv的使用---二值化
- 视图+视图定义+创建视图+视图的表结构+创建视图的语句+查看视图哪些列是可以进行DML操作
- map、mapPartitions、mapValues、mapWith、flatMap、flatMapWith、flatMapValues
- Vue全家桶+Mint-Ui打造高仿QQMusic,搭配详细说明
- Qt 自定义信号槽
- jQuery基础第二天:选择器 事件处理函数
- 视频带宽计算公式(码流_分辨率_帧率)
- Redis探索之旅(1)- Redis初识
- Java二分法查找实现
- 获取src/main/resources下文件的绝对路径
- 典型数据库架构设计与实践 | 架构师之路