瞌睡中的葡萄虎

博客园 首页 新随笔 联系 订阅 管理

RDD: Resilient Distributed Dataset

RDD的特点:
1、A list of partitions  
    一系列的分片:比如说64M一片;类似于Hadoop中的split;
 
2、A function for computing each split
    在每个分片上都有一个函数去迭代/执行/计算它
 
3、A list of dependencies on other RDDs
    一系列的依赖:RDDa转换为RDDb,RDDb转换为RDDc,那么RDDc就依赖于RDDb,RDDb就依赖于RDDa
 
4、Optionally, a Partitioner for key-value RDDs (e.g. to say that the RDD is hash-partitioned) 
    对于key-value的RDD可指定一个partitioner,告诉它如何分片;常用的有hash,range
 
5、Optionally, a list of preferred location(s) to compute each split on (e.g. block locations for an HDFS file)
    要运行的计算/执行最好在哪(几)个机器上运行。数据本地性。
  为什么会有哪几个呢?
  比如:hadoop默认有三个位置,或者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
 
 
 
 
 
 
 
  HadoopRDD Filtered RDD JoinedRDD
partitions HDFS上的block 与父RDD一致 一个partition一个任务
dependencies 无 与父RDD 一对一 依赖shuffle的每个父RDD
compute 读取每个block的信息 计算父RDD的每个分区并过滤 读取shuffle数据      
partitioner HDFS block所在位置 无 HashPartitioner
preferredLocations 无 无(与父RDD一致) 无
 
 
 
 
 
 
 
posted on 2014-06-21 15:12  瞌睡中的葡萄虎  阅读(1105)  评论(0)    收藏  举报