DAGScheduler Master Worker RDD源码中隐式转换和Actor并发编程
def distinct(numPartitions: Int)(implicit ord: Ordering[T] = null): RDD[T] = withScope {
map(x => (x, null)).reduceByKey((x, y) => x, numPartitions).map(_._1)
}
使用了隐式参数,运行时不需要手动提供参数ord,运行时会根据上下文注入参数
最简单的actor并发编程:
import scala.actors.Actor
class HiActor extends Actor{
def act(){
while(true){
receive{
case name:String => println(name)
}
}
}
}
调用:actor ! "Spark"