def byteCount(data: RDD[(String, Array[String])]): RDD[(String, Map[String, Double])] = {
try {
data.map({
doc =>
(
doc._1,
doc._2.foldLeft(Map.empty[String, Double]) {
(acc: Map[String, Double], word: String) =>
acc + (word -> (acc.getOrElse(word, 0.0) + 1.0))
}
)
})
} catch {
case _ => println("Error at byteCount")
Driver.sc.stop()
return null
}
}