Spark内核以及源码解析
生活随笔
收集整理的這篇文章主要介紹了
Spark内核以及源码解析
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
2019獨角獸企業(yè)重金招聘Python工程師標準>>>
一:圖RDD
1.上圖groupBy,Join會產(chǎn)生shuffle,shuffle可以做性能優(yōu)化。
2.stage1和stage2的數(shù)據(jù)要計算完成才shuffle。
?
二:Spark Core圖
SparkContext:應(yīng)用程序通往集群的唯一通道,會構(gòu)建DAGSchedler,TaskSchedler
廣播變量:在每一個Executor中的全局變量,對所有的Executor只發(fā)送一次,Executor中的每一個task可以獲取
累加器:全局累加器只能增加和讀取
三:和MapReduce的區(qū)別
spark全在內(nèi)存做計算,Hadoop會保存在磁盤
pipeline:算子沿著數(shù)據(jù)通道計算下去?,全在內(nèi)存做計算,優(yōu)化執(zhí)行效率
?
四:幾個重要的RDD
?
五:源碼分析
一:RDD必須 * - A list of partitions 一系列partitions集合* - A function for computing each split 為每個分區(qū)提供一個computing的函數(shù)* - A list of dependencies on other RDDs RDD會依賴其他RDDs, 這種特性叫做:lineage(生命線);特例:第一個RDD不依賴其他RDD可選* - Optionally, a Partitioner for key-value RDDs (e.g. to say that the RDD is hash-partitioned)* - Optionally, a list of preferred locations to compute each split on (e.g. block locations for* an HDFS file)兩個Partitioner:range Partitioner, Hash Partitioner abstract class RDD[T: ClassTag](@transient private var _sc: SparkContext,@transient private var deps: Seq[Dependency[_]]) extends Serializable with Logging {protected def getPartitions: Array[Partition]: ===> 獲取當(dāng)前RDD所有的分區(qū)def compute(split: Partition, context: TaskContext): Iterator[T] ===> 對每個分區(qū)上的數(shù)據(jù)進行計算操作protected def getDependencies: Seq[Dependency[_]]: ===> 獲取依賴的RDD,依賴的RDD是一個集合protected def getPreferredLocations(split: Partition): Seq[String] ===> 數(shù)據(jù)計算本地化專用val partitioner: Option[Partitioner] ===> 獲取分區(qū)器}二:HadoopRDD 1:分區(qū):每個HDFS block 2:依賴:無依賴,因為直接從hdfs讀取數(shù)據(jù) 3:函數(shù):讀取每一個block 4:最佳位置:Hdfs block所在的位置 5:分區(qū):無@DeveloperApi class HadoopRDD[K, V](sc: SparkContext,broadcastedConf: Broadcast[SerializableConfiguration],initLocalJobConfFuncOpt: Option[JobConf => Unit],inputFormatClass: Class[_ <: InputFormat[K, V]],keyClass: Class[K],valueClass: Class[V],minPartitions: Int)extends RDD[(K, V)](sc, Nil) with Logging {//讀取數(shù)據(jù)getInputFormat數(shù)據(jù)有不同的Format方式protected def getInputFormat(conf: JobConf): InputFormat[K, V] = {val newInputFormat = ReflectionUtils.newInstance(inputFormatClass.asInstanceOf[Class[_]], conf).asInstanceOf[InputFormat[K, V]]newInputFormat match {case c: Configurable => c.setConf(conf)case _ =>}newInputFormat}」?
轉(zhuǎn)載于:https://my.oschina.net/u/2253438/blog/1577239
總結(jié)
以上是生活随笔為你收集整理的Spark内核以及源码解析的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: centos7安装dhcp服务器并由客户
- 下一篇: Qt学习之路(52): 拖放技术之一