zoukankan      html  css  js  c++  java
  • Spark核心概念之RDD

    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一致)
     
     
     
     
     
     
     
  • 相关阅读:
    WEB环境搭建(tomcat)、Eclipse连接tomcat
    spring—springmvc整合
    声明式事务
    mybatis—当表的字段名和实体类的列名不对应时的三种处理方式
    Spring整合MyBatis
    mybatis关系映射(1对1,1对多,多对多)
    mybatis
    编程式事务
    使用maven在netbeans下构建wicket项目
    mysql问题Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)的解决方法
  • 原文地址:https://www.cnblogs.com/luogankun/p/3801035.html
Copyright © 2011-2022 走看看