spark的闭包 val a =null rdd.foreach(x =>{a = x }) 因为闭包无法将x的值传递给x在外面打印 有两种方法 1 rdd.collect讲值返回driver 2使用累加器方式