Reputation: 3256
Not sure what caused this problem: error: '=' expected but ';' found.
val vectors = filtered_data_by_key.map( x => {
var temp
x._2.copyToArray(temp) // Error occurs here
(x._1, temp)
})
Upvotes: 6
Views: 22709
Reputation: 2857
If filtered_data_by_key is an RDD of (T, Iterable), or in other words, a result of groupByKey transformation, then this can be written simply like this:
val vectors = filtered_data_by_key.map( { case (x, iter) => (x, iter.toArray) })
Upvotes: 0
Reputation: 4060
var temp
isn't a statement.
If you're trying to declare temp without assigning anything to it, do
var temp :Array[_] = _
But is temp supposed to be an array? then try var temp = Array()
. temp
needs something assigned to it before being passed into copyToArray
. Also as you're not destructively assigning to temp it doesn't need to be a var.
Upvotes: 8