Spark和scala,如何创建矩阵?

时间:2017-08-14 11:57:49

标签: scala apache-spark

我试过在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是空的。有什么问题?

0 个答案:

没有答案