谁能解释一下执行器中的rdd块

Sai*_*ash 3 apache-spark rdd

任何人都可以解释为什么当我第二次运行 Spark 代码时 rdd 块会增加,即使它们在第一次运行期间存储在 Spark 内存中。我使用线程提供输入。rdd 块的确切含义是什么。

Pra*_*rma 6

我今天一直在研究这个问题,看来 RDD 块是 RDD 块和非 RDD 块的总和。查看代码: https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/ui/exec/ExecutorsPage.scala

 val rddBlocks = status.numBlocks
Run Code Online (Sandbox Code Playgroud)

如果您访问 Github 上的 Apache Spark Repo 的以下链接: https: //github.com/apache/spark/blob/d5b1d5fc80153571c308130833d0c0774de62c92/core/src/main/scala/org/apache/spark/storage/StorageUtils.scala

你会发现以下几行代码:

      /**
   * Return the number of blocks stored in this block manager in O(RDDs) time.
   *
   * @note This is much faster than `this.blocks.size`, which is O(blocks) time.
   */
  def numBlocks: Int = _nonRddBlocks.size + numRddBlocks
Run Code Online (Sandbox Code Playgroud)

非 rdd 块是由广播变量创建的块,因为它们作为缓存块存储在内存中。任务由驱动程序通过广播变量发送给执行程序。现在,这些系统创建的广播变量将通过 ContextCleaner 服务删除,从而删除相应的非 RDD 块。RDD 块通过 rdd.unpersist() 取消持久化。