Is there any idea on why the whole object B need to be serialized?
object A{
def main(args:Array[String])= {
val conf = new SparkConf().setAppName("test").setMaster("local")
val sc = new SparkContext(conf)
val rdd=sc.makeRDD(Seq(1,2,3,4,5,6,7))
val b=new B
b.add(rdd)
}
}
class B {
val s="456"
def add=(rdd:RDD[Int])=>{
rdd.map(e=>e+" "+s).foreach(println)
}
}
Exception about "object not serializable":
Serialization stack:
- object not serializable (class: B, value: B@1fde4f40)
- field (class: B$$anonfun$add$1, name: $outer, type: class B)
- object (class B$$anonfun$add$1, <function1>)
- field (class: B$$anonfun$add$1$$anonfun$apply$1, name: $outer, type: class B$$anonfun$add$1)
- object (class B$$anonfun$add$1$$anonfun$apply$1, <function1>)