Spark RDD特点

RDD:Resilient Distributed Dataset

A Resilient Distributed Dataset(RDD), the basic abstraction in Spark. Represents an immutable, partitioned collection of elements that can be operated on in parallel.

 

RDD特点:

  • A list of partitions —— 一系列的分片:比如说64M一片;类似于Hadoop中的split
  • A function for computing each split —— 在每个分片上都有一个函数去迭代/执行/计算它
  • A list of dependencies on other RDDs —— 一系列的依赖:RDDa转换为RDDb,RDDb转换为RDDc,那么RDDc就依赖于RDDb,RDDb就依赖于RDDa
  • Optionally, a Partitioner for key-value RDDs(e.g. to say that the RDD is hash-partitioned) —— 对于key-value的RDD可指定一个partitioner,告诉它如何分片;常用的有hash,range
  • Optionally, a list of perferred location(s) to compute each split on(e.g. block locations for an HDFS file) —— 要运行的计算/执行最好在哪(几)个机器上运行。数据的本地性。
    为什么会有哪几个?
    比如:hadoop默认有3个位置,或者spark cache到内存是可能通过StorageLevel设置了多个副本,所以一个partition可能返回多个最佳位置

前三个特点对应于Lineage,后两个对应于Optimized execution

 

对于如上的5个特点,对应于RDD中的5个方法

getPartitions                         the set of partitions in this RDD

compute                               compute a given partition

getDependencies                 return how this RDD depends on parent RDDs

partitioner                             specify how they are partitioned

getPreferredLocations          specify placement preferences

 

参考资料:http://www.it610.com/article/1916210.htm

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值