Assuming I have an RDD containing (Int, Int) tuples. I want to turn it into a vector, where the first Int in the tuple is the index and the second is the value.
Any idea how I can do this?
I am updating my question and adding my solution to clarify: My RDD is already reduced by key, and the number of keys is known. I want a vector for updating a single battery instead of multiple batteries.
There for my final decision was:
reducedStream.foreachRDD(rdd => rdd.collect({case (x: Int,y: Int) => { val v = Array(0,0,0,0) v(x) = y accumulator += new Vector(v) }}))
Using Vector from the battery example in the documentation.
source share