RDD源码分析
RDD源码解析
一、
RDD.scala
- Resilient Distributed Dataset (RDD)
弹性分布式数据集
弹性: 体现在计算上面
- the basic abstraction in Spark
- Represents an immutable
val
RDDA == RDDB
- partitioned collection of elements
- that can be operated on in parallel
RDDA: (1,2,3,4,5,6,7,8,9) operated +1。(对RDD执行加1的操作)
hadoop000:Partition1: (1,2,3) +1
hadoop001:Partition2: (4,5,6) +1
hadoop002:Partition3: (7,8,9) +1
对RDD上的所有元素进行加1,他在hadoop000,hadoop001,hadoop002三台机器上同时进行
对RDD进行操作,也就是对`RDD上的所有分区进行操作`
abstract class RDD[T: ClassTag](
@transient private var _sc: SparkContext,
@transient private var deps: Seq[Dependency[_]]
) extends Serializable with Logging {}
关键字: (从上面获得的信息)
1) 抽象类: RDD必然是有之类实现的,我们使用时直接使用其之类即可
2) Serializable(序列化)
3) Logging(日志)
4) T (泛型)
5) SparkContext (入口点)
6) @transient(注解,暂时不懂)
二、JdbcRDD.scala
class JdbcRDD[T: ClassTag](
sc: SparkContext,
getConnection: () => Connection,
sql: String,
lowerBound: Long,
upperBound: Long,
numPartitions: Int,
mapRow: (ResultSet) => T = JdbcRDD.resultSetToObjectArray _)
extends RDD[T](sc, Nil) with Logging {
三、 RDD五大特性:
Internally, each RDD is characterized by five main properties:
(1、2、3必选,4、5可选)
1) A list of partitions (分区列表)
2) A function for computing each split/partition (用于计算每个 分片/分区 的函数)
3) A list of dependencies on other RDDs (其它的RDD依赖关系)
RDDA => RDDB => RDDC ==> RDDD
4) Optionally, a Partitioner for key-value RDDs (e.g. to say that the RDD is hash-partitioned) (可选的,用于键值RDD的分区程序,(例如: 说明RDD时哈希分区))
5) Optionally, a list of preferred locations to compute each split on (e.g. block locations foran HDFS file) (可选的,用于计算每个首选位置的分片列表(例如: 块位置为HDFS文件))
preferred locations (一个RDD,对应多个partition,所有有 s )
深入理解 RDD 与 关键字 之间的关系
Resilient、Distributed、Dataste (弹性、分布式、数据集)
(木桶原理,性能由最短的那块板决定,由最慢的任务决定计算性能)
四、RDD五大特性和RDD源码中 方法的 对应关系
1) def compute(split: Partition, context: TaskContext): Iterator[T]
2) protected def getPartitions: Array[Partition]
3) protected def getDependencies: Seq[Dependency[_]] = deps
4) protected def getPreferredLocations(split: Partition): Seq[String] = Nil
5) @transient val partitioner: Option[Partitioner] = None
RDD源码分析的更多相关文章
- 第七篇:Spark SQL 源码分析之Physical Plan 到 RDD的具体实现
/** Spark SQL源码分析系列文章*/ 接上一篇文章Spark SQL Catalyst源码分析之Physical Plan,本文将介绍Physical Plan的toRDD的具体实现细节: ...
- Spark中决策树源码分析
1.Example 使用Spark MLlib中决策树分类器API,训练出一个决策树模型,使用Python开发. """ Decision Tree Classifica ...
- SparkMLlib之 logistic regression源码分析
最近在研究机器学习,使用的工具是spark,本文是针对spar最新的源码Spark1.6.0的MLlib中的logistic regression, linear regression进行源码分析,其 ...
- Spark MLlib - Decision Tree源码分析
http://spark.apache.org/docs/latest/mllib-decision-tree.html 以决策树作为开始,因为简单,而且也比较容易用到,当前的boosting或ran ...
- 《深入理解Spark:核心思想与源码分析》(第2章)
<深入理解Spark:核心思想与源码分析>一书前言的内容请看链接<深入理解SPARK:核心思想与源码分析>一书正式出版上市 <深入理解Spark:核心思想与源码分析> ...
- Spark技术内幕:Stage划分及提交源码分析
http://blog.csdn.net/anzhsoft/article/details/39859463 当触发一个RDD的action后,以count为例,调用关系如下: org.apache. ...
- Spark Scheduler模块源码分析之TaskScheduler和SchedulerBackend
本文是Scheduler模块源码分析的第二篇,第一篇Spark Scheduler模块源码分析之DAGScheduler主要分析了DAGScheduler.本文接下来结合Spark-1.6.0的源码继 ...
- Spark Scheduler模块源码分析之DAGScheduler
本文主要结合Spark-1.6.0的源码,对Spark中任务调度模块的执行过程进行分析.Spark Application在遇到Action操作时才会真正的提交任务并进行计算.这时Spark会根据Ac ...
- Spark-RDD之Partition源码分析
概要 Spark RDD主要由Dependency.Partition.Partitioner组成,Partition是其中之一.一份待处理的原始数据会被按照相应的逻辑(例如jdbc和hdfs的spl ...
随机推荐
- [Linux] 解决nginx: [emerg] directive "rewrite" is not terminated by ";"
解决nginx: [emerg] directive "rewrite" is not terminated by ";"nginx的rewite规则有时候没注 ...
- (二)Amazon Lightsail 部署LAMP应用程序之部署单片LAMP应用程序
部署单片LAMP应用程序 简介:通过复制应用程序代码并提供链接PHP前端和本地MySQL数据库的参数,将LAMP对战应用程序部署到先前启动的Lightsail实例中.完成后,Apache/PHP前端和 ...
- vue 组件之纯表格渲染--没有事件交互
组件 名称小写==> 用-链接 02===> 属性==> empty-text="暂无数据" 当表格中没有数据 就会显示 暂无数据 <el-table-co ...
- node exporter
在prometheus中负责数据汇报的程序统一叫做exporter; 负责主机信息收集的node_exporter 可以利用prometheus的static_configs来拉取node_expor ...
- itestpdf
itestpdf jar pdf
- 小程序的flex布局
小程序建议使用flex布局进行排版 flex就是一个盒装弹性布局 flex是一个容器,所有子元素都是他的成员 小程序的flex布局 定义布局 display:flex flex容器的属性: flex- ...
- 改名移动批量文件 shutil.copy
import glob import os import shutil filePath = 'F:/project/Breast/InBreast/INBreast/imgout/' newFile ...
- [C7] 支持向量机(Support Vector Machines) (待整理)
支持向量机(Support Vector Machines) 优化目标(Optimization Objective) 到目前为止,你已经见过一系列不同的学习算法.在监督学习中,许多学习算法的性能都非 ...
- Mybatis全局配置文件详解(三)
每个基于Mybatis应用都是以一个SqlSessionFactory实例为中心.SqlSessionFactory实例可以由SqlSessionFactoryBuild获得,而SqlSessionF ...
- LG1505 [国家集训队]旅游 树链剖分
问题描述 LG1505 题解 边化点权. 超级多操作的树剖板子... 以后就拿这个当树剖板子复习吧... \(\mathrm{Code}\) #include<bits/stdc++.h> ...