ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [06/28] ignite git commit: IGNITE-6762: Fixed SparseDistributedMatrixExample failed with NPE. This closes #3003
Date Mon, 13 Nov 2017 09:52:00 GMT
IGNITE-6762: Fixed SparseDistributedMatrixExample failed with NPE.
This closes #3003


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

Branch: refs/heads/ignite-zk
Commit: c939bdba3a159d1ccb080686796b50a03ac77c9f
Parents: 8195ba5
Author: Yury Babak <ybabak@gridgain.com>
Authored: Thu Nov 9 16:45:49 2017 +0300
Committer: Igor Sapego <isapego@gridgain.com>
Committed: Thu Nov 9 16:45:49 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/ml/math/distributed/CacheUtils.java | 14 +++++---------
 .../ignite/ml/math/impls/vector/CacheVectorTest.java  | 10 ++--------
 .../ml/math/impls/vector/VectorToMatrixTest.java      |  3 ---
 3 files changed, 7 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c939bdba/modules/ml/src/main/java/org/apache/ignite/ml/math/distributed/CacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/distributed/CacheUtils.java
b/modules/ml/src/main/java/org/apache/ignite/ml/math/distributed/CacheUtils.java
index 9a73c5a..8c8bba7 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/distributed/CacheUtils.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/distributed/CacheUtils.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.distributed;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
+import java.util.Objects;
 import java.util.function.BinaryOperator;
 import javax.cache.Cache;
 import org.apache.ignite.Ignite;
@@ -73,7 +74,6 @@ public class CacheUtils {
 
         /**
          *
-         *
          */
         public Cache.Entry<K, V> entry() {
             return entry;
@@ -81,7 +81,6 @@ public class CacheUtils {
 
         /**
          *
-         *
          */
         public IgniteCache<K, V> cache() {
             return cache;
@@ -165,12 +164,8 @@ public class CacheUtils {
      * @return Sum of the values.
      */
     private static double sum(Collection<Double> c) {
-        double sum = 0.0;
-
-        for (double d : c)
-            sum += d;
-
-        return sum;
+        // Fix for IGNITE-6762, some collections could store null values.
+        return c.stream().filter(Objects::nonNull).mapToDouble(Double::doubleValue).sum();
     }
 
     /**
@@ -401,7 +396,8 @@ public class CacheUtils {
 
                 // Iterate over given partition.
                 // Query returns an empty cursor if this partition is not stored on this
node.
-                for (Cache.Entry<K, V> entry : cache.query(new ScanQuery<K, V>(part,
(k, v) -> affinity.mapPartitionToNode(p) == locNode && (keyFilter == null || keyFilter.apply(k)))))
+                for (Cache.Entry<K, V> entry : cache.query(new ScanQuery<K, V>(part,
+                    (k, v) -> affinity.mapPartitionToNode(p) == locNode && (keyFilter
== null || keyFilter.apply(k)))))
                     fun.accept(new CacheEntry<>(entry, cache));
             }
         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/c939bdba/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
index a6cdd4c..1008cc2 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
@@ -143,19 +143,13 @@ public class CacheVectorTest extends GridCommonAbstractTest {
     }
 
     /** */
-    public void testSumNegative() {
+    public void testSumEmptyVector() {
         IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
 
         IdentityValueMapper valMapper = new IdentityValueMapper();
         CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(),
keyMapper, valMapper);
 
-        try {
-            double d = cacheVector.sum();
-            fail();
-        }
-        catch (NullPointerException e) {
-            // No-op.
-        }
+        cacheVector.sum();
     }
 
     /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/c939bdba/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorToMatrixTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorToMatrixTest.java
b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorToMatrixTest.java
index 98230c3..a003dcf 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorToMatrixTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorToMatrixTest.java
@@ -188,9 +188,6 @@ public class VectorToMatrixTest {
 
     /** */
     private void assertCross(Vector v1, Vector v2, String desc) {
-        if (true) // TODO: IGNITE-5777, wait BLAS integration.
-            return;
-
         assertNotNull(v1);
         assertNotNull(v2);
 


Mime
View raw message