I call a function in scala that gives RDD[(Long,Long,Double)]
as the output.
def helperfunction(): RDD[(Long, Long, Double)]
I call this function in a loop in another part of the code, and I want to combine all the generated RDDs. The loop calling the function looks something like this:
for (i <- 1 to n){ val tOp = helperfunction()
What I want to do is something similar to what StringBuilder will do for you in Java when you want to concatenate strings. I looked at RDD merge methods, which basically indicate the use of a join function like this
RDD1.union(RDD2)
But this requires both RDDs to be generated before they are combined. Although I initialize var RDD1 to accumulate the results outside the for loop, I am not sure how I can initialize an empty RDD of type [(Long,Long,Double)]
. I also start with a spark, so I'm not even sure that this is the most elegant way to solve this problem.
source share