- 一个父RDD的分区对应于一个子RDD的分区
- 两个父RDD的分区对应于一个子RDD 的分区。
如上面的map,filter,union属于第一类窄依赖,而join with inputs co-partitioned(对输入进行协同划分的join操作)则为第二类窄依赖
/**
* :: DeveloperApi ::
* Base class for dependencies.
*/
@DeveloperApi
abstract class Dependency[ T] extends Serializable {
def rdd: RDD[ T]
}
/**
* :: DeveloperApi ::
* Base class for dependencies where each partition of the child RDD depends on a small number
* of partitions of the parent RDD. Narrow dependencies allow for pipelined execution.
* 这里是说,窄依赖是指子RDD的每个Partition只依赖于父RDD很少部分的的分区,文档明显说的不对!窄依赖起码需要,父RDD的每个Partition只被一个子RDD的Partition依赖
*/
@DeveloperApi
abstract class NarrowDependency[ T](_rdd: RDD[ T]) extends Dependency[ T] {
/**
* Get the parent partitions for a child partition.
* @param partitionId a partition of the child RDD
* @return the partitions of the parent RDD that the child partition depends upon
*/
def getParents(partitionId: Int): Seq[ Int]
override def rdd: RDD[ T] = _rdd
}
/**
* ShuffleDependency指的是,子RDD的partition部分依赖于父RDD的每个Partition 部分依赖被称为 ShuffleDependency。
* 其实 ShuffleDependency 跟 MapReduce 中 shuffle 的数据依赖相同
* (mapper 将其 output 进行 partition,然后每个 reducer 会将所有 mapper 输出中属于自己的 partition 通过 HTTP fetch 得到)。
*/
/**
* :: DeveloperApi ::
* Represents a dependency on the output of a shuffle stage. Note that in the case of shuffle,
* the RDD is transient since we don't need it on the executor side.
*
* @param _rdd the parent RDD
* @param partitioner partitioner used to partition the shuffle output
* @param serializer [[ org.apache.spark.serializer.Serializer Serializer ]] to use. If set to None,
* the default serializer, as specified by ` spark.serializer ` config option, will
* be used.
* @param keyOrdering key ordering for RDD's shuffles
* @param aggregator map/reduce-side aggregator for RDD's shuffle
* @param mapSideCombine whether to perform partial aggregation (also known as map-side combine)
*/
@DeveloperApi
class ShuffleDependency[ K: ClassTag , V: ClassTag , C: ClassTag](
@transient private val _rdd: RDD[_ <: Product2[ K , V]] ,
val partitioner: Partitioner ,
val serializer: Option[Serializer] = None ,
<
6227




被折叠的 条评论
为什么被折叠?



