question: public static MatrixBlock toMatrixBlock ( JavaPairRDD < MatrixIndexes , MatrixCell > rdd , int rlen , int clen , long nnz ) throws DMLRuntimeException { long t0 = DMLScript . STATISTICS ? System . nanoTime ( ) : 0 ; MatrixBlock out = null ; long lnnz = ( nnz >= 0 ) ? nnz : ( long ) rlen * clen ; boolean sparse = MatrixBlock . evalSparseFormatInMemory ( rlen , clen , lnnz ) ; out = new MatrixBlock ( rlen , clen , sparse ) ; List < Tuple2 < MatrixIndexes , MatrixCell > > list = rdd . collect ( ) ; for ( Tuple2 < MatrixIndexes , MatrixCell > keyval : list ) { MatrixIndexes ix = keyval . _1 ( ) ; MatrixCell cell = keyval . _2 ( ) ; out . appendValue ( ( int ) ix . getRowIndex ( ) - 1 , ( int ) ix . getColumnIndex ( ) - 1 , cell . getValue ( ) ) ; } if ( sparse ) out . sortSparseRows ( ) ; out . recomputeNonZeros ( ) ; out . examSparsity ( ) ; if ( DMLScript . STATISTICS ) { Statistics . accSparkCollectTime ( System . nanoTime ( ) - t0 ) ; Statistics . incSparkCollectCount ( 1 ) ; } return out ; }
target:  Utility method for creating a single matrix block out of a binary cell RDD.  Note that this collect call might trigger execution of any pending transformations. 