def map[U: ClassTag](f: T => U): RDD[U] = {
val cleanF = sc.clean(f)
new MapPartitionsRDD[U, T](this, (context, pid, iter) => iter.map(cleanF))
}
RDD.scala里的這個方法里的context, pid, iter不知道從哪來的啊??
https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/rdd/RDD.scala
uj5u.com熱心網友回復:
這里的 (context, pid, iter) => iter.map(cleanF)是個匿名函式, 作為一個類引數傳入MapPartitionsRDD(也就是說在這個地方當前不會運行), (context, pid, iter)是該匿名函式的引數串列.context, pid, iter 的實際值是在MapPartitionsRDD.compute方法中呼叫該匿名函式時傳入的.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/95751.html
標籤:Spark
