How to share global Map values among RDDs in Spark? -


i trying access map rdds on different compute nodes, without success. map like:

val map1 = map("aa"->1,"bb->2,"cc->3,...) 

all rdds have check against see if key in map or not, seems have make map global, problem if map stored rdds , spread across different nodes, each node see piece of map , info not complete check against map( replace key corresponding value) e,g:

val matchs= vecs.map(term=>term.map{case (a,b)=>(map1(a),b)}) 

any idea this? thanks!

it sounds want use broadcast variable:

val broadcastmap = sc.broadcast(map) vec.map(term=>term.map{case (a,b)=>(broadcastmap.value(a),b)}) 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -