Why does RDD.foreach fail with “SparkException: This RDD lacks a SparkContext”?
I have a dataset (as an RDD ) that I divide into 4 RDDs by using different filter operators. val RSet = datasetRdd. flatMap(x => RSetForAttr(x, alLevel, hieDict)). map(x => (x, 1)). reduceByKey((x, y) => x + y) val Rp:RDD[(String, Int)] = RSet.filter(x => x._1.split(",")(0).equals("Rp")) val Rc:RDD[(String, Int)] = RSet.filter(x => x._1.split(",")(0).equals("Rc")) val RpSv:RDD[(String, Int)] = RSet.filter(x => x._1.split(",")(0).equals("RpSv")) val RcSv:RDD[(String, Int)] = RSet.filter(x => x._1.split(",")(0).equals("RcSv")) I sent Rp and RpSV to the following function calculateEntropy : def