Repository: systemml
Updated Branches:
  refs/heads/master 864bfc912 -> 68b93c75f


[SYSTEMML-2098] Fix robustness CSR resizing w/ initial size zero

This patch fixes a special cases of CSR resizing where the initial
capacity was set to zero, which occurred during sparse result merge of
an initially empty update in place variable.

Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/e63eb2e7
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/e63eb2e7
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/e63eb2e7

Branch: refs/heads/master
Commit: e63eb2e7a3dc7100dc400cbdad6af26e67e29cad
Parents: 864bfc9
Author: Matthias Boehm <[email protected]>
Authored: Sun Jan 28 15:57:13 2018 -0800
Committer: Matthias Boehm <[email protected]>
Committed: Sun Jan 28 15:57:13 2018 -0800

----------------------------------------------------------------------
 .../org/apache/sysml/runtime/matrix/data/SparseBlockCSR.java    | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/e63eb2e7/src/main/java/org/apache/sysml/runtime/matrix/data/SparseBlockCSR.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/runtime/matrix/data/SparseBlockCSR.java 
b/src/main/java/org/apache/sysml/runtime/matrix/data/SparseBlockCSR.java
index 2a2ccef..766ba8c 100644
--- a/src/main/java/org/apache/sysml/runtime/matrix/data/SparseBlockCSR.java
+++ b/src/main/java/org/apache/sysml/runtime/matrix/data/SparseBlockCSR.java
@@ -847,12 +847,11 @@ public class SparseBlockCSR extends SparseBlock
        
        private int newCapacity(int minsize) {
                //compute new size until minsize reached
-               double tmpCap = _values.length;
+               double tmpCap = Math.max(_values.length, 1);
                while( tmpCap < minsize ) {
                        tmpCap *= (tmpCap <= 1024) ? 
-                                       RESIZE_FACTOR1 : RESIZE_FACTOR2;
+                               RESIZE_FACTOR1 : RESIZE_FACTOR2;
                }
-               
                return (int)Math.min(tmpCap, Integer.MAX_VALUE);
        }
 

Reply via email to