我试过在rdd的apache spark中创建矩阵。但我失败了。
如何在spark和scala中创建矩阵?
resultRDD: org.apache.spark.rdd.RDD[(Something, Something)]
(SomethingA1, SomethingA2)
(SomethingB1, SomethingB2)
val total_int_len = 10
val collectMatrix = new ArrayBuffer[Array[Double]]()
val createMatrixRDD = resultRDD.map{ x =>
for(i <- 0 to total_int_len - 1) {
val collectRow = ArrayBuffer[Double]()
for(j <- 0 to total_int_len - 1) {
collectRow = 1.1
//collectRow += getSomethingDoubleValue(x(i), x(j))
}
collectMatrix += collectRow.toArray
}
}
collectMatrix是空的。有什么问题?