Spark API 详解/大白话解释 之 map、mapPartitions、mapValues、mapWith、flatMap、flatMapWith、flatMapValues
来源:互联网 发布:山西大学软件学院 编辑:程序博客网 时间:2024/06/06 03:08
重点看mapPartitions
本文转自http://blog.csdn.net/guotong1988/article/details/50555185,所有权力归原作者所有。
map(function)
map是对RDD中的每个元素都执行一个指定的函数来产生一个新的RDD。任何原RDD中的元素在新RDD中都有且只有一个元素与之对应。
举例:
当然map也可以把Key变成Key-Value对
mapPartitions(function)
map()的输入函数是应用于RDD中每个元素,而mapPartitions()的输入函数是应用于每个分区
mapValues(function)
原RDD中的Key保持不变,与新的Value一起组成新的RDD中的元素。因此,该函数只适用于元素为KV对的RDD。
//"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处理后可生成多个元素
flatMapValues(function)
0 0
- Spark API 详解/大白话解释 之 map、mapPartitions、mapValues、mapWith、flatMap、flatMapWith、flatMapValues
- Spark API 详解/大白话解释 之 map、mapPartitions、mapValues、mapWith、flatMap、flatMapWith、flatMapValues
- map、mapPartitions、mapValues、mapWith、flatMap、flatMapWith、flatMapValues
- spark:map mapPartitions flatmap
- spark:map mapPartitions flatmap
- Spark API 之 map、mapPartitions
- Spark RDD中Transformation的map、flatMap、mapPartitions、glom详解
- spark 的transformations之map,flatMap,mapPartitions,mapPartitionsWithIndex的用法
- Spark API 详解/大白话解释 之 RDD、partition、count、collect
- Spark API 详解/大白话解释 之 reduce、reduceByKey
- Spark API 详解/大白话解释 之 groupBy、groupByKey
- Spark API 详解/大白话解释 之 groupBy、groupByKey
- Spark API 详解/大白话解释 之 reduce、reduceByKey
- 第45课 Spark 2.0实战之Dataset:map、flatMap、mapPartitions、dropDuplicate、coalesce、repartition等
- spark map flatMap flatMapToPair mapPartitions 的区别和用途
- spark map flatMap flatMapToPair mapPartitions 的区别和用途
- Spark API 之 reduce、reduceByKey 、 mapvalues
- Spark之 map和flatMap
- Django笔记 生产环境 Nginx静态文件设置
- C#界面设计之Ping服务器IP地址
- 求整型 数组中最大值和最小值元素的距离
- App调取AppStore
- leetcode11.ContainerWithMostWater
- Spark API 详解/大白话解释 之 map、mapPartitions、mapValues、mapWith、flatMap、flatMapWith、flatMapValues
- JS获得一个对象的所有属性和方法
- JVM-FULL-GC
- Android 进程间通信(AIDL)
- USB驱动开发(五)之程序设计
- 自定义带闪动和多背景的textview
- Android 颜色渲染(九) PorterDuff及Xfermode详解
- FloatingActionButton&Snackbar
- 软件安装