spark中生成stage的过程中,是如何得知某个rdd的缓存情况。

经过查看源代码spark2.0得知,在DagScheduler中,存在一个名为cacheLocs的变量,存储了每个RDD分区的缓存位置,定义如下:

  //org.apache.spark.scheduler.DAGScheduler

  /**
   * Contains the locations that each RDD's partitions are cached on.  This map's keys are RDD ids
   * and its values are arrays indexed by partition numbers. Each array value is the set of
   * locations where that RDD partition is cached.
   *
   * All accesses to this map should be guarded by synchronizing on it (see SPARK-4454).
   */
  private val cacheLocs = new HashMap[Int, IndexedSeq[Seq[TaskLocation]]]

得知rdd缓存情况的主要流程如下:

//org.apache.spark.scheduler.DAGScheduler

1)handleJobSubmitted
2)submitStage
3)getMissingParentStages
4)getCacheLocs

通过调用getCacheLocs(),访问cacheLocs变量得知rdd缓存情况。

在生成stage过程中,一旦回溯到某个rdd,并得知此rdd已经缓存,则停止回溯。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值