RDD中cache和persist的區別

 

RDD中cache和persist的區別html

  
 

經過觀察RDD.scala源代碼便可知道cache和persist的區別:web

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)this

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

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

 

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

相關文章
相關標籤/搜索