I have a RDD[(breeze.linalg.DenseMatrix[Int], Array[Int])]
, using a DenseMatrix
from the Breeze library that I would like to reduce but I am not sure how. Here is an example (I simplified the code, a DenseMatrix
with only one column is not really useful in real life):
First cell of the RDD: (DenseMatrix((1), (2), (3)), Array(2, 1))
Second cell of the RDD: (DenseMatrix((4), (5), (6)), Array(1, 2))
Expected result: (DenseMatrix((1), (2), (3), (4), (5), (6)), Array(2, 1, 1, 2))
or (DenseMatrix((4), (5), (6), (1), (2), (3)), Array(1, 2, 2, 1))
. The order of the cells reduced does not matter.
I know the size of the resulted DenseMatrix
in advance thus I was thinking about creating an empty one then fill it in by looping over the RDD but could I use reduce()
or fold()
? How can I use it with an immutable type that is not standard like DenseMatrix
?