How to set Map values in spark/scala -


i new spark-scala development. trying create map values in spark using scala getting nothing printed

def createmap() : map[string, int] = { var tmap:map[string, int] = map() val tdf = spark.sql("select a, b, c temp") (x <- tdf) {   val k = x.getas[long](0) + "|" + x.getas[long](1)   val v = x.getas[int](2)   tmap += ( k -> v )   println( k -> v ) ///----------this print values } println("hellllooooooooo1") ((k,v) <- tmap) println("key = " + k+ ", value= " + v) ////------this prints nothing println("hellllooooooooo2") return tmap } 

please suggest.

user8598832 gives how (for value of properly). reason approach doesn't work you're adding (k, v) map in executor, println occurs in driver, won't see map(s) in executor(s) (to extent might, that's artifact of running in local mode not in distributed mode).


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -