spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "octavian.ganea" <octavian.ga...@inf.ethz.ch>
Subject NullPointerException when using Accumulators on cluster
Date Sat, 25 Oct 2014 18:38:21 GMT
Hi,

I have a simple accumulator that needs to be passed to a foo() function
inside a map job:

val myCounter = sc.accumulator(0)
val myRDD = sc.textFile(inputpath) // :spark.RDD[String]
myRDD.flatMap(line => foo(line))

def foo(line: String) = {
   myCounter += 1  // line throwing NullPointerException
   // compute something on the input
}

If I pass myCounter as a parameter to foo(), then I get : noSerializable
exception for SparkContext. If I keep myCounter global (in a scala singleton
object), I get nullpointer exception. 

What is the proper way send an accumulator distributed to all nodes when
running on a cluster?

Thanks,



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/NullPointerException-when-using-Accumulators-on-cluster-tp17261.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org


Mime
View raw message