Spark中的narrow/wide dependency如何理解,有什么作用?

0
我在RDD的论文中看到他们的定义是这样的
”narrow dependencies, where each
partition of the parent RDD is used by at most one partition
of the child RDD, wide dependencies, where multiple
child partitions may depend on it”
我的理解是narrow就是独生子女,一个父亲只有一个孩子;wide是一个父亲多个孩子。
但是我感觉这个定义与论文中区分这两种dependency的作用是矛盾的:
“First, narrow
dependencies allow for pipelined execution on one cluster
node, which can compute all the parent partitions. For
example, one can apply a map followed by a filter on an
element-by-element basis. In contrast, wide dependencies
require data from all parent partitions to be available
and to be shuffled across the nodes using a MapReducelike
operation. Second, recovery after a node failure is
more efficient with a narrow dependency, as only the lost
parent partitions need to be recomputed, and they can be
recomputed in parallel on different nodes. In contrast, in
a lineage graph with wide dependencies, a single failed
node might cause the loss of some partition from all the
ancestors of an RDD, requiring a complete re-execution.”
narrow的第一个作用,我的理解是可以不用等上一次操作全部做完,每完成一条记录就可以进行下次操作,如map产生一条新纪录马上就做filter,但是对于wide,为什么不能这样做呢?另外,union是narrow操作,对两个分区做合并不需要shuffle吗,为什么只有wide操作才需要shuffle?
对于narrow的第二个作用,两种dependency丢失单个分区会分别导致哪些其他分区也丢失呢?
已邀请:
1

牟瑞 - 大数据 Hadoop 讲师 Hadoop入门课程地址:http://www.hellobi.com/course/39 有架构师,技术总监,CTO的职位请联系我! 2015-11-04 回答

最近做公司的烂项目做到吐血,跟大数据没有大多的关系。很多技术点都扔了。回复下个人对这块的理解。
[narrow的第一个作用,我的理解是可以不用等上一次操作全部做完,每完成一条记录就可以进行下次操作,如map产生一条新纪录马上就做filter]这块的内容理解上是没有问题的。那么对于wide,并且之所以叫wid就是因为它要依赖多方,不能顺序执行,比如groupByKey操作。它需要等所有的计算map,filter都做完,才能做ByKey的计算。
另外,union这个必须要重点提一下。这个操作只能说不一定,记住:不一定。为什么这么说呢。。因为如果你的计算非常少,最后只有一个DAG在计算,那它就是narrow。。。如果是多个DAG,那此时必然是wide,必然要做shuffle。

要回复问题请先登录注册