janniklinde commented on code in PR #2361:
URL: https://github.com/apache/systemds/pull/2361#discussion_r2560060994


##########
src/main/java/org/apache/sysds/runtime/compress/lib/CLALibUnary.java:
##########
@@ -43,6 +48,35 @@ public static MatrixBlock 
unaryOperations(CompressedMatrixBlock m, UnaryOperator
                final boolean overlapping = m.isOverlapping();
                final int r = m.getNumRows();
                final int c = m.getNumColumns();
+               
+               if(Builtin.isBuiltinCode(op.fn, BuiltinCode.CUMSUM, 
BuiltinCode.ROWCUMSUM)) {
+                       MatrixBlock uncompressed = 
m.getUncompressed("CUMSUM/ROWCUMSUM requires uncompression", 
op.getNumThreads());
+                       MatrixBlock opResult = uncompressed.unaryOperations(op, 
null);
+                       
+                       CompressionSettingsBuilder csb = new 
CompressionSettingsBuilder();
+                       csb.clearValidCompression();
+                       csb.setPreferDeltaEncoding(true);
+                       csb.addValidCompression(CompressionType.DeltaDDC);
+                       csb.setMinimumCompressionRatio(0.0);
+                       csb.setTransposeInput("false");
+                       Pair<MatrixBlock, CompressionStatistics> compressedPair 
= CompressedMatrixBlockFactory.compress(opResult, op.getNumThreads(), csb);
+                       MatrixBlock compressedResult = compressedPair.getLeft();
+                       
+                       if(compressedResult == null) {
+                               compressedResult = opResult;
+                       }
+                       
+                       CompressedMatrixBlock finalResult;
+                       if(compressedResult instanceof CompressedMatrixBlock) {
+                               finalResult = (CompressedMatrixBlock) 
compressedResult;
+                       }
+                       else {
+                               finalResult = 
CompressedMatrixBlockFactory.genUncompressedCompressedMatrixBlock(compressedResult);
+                       }
+                       
+                       return finalResult;
+               }
+               

Review Comment:
   Compression should only be applied if it is beneficial rather than enforcing 
it. For example, if we have CUMSUM and DDC colgroups, then we can just 
reinterpret them as DeltaDDC.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to