码迷,mamicode.com
首页 > 系统相关 > 详细

RDD中cache和persist的区别

时间:2019-07-11 09:17:38      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:table   def   class   tor   ati   type   each   The   targe   

 

RDD中cache和persist的区别

  

通过观察RDD.scala源代码即可知道cache和persist的区别:

def persist(newLevel: StorageLevel): this.type = {
  if (storageLevel != StorageLevel.NONE && newLevel != storageLevel) {
    throw new UnsupportedOperationException( "Cannot change storage level of an RDD after it was already assigned a level")
  }
  sc.persistRDD(this)

  sc.cleaner.foreach(_.registerRDDForCleanup(this))
  storageLevel = newLevel
  this
}

/** Persist this RDD with the default storage level (`MEMORY_ONLY`). */
def persist(): this.type = persist(StorageLevel.MEMORY_ONLY)

 

/** Persist this RDD with the default storage level (`MEMORY_ONLY`). */
def cache(): this.type = persist()

RDD中cache和persist的区别

标签:table   def   class   tor   ati   type   each   The   targe   

原文地址:https://www.cnblogs.com/timssd/p/11167868.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!