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一致)
     
     
     
     
     
     
     
  • 相关阅读:
    STM32系列命名规则
    在使用MOS管时要注意的问题
    LED汽车前大灯
    Linux Makefile analysis for plain usr
    Linux Kernel Makefile Test
    linux源码Makefile的详细分析
    "The connection for the USB device '###' was unsuccessful. The device is currently in use"
    Allegro使用技巧
    Integrated Circuit Intro
    ADC/DAC的一些参数
  • 原文地址:https://www.cnblogs.com/luogankun/p/3801035.html
Copyright © 2011-2022 走看看