5858import org .apache .sysds .runtime .compress .lib .CLALibMMChain ;
5959import org .apache .sysds .runtime .compress .lib .CLALibMatrixMult ;
6060import org .apache .sysds .runtime .compress .lib .CLALibMerge ;
61- import org .apache .sysds .runtime .compress .lib .CLALibReplace ;
61+ import org .apache .sysds .runtime .compress .lib .CLALibRemoveEmpty ;
6262import org .apache .sysds .runtime .compress .lib .CLALibReorg ;
63+ import org .apache .sysds .runtime .compress .lib .CLALibReplace ;
6364import org .apache .sysds .runtime .compress .lib .CLALibReshape ;
6465import org .apache .sysds .runtime .compress .lib .CLALibRexpand ;
6566import org .apache .sysds .runtime .compress .lib .CLALibScalar ;
6667import org .apache .sysds .runtime .compress .lib .CLALibSlice ;
68+ import org .apache .sysds .runtime .compress .lib .CLALibSort ;
6769import org .apache .sysds .runtime .compress .lib .CLALibSquash ;
6870import org .apache .sysds .runtime .compress .lib .CLALibTSMM ;
6971import org .apache .sysds .runtime .compress .lib .CLALibTernaryOp ;
101103import org .apache .sysds .runtime .util .IndexRange ;
102104import org .apache .sysds .utils .DMLCompressionStatistics ;
103105import org .apache .sysds .utils .stats .InfrastructureAnalyzer ;
106+ import org .apache .sysds .utils .stats .Timing ;
104107
105108public class CompressedMatrixBlock extends MatrixBlock {
106109 private static final Log LOG = LogFactory .getLog (CompressedMatrixBlock .class .getName ());
@@ -475,16 +478,20 @@ public void readFields(DataInput in) throws IOException {
475478 }
476479
477480 public static CompressedMatrixBlock read (DataInput in ) throws IOException {
481+ Timing t = new Timing ();
478482 int rlen = in .readInt ();
479483 int clen = in .readInt ();
480484 long nonZeros = in .readLong ();
481485 boolean overlappingColGroups = in .readBoolean ();
482486 List <AColGroup > groups = ColGroupIO .readGroups (in , rlen );
483- return new CompressedMatrixBlock (rlen , clen , nonZeros , overlappingColGroups , groups );
487+ CompressedMatrixBlock ret = new CompressedMatrixBlock (rlen , clen , nonZeros , overlappingColGroups , groups );
488+ LOG .debug ("Compressed read serialization time: " + t .stop ());
489+ return ret ;
484490 }
485491
486492 @ Override
487493 public void write (DataOutput out ) throws IOException {
494+ Timing t = new Timing ();
488495 final long estimateUncompressed = nonZeros > 0 ? MatrixBlock .estimateSizeOnDisk (rlen , clen ,
489496 nonZeros ) : Long .MAX_VALUE ;
490497 final long estDisk = nonZeros > 0 ? getExactSizeOnDisk () : Long .MAX_VALUE ;
@@ -512,6 +519,7 @@ public void write(DataOutput out) throws IOException {
512519 out .writeLong (nonZeros );
513520 out .writeBoolean (overlappingColGroups );
514521 ColGroupIO .writeGroups (out , _colGroups );
522+ LOG .debug ("Compressed write serialization time: " + t .stop ());
515523 }
516524
517525 /**
@@ -611,14 +619,6 @@ public MatrixBlock aggregateUnaryOperations(AggregateUnaryOperator op, MatrixVal
611619 public MatrixBlock transposeSelfMatrixMultOperations (MatrixBlock out , MMTSJType tstype , int k ) {
612620 // check for transpose type
613621 if (tstype == MMTSJType .LEFT ) {
614- if (isEmpty ())
615- return new MatrixBlock (clen , clen , true );
616- // create output matrix block
617- if (out == null )
618- out = new MatrixBlock (clen , clen , false );
619- else
620- out .reset (clen , clen , false );
621- out .allocateDenseBlock ();
622622 CLALibTSMM .leftMultByTransposeSelf (this , out , k );
623623 return out ;
624624 }
@@ -846,9 +846,8 @@ public CM_COV_Object covOperations(COVOperator op, MatrixBlock that, MatrixBlock
846846 }
847847
848848 @ Override
849- public MatrixBlock sortOperations (MatrixValue weights , MatrixBlock result ) {
850- MatrixBlock right = getUncompressed (weights );
851- return getUncompressed ("sortOperations" ).sortOperations (right , result );
849+ public MatrixBlock sortOperations (MatrixValue weights , MatrixBlock result , int k ) {
850+ return CLALibSort .sort (this , weights , result , k );
852851 }
853852
854853 @ Override
@@ -871,9 +870,7 @@ public MatrixBlock groupedAggOperations(MatrixValue tgt, MatrixValue wghts, Matr
871870
872871 @ Override
873872 public MatrixBlock removeEmptyOperations (MatrixBlock ret , boolean rows , boolean emptyReturn , MatrixBlock select ) {
874- printDecompressWarning ("removeEmptyOperations" );
875- MatrixBlock tmp = getUncompressed ();
876- return tmp .removeEmptyOperations (ret , rows , emptyReturn , select );
873+ return CLALibRemoveEmpty .rmempty (this , ret , rows , emptyReturn , select );
877874 }
878875
879876 @ Override
@@ -1202,8 +1199,8 @@ public void examSparsity(boolean allowCSR, int k) {
12021199 }
12031200
12041201 @ Override
1205- public void sparseToDense (int k ) {
1206- // do nothing
1202+ public MatrixBlock sparseToDense (int k ) {
1203+ return this ; // do nothing
12071204 }
12081205
12091206 @ Override
@@ -1236,16 +1233,6 @@ public double interQuartileMean() {
12361233 return getUncompressed ("interQuartileMean" ).interQuartileMean ();
12371234 }
12381235
1239- @ Override
1240- public MatrixBlock pickValues (MatrixValue quantiles , MatrixValue ret ) {
1241- return getUncompressed ("pickValues" ).pickValues (quantiles , ret );
1242- }
1243-
1244- @ Override
1245- public double pickValue (double quantile , boolean average ) {
1246- return getUncompressed ("pickValue" ).pickValue (quantile , average );
1247- }
1248-
12491236 @ Override
12501237 public double sumWeightForQuantile () {
12511238 return getUncompressed ("sumWeightForQuantile" ).sumWeightForQuantile ();
0 commit comments