question: public static JavaPairRDD < MatrixIndexes , MatrixBlock > toMatrixJavaPairRDD ( JavaSparkContext sc , MatrixBlock src , int brlen , int bclen ) throws DMLRuntimeException { long t0 = DMLScript . STATISTICS ? System . nanoTime ( ) : 0 ; LinkedList < Tuple2 < MatrixIndexes , MatrixBlock > > list = new LinkedList < Tuple2 < MatrixIndexes , MatrixBlock > > ( ) ; if ( src . getNumRows ( ) <= brlen && src . getNumColumns ( ) <= bclen ) { list . addLast ( new Tuple2 < MatrixIndexes , MatrixBlock > ( new MatrixIndexes ( 1 , 1 ) , src ) ) ; } else { boolean sparse = src . isInSparseFormat ( ) ; for ( int blockRow = 0 ; blockRow < ( int ) Math . ceil ( src . getNumRows ( ) / ( double ) brlen ) ; blockRow ++ ) for ( int blockCol = 0 ; blockCol < ( int ) Math . ceil ( src . getNumColumns ( ) / ( double ) bclen ) ; blockCol ++ ) { int maxRow = ( blockRow * brlen + brlen < src . getNumRows ( ) ) ? brlen : src . getNumRows ( ) - blockRow * brlen ; int maxCol = ( blockCol * bclen + bclen < src . getNumColumns ( ) ) ? bclen : src . getNumColumns ( ) - blockCol * bclen ; MatrixBlock block = new MatrixBlock ( maxRow , maxCol , sparse ) ; int row_offset = blockRow * brlen ; int col_offset = blockCol * bclen ; src . sliceOperations ( row_offset , row_offset + maxRow - 1 , col_offset , col_offset + maxCol - 1 , block ) ; MatrixIndexes indexes = new MatrixIndexes ( blockRow + 1 , blockCol + 1 ) ; list . addLast ( new Tuple2 < MatrixIndexes , MatrixBlock > ( indexes , block ) ) ; } } JavaPairRDD < MatrixIndexes , MatrixBlock > result = sc . parallelizePairs ( list ) ; if ( DMLScript . STATISTICS ) { Statistics . accSparkParallelizeTime ( System . nanoTime ( ) - t0 ) ; Statistics . incSparkParallelizeCount ( 1 ) ; } return result ; }
target:  Utility method for creating an RDD out of an in-memory matrix block.