Here is the code I run in spark-shell:
val table = sc.textFile(args(1))
val histMap = collection.mutable.Map[Int,Int]()
for (x - table) {
val tuple = x.split('|')
histMap.put(tuple(0).toInt, 1)
}
Why is histMap still null?
Is there something wrong with my code?
Here is the code I run in spark-shell:
val table = sc.textFile(args(1))
val histMap = collection.mutable.Map[Int,Int]()
for (x - table) {
val tuple = x.split('|')
histMap.put(tuple(0).toInt, 1)
}
Why is histMap still null?
Is there something wrong with my code?
Thanks,
It doesn't work that way.
Following is the correct way:
val table = sc.textFile(args(1))
val histMap = table.map(x = {
x.split('|')(0).toInt,1
})
-
Lalit Yadav
la...@sigmoidanalytics.com
--
View this message in context:
http://apache-spark-user-list.1001560.n3.nabble.com/How-to-add