This is an automated email from the ASF dual-hosted git repository.

baunsgaard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git


The following commit(s) were added to refs/heads/main by this push:
     new b0fc281cc6 [MINOR] Fix incorrect merge of MatrixBlock
b0fc281cc6 is described below

commit b0fc281cc616140d29c6e7406665b027dac0686e
Author: Sebastian Baunsgaard <[email protected]>
AuthorDate: Sun Jan 7 19:59:58 2024 +0100

    [MINOR] Fix incorrect merge of MatrixBlock
---
 .../sysds/runtime/matrix/data/MatrixBlock.java      | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git 
a/src/main/java/org/apache/sysds/runtime/matrix/data/MatrixBlock.java 
b/src/main/java/org/apache/sysds/runtime/matrix/data/MatrixBlock.java
index 085b6a5c52..6e3ad9f8b9 100644
--- a/src/main/java/org/apache/sysds/runtime/matrix/data/MatrixBlock.java
+++ b/src/main/java/org/apache/sysds/runtime/matrix/data/MatrixBlock.java
@@ -586,16 +586,19 @@ public class MatrixBlock extends MatrixValue implements 
CacheBlock<MatrixBlock>,
        public final boolean isEmptyBlock() {
                return isEmptyBlock(true);
        }
-       
-       public boolean isEmptyBlock(boolean safe)
-       {
-               boolean ret = ( sparse && sparseBlock==null ) || ( !sparse && 
denseBlock==null );
-               if( nonZeros==0 )
-               {
-                       //prevent under-estimation
-                       if(safe)
+       /**
+        * Get if this MatrixBlock is an empty block. The call can potentially 
tricker a recomputation of non zeros if the
+        * non-zero count is unknown.
+        * 
+        * @param safe True if we want to ensure the count non zeros if the nnz 
is unknown.
+        * @return If the block is empty.
+        */
+       public boolean isEmptyBlock(boolean safe) {
+               boolean ret = (sparse && sparseBlock == null) || (!sparse && 
denseBlock == null);
+               if(nonZeros <= 0) { // estimate non zeros if unknown or 0.
+                       if(safe) // only allow the recompute if safe flag is 
false.
                                recomputeNonZeros();
-                       ret = (nonZeros==0);
+                       ret = (nonZeros == 0);
                }
                return ret;
        }

Reply via email to