宽窄依赖


spark依赖说明

种类

spark的依赖关系大致有两类

  • narrow dependency
  • wide dependency

说明

narrow dependency

父Partition ===> 子partition 多对一或一对一 flatMap ,mapToPair ,map ,filter等算子
父partition ===> 子partition 一对多 reduce ,group by 等.

stage

当一个dag串联遇到宽依赖时形成stage.一个stage对应一个task.这个task的并行度由最后一个依赖决定.应该就是说由wide dependency 的具体并行度决度.如
reduce ,partition=3.就3的并行度.这里的参数可以设置.

wide dependency 必定对应的有shuffle.但shuffle不一定是wide dependency 如sort orderby

join 即可能发生shuffle也可能不,具体看情况.

pipeline

一个stage划分好后.一条数据的具体运算逻辑是会一直走完所有计算逻辑后才会落地.这是与mapreduce的区别
mapreduce是计算逻辑走完落地,再启动,计算又落地.

所以说spark的效率比mapreduce高也是有这个原因.dag串联后,运算优先.


Author: Kuiq Wang
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source Kuiq Wang !
  TOC