You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/04/24 08:21:19 UTC

[01/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Repository: ignite
Updated Branches:
  refs/heads/ignite-5024 67ba03bc2 -> 777bd7763


http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorIterableTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorIterableTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorIterableTest.java
new file mode 100644
index 0000000..16c2571
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorIterableTest.java
@@ -0,0 +1,376 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Spliterator;
+import java.util.function.BiConsumer;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.junit.Test;
+
+import static java.util.Spliterator.ORDERED;
+import static java.util.Spliterator.SIZED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/** */
+public class VectorIterableTest {
+    /** */
+    @Test
+    public void allTest() {
+        consumeSampleVectors(
+            (v, desc) -> {
+                int expIdx = 0;
+
+                for (Vector.Element e : v.all()) {
+                    int actualIdx = e.index();
+
+                    assertEquals("Unexpected index for " + desc,
+                        expIdx, actualIdx);
+
+                    expIdx++;
+                }
+
+                assertEquals("Unexpected amount of elements for " + desc,
+                    expIdx, v.size());
+            }
+        );
+    }
+
+    /** */
+    @Test
+    public void allTestBound() {
+        consumeSampleVectors(
+            (v, desc) -> iteratorTestBound(v.all().iterator(), desc)
+        );
+    }
+
+    /** */
+    @Test
+    public void nonZeroesTestBasic() {
+        final int size = 5;
+
+        final double[] nonZeroesOddData = new double[size], nonZeroesEvenData = new double[size];
+
+        for (int idx = 0; idx < size; idx++) {
+            final boolean odd = (idx & 1) == 1;
+
+            nonZeroesOddData[idx] = odd ? 1 : 0;
+
+            nonZeroesEvenData[idx] = odd ? 0 : 1;
+        }
+
+        assertTrue("Arrays failed to initialize.",
+            !isZero(nonZeroesEvenData[0])
+                && isZero(nonZeroesEvenData[1])
+                && isZero(nonZeroesOddData[0])
+                && !isZero(nonZeroesOddData[1]));
+
+        final Vector nonZeroesEvenVec = new DenseLocalOnHeapVector(nonZeroesEvenData),
+            nonZeroesOddVec = new DenseLocalOnHeapVector(nonZeroesOddData);
+
+        assertTrue("Vectors failed to initialize.",
+            !isZero(nonZeroesEvenVec.getElement(0).get())
+                && isZero(nonZeroesEvenVec.getElement(1).get())
+                && isZero(nonZeroesOddVec.getElement(0).get())
+                && !isZero(nonZeroesOddVec.getElement(1).get()));
+
+        assertTrue("Iterator(s) failed to start.",
+            nonZeroesEvenVec.nonZeroes().iterator().next() != null
+                && nonZeroesOddVec.nonZeroes().iterator().next() != null);
+
+        int nonZeroesActual = 0;
+
+        for (Vector.Element e : nonZeroesEvenVec.nonZeroes()) {
+            final int idx = e.index();
+
+            final boolean odd = (idx & 1) == 1;
+
+            final double val = e.get();
+
+            assertTrue("Not an even index " + idx + ", for value " + val, !odd);
+
+            assertTrue("Zero value " + val + " at even index " + idx, !isZero(val));
+
+            nonZeroesActual++;
+        }
+
+        final int nonZeroesOddExp = (size + 1) / 2;
+
+        assertEquals("Unexpected num of iterated odd non-zeroes.", nonZeroesOddExp, nonZeroesActual);
+
+        assertEquals("Unexpected nonZeroElements of odd.", nonZeroesOddExp, nonZeroesEvenVec.nonZeroElements());
+
+        nonZeroesActual = 0;
+
+        for (Vector.Element e : nonZeroesOddVec.nonZeroes()) {
+            final int idx = e.index();
+
+            final boolean odd = (idx & 1) == 1;
+
+            final double val = e.get();
+
+            assertTrue("Not an odd index " + idx + ", for value " + val, odd);
+
+            assertTrue("Zero value " + val + " at even index " + idx, !isZero(val));
+
+            nonZeroesActual++;
+        }
+
+        final int nonZeroesEvenExp = size / 2;
+
+        assertEquals("Unexpected num of iterated even non-zeroes", nonZeroesEvenExp, nonZeroesActual);
+
+        assertEquals("Unexpected nonZeroElements of even", nonZeroesEvenExp, nonZeroesOddVec.nonZeroElements());
+    }
+
+    /** */
+    @Test
+    public void nonZeroesTest() {
+        // todo make RandomVector constructor that accepts a function and use it here
+        //  in order to *reliably* test non-zeroes in there
+        consumeSampleVectors(
+            (v, desc) -> consumeSampleVectorsWithZeroes(v, (vec, numZeroes)
+                -> {
+                int numZeroesActual = vec.size();
+
+                for (Vector.Element e : vec.nonZeroes()) {
+                    numZeroesActual--;
+
+                    assertTrue("Unexpected zero at " + desc + ", index " + e.index(), !isZero(e.get()));
+                }
+
+                assertEquals("Unexpected num zeroes at " + desc, (int)numZeroes, numZeroesActual);
+            }));
+    }
+
+    /** */
+    @Test
+    public void nonZeroesTestBound() {
+        consumeSampleVectors(
+            (v, desc) -> consumeSampleVectorsWithZeroes(v, (vec, numZeroes)
+                -> iteratorTestBound(vec.nonZeroes().iterator(), desc)));
+    }
+
+    /** */
+    @Test
+    public void nonZeroElementsTest() {
+        consumeSampleVectors(
+            (v, desc) -> consumeSampleVectorsWithZeroes(v, (vec, numZeroes)
+                -> assertEquals("Unexpected num zeroes at " + desc,
+                (int)numZeroes, vec.size() - vec.nonZeroElements())));
+    }
+
+    /** */
+    @Test
+    public void allSpliteratorTest() {
+        consumeSampleVectors(
+            (v, desc) -> {
+                final String desc1 = " " + desc;
+
+                Spliterator<Double> spliterator = v.allSpliterator();
+
+                assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator);
+
+                assertNull(MathTestConstants.NOT_NULL_VAL + desc1, spliterator.trySplit());
+
+                assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED));
+
+                if (!readOnly(v))
+                    fillWithNonZeroes(v);
+
+                spliterator = v.allSpliterator();
+
+                assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator);
+
+                assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.estimateSize(), v.size());
+
+                assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.getExactSizeIfKnown(), v.size());
+
+                assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED));
+
+                Spliterator<Double> secondHalf = spliterator.trySplit();
+
+                assertNull(MathTestConstants.NOT_NULL_VAL + desc1, secondHalf);
+
+                spliterator.tryAdvance(x -> {
+                });
+            }
+        );
+    }
+
+    /** */
+    @Test
+    public void nonZeroSpliteratorTest() {
+        consumeSampleVectors(
+            (v, desc) -> consumeSampleVectorsWithZeroes(v, (vec, numZeroes)
+                -> {
+                final String desc1 = " Num zeroes " + numZeroes + " " + desc;
+
+                Spliterator<Double> spliterator = vec.nonZeroSpliterator();
+
+                assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator);
+
+                assertNull(MathTestConstants.NOT_NULL_VAL + desc1, spliterator.trySplit());
+
+                assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED));
+
+                spliterator = vec.nonZeroSpliterator();
+
+                assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator);
+
+                assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.estimateSize(), vec.size() - numZeroes);
+
+                assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.getExactSizeIfKnown(), vec.size() - numZeroes);
+
+                assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED));
+
+                Spliterator<Double> secondHalf = spliterator.trySplit();
+
+                assertNull(MathTestConstants.NOT_NULL_VAL + desc1, secondHalf);
+
+                double[] data = new double[vec.size()];
+
+                for (Vector.Element e : vec.all())
+                    data[e.index()] = e.get();
+
+                spliterator = vec.nonZeroSpliterator();
+
+                assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator);
+
+                assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.estimateSize(),
+                    Arrays.stream(data).filter(x -> x != 0d).count());
+
+                assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.getExactSizeIfKnown(),
+                    Arrays.stream(data).filter(x -> x != 0d).count());
+
+                assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED));
+
+                secondHalf = spliterator.trySplit();
+
+                assertNull(MathTestConstants.NOT_NULL_VAL + desc1, secondHalf);
+
+                if (!spliterator.tryAdvance(x -> {
+                }))
+                    fail(MathTestConstants.NO_NEXT_ELEMENT + desc1);
+            }));
+    }
+
+    /** */
+    private void iteratorTestBound(Iterator<Vector.Element> it, String desc) {
+        while (it.hasNext())
+            assertNotNull(it.next());
+
+        boolean expECaught = false;
+
+        try {
+            it.next();
+        }
+        catch (NoSuchElementException e) {
+            expECaught = true;
+        }
+
+        assertTrue("Expected exception missed for " + desc,
+            expECaught);
+    }
+
+    /** */
+    private void consumeSampleVectorsWithZeroes(Vector sample,
+        BiConsumer<Vector, Integer> consumer) {
+        if (readOnly(sample)) {
+            int numZeroes = 0;
+
+            for (Vector.Element e : sample.all())
+                if (isZero(e.get()))
+                    numZeroes++;
+
+            consumer.accept(sample, numZeroes);
+
+            return;
+        }
+
+        fillWithNonZeroes(sample);
+
+        consumer.accept(sample, 0);
+
+        final int sampleSize = sample.size();
+
+        if (sampleSize == 0)
+            return;
+
+        for (Vector.Element e : sample.all())
+            e.set(0);
+
+        consumer.accept(sample, sampleSize);
+
+        fillWithNonZeroes(sample);
+
+        for (int testIdx : new int[] {0, sampleSize / 2, sampleSize - 1}) {
+            final Vector.Element e = sample.getElement(testIdx);
+
+            final double backup = e.get();
+
+            e.set(0);
+
+            consumer.accept(sample, 1);
+
+            e.set(backup);
+        }
+
+        if (sampleSize < 3)
+            return;
+
+        sample.getElement(sampleSize / 3).set(0);
+
+        sample.getElement((2 * sampleSize) / 3).set(0);
+
+        consumer.accept(sample, 2);
+    }
+
+    /** */
+    private void fillWithNonZeroes(Vector sample) {
+        int idx = 0;
+
+        for (Vector.Element e : sample.all())
+            e.set(1 + idx++);
+
+        assertEquals("Not all filled with non-zeroes", idx, sample.size());
+    }
+
+    /** */
+    private void consumeSampleVectors(BiConsumer<Vector, String> consumer) {
+        new VectorImplementationsFixtures().consumeSampleVectors(null, consumer);
+    }
+
+    /** */
+    private boolean isZero(double val) {
+        return val == 0.0;
+    }
+
+    /** */
+    private boolean readOnly(Vector v) {
+        return v instanceof RandomVector || v instanceof ConstantVector;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorNormTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorNormTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorNormTest.java
new file mode 100644
index 0000000..4e4f212
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorNormTest.java
@@ -0,0 +1,247 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import org.apache.ignite.ml.math.Vector;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class VectorNormTest {
+    /** */
+    @Test
+    public void normalizeTest() {
+        normalizeTest(2, (val, len) -> val / len, Vector::normalize);
+    }
+
+    /** */
+    @Test
+    public void normalizePowerTest() {
+        for (double pow : new double[] {0, 0.5, 1, 2, 2.5, Double.POSITIVE_INFINITY})
+            normalizeTest(pow, (val, norm) -> val / norm, (v) -> v.normalize(pow));
+    }
+
+    /** */
+    @Test
+    public void logNormalizeTest() {
+        normalizeTest(2, (val, len) -> Math.log1p(val) / (len * Math.log(2)), Vector::logNormalize);
+    }
+
+    /** */
+    @Test
+    public void logNormalizePowerTest() {
+        for (double pow : new double[] {1.1, 2, 2.5})
+            normalizeTest(pow, (val, norm) -> Math.log1p(val) / (norm * Math.log(pow)), (v) -> v.logNormalize(pow));
+    }
+
+    /** */
+    @Test
+    public void kNormTest() {
+        for (double pow : new double[] {0, 0.5, 1, 2, 2.5, Double.POSITIVE_INFINITY})
+            toDoubleTest(pow, ref -> new Norm(ref, pow).calculate(), v -> v.kNorm(pow));
+    }
+
+    /** */
+    @Test
+    public void getLengthSquaredTest() {
+        toDoubleTest(2.0, ref -> new Norm(ref, 2).sumPowers(), Vector::getLengthSquared);
+    }
+
+    /** */
+    @Test
+    public void getDistanceSquaredTest() {
+        consumeSampleVectors((v, desc) -> {
+            new VectorImplementationsTest.ElementsChecker(v, desc); // IMPL NOTE this initialises vector
+
+            final int size = v.size();
+            final Vector vOnHeap = new DenseLocalOnHeapVector(size);
+            final Vector vOffHeap = new DenseLocalOffHeapVector(size);
+
+            invertValues(v, vOnHeap);
+            invertValues(v, vOffHeap);
+
+            for (int idx = 0; idx < size; idx++) {
+                final double exp = v.get(idx);
+                final int idxMirror = size - 1 - idx;
+
+                assertTrue("On heap vector difference at " + desc + ", idx " + idx,
+                    exp - vOnHeap.get(idxMirror) == 0);
+                assertTrue("Off heap vector difference at " + desc + ", idx " + idx,
+                    exp - vOffHeap.get(idxMirror) == 0);
+            }
+
+            final double exp = vOnHeap.minus(v).getLengthSquared(); // IMPL NOTE this won't mutate vOnHeap
+            final VectorImplementationsTest.Metric metric = new VectorImplementationsTest.Metric(exp, v.getDistanceSquared(vOnHeap));
+
+            assertTrue("On heap vector not close enough at " + desc + ", " + metric,
+                metric.closeEnough());
+
+            final VectorImplementationsTest.Metric metric1 = new VectorImplementationsTest.Metric(exp, v.getDistanceSquared(vOffHeap));
+
+            assertTrue("Off heap vector not close enough at " + desc + ", " + metric1,
+                metric1.closeEnough());
+        });
+    }
+
+    /** */
+    @Test
+    public void dotTest() {
+        consumeSampleVectors((v, desc) -> {
+            new VectorImplementationsTest.ElementsChecker(v, desc); // IMPL NOTE this initialises vector
+
+            final int size = v.size();
+            final Vector v1 = new DenseLocalOnHeapVector(size);
+
+            invertValues(v, v1);
+
+            final double actual = v.dot(v1);
+
+            double exp = 0;
+
+            for (Vector.Element e : v.all())
+                exp += e.get() * v1.get(e.index());
+
+            final VectorImplementationsTest.Metric metric = new VectorImplementationsTest.Metric(exp, actual);
+
+            assertTrue("Dot product not close enough at " + desc + ", " + metric,
+                metric.closeEnough());
+        });
+    }
+
+    /** */
+    private void invertValues(Vector src, Vector dst) {
+        final int size = src.size();
+
+        for (Vector.Element e : src.all()) {
+            final int idx = size - 1 - e.index();
+            final double val = e.get();
+
+            dst.set(idx, val);
+        }
+    }
+
+    /** */
+    private void toDoubleTest(Double val, Function<double[], Double> calcRef, Function<Vector, Double> calcVec) {
+        consumeSampleVectors((v, desc) -> {
+            final int size = v.size();
+            final double[] ref = new double[size];
+
+            new VectorImplementationsTest.ElementsChecker(v, ref, desc); // IMPL NOTE this initialises vector and reference array
+
+            final double exp = calcRef.apply(ref);
+            final double obtained = calcVec.apply(v);
+            final VectorImplementationsTest.Metric metric = new VectorImplementationsTest.Metric(exp, obtained);
+
+            assertTrue("Not close enough at " + desc
+                + (val == null ? "" : ", value " + val) + ", " + metric, metric.closeEnough());
+        });
+    }
+
+    /** */
+    private void normalizeTest(double pow, BiFunction<Double, Double, Double> operation,
+        Function<Vector, Vector> vecOperation) {
+        consumeSampleVectors((v, desc) -> {
+            final int size = v.size();
+            final double[] ref = new double[size];
+            final boolean nonNegative = pow != (int)pow;
+
+            final VectorImplementationsTest.ElementsChecker checker = new VectorImplementationsTest.ElementsChecker(v, ref, desc + ", pow = " + pow, nonNegative);
+            final double norm = new Norm(ref, pow).calculate();
+
+            for (int idx = 0; idx < size; idx++)
+                ref[idx] = operation.apply(ref[idx], norm);
+
+            checker.assertCloseEnough(vecOperation.apply(v), ref);
+        });
+    }
+
+    /** */
+    private void consumeSampleVectors(BiConsumer<Vector, String> consumer) {
+        new VectorImplementationsFixtures().consumeSampleVectors(null, consumer);
+    }
+
+    /** */
+    private static class Norm {
+        /** */
+        private final double[] arr;
+
+        /** */
+        private final Double pow;
+
+        /** */
+        Norm(double[] arr, double pow) {
+            this.arr = arr;
+            this.pow = pow;
+        }
+
+        /** */
+        double calculate() {
+            if (pow.equals(0.0))
+                return countNonZeroes(); // IMPL NOTE this is beautiful if you think of it
+
+            if (pow.equals(Double.POSITIVE_INFINITY))
+                return maxAbs();
+
+            return Math.pow(sumPowers(), 1 / pow);
+        }
+
+        /** */
+        double sumPowers() {
+            if (pow.equals(0.0))
+                return countNonZeroes();
+
+            double norm = 0;
+
+            for (double val : arr)
+                norm += pow == 1 ? Math.abs(val) : Math.pow(val, pow);
+
+            return norm;
+        }
+
+        /** */
+        private int countNonZeroes() {
+            int cnt = 0;
+
+            final Double zero = 0.0;
+
+            for (double val : arr)
+                if (!zero.equals(val))
+                    cnt++;
+
+            return cnt;
+        }
+
+        /** */
+        private double maxAbs() {
+            double res = 0;
+
+            for (double val : arr) {
+                final double abs = Math.abs(val);
+
+                if (abs > res)
+                    res = abs;
+            }
+
+            return res;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/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
new file mode 100644
index 0000000..4d5bc56
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorToMatrixTest.java
@@ -0,0 +1,308 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOffHeapMatrix;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.impls.matrix.RandomMatrix;
+import org.apache.ignite.ml.math.impls.matrix.SparseLocalOnHeapMatrix;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+/** Tests for methods of Vector that involve Matrix. */
+public class VectorToMatrixTest {
+    /** */
+    private static final Map<Class<? extends Vector>, Class<? extends Matrix>> typesMap = typesMap();
+
+    /** */
+    private static final List<Class<? extends Vector>> likeMatrixUnsupported = Arrays.asList(FunctionVector.class,
+        SingleElementVector.class, SingleElementVectorView.class, ConstantVector.class);
+
+    /** */
+    @Test
+    public void testHaveLikeMatrix() throws InstantiationException, IllegalAccessException {
+        for (Class<? extends Vector> key : typesMap.keySet()) {
+            Class<? extends Matrix> val = typesMap.get(key);
+
+            if (val == null && likeMatrixSupported(key))
+                System.out.println("Missing test for implementation of likeMatrix for " + key.getSimpleName());
+        }
+    }
+
+    /** */
+    @Test
+    public void testLikeMatrixUnsupported() throws Exception {
+        consumeSampleVectors((v, desc) -> {
+            if (likeMatrixSupported(v.getClass()))
+                return;
+
+            boolean expECaught = false;
+
+            try {
+                assertNull("Null view instead of exception in " + desc, v.likeMatrix(1, 1));
+            }
+            catch (UnsupportedOperationException uoe) {
+                expECaught = true;
+            }
+
+            assertTrue("Expected exception was not caught in " + desc, expECaught);
+        });
+    }
+
+    /** */
+    @Test
+    public void testLikeMatrix() {
+        consumeSampleVectors((v, desc) -> {
+            if (!availableForTesting(v))
+                return;
+
+            final Matrix matrix = v.likeMatrix(1, 1);
+
+            Class<? extends Vector> key = v.getClass();
+
+            Class<? extends Matrix> expMatrixType = typesMap.get(key);
+
+            assertNotNull("Expect non-null matrix for " + key.getSimpleName() + " in " + desc, matrix);
+
+            Class<? extends Matrix> actualMatrixType = matrix.getClass();
+
+            assertTrue("Expected matrix type " + expMatrixType.getSimpleName()
+                    + " should be assignable from actual type " + actualMatrixType.getSimpleName() + " in " + desc,
+                expMatrixType.isAssignableFrom(actualMatrixType));
+
+            for (int rows : new int[] {1, 2})
+                for (int cols : new int[] {1, 2}) {
+                    final Matrix actualMatrix = v.likeMatrix(rows, cols);
+
+                    String details = "rows " + rows + " cols " + cols;
+
+                    assertNotNull("Expect non-null matrix for " + details + " in " + desc,
+                        actualMatrix);
+
+                    assertEquals("Unexpected number of rows in " + desc, rows, actualMatrix.rowSize());
+
+                    assertEquals("Unexpected number of cols in " + desc, cols, actualMatrix.columnSize());
+                }
+        });
+    }
+
+    /** */
+    @Test
+    public void testToMatrix() {
+        consumeSampleVectors((v, desc) -> {
+            if (!availableForTesting(v))
+                return;
+
+            fillWithNonZeroes(v);
+
+            final Matrix matrixRow = v.toMatrix(true);
+
+            final Matrix matrixCol = v.toMatrix(false);
+
+            for (Vector.Element e : v.all())
+                assertToMatrixValue(desc, matrixRow, matrixCol, e.get(), e.index());
+        });
+    }
+
+    /** */
+    @Test
+    public void testToMatrixPlusOne() {
+        consumeSampleVectors((v, desc) -> {
+            if (!availableForTesting(v))
+                return;
+
+            fillWithNonZeroes(v);
+
+            for (double zeroVal : new double[] {-1, 0, 1, 2}) {
+                final Matrix matrixRow = v.toMatrixPlusOne(true, zeroVal);
+
+                final Matrix matrixCol = v.toMatrixPlusOne(false, zeroVal);
+
+                final Metric metricRow0 = new Metric(zeroVal, matrixRow.get(0, 0));
+
+                assertTrue("Not close enough row like " + metricRow0 + " at index 0 in " + desc,
+                    metricRow0.closeEnough());
+
+                final Metric metricCol0 = new Metric(zeroVal, matrixCol.get(0, 0));
+
+                assertTrue("Not close enough cols like " + metricCol0 + " at index 0 in " + desc,
+                    metricCol0.closeEnough());
+
+                for (Vector.Element e : v.all())
+                    assertToMatrixValue(desc, matrixRow, matrixCol, e.get(), e.index() + 1);
+            }
+        });
+    }
+
+    /** */
+    @Test
+    public void testCross() {
+        consumeSampleVectors((v, desc) -> {
+            if (!availableForTesting(v))
+                return;
+
+            fillWithNonZeroes(v);
+
+            for (int delta : new int[] {-1, 0, 1}) {
+                final int size2 = v.size() + delta;
+
+                if (size2 < 1)
+                    return;
+
+                final Vector v2 = new DenseLocalOnHeapVector(size2);
+
+                for (Vector.Element e : v2.all())
+                    e.set(size2 - e.index());
+
+                assertCross(v, v2, desc);
+            }
+        });
+    }
+
+    /** */
+    private void assertCross(Vector v1, Vector v2, String desc) {
+        assertNotNull(v1);
+        assertNotNull(v2);
+
+        final Matrix res = v1.cross(v2);
+
+        assertNotNull("Cross matrix is expected to be not null in " + desc, res);
+
+        assertEquals("Unexpected number of rows in cross Matrix in " + desc, v1.size(), res.rowSize());
+
+        assertEquals("Unexpected number of cols in cross Matrix in " + desc, v2.size(), res.columnSize());
+
+        for (int row = 0; row < v1.size(); row++)
+            for (int col = 0; col < v2.size(); col++) {
+                final Metric metric = new Metric(v1.get(row) * v2.get(col), res.get(row, col));
+
+                assertTrue("Not close enough cross " + metric + " at row " + row + " at col " + col
+                    + " in " + desc, metric.closeEnough());
+            }
+    }
+
+    /** */
+    private void assertToMatrixValue(String desc, Matrix matrixRow, Matrix matrixCol, double exp, int idx) {
+        final Metric metricRow = new Metric(exp, matrixRow.get(0, idx));
+
+        assertTrue("Not close enough row like " + metricRow + " at index " + idx + " in " + desc,
+            metricRow.closeEnough());
+
+        final Metric metricCol = new Metric(exp, matrixCol.get(idx, 0));
+
+        assertTrue("Not close enough cols like " + matrixCol + " at index " + idx + " in " + desc,
+            metricCol.closeEnough());
+    }
+
+    /** */
+    private void fillWithNonZeroes(Vector sample) {
+        if (sample instanceof RandomVector)
+            return;
+
+        for (Vector.Element e : sample.all())
+            e.set(1 + e.index());
+    }
+
+    /** */
+    private boolean availableForTesting(Vector v) {
+        assertNotNull("Error in test: vector is null", v);
+
+        if (!likeMatrixSupported(v.getClass()))
+            return false;
+
+        final boolean availableForTesting = typesMap.get(v.getClass()) != null;
+
+        final Matrix actualLikeMatrix = v.likeMatrix(1, 1);
+
+        assertTrue("Need to enable matrix testing for vector type " + v.getClass().getSimpleName(),
+            availableForTesting || actualLikeMatrix == null);
+
+        return availableForTesting;
+    }
+
+    /** Ignore test for given vector type. */
+    private boolean likeMatrixSupported(Class<? extends Vector> clazz) {
+        for (Class<? extends Vector> ignoredClass : likeMatrixUnsupported)
+            if (ignoredClass.isAssignableFrom(clazz))
+                return false;
+
+        return true;
+    }
+
+    /** */
+    private void consumeSampleVectors(BiConsumer<Vector, String> consumer) {
+        new VectorImplementationsFixtures().consumeSampleVectors(null, consumer);
+    }
+
+    /** */
+    private static Map<Class<? extends Vector>, Class<? extends Matrix>> typesMap() {
+        return new LinkedHashMap<Class<? extends Vector>, Class<? extends Matrix>>() {{
+            put(DenseLocalOnHeapVector.class, DenseLocalOnHeapMatrix.class);
+            put(DenseLocalOffHeapVector.class, DenseLocalOffHeapMatrix.class);
+            put(RandomVector.class, RandomMatrix.class);
+            put(SparseLocalVector.class, SparseLocalOnHeapMatrix.class);
+            put(SingleElementVector.class, null); // todo find out if we need SingleElementMatrix to match, or skip it
+            put(ConstantVector.class, null);
+            put(FunctionVector.class, null);
+            put(PivotedVectorView.class, DenseLocalOnHeapMatrix.class); // IMPL NOTE per fixture
+            put(SingleElementVectorView.class, null);
+            put(MatrixVectorView.class, DenseLocalOnHeapMatrix.class); // IMPL NOTE per fixture
+            put(DelegatingVector.class, DenseLocalOnHeapMatrix.class); // IMPL NOTE per fixture
+            // IMPL NOTE check for presence of all implementations here will be done in testHaveLikeMatrix via Fixture
+        }};
+    }
+
+    /** */
+    private static class Metric { // todo consider if softer tolerance (like say 0.1 or 0.01) would make sense here
+        /** */
+        private final double exp;
+
+        /** */
+        private final double obtained;
+
+        /** **/
+        Metric(double exp, double obtained) {
+            this.exp = exp;
+            this.obtained = obtained;
+        }
+
+        /** */
+        boolean closeEnough() {
+            return new Double(exp).equals(obtained);
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return "Metric{" + "expected=" + exp +
+                ", obtained=" + obtained +
+                '}';
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorViewTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorViewTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorViewTest.java
new file mode 100644
index 0000000..ad2bc3f
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorViewTest.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.function.BiConsumer;
+import java.util.stream.IntStream;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Unit tests for {@link VectorView}.
+ */
+public class VectorViewTest {
+    /** */
+    private static final int OFFSET = 10;
+
+    /** */
+    private static final int VIEW_LENGTH = 80;
+
+    /** */
+    private static final String EXTERNALIZE_TEST_FILE_NAME = "externalizeTest";
+
+    /** */
+    private VectorView testVector;
+
+    /** */
+    private DenseLocalOnHeapVector parentVector;
+
+    /** */
+    private double[] parentData;
+
+    /** */
+    @Before
+    public void setup() {
+        parentVector = new DenseLocalOnHeapVector(MathTestConstants.STORAGE_SIZE);
+
+        IntStream.range(0, MathTestConstants.STORAGE_SIZE).forEach(idx -> parentVector.set(idx, Math.random()));
+
+        parentData = parentVector.getStorage().data().clone();
+
+        testVector = new VectorView(parentVector, OFFSET, VIEW_LENGTH);
+    }
+
+    /** */
+    @AfterClass
+    public static void cleanup() throws IOException {
+        Files.deleteIfExists(Paths.get(EXTERNALIZE_TEST_FILE_NAME));
+    }
+
+    /** */
+    @Test
+    public void testCopy() throws Exception {
+        Vector cp = testVector.copy();
+
+        assertTrue(MathTestConstants.VAL_NOT_EQUALS, cp.equals(testVector));
+    }
+
+    /** */
+    @Test(expected = UnsupportedOperationException.class)
+    public void testLike() throws Exception {
+        for (int card : new int[] {1, 2, 4, 8, 16, 32, 64, 128})
+            consumeSampleVectors((v, desc) -> {
+                Vector vLike = new VectorView(v, 0, 1).like(card);
+
+                Class<? extends Vector> expType = v.getClass();
+
+                assertNotNull("Expect non-null like vector for " + expType.getSimpleName() + " in " + desc, vLike);
+
+                assertEquals("Expect size equal to cardinality at " + desc, card, vLike.size());
+
+                Class<? extends Vector> actualType = vLike.getClass();
+
+                assertTrue("Expected matrix type " + expType.getSimpleName()
+                        + " should be assignable from actual type " + actualType.getSimpleName() + " in " + desc,
+                    expType.isAssignableFrom(actualType));
+
+            });
+    }
+
+    /** See also {@link VectorToMatrixTest#testLikeMatrix()}. */
+    @Test
+    public void testLikeMatrix() {
+        consumeSampleVectors((v, desc) -> {
+            boolean expECaught = false;
+
+            try {
+                assertNull("Null view instead of exception in " + desc, new VectorView(v, 0, 1).likeMatrix(1, 1));
+            }
+            catch (UnsupportedOperationException uoe) {
+                expECaught = true;
+            }
+
+            assertTrue("Expected exception was not caught in " + desc, expECaught);
+        });
+    }
+
+    /** */
+    @Test
+    public void testWriteReadExternal() throws Exception {
+        assertNotNull("Unexpected null parent data", parentData);
+
+        File f = new File(EXTERNALIZE_TEST_FILE_NAME);
+
+        try {
+            ObjectOutputStream objOutputStream = new ObjectOutputStream(new FileOutputStream(f));
+
+            objOutputStream.writeObject(testVector);
+
+            objOutputStream.close();
+
+            ObjectInputStream objInputStream = new ObjectInputStream(new FileInputStream(f));
+
+            VectorView readVector = (VectorView)objInputStream.readObject();
+
+            objInputStream.close();
+
+            assertTrue(MathTestConstants.VAL_NOT_EQUALS, testVector.equals(readVector));
+        }
+        catch (ClassNotFoundException | IOException e) {
+            fail(e.getMessage());
+        }
+    }
+
+    /** */
+    private void consumeSampleVectors(BiConsumer<Vector, String> consumer) {
+        new VectorImplementationsFixtures().consumeSampleVectors(null, consumer);
+    }
+
+}


[38/65] [abbrv] ignite git commit: IGNITE-4997: DDL: Fixed schema state replay on client reconnect. This closes #1845.

Posted by ag...@apache.org.
IGNITE-4997: DDL: Fixed schema state replay on client reconnect. This closes #1845.


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

Branch: refs/heads/ignite-5024
Commit: 3eb52a8a4d42add524051a9611b1b7d1a1d17398
Parents: 8ad5a94
Author: Alexander Paschenko <al...@gmail.com>
Authored: Fri Apr 21 11:15:55 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Fri Apr 21 11:15:55 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheProcessor.java    |  12 ++
 .../processors/query/GridQueryProcessor.java    | 173 ++++++++++---------
 .../cache/index/AbstractSchemaSelfTest.java     |  44 +++--
 .../DynamicIndexAbstractConcurrentSelfTest.java | 122 +++++++++++++
 .../cache/index/SchemaExchangeSelfTest.java     |  57 +++++-
 5 files changed, 307 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3eb52a8a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index da6ebc1..28ef22f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -1185,6 +1185,18 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 cache.onReconnected();
 
                 reconnected.add(cache);
+
+                if (!sysCache) {
+                    // Re-create cache structures inside indexing in order to apply recent schema changes.
+                    GridCacheContext cctx = cache.context();
+
+                    DynamicCacheDescriptor desc = cacheDescriptor(name);
+
+                    assert desc != null;
+
+                    ctx.query().onCacheStop0(cctx.name());
+                    ctx.query().onCacheStart0(cctx, desc.schema());
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3eb52a8a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 8381882..e0dc387 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -652,113 +652,122 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     }
 
     /**
+     * Create type descriptors from schema and initialize indexing for given cache.<p>
+     * Use with {@link #busyLock} where appropriate.
      * @param cctx Cache context.
      * @param schema Initial schema.
      * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings({"deprecation", "ThrowableResultOfMethodCallIgnored"})
-    private void initializeCache(GridCacheContext<?, ?> cctx, QuerySchema schema) throws IgniteCheckedException {
-        String space = cctx.name();
+    public void onCacheStart0(GridCacheContext<?, ?> cctx, QuerySchema schema)
+        throws IgniteCheckedException {
 
-        // Prepare candidates.
-        List<Class<?>> mustDeserializeClss = new ArrayList<>();
+        cctx.shared().database().checkpointReadLock();
 
-        Collection<QueryTypeCandidate> cands = new ArrayList<>();
+        try {
+            synchronized (stateMux) {
+                String space = cctx.name();
 
-        Collection<QueryEntity> qryEntities = schema.entities();
+                // Prepare candidates.
+                List<Class<?>> mustDeserializeClss = new ArrayList<>();
 
-        if (!F.isEmpty(qryEntities)) {
-            for (QueryEntity qryEntity : qryEntities) {
-                QueryTypeCandidate cand = QueryUtils.typeForQueryEntity(space, cctx, qryEntity, mustDeserializeClss);
+                Collection<QueryTypeCandidate> cands = new ArrayList<>();
 
-                cands.add(cand);
-            }
-        }
+                Collection<QueryEntity> qryEntities = schema.entities();
 
-        // Ensure that candidates has unique index names. Otherwise we will not be able to apply pending operations.
-        Map<String, QueryTypeDescriptorImpl> tblTypMap = new HashMap<>();
-        Map<String, QueryTypeDescriptorImpl> idxTypMap = new HashMap<>();
+                if (!F.isEmpty(qryEntities)) {
+                    for (QueryEntity qryEntity : qryEntities) {
+                        QueryTypeCandidate cand = QueryUtils.typeForQueryEntity(space, cctx, qryEntity,
+                            mustDeserializeClss);
 
-        for (QueryTypeCandidate cand : cands) {
-            QueryTypeDescriptorImpl desc = cand.descriptor();
+                        cands.add(cand);
+                    }
+                }
 
-            QueryTypeDescriptorImpl oldDesc = tblTypMap.put(desc.tableName(), desc);
+                // Ensure that candidates has unique index names. Otherwise we will not be able to apply pending operations.
+                Map<String, QueryTypeDescriptorImpl> tblTypMap = new HashMap<>();
+                Map<String, QueryTypeDescriptorImpl> idxTypMap = new HashMap<>();
 
-            if (oldDesc != null)
-                throw new IgniteException("Duplicate table name [cache=" + space +
-                    ", tblName=" + desc.tableName() + ", type1=" + desc.name() + ", type2=" + oldDesc.name() + ']');
+                for (QueryTypeCandidate cand : cands) {
+                    QueryTypeDescriptorImpl desc = cand.descriptor();
 
-            for (String idxName : desc.indexes().keySet()) {
-                oldDesc = idxTypMap.put(idxName, desc);
+                    QueryTypeDescriptorImpl oldDesc = tblTypMap.put(desc.tableName(), desc);
 
-                if (oldDesc != null)
-                    throw new IgniteException("Duplicate index name [cache=" + space +
-                        ", idxName=" + idxName + ", type1=" + desc.name() + ", type2=" + oldDesc.name() + ']');
-            }
-        }
+                    if (oldDesc != null)
+                        throw new IgniteException("Duplicate table name [cache=" + space +
+                            ", tblName=" + desc.tableName() + ", type1=" + desc.name() + ", type2=" + oldDesc.name() + ']');
 
-        // Apply pending operation which could have been completed as no-op at this point. There could be only one
-        // in-flight operation for a cache.
-        synchronized (stateMux) {
-            if (disconnected)
-                return;
+                    for (String idxName : desc.indexes().keySet()) {
+                        oldDesc = idxTypMap.put(idxName, desc);
 
-            for (SchemaOperation op : schemaOps.values()) {
-                if (F.eq(op.proposeMessage().deploymentId(), cctx.dynamicDeploymentId())) {
-                    if (op.started()) {
-                        SchemaOperationWorker worker = op.manager().worker();
+                        if (oldDesc != null)
+                            throw new IgniteException("Duplicate index name [cache=" + space +
+                                ", idxName=" + idxName + ", type1=" + desc.name() + ", type2=" + oldDesc.name() + ']');
+                    }
+                }
 
-                        assert !worker.cacheRegistered();
+                // Apply pending operation which could have been completed as no-op at this point.
+                // There could be only one in-flight operation for a cache.
+                for (SchemaOperation op : schemaOps.values()) {
+                    if (F.eq(op.proposeMessage().deploymentId(), cctx.dynamicDeploymentId())) {
+                        if (op.started()) {
+                            SchemaOperationWorker worker = op.manager().worker();
 
-                        if (!worker.nop()) {
-                            IgniteInternalFuture fut = worker.future();
+                            assert !worker.cacheRegistered();
 
-                            assert fut.isDone();
+                            if (!worker.nop()) {
+                                IgniteInternalFuture fut = worker.future();
 
-                            if (fut.error() == null) {
-                                SchemaAbstractOperation op0 = op.proposeMessage().operation();
+                                assert fut.isDone();
 
-                                if (op0 instanceof SchemaIndexCreateOperation) {
-                                    SchemaIndexCreateOperation opCreate = (SchemaIndexCreateOperation)op0;
+                                if (fut.error() == null) {
+                                    SchemaAbstractOperation op0 = op.proposeMessage().operation();
 
-                                    QueryTypeDescriptorImpl typeDesc = tblTypMap.get(opCreate.tableName());
+                                    if (op0 instanceof SchemaIndexCreateOperation) {
+                                        SchemaIndexCreateOperation opCreate = (SchemaIndexCreateOperation) op0;
 
-                                    assert typeDesc != null;
+                                        QueryTypeDescriptorImpl typeDesc = tblTypMap.get(opCreate.tableName());
 
-                                    QueryUtils.processDynamicIndexChange(opCreate.indexName(), opCreate.index(),
-                                        typeDesc);
-                                }
-                                else if (op0 instanceof SchemaIndexDropOperation) {
-                                    SchemaIndexDropOperation opDrop = (SchemaIndexDropOperation)op0;
+                                        assert typeDesc != null;
+
+                                        QueryUtils.processDynamicIndexChange(opCreate.indexName(), opCreate.index(),
+                                            typeDesc);
+                                    }
+                                    else if (op0 instanceof SchemaIndexDropOperation) {
+                                        SchemaIndexDropOperation opDrop = (SchemaIndexDropOperation) op0;
 
-                                    QueryTypeDescriptorImpl typeDesc = idxTypMap.get(opDrop.indexName());
+                                        QueryTypeDescriptorImpl typeDesc = idxTypMap.get(opDrop.indexName());
 
-                                    assert typeDesc != null;
+                                        assert typeDesc != null;
 
-                                    QueryUtils.processDynamicIndexChange(opDrop.indexName(), null, typeDesc);
+                                        QueryUtils.processDynamicIndexChange(opDrop.indexName(), null, typeDesc);
+                                    }
+                                    else
+                                        assert false;
                                 }
-                                else
-                                    assert false;
                             }
                         }
+
+                        break;
                     }
+                }
 
-                    break;
+                // Ready to register at this point.
+                registerCache0(space, cctx, cands);
+
+                // Warn about possible implicit deserialization.
+                if (!mustDeserializeClss.isEmpty()) {
+                    U.warn(log, "Some classes in query configuration cannot be written in binary format " +
+                        "because they either implement Externalizable interface or have writeObject/readObject " +
+                        "methods. Instances of these classes will be deserialized in order to build indexes. Please " +
+                        "ensure that all nodes have these classes in classpath. To enable binary serialization " +
+                        "either implement " + Binarylizable.class.getSimpleName() + " interface or set explicit " +
+                        "serializer using BinaryTypeConfiguration.setSerializer() method: " + mustDeserializeClss);
                 }
             }
         }
-
-        // Ready to register at this point.
-        registerCache0(space, cctx, cands);
-
-        // Warn about possible implicit deserialization.
-        if (!mustDeserializeClss.isEmpty()) {
-            U.warn(log, "Some classes in query configuration cannot be written in binary format " +
-                "because they either implement Externalizable interface or have writeObject/readObject methods. " +
-                "Instances of these classes will be deserialized in order to build indexes. Please ensure that " +
-                "all nodes have these classes in classpath. To enable binary serialization either implement " +
-                Binarylizable.class.getSimpleName() + " interface or set explicit serializer using " +
-                "BinaryTypeConfiguration.setSerializer() method: " + mustDeserializeClss);
+        finally {
+            cctx.shared().database().checkpointReadUnlock();
         }
     }
 
@@ -780,7 +789,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             schemaOps.clear();
         }
 
-        // Complete client futures outside of synchonized block because they may have listeners/chains.
+        // Complete client futures outside of synchronized block because they may have listeners/chains.
         for (SchemaOperationClientFuture fut : futs)
             fut.onDone(new SchemaOperationException("Client node is disconnected (operation result is unknown)."));
 
@@ -804,14 +813,10 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         if (!busyLock.enterBusy())
             return;
 
-        cctx.shared().database().checkpointReadLock();
-
         try {
-            initializeCache(cctx, schema);
+            onCacheStart0(cctx, schema);
         }
         finally {
-            cctx.shared().database().checkpointReadUnlock();
-
             busyLock.leaveBusy();
         }
     }
@@ -827,7 +832,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             return;
 
         try {
-            unregisterCache0(cctx.name());
+            onCacheStop0(cctx.name());
         }
         finally {
             busyLock.leaveBusy();
@@ -1302,7 +1307,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                 spaces.add(CU.mask(space));
             }
             catch (IgniteCheckedException | RuntimeException e) {
-                unregisterCache0(space);
+                onCacheStop0(space);
 
                 throw e;
             }
@@ -1310,12 +1315,14 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     }
 
     /**
-     * Unregister cache.
+     * Unregister cache.<p>
+     * Use with {@link #busyLock} where appropriate.
      *
      * @param space Space.
      */
-    private void unregisterCache0(String space) {
-        assert idx != null;
+    public void onCacheStop0(String space) {
+        if (idx == null)
+            return;
 
         synchronized (stateMux) {
             // Clear types.
@@ -1464,8 +1471,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
 
                     fut.onDone(e);
 
-                    if (e instanceof Error)
-                        throw e;
+                    throw e;
                 }
             }
         };
@@ -1547,6 +1553,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @return Type descriptor if found.
      * @throws IgniteCheckedException If type check failed.
      */
+    @SuppressWarnings("ConstantConditions")
     @Nullable private QueryTypeDescriptorImpl typeByValue(CacheObjectContext coctx,
         KeyCacheObject key,
         CacheObject val,

http://git-wip-us.apache.org/repos/asf/ignite/blob/3eb52a8a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java
index e228026..19d6f54 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java
@@ -27,6 +27,7 @@ import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor;
+import org.apache.ignite.internal.processors.query.GridQueryIndexDescriptor;
 import org.apache.ignite.internal.processors.query.GridQueryProcessor;
 import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
 import org.apache.ignite.internal.processors.query.QueryIndexDescriptorImpl;
@@ -131,7 +132,7 @@ public class AbstractSchemaSelfTest extends GridCommonAbstractTest {
     }
 
     /**
-     * Assert index state on all nodes.
+     * Assert index state on all <b>affinity</b> nodes.
      *
      * @param cacheName Cache name.
      * @param tblName Table name.
@@ -140,25 +141,44 @@ public class AbstractSchemaSelfTest extends GridCommonAbstractTest {
      */
     protected static void assertIndex(String cacheName, String tblName, String idxName,
         IgniteBiTuple<String, Boolean>... fields) {
+        assertIndex(cacheName, false, tblName, idxName, fields);
+    }
+
+    /**
+     * Assert index state on all nodes.
+     *
+     * @param cacheName Cache name.
+     * @param checkNonAffinityNodes Whether existence of {@link GridQueryIndexDescriptor} must be checked on non
+     *     affinity nodes as well.
+     * @param tblName Table name.
+     * @param idxName Index name.
+     * @param fields Fields.
+     */
+    protected static void assertIndex(String cacheName, boolean checkNonAffinityNodes, String tblName, String idxName,
+        IgniteBiTuple<String, Boolean>... fields) {
         for (Ignite node : Ignition.allGrids())
-            assertIndex((IgniteEx)node, cacheName, tblName, idxName, fields);
+            assertIndex(node, checkNonAffinityNodes, cacheName, tblName, idxName, fields);
     }
 
     /**
      * Assert index state on particular node.
      *
      * @param node Node.
+     * @param checkNonAffinityNode Whether existence of {@link GridQueryIndexDescriptor} must be checked regardless of
+     * whether this node is affinity node or not.
      * @param cacheName Cache name.
      * @param tblName Table name.
      * @param idxName Index name.
      * @param fields Fields.
      */
-    protected static void assertIndex(IgniteEx node, String cacheName, String tblName, String idxName,
-        IgniteBiTuple<String, Boolean>... fields) {
-        assertIndexDescriptor(node, cacheName, tblName, idxName, fields);
+    protected static void assertIndex(Ignite node, boolean checkNonAffinityNode, String cacheName, String tblName,
+        String idxName, IgniteBiTuple<String, Boolean>... fields) {
+        IgniteEx node0 = (IgniteEx)node;
+
+        assertIndexDescriptor(node0, cacheName, tblName, idxName, fields);
 
-        if (affinityNode(node, cacheName)) {
-            QueryTypeDescriptorImpl typeDesc = typeExisting(node, cacheName, tblName);
+        if (checkNonAffinityNode || affinityNode(node0, cacheName)) {
+            QueryTypeDescriptorImpl typeDesc = typeExisting(node0, cacheName, tblName);
 
             assertIndex(typeDesc, idxName, fields);
         }
@@ -263,11 +283,13 @@ public class AbstractSchemaSelfTest extends GridCommonAbstractTest {
      * @param tblName Table name.
      * @param idxName Index name.
      */
-    protected static void assertNoIndex(IgniteEx node, String cacheName, String tblName, String idxName) {
-        assertNoIndexDescriptor(node, cacheName, idxName);
+    protected static void assertNoIndex(Ignite node, String cacheName, String tblName, String idxName) {
+        IgniteEx node0 = (IgniteEx)node;
+
+        assertNoIndexDescriptor(node0, cacheName, idxName);
 
-        if (affinityNode(node, cacheName)) {
-            QueryTypeDescriptorImpl typeDesc = typeExisting(node, cacheName, tblName);
+        if (affinityNode(node0, cacheName)) {
+            QueryTypeDescriptorImpl typeDesc = typeExisting(node0, cacheName, tblName);
 
             assertNoIndex(typeDesc, idxName);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3eb52a8a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
index d2a2f49..5976615 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache.index;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.cache.CacheAtomicityMode;
@@ -28,6 +29,7 @@ import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.cache.query.SqlQuery;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteClientReconnectAbstractTest;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.processors.query.GridQueryProcessor;
@@ -47,6 +49,8 @@ import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import static org.apache.ignite.internal.IgniteClientReconnectAbstractTest.TestTcpDiscoverySpi;
+
 /**
  * Concurrency tests for dynamic index create/drop.
  */
@@ -111,6 +115,11 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
         return ccfg.setCacheMode(cacheMode).setAtomicityMode(atomicityMode);
     }
 
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration commonConfiguration(int idx) throws Exception {
+        return super.commonConfiguration(idx).setDiscoverySpi(new TestTcpDiscoverySpi());
+    }
+
     /**
      * Make sure that coordinator migrates correctly between nodes.
      *
@@ -600,6 +609,119 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
     }
 
     /**
+     * Make sure that client receives schema changes made while it was disconnected.
+     *
+     * @throws Exception If failed.
+     */
+    public void testClientReconnect() throws Exception {
+        checkClientReconnect(false);
+    }
+
+    /**
+     * Make sure that client receives schema changes made while it was disconnected, even with cache recreation.
+     *
+     * @throws Exception If failed.
+     */
+    public void testClientReconnectWithCacheRestart() throws Exception {
+        checkClientReconnect(true);
+    }
+
+    /**
+     * Make sure that client receives schema changes made while it was disconnected, optionally with cache restart
+     * in the interim.
+     *
+     * @param restartCache Whether cache needs to be recreated during client's absence.
+     * @throws Exception If failed.
+     */
+    private void checkClientReconnect(final boolean restartCache) throws Exception {
+        // Start complex topology.
+        final Ignite srv = Ignition.start(serverConfiguration(1));
+        Ignition.start(serverConfiguration(2));
+        Ignition.start(serverConfiguration(3, true));
+
+        final Ignite cli = Ignition.start(clientConfiguration(4));
+
+        cli.createCache(cacheConfiguration());
+
+        // Check index create.
+        reconnectClientNode(srv, cli, restartCache, new RunnableX() {
+            @Override public void run() throws Exception {
+                final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
+
+                queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false).get();
+            }
+        });
+
+        assertIndex(cli, true, CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1));
+        assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
+
+        // Check index drop.
+        reconnectClientNode(srv, cli, restartCache, new RunnableX() {
+            @Override public void run() throws Exception {
+                if (!restartCache)
+                    queryProcessor(srv).dynamicIndexDrop(CACHE_NAME, IDX_NAME_1, false).get();
+            }
+        });
+
+        assertNoIndex(cli, CACHE_NAME, TBL_NAME, IDX_NAME_1);
+        assertIndexNotUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
+
+        // Update existing index.
+        QueryIndex idx = index(IDX_NAME_2, field(alias(FIELD_NAME_2)));
+
+        queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false).get();
+
+        assertIndex(cli, true, CACHE_NAME, TBL_NAME, IDX_NAME_2, field(alias(FIELD_NAME_2)));
+        assertIndexUsed(IDX_NAME_2, SQL_SIMPLE_FIELD_2, SQL_ARG_2);
+
+        reconnectClientNode(srv, cli, restartCache, new RunnableX() {
+            @Override public void run() throws Exception {
+                if (!restartCache)
+                    queryProcessor(srv).dynamicIndexDrop(CACHE_NAME, IDX_NAME_2, false).get();
+
+                final QueryIndex idx = index(IDX_NAME_2, field(FIELD_NAME_1), field(alias(FIELD_NAME_2)));
+
+                queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
+            }
+        });
+
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(FIELD_NAME_1), field(alias(FIELD_NAME_2)));
+        assertIndexUsed(IDX_NAME_2, SQL_COMPOSITE, SQL_ARG_1, SQL_ARG_2);
+    }
+
+    /**
+     * Reconnect the client and run specified actions while it's out.
+     *
+     * @param srvNode Server node.
+     * @param cliNode Client node.
+     * @param restart Whether cache has to be recreated prior to executing required actions.
+     * @param clo Closure to run
+     * @throws Exception If failed.
+     */
+    private void reconnectClientNode(final Ignite srvNode, final Ignite cliNode, final boolean restart,
+        final RunnableX clo) throws Exception {
+        IgniteClientReconnectAbstractTest.reconnectClientNode(log, cliNode, srvNode, new Runnable() {
+            @Override public void run() {
+                if (restart) {
+                    srvNode.destroyCache(CACHE_NAME);
+
+                    srvNode.getOrCreateCache(cacheConfiguration().setName(CACHE_NAME));
+                }
+
+                try {
+                    clo.run();
+                }
+                catch (Exception e) {
+                    throw new IgniteException("Test reconnect runnable failed.", e);
+                }
+            }
+        });
+
+        if (restart)
+            cliNode.cache(CACHE_NAME);
+    }
+
+    /**
      * Test concurrent node start/stop along with index operations. Nothing should hang.
      *
      * @throws Exception If failed.

http://git-wip-us.apache.org/repos/asf/ignite/blob/3eb52a8a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java
index 95ad2f1..5a00345 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java
@@ -17,8 +17,11 @@
 
 package org.apache.ignite.internal.processors.cache.index;
 
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteClientDisconnectedException;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -34,6 +37,9 @@ import org.apache.ignite.testframework.GridTestUtils;
 import java.util.Collections;
 import java.util.Map;
 
+import static org.apache.ignite.internal.IgniteClientReconnectAbstractTest.TestTcpDiscoverySpi;
+import static org.apache.ignite.internal.IgniteClientReconnectAbstractTest.reconnectClientNode;
+
 /**
  * Tests for schema exchange between nodes.
  */
@@ -396,11 +402,11 @@ public class SchemaExchangeSelfTest extends AbstractSchemaSelfTest {
     }
 
     /**
-     * Test client reconnect.
+     * Test client reconnect after server restart accompanied by schema change.
      *
      * @throws Exception If failed.
      */
-    public void testClientReconnect() throws Exception {
+    public void testServerRestartWithNewTypes() throws Exception {
         IgniteEx node1 = start(1, KeyClass.class, ValueClass.class);
         assertTypes(node1, ValueClass.class);
 
@@ -412,11 +418,11 @@ public class SchemaExchangeSelfTest extends AbstractSchemaSelfTest {
 
         stopGrid(1);
 
-        assert GridTestUtils.waitForCondition(new GridAbsPredicate() {
+        assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
             @Override public boolean apply() {
                 return grid(2).context().clientDisconnected();
             }
-        }, 10_000L);
+        }, 10_000L));
 
         IgniteFuture reconnFut = null;
 
@@ -441,6 +447,40 @@ public class SchemaExchangeSelfTest extends AbstractSchemaSelfTest {
     }
 
     /**
+     * Test client reconnect.
+     *
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("unchecked")
+    public void testClientReconnect() throws Exception {
+        final IgniteEx node1 = start(1, KeyClass.class, ValueClass.class);
+        assertTypes(node1, ValueClass.class);
+
+        final IgniteEx node2 = startClientNoCache(2);
+        assertTypes(node2);
+
+        node2.cache(CACHE_NAME);
+        assertTypes(node2, ValueClass.class);
+
+        reconnectClientNode(log, node2, node1, new Runnable() {
+            @Override public void run() {
+                assertTrue(node2.context().clientDisconnected());
+
+                final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
+
+                try {
+                    queryProcessor(node1).dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false).get();
+                }
+                catch (IgniteCheckedException e) {
+                    throw new IgniteException(e);
+                }
+            }
+        });
+
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1));
+    }
+
+    /**
      * Ensure that only provided types exists for the given cache.
      *
      * @param node Node.
@@ -449,15 +489,15 @@ public class SchemaExchangeSelfTest extends AbstractSchemaSelfTest {
     private static void assertTypes(IgniteEx node, Class... clss) {
         Map<String, QueryTypeDescriptorImpl> types = types(node, CACHE_NAME);
 
-        if (clss == null || clss.length == 0)
-            assert types.isEmpty();
+        if (F.isEmpty(clss))
+            assertTrue(types.isEmpty());
         else {
             assertEquals(clss.length, types.size());
 
             for (Class cls : clss) {
                 String tblName = tableName(cls);
 
-                assert types.containsKey(tblName);
+                assertTrue(types.containsKey(tblName));
             }
         }
     }
@@ -498,6 +538,7 @@ public class SchemaExchangeSelfTest extends AbstractSchemaSelfTest {
         cfg.setClientMode(client);
         cfg.setLocalHost("127.0.0.1");
         cfg.setCacheConfiguration(cacheConfiguration(clss));
+        cfg.setDiscoverySpi(new TestTcpDiscoverySpi());
 
         if (filterNodeName != null && F.eq(name, filterNodeName))
             cfg.setUserAttributes(Collections.singletonMap("AFF_NODE", true));
@@ -543,6 +584,8 @@ public class SchemaExchangeSelfTest extends AbstractSchemaSelfTest {
         cfg.setClientMode(client);
         cfg.setLocalHost("127.0.0.1");
 
+        cfg.setDiscoverySpi(new TestTcpDiscoverySpi());
+
         return (IgniteEx)Ignition.start(cfg);
     }
 


[45/65] [abbrv] ignite git commit: ignite-2.0 - Properly handle DhtInvalidPartitionException in GridDhtGetFuture

Posted by ag...@apache.org.
ignite-2.0 - Properly handle DhtInvalidPartitionException in GridDhtGetFuture


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

Branch: refs/heads/ignite-5024
Commit: 04e0822e686734626ede2d8cf1dd33e851ad9838
Parents: d5a2ca2
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Apr 21 14:48:00 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Apr 21 14:48:25 2017 +0300

----------------------------------------------------------------------
 .../cache/distributed/dht/GridDhtGetFuture.java | 37 ++++++++++++--------
 1 file changed, 23 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/04e0822e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
index 5fe0ef4..7bc17a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
@@ -291,27 +291,36 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
      * @return {@code True} if mapped.
      */
     private boolean map(KeyCacheObject key) {
-        GridDhtLocalPartition part = topVer.topologyVersion() > 0 ?
-            cache().topology().localPartition(cctx.affinity().partition(key), topVer, true) :
-            cache().topology().localPartition(key, false);
+        try {
+            GridDhtLocalPartition part = topVer.topologyVersion() > 0 ?
+                cache().topology().localPartition(cctx.affinity().partition(key), topVer, true) :
+                cache().topology().localPartition(key, false);
 
-        if (part == null)
-            return false;
+            if (part == null)
+                return false;
 
-        if (parts == null || !F.contains(parts, part.id())) {
-            // By reserving, we make sure that partition won't be unloaded while processed.
-            if (part.reserve()) {
-                parts = parts == null ? new int[1] : Arrays.copyOf(parts, parts.length + 1);
+            if (parts == null || !F.contains(parts, part.id())) {
+                // By reserving, we make sure that partition won't be unloaded while processed.
+                if (part.reserve()) {
+                    parts = parts == null ? new int[1] : Arrays.copyOf(parts, parts.length + 1);
 
-                parts[parts.length - 1] = part.id();
+                    parts[parts.length - 1] = part.id();
 
-                return true;
+                    return true;
+                }
+                else
+                    return false;
             }
             else
-                return false;
+                return true;
+        }
+        catch (GridDhtInvalidPartitionException e) {
+            if (log.isDebugEnabled())
+                log.debug("Attempted to create a partition which does not belong to local node, will remap " +
+                    "[key=" + key + ", part=" + e.partition() + ']');
+
+            return false;
         }
-        else
-            return true;
     }
 
     /**


[24/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
IGNITE-5000 Rename Ignite Math module to Ignite ML module
      added missed licenses
      renamed packages
      fixed wrong ml profile activation
(cherry picked from commit d78e071)


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

Branch: refs/heads/ignite-5024
Commit: 0abf6601fc1ff1e6e659381666ae706e31b51de0
Parents: 5d8e318
Author: Yury Babak <yb...@gridgain.com>
Authored: Tue Apr 18 16:47:15 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Tue Apr 18 17:54:20 2017 +0300

----------------------------------------------------------------------
 examples/pom-standalone-lgpl.xml                |    4 -
 examples/pom-standalone.xml                     |    4 -
 examples/pom.xml                                |    4 -
 .../CholeskyDecompositionExample.java           |    8 +-
 .../EigenDecompositionExample.java              |    8 +-
 .../decompositions/LUDecompositionExample.java  |    8 +-
 .../SingularValueDecompositionExample.java      |    6 +-
 .../ml/math/matrix/CacheMatrixExample.java      |   10 +-
 .../ml/math/matrix/ExampleMatrixStorage.java    |    4 +-
 .../math/matrix/MatrixCustomStorageExample.java |   12 +-
 .../examples/ml/math/matrix/MatrixExample.java  |    4 +-
 .../ml/math/matrix/MatrixExampleUtil.java       |    4 +-
 .../ml/math/matrix/OffHeapMatrixExample.java    |    4 +-
 .../matrix/SparseDistributedMatrixExample.java  |    5 +-
 .../ml/math/matrix/SparseMatrixExample.java     |    4 +-
 .../examples/ml/math/tracer/TracerExample.java  |    4 +-
 .../ml/math/vector/CacheVectorExample.java      |    8 +-
 .../ml/math/vector/ExampleVectorStorage.java    |    4 +-
 .../ml/math/vector/OffHeapVectorExample.java    |    4 +-
 .../ml/math/vector/SparseVectorExample.java     |    6 +-
 .../math/vector/VectorCustomStorageExample.java |   14 +-
 .../examples/ml/math/vector/VectorExample.java  |    4 +-
 modules/ml/pom.xml                              |    6 -
 .../java/org/apache/ignite/math/Algebra.java    |  571 ---------
 .../java/org/apache/ignite/math/Constants.java  |   42 -
 .../org/apache/ignite/math/Destroyable.java     |   30 -
 .../apache/ignite/math/IdentityValueMapper.java |   53 -
 .../java/org/apache/ignite/math/KeyMapper.java  |   33 -
 .../java/org/apache/ignite/math/Matrix.java     |  518 --------
 .../org/apache/ignite/math/MatrixKeyMapper.java |   30 -
 .../org/apache/ignite/math/MatrixStorage.java   |   58 -
 .../org/apache/ignite/math/MetaAttributes.java  |   76 --
 .../java/org/apache/ignite/math/MurmurHash.java |  246 ----
 .../apache/ignite/math/StorageConstants.java    |   49 -
 .../apache/ignite/math/StorageOpsMetrics.java   |   49 -
 .../java/org/apache/ignite/math/Tracer.java     |  456 -------
 .../org/apache/ignite/math/ValueMapper.java     |   27 -
 .../java/org/apache/ignite/math/Vector.java     |  498 --------
 .../org/apache/ignite/math/VectorKeyMapper.java |   29 -
 .../org/apache/ignite/math/VectorStorage.java   |   53 -
 .../decompositions/CholeskyDecomposition.java   |  306 -----
 .../decompositions/DecompositionSupport.java    |  105 --
 .../math/decompositions/EigenDecomposition.java |  923 ---------------
 .../math/decompositions/LUDecomposition.java    |  366 ------
 .../math/decompositions/QRDecomposition.java    |  186 ---
 .../SingularValueDecomposition.java             |  620 ----------
 .../math/decompositions/package-info.java       |   22 -
 .../math/exceptions/CardinalityException.java   |   38 -
 .../math/exceptions/ColumnIndexException.java   |   35 -
 .../ignite/math/exceptions/IndexException.java  |   35 -
 .../NonPositiveDefiniteMatrixException.java     |   20 -
 .../exceptions/NonSymmetricMatrixException.java |   18 -
 .../math/exceptions/RowIndexException.java      |   35 -
 .../exceptions/SingularMatrixException.java     |   30 -
 .../exceptions/UnknownProviderException.java    |   35 -
 .../UnsupportedOperationException.java          |   44 -
 .../ignite/math/exceptions/package-info.java    |   22 -
 .../apache/ignite/math/functions/Functions.java |  136 ---
 .../ignite/math/functions/IgniteBiConsumer.java |   12 -
 .../ignite/math/functions/IgniteBiFunction.java |   29 -
 .../ignite/math/functions/IgniteConsumer.java   |   29 -
 .../math/functions/IgniteDoubleFunction.java    |   29 -
 .../ignite/math/functions/IgniteFunction.java   |   30 -
 .../math/functions/IntDoubleToVoidFunction.java |   25 -
 .../functions/IntIntDoubleToVoidFunction.java   |   28 -
 .../math/functions/IntIntToDoubleFunction.java  |   24 -
 .../ignite/math/functions/package-info.java     |   22 -
 .../apache/ignite/math/impls/CacheUtils.java    |  356 ------
 .../math/impls/matrix/AbstractMatrix.java       |  880 --------------
 .../ignite/math/impls/matrix/CacheMatrix.java   |  158 ---
 .../impls/matrix/DenseLocalOffHeapMatrix.java   |   90 --
 .../impls/matrix/DenseLocalOnHeapMatrix.java    |   86 --
 .../math/impls/matrix/DiagonalMatrix.java       |  101 --
 .../math/impls/matrix/FunctionMatrix.java       |   95 --
 .../ignite/math/impls/matrix/MatrixView.java    |   84 --
 .../math/impls/matrix/PivotedMatrixView.java    |  243 ----
 .../ignite/math/impls/matrix/RandomMatrix.java  |   97 --
 .../impls/matrix/SparseDistributedMatrix.java   |  155 ---
 .../impls/matrix/SparseLocalOnHeapMatrix.java   |   72 --
 .../math/impls/matrix/TransposedMatrixView.java |   84 --
 .../ignite/math/impls/matrix/package-info.java  |   22 -
 .../apache/ignite/math/impls/package-info.java  |   22 -
 .../storage/matrix/ArrayMatrixStorage.java      |  161 ---
 .../storage/matrix/CacheMatrixStorage.java      |  180 ---
 .../matrix/DenseOffHeapMatrixStorage.java       |  197 ----
 .../storage/matrix/DiagonalMatrixStorage.java   |  136 ---
 .../storage/matrix/FunctionMatrixStorage.java   |  175 ---
 .../storage/matrix/MatrixDelegateStorage.java   |  205 ----
 .../storage/matrix/PivotedMatrixStorage.java    |  256 ----
 .../storage/matrix/RandomMatrixStorage.java     |  176 ---
 .../matrix/SparseDistributedMatrixStorage.java  |  281 -----
 .../matrix/SparseLocalOnHeapMatrixStorage.java  |  226 ----
 .../math/impls/storage/matrix/package-info.java |   22 -
 .../storage/vector/ArrayVectorStorage.java      |  135 ---
 .../storage/vector/CacheVectorStorage.java      |  175 ---
 .../storage/vector/ConstantVectorStorage.java   |  133 ---
 .../storage/vector/DelegateVectorStorage.java   |  157 ---
 .../vector/DenseLocalOffHeapVectorStorage.java  |  172 ---
 .../storage/vector/FunctionVectorStorage.java   |  141 ---
 .../storage/vector/MatrixVectorStorage.java     |  185 ---
 .../storage/vector/PivotedVectorStorage.java    |  175 ---
 .../storage/vector/RandomVectorStorage.java     |  152 ---
 .../SingleElementVectorDelegateStorage.java     |  145 ---
 .../vector/SingleElementVectorStorage.java      |  143 ---
 .../vector/SparseLocalOffHeapVectorStorage.java |  148 ---
 .../vector/SparseLocalOnHeapVectorStorage.java  |  152 ---
 .../math/impls/storage/vector/package-info.java |   22 -
 .../impls/vector/AbstractReadOnlyVector.java    |  108 --
 .../math/impls/vector/AbstractVector.java       |  903 --------------
 .../ignite/math/impls/vector/CacheVector.java   |  140 ---
 .../math/impls/vector/ConstantVector.java       |   84 --
 .../math/impls/vector/DelegatingVector.java     |  391 ------
 .../impls/vector/DenseLocalOffHeapVector.java   |   89 --
 .../impls/vector/DenseLocalOnHeapVector.java    |  104 --
 .../math/impls/vector/FunctionVector.java       |  112 --
 .../math/impls/vector/MatrixVectorView.java     |  139 ---
 .../math/impls/vector/PivotedVectorView.java    |  163 ---
 .../ignite/math/impls/vector/RandomVector.java  |  128 --
 .../math/impls/vector/SingleElementVector.java  |  102 --
 .../impls/vector/SingleElementVectorView.java   |   97 --
 .../impls/vector/SparseLocalOffHeapVector.java  |   47 -
 .../math/impls/vector/SparseLocalVector.java    |   71 --
 .../ignite/math/impls/vector/VectorView.java    |   85 --
 .../ignite/math/impls/vector/package-info.java  |   22 -
 .../org/apache/ignite/math/package-info.java    |   22 -
 .../java/org/apache/ignite/ml/math/Algebra.java |  571 +++++++++
 .../org/apache/ignite/ml/math/Constants.java    |   42 +
 .../org/apache/ignite/ml/math/Destroyable.java  |   30 +
 .../ignite/ml/math/IdentityValueMapper.java     |   53 +
 .../org/apache/ignite/ml/math/KeyMapper.java    |   33 +
 .../java/org/apache/ignite/ml/math/Matrix.java  |  518 ++++++++
 .../apache/ignite/ml/math/MatrixKeyMapper.java  |   30 +
 .../apache/ignite/ml/math/MatrixStorage.java    |   58 +
 .../apache/ignite/ml/math/MetaAttributes.java   |   76 ++
 .../org/apache/ignite/ml/math/MurmurHash.java   |  246 ++++
 .../apache/ignite/ml/math/StorageConstants.java |   49 +
 .../ignite/ml/math/StorageOpsMetrics.java       |   49 +
 .../java/org/apache/ignite/ml/math/Tracer.java  |  456 +++++++
 .../org/apache/ignite/ml/math/ValueMapper.java  |   35 +
 .../java/org/apache/ignite/ml/math/Vector.java  |  498 ++++++++
 .../apache/ignite/ml/math/VectorKeyMapper.java  |   29 +
 .../apache/ignite/ml/math/VectorStorage.java    |   53 +
 .../decompositions/CholeskyDecomposition.java   |  306 +++++
 .../decompositions/DecompositionSupport.java    |  105 ++
 .../math/decompositions/EigenDecomposition.java |  923 +++++++++++++++
 .../ml/math/decompositions/LUDecomposition.java |  366 ++++++
 .../ml/math/decompositions/QRDecomposition.java |  186 +++
 .../SingularValueDecomposition.java             |  620 ++++++++++
 .../ml/math/decompositions/package-info.java    |   22 +
 .../math/exceptions/CardinalityException.java   |   38 +
 .../math/exceptions/ColumnIndexException.java   |   35 +
 .../ml/math/exceptions/IndexException.java      |   35 +
 .../NonPositiveDefiniteMatrixException.java     |   37 +
 .../exceptions/NonSymmetricMatrixException.java |   35 +
 .../ml/math/exceptions/RowIndexException.java   |   35 +
 .../exceptions/SingularMatrixException.java     |   30 +
 .../exceptions/UnknownProviderException.java    |   35 +
 .../UnsupportedOperationException.java          |   44 +
 .../ignite/ml/math/exceptions/package-info.java |   22 +
 .../ignite/ml/math/functions/Functions.java     |  136 +++
 .../ml/math/functions/IgniteBiConsumer.java     |   29 +
 .../ml/math/functions/IgniteBiFunction.java     |   29 +
 .../ml/math/functions/IgniteConsumer.java       |   29 +
 .../ml/math/functions/IgniteDoubleFunction.java |   29 +
 .../ml/math/functions/IgniteFunction.java       |   30 +
 .../math/functions/IntDoubleToVoidFunction.java |   25 +
 .../functions/IntIntDoubleToVoidFunction.java   |   28 +
 .../math/functions/IntIntToDoubleFunction.java  |   24 +
 .../ignite/ml/math/functions/package-info.java  |   22 +
 .../apache/ignite/ml/math/impls/CacheUtils.java |  356 ++++++
 .../ml/math/impls/matrix/AbstractMatrix.java    |  880 ++++++++++++++
 .../ml/math/impls/matrix/CacheMatrix.java       |  158 +++
 .../impls/matrix/DenseLocalOffHeapMatrix.java   |   90 ++
 .../impls/matrix/DenseLocalOnHeapMatrix.java    |   86 ++
 .../ml/math/impls/matrix/DiagonalMatrix.java    |  101 ++
 .../ml/math/impls/matrix/FunctionMatrix.java    |   95 ++
 .../ignite/ml/math/impls/matrix/MatrixView.java |   84 ++
 .../ml/math/impls/matrix/PivotedMatrixView.java |  243 ++++
 .../ml/math/impls/matrix/RandomMatrix.java      |   97 ++
 .../impls/matrix/SparseDistributedMatrix.java   |  155 +++
 .../impls/matrix/SparseLocalOnHeapMatrix.java   |   72 ++
 .../math/impls/matrix/TransposedMatrixView.java |   84 ++
 .../ml/math/impls/matrix/package-info.java      |   22 +
 .../ignite/ml/math/impls/package-info.java      |   22 +
 .../storage/matrix/ArrayMatrixStorage.java      |  161 +++
 .../storage/matrix/CacheMatrixStorage.java      |  180 +++
 .../matrix/DenseOffHeapMatrixStorage.java       |  197 ++++
 .../storage/matrix/DiagonalMatrixStorage.java   |  136 +++
 .../storage/matrix/FunctionMatrixStorage.java   |  175 +++
 .../storage/matrix/MatrixDelegateStorage.java   |  205 ++++
 .../storage/matrix/PivotedMatrixStorage.java    |  256 ++++
 .../storage/matrix/RandomMatrixStorage.java     |  176 +++
 .../matrix/SparseDistributedMatrixStorage.java  |  290 +++++
 .../matrix/SparseLocalOnHeapMatrixStorage.java  |  226 ++++
 .../math/impls/storage/matrix/package-info.java |   22 +
 .../storage/vector/ArrayVectorStorage.java      |  135 +++
 .../storage/vector/CacheVectorStorage.java      |  175 +++
 .../storage/vector/ConstantVectorStorage.java   |  133 +++
 .../storage/vector/DelegateVectorStorage.java   |  157 +++
 .../vector/DenseLocalOffHeapVectorStorage.java  |  172 +++
 .../storage/vector/FunctionVectorStorage.java   |  141 +++
 .../storage/vector/MatrixVectorStorage.java     |  185 +++
 .../storage/vector/PivotedVectorStorage.java    |  175 +++
 .../storage/vector/RandomVectorStorage.java     |  152 +++
 .../SingleElementVectorDelegateStorage.java     |  145 +++
 .../vector/SingleElementVectorStorage.java      |  143 +++
 .../vector/SparseLocalOffHeapVectorStorage.java |  149 +++
 .../vector/SparseLocalOnHeapVectorStorage.java  |  152 +++
 .../math/impls/storage/vector/package-info.java |   22 +
 .../impls/vector/AbstractReadOnlyVector.java    |  125 ++
 .../ml/math/impls/vector/AbstractVector.java    |  903 ++++++++++++++
 .../ml/math/impls/vector/CacheVector.java       |  140 +++
 .../ml/math/impls/vector/ConstantVector.java    |   84 ++
 .../ml/math/impls/vector/DelegatingVector.java  |  391 ++++++
 .../impls/vector/DenseLocalOffHeapVector.java   |   89 ++
 .../impls/vector/DenseLocalOnHeapVector.java    |  104 ++
 .../ml/math/impls/vector/FunctionVector.java    |  112 ++
 .../ml/math/impls/vector/MatrixVectorView.java  |  139 +++
 .../ml/math/impls/vector/PivotedVectorView.java |  163 +++
 .../ml/math/impls/vector/RandomVector.java      |  129 ++
 .../math/impls/vector/SingleElementVector.java  |  102 ++
 .../impls/vector/SingleElementVectorView.java   |   97 ++
 .../impls/vector/SparseLocalOffHeapVector.java  |   47 +
 .../ml/math/impls/vector/SparseLocalVector.java |   71 ++
 .../ignite/ml/math/impls/vector/VectorView.java |   85 ++
 .../ml/math/impls/vector/package-info.java      |   22 +
 .../org/apache/ignite/ml/math/package-info.java |   22 +
 .../apache/ignite/math/d3-matrix-template.html  |  128 --
 .../apache/ignite/math/d3-vector-template.html  |  111 --
 .../ignite/ml/math/d3-matrix-template.html      |  128 ++
 .../ignite/ml/math/d3-vector-template.html      |  111 ++
 .../org/apache/ignite/math/ExternalizeTest.java |   66 --
 .../math/MathImplDistributedTestSuite.java      |   39 -
 .../ignite/math/MathImplLocalTestSuite.java     |  123 --
 .../ignite/math/MathImplMainTestSuite.java      |   33 -
 .../java/org/apache/ignite/math/TracerTest.java |  195 ---
 .../ignite/math/benchmark/MathBenchmark.java    |  205 ----
 .../math/benchmark/MathBenchmarkSelfTest.java   |  100 --
 .../ignite/math/benchmark/ResultsWriter.java    |  127 --
 .../math/benchmark/VectorBenchmarkTest.java     |  138 ---
 .../ignite/math/benchmark/package-info.java     |   18 -
 .../CholeskyDecompositionTest.java              |  158 ---
 .../decompositions/EigenDecompositionTest.java  |  193 ---
 .../decompositions/LUDecompositionTest.java     |  250 ----
 .../decompositions/QRDecompositionTest.java     |  139 ---
 .../SingularValueDecompositionTest.java         |  120 --
 .../ignite/math/impls/MathTestConstants.java    |   88 --
 .../math/impls/matrix/CacheMatrixTest.java      |  369 ------
 .../DenseLocalOffHeapMatrixConstructorTest.java |   65 -
 .../DenseLocalOnHeapMatrixConstructorTest.java  |   71 --
 .../math/impls/matrix/DiagonalMatrixTest.java   |  209 ----
 .../matrix/FunctionMatrixConstructorTest.java   |  113 --
 .../math/impls/matrix/MatrixAttributeTest.java  |  156 ---
 .../matrix/MatrixImplementationFixtures.java    |  381 ------
 .../impls/matrix/MatrixImplementationsTest.java | 1113 ------------------
 .../impls/matrix/MatrixKeyMapperForTests.java   |   69 --
 .../impls/matrix/MatrixViewConstructorTest.java |  114 --
 .../PivotedMatrixViewConstructorTest.java       |  128 --
 .../matrix/RandomMatrixConstructorTest.java     |   71 --
 .../matrix/SparseDistributedMatrixTest.java     |  265 -----
 .../SparseLocalOnHeapMatrixConstructorTest.java |   53 -
 .../impls/matrix/TransposedMatrixViewTest.java  |   87 --
 .../storage/matrix/MatrixArrayStorageTest.java  |   63 -
 .../storage/matrix/MatrixBaseStorageTest.java   |   89 --
 .../matrix/MatrixOffHeapStorageTest.java        |   39 -
 .../storage/matrix/MatrixStorageFixtures.java   |  141 ---
 .../matrix/MatrixStorageImplementationTest.java |   73 --
 .../SparseDistributedMatrixStorageTest.java     |  126 --
 .../RandomAccessSparseVectorStorageTest.java    |   60 -
 .../SparseLocalOffHeapVectorStorageTest.java    |   78 --
 .../storage/vector/VectorArrayStorageTest.java  |   58 -
 .../storage/vector/VectorBaseStorageTest.java   |   69 --
 .../vector/VectorOffheapStorageTest.java        |   73 --
 .../math/impls/vector/AbstractVectorTest.java   |  543 ---------
 .../math/impls/vector/CacheVectorTest.java      |  417 -------
 .../vector/ConstantVectorConstructorTest.java   |   52 -
 .../vector/DelegatingVectorConstructorTest.java |   62 -
 .../DenseLocalOffHeapVectorConstructorTest.java |   59 -
 .../DenseLocalOnHeapVectorConstructorTest.java  |  163 ---
 .../vector/FunctionVectorConstructorTest.java   |  121 --
 .../math/impls/vector/MatrixVectorViewTest.java |  209 ----
 .../PivotedVectorViewConstructorTest.java       |  211 ----
 .../vector/RandomVectorConstructorTest.java     |  145 ---
 .../SingleElementVectorConstructorTest.java     |  159 ---
 .../SingleElementVectorViewConstructorTest.java |  137 ---
 .../SparseLocalVectorConstructorTest.java       |   54 -
 .../math/impls/vector/VectorAttributesTest.java |  217 ----
 .../math/impls/vector/VectorFoldMapTest.java    |  122 --
 .../vector/VectorImplementationsFixtures.java   |  655 -----------
 .../impls/vector/VectorImplementationsTest.java |  860 --------------
 .../math/impls/vector/VectorIterableTest.java   |  376 ------
 .../math/impls/vector/VectorNormTest.java       |  247 ----
 .../math/impls/vector/VectorToMatrixTest.java   |  291 -----
 .../math/impls/vector/VectorViewTest.java       |  162 ---
 .../apache/ignite/ml/math/ExternalizeTest.java  |   66 ++
 .../ml/math/MathImplDistributedTestSuite.java   |   39 +
 .../ignite/ml/math/MathImplLocalTestSuite.java  |  123 ++
 .../ignite/ml/math/MathImplMainTestSuite.java   |   33 +
 .../org/apache/ignite/ml/math/TracerTest.java   |  195 +++
 .../ignite/ml/math/benchmark/MathBenchmark.java |  205 ++++
 .../math/benchmark/MathBenchmarkSelfTest.java   |  100 ++
 .../ignite/ml/math/benchmark/ResultsWriter.java |  127 ++
 .../ml/math/benchmark/VectorBenchmarkTest.java  |  138 +++
 .../ignite/ml/math/benchmark/package-info.java  |   18 +
 .../CholeskyDecompositionTest.java              |  158 +++
 .../decompositions/EigenDecompositionTest.java  |  193 +++
 .../decompositions/LUDecompositionTest.java     |  250 ++++
 .../decompositions/QRDecompositionTest.java     |  139 +++
 .../SingularValueDecompositionTest.java         |  120 ++
 .../ignite/ml/math/impls/MathTestConstants.java |   88 ++
 .../ml/math/impls/matrix/CacheMatrixTest.java   |  369 ++++++
 .../DenseLocalOffHeapMatrixConstructorTest.java |   65 +
 .../DenseLocalOnHeapMatrixConstructorTest.java  |   71 ++
 .../math/impls/matrix/DiagonalMatrixTest.java   |  209 ++++
 .../matrix/FunctionMatrixConstructorTest.java   |  113 ++
 .../math/impls/matrix/MatrixAttributeTest.java  |  156 +++
 .../matrix/MatrixImplementationFixtures.java    |  381 ++++++
 .../impls/matrix/MatrixImplementationsTest.java | 1113 ++++++++++++++++++
 .../impls/matrix/MatrixKeyMapperForTests.java   |   69 ++
 .../impls/matrix/MatrixViewConstructorTest.java |  114 ++
 .../PivotedMatrixViewConstructorTest.java       |  129 ++
 .../matrix/RandomMatrixConstructorTest.java     |   71 ++
 .../matrix/SparseDistributedMatrixTest.java     |  265 +++++
 .../SparseLocalOnHeapMatrixConstructorTest.java |   53 +
 .../impls/matrix/TransposedMatrixViewTest.java  |   87 ++
 .../storage/matrix/MatrixArrayStorageTest.java  |   63 +
 .../storage/matrix/MatrixBaseStorageTest.java   |   89 ++
 .../matrix/MatrixOffHeapStorageTest.java        |   39 +
 .../storage/matrix/MatrixStorageFixtures.java   |  137 +++
 .../matrix/MatrixStorageImplementationTest.java |   73 ++
 .../SparseDistributedMatrixStorageTest.java     |  126 ++
 .../RandomAccessSparseVectorStorageTest.java    |   60 +
 .../SparseLocalOffHeapVectorStorageTest.java    |   78 ++
 .../storage/vector/VectorArrayStorageTest.java  |   58 +
 .../storage/vector/VectorBaseStorageTest.java   |   69 ++
 .../vector/VectorOffheapStorageTest.java        |   73 ++
 .../math/impls/vector/AbstractVectorTest.java   |  543 +++++++++
 .../ml/math/impls/vector/CacheVectorTest.java   |  434 +++++++
 .../vector/ConstantVectorConstructorTest.java   |   52 +
 .../vector/DelegatingVectorConstructorTest.java |   62 +
 .../DenseLocalOffHeapVectorConstructorTest.java |   59 +
 .../DenseLocalOnHeapVectorConstructorTest.java  |  163 +++
 .../vector/FunctionVectorConstructorTest.java   |  121 ++
 .../math/impls/vector/MatrixVectorViewTest.java |  226 ++++
 .../PivotedVectorViewConstructorTest.java       |  211 ++++
 .../vector/RandomVectorConstructorTest.java     |  145 +++
 .../SingleElementVectorConstructorTest.java     |  159 +++
 .../SingleElementVectorViewConstructorTest.java |  137 +++
 .../SparseLocalVectorConstructorTest.java       |   54 +
 .../math/impls/vector/VectorAttributesTest.java |  217 ++++
 .../ml/math/impls/vector/VectorFoldMapTest.java |  122 ++
 .../vector/VectorImplementationsFixtures.java   |  655 +++++++++++
 .../impls/vector/VectorImplementationsTest.java |  861 ++++++++++++++
 .../math/impls/vector/VectorIterableTest.java   |  376 ++++++
 .../ml/math/impls/vector/VectorNormTest.java    |  247 ++++
 .../math/impls/vector/VectorToMatrixTest.java   |  308 +++++
 .../ml/math/impls/vector/VectorViewTest.java    |  162 +++
 357 files changed, 27247 insertions(+), 27128 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/pom-standalone-lgpl.xml
----------------------------------------------------------------------
diff --git a/examples/pom-standalone-lgpl.xml b/examples/pom-standalone-lgpl.xml
index 2b4ece0..5fbb4ea 100644
--- a/examples/pom-standalone-lgpl.xml
+++ b/examples/pom-standalone-lgpl.xml
@@ -113,10 +113,6 @@
                 <java.ver>1.8</java.ver>
             </properties>
 
-            <activation>
-                <jdk>[1.8,)</jdk>
-            </activation>
-
             <dependencies>
                 <dependency>
                     <groupId>org.apache.ignite</groupId>

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/pom-standalone.xml
----------------------------------------------------------------------
diff --git a/examples/pom-standalone.xml b/examples/pom-standalone.xml
index 64b4301..0183563 100644
--- a/examples/pom-standalone.xml
+++ b/examples/pom-standalone.xml
@@ -113,10 +113,6 @@
                 <java.ver>1.8</java.ver>
             </properties>
 
-            <activation>
-                <jdk>[1.8,)</jdk>
-            </activation>
-
             <dependencies>
                 <dependency>
                     <groupId>org.apache.ignite</groupId>

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index b933385..895519b 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -260,10 +260,6 @@
                 <ml.folder>src/main/ml</ml.folder>
             </properties>
 
-            <activation>
-                <jdk>[1.8,)</jdk>
-            </activation>
-
             <build>
                 <plugins>
                     <plugin>

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/CholeskyDecompositionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/CholeskyDecompositionExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/CholeskyDecompositionExample.java
index 07308f5..ebac2b1 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/CholeskyDecompositionExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/CholeskyDecompositionExample.java
@@ -17,10 +17,10 @@
 
 package org.apache.ignite.examples.ml.math.decompositions;
 
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Tracer;
-import org.apache.ignite.math.decompositions.CholeskyDecomposition;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Tracer;
+import org.apache.ignite.ml.math.decompositions.CholeskyDecomposition;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
 
 /**
  * Example of using {@link CholeskyDecomposition}.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/EigenDecompositionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/EigenDecompositionExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/EigenDecompositionExample.java
index 16e692b..cda37f4 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/EigenDecompositionExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/EigenDecompositionExample.java
@@ -17,10 +17,10 @@
 
 package org.apache.ignite.examples.ml.math.decompositions;
 
-import org.apache.ignite.math.Tracer;
-import org.apache.ignite.math.decompositions.EigenDecomposition;
-import org.apache.ignite.math.functions.Functions;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.Tracer;
+import org.apache.ignite.ml.math.decompositions.EigenDecomposition;
+import org.apache.ignite.ml.math.functions.Functions;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
 
 /**
  * Example of using {@link EigenDecomposition}.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/LUDecompositionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/LUDecompositionExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/LUDecompositionExample.java
index c670eab..a815047 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/LUDecompositionExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/LUDecompositionExample.java
@@ -17,10 +17,10 @@
 
 package org.apache.ignite.examples.ml.math.decompositions;
 
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Tracer;
-import org.apache.ignite.math.decompositions.LUDecomposition;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Tracer;
+import org.apache.ignite.ml.math.decompositions.LUDecomposition;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
 
 /**
  * Example of using {@link LUDecomposition}.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/SingularValueDecompositionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/SingularValueDecompositionExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/SingularValueDecompositionExample.java
index 281fbc4..81406ae 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/SingularValueDecompositionExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/SingularValueDecompositionExample.java
@@ -17,9 +17,9 @@
 
 package org.apache.ignite.examples.ml.math.decompositions;
 
-import org.apache.ignite.math.Tracer;
-import org.apache.ignite.math.decompositions.SingularValueDecomposition;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.Tracer;
+import org.apache.ignite.ml.math.decompositions.SingularValueDecomposition;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
 
 /**
  * Example of using {@link SingularValueDecomposition}.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/CacheMatrixExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/CacheMatrixExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/CacheMatrixExample.java
index 80f861f..ec414e5 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/CacheMatrixExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/CacheMatrixExample.java
@@ -21,11 +21,11 @@ import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.math.IdentityValueMapper;
-import org.apache.ignite.math.MatrixKeyMapper;
-import org.apache.ignite.math.ValueMapper;
-import org.apache.ignite.math.functions.Functions;
-import org.apache.ignite.math.impls.matrix.CacheMatrix;
+import org.apache.ignite.ml.math.IdentityValueMapper;
+import org.apache.ignite.ml.math.MatrixKeyMapper;
+import org.apache.ignite.ml.math.ValueMapper;
+import org.apache.ignite.ml.math.functions.Functions;
+import org.apache.ignite.ml.math.impls.matrix.CacheMatrix;
 
 /** */
 public class CacheMatrixExample {

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.java
index d0c8604..5fb06d7 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.java
@@ -22,10 +22,10 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Arrays;
 
-import org.apache.ignite.math.MatrixStorage;
+import org.apache.ignite.ml.math.MatrixStorage;
 
 /**
- * Example matrix storage, modeled after {@link org.apache.ignite.math.impls.storage.matrix.ArrayMatrixStorage}.
+ * Example matrix storage, modeled after {@link org.apache.ignite.ml.math.impls.storage.matrix.ArrayMatrixStorage}.
  */
 class ExampleMatrixStorage implements MatrixStorage {
     /** Backing data array. */

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixCustomStorageExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixCustomStorageExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixCustomStorageExample.java
index b3df9f1..76716cc 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixCustomStorageExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixCustomStorageExample.java
@@ -17,11 +17,11 @@
 
 package org.apache.ignite.examples.ml.math.matrix;
 
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.matrix.AbstractMatrix;
-import org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.matrix.AbstractMatrix;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
 
 /**
  * This example shows how to use {@link Matrix} API based on custom {@link MatrixStorage}.
@@ -82,7 +82,7 @@ public final class MatrixCustomStorageExample {
 
     /**
      * Example of vector with custom storage, modeled after
-     * {@link org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix}.
+     * {@link org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix}.
      */
     static class MatrixCustomStorage extends AbstractMatrix {
         /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixExample.java
index 66f50d5..66db374 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixExample.java
@@ -17,8 +17,8 @@
 
 package org.apache.ignite.examples.ml.math.matrix;
 
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
 
 /**
  * This example shows how to use {@link Matrix} API.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixExampleUtil.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixExampleUtil.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixExampleUtil.java
index bf406a8..af12e15 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixExampleUtil.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixExampleUtil.java
@@ -17,8 +17,8 @@
 
 package org.apache.ignite.examples.ml.math.matrix;
 
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Tracer;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Tracer;
 
 /**
  * Utility functions for {@link Matrix} API examples.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/OffHeapMatrixExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/OffHeapMatrixExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/OffHeapMatrixExample.java
index 71dc2b8..f743bd9 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/OffHeapMatrixExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/OffHeapMatrixExample.java
@@ -17,8 +17,8 @@
 
 package org.apache.ignite.examples.ml.math.matrix;
 
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.impls.matrix.DenseLocalOffHeapMatrix;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOffHeapMatrix;
 
 /**
  * This example shows how to use off-heap {@link Matrix} API.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/SparseDistributedMatrixExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/SparseDistributedMatrixExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/SparseDistributedMatrixExample.java
index ffbd9af..1e5f099 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/SparseDistributedMatrixExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/SparseDistributedMatrixExample.java
@@ -14,12 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.ignite.examples.ml.math.matrix;
 
 import org.apache.ignite.Ignite;
 import org.apache.ignite.Ignition;
-import org.apache.ignite.math.StorageConstants;
-import org.apache.ignite.math.impls.matrix.SparseDistributedMatrix;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
 import org.apache.ignite.thread.IgniteThread;
 
 /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/SparseMatrixExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/SparseMatrixExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/SparseMatrixExample.java
index d63d985..d3715ea 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/SparseMatrixExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/SparseMatrixExample.java
@@ -17,8 +17,8 @@
 
 package org.apache.ignite.examples.ml.math.matrix;
 
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.impls.matrix.SparseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.SparseLocalOnHeapMatrix;
 
 /**
  * This example shows how to use sparse {@link Matrix} API.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/tracer/TracerExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/tracer/TracerExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/tracer/TracerExample.java
index 0bf7743..085153c 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/tracer/TracerExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/tracer/TracerExample.java
@@ -19,8 +19,8 @@ package org.apache.ignite.examples.ml.math.tracer;
 
 import java.awt.Color;
 import java.io.IOException;
-import org.apache.ignite.math.Tracer;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.Tracer;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
 
 /**
  * Example of using {@link Tracer} utility API.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/CacheVectorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/CacheVectorExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/CacheVectorExample.java
index 3e83ef5..789248c 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/CacheVectorExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/CacheVectorExample.java
@@ -21,10 +21,10 @@ import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.math.IdentityValueMapper;
-import org.apache.ignite.math.ValueMapper;
-import org.apache.ignite.math.VectorKeyMapper;
-import org.apache.ignite.math.impls.vector.CacheVector;
+import org.apache.ignite.ml.math.IdentityValueMapper;
+import org.apache.ignite.ml.math.ValueMapper;
+import org.apache.ignite.ml.math.VectorKeyMapper;
+import org.apache.ignite.ml.math.impls.vector.CacheVector;
 
 /**
  * This example shows how to use {@link CacheVector} API.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/ExampleVectorStorage.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/ExampleVectorStorage.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/ExampleVectorStorage.java
index b382c46..bc46b63 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/ExampleVectorStorage.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/ExampleVectorStorage.java
@@ -22,10 +22,10 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Arrays;
 
-import org.apache.ignite.math.VectorStorage;
+import org.apache.ignite.ml.math.VectorStorage;
 
 /**
- * Example vector storage, modeled after {@link org.apache.ignite.math.impls.storage.vector.ArrayVectorStorage}.
+ * Example vector storage, modeled after {@link org.apache.ignite.ml.math.impls.storage.vector.ArrayVectorStorage}.
  */
 class ExampleVectorStorage implements VectorStorage {
     /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/OffHeapVectorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/OffHeapVectorExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/OffHeapVectorExample.java
index 031843b..f470aef 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/OffHeapVectorExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/OffHeapVectorExample.java
@@ -18,8 +18,8 @@
 package org.apache.ignite.examples.ml.math.vector;
 
 import java.util.Arrays;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.vector.DenseLocalOffHeapVector;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOffHeapVector;
 
 /**
  * This example shows how to use off-heap {@link Vector} API.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/SparseVectorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/SparseVectorExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/SparseVectorExample.java
index f5678f6..8ace55b 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/SparseVectorExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/SparseVectorExample.java
@@ -18,10 +18,10 @@
 package org.apache.ignite.examples.ml.math.vector;
 
 import java.util.Arrays;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.vector.SparseLocalVector;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.vector.SparseLocalVector;
 
-import static org.apache.ignite.math.StorageConstants.RANDOM_ACCESS_MODE;
+import static org.apache.ignite.ml.math.StorageConstants.RANDOM_ACCESS_MODE;
 
 /**
  * This example shows how to use sparse {@link Vector} API.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/VectorCustomStorageExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/VectorCustomStorageExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/VectorCustomStorageExample.java
index 2d549ae..a7204ad 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/VectorCustomStorageExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/VectorCustomStorageExample.java
@@ -18,11 +18,11 @@
 package org.apache.ignite.examples.ml.math.vector;
 
 import java.util.Arrays;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.math.impls.vector.AbstractVector;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.impls.vector.AbstractVector;
 
 /**
  * This example shows how to use {@link Vector} based on custom {@link VectorStorage}.
@@ -78,7 +78,7 @@ public final class VectorCustomStorageExample {
 
     /**
      * Example of vector with custom storage, modeled after
-     * {@link org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector}.
+     * {@link org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector}.
      */
     static class VectorCustomStorage extends AbstractVector {
         /**
@@ -118,7 +118,7 @@ public final class VectorCustomStorageExample {
 
         /** {@inheritDoc */
         @Override public Vector like(int crd) {
-            return new org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector(crd);
+            return new org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector(crd);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/VectorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/VectorExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/VectorExample.java
index d6971a7..3390de5 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/VectorExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/VectorExample.java
@@ -18,8 +18,8 @@
 package org.apache.ignite.examples.ml.math.vector;
 
 import java.util.Arrays;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
 
 /**
  * This example shows how to use {@link Vector} API.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/pom.xml
----------------------------------------------------------------------
diff --git a/modules/ml/pom.xml b/modules/ml/pom.xml
index 4755a2c..e6f5acb 100644
--- a/modules/ml/pom.xml
+++ b/modules/ml/pom.xml
@@ -100,10 +100,4 @@
             </plugin>
         </plugins>
     </build>
-
-    <profiles>
-        <profile>
-            <id>math</id>
-        </profile>
-    </profiles>
 </project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/Algebra.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/Algebra.java b/modules/ml/src/main/java/org/apache/ignite/math/Algebra.java
deleted file mode 100644
index 6bfd608..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/Algebra.java
+++ /dev/null
@@ -1,571 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
-Copyright 1999 CERN - European Organization for Nuclear Research.
-Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
-is hereby granted without fee, provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear in supporting documentation.
-CERN makes no representations about the suitability of this software for any purpose.
-It is provided "as is" without expressed or implied warranty.
-*/
-
-package org.apache.ignite.math;
-
-/**
- * Miscellaneous arithmetic and algebra functions.
- * Lifted from Apache Mahout.
- */
-public class Algebra extends Constants {
-    /** */ private static final double[] STIRLING_CORRECTION = {
-        0.0,
-        8.106146679532726e-02, 4.134069595540929e-02,
-        2.767792568499834e-02, 2.079067210376509e-02,
-        1.664469118982119e-02, 1.387612882307075e-02,
-        1.189670994589177e-02, 1.041126526197209e-02,
-        9.255462182712733e-03, 8.330563433362871e-03,
-        7.573675487951841e-03, 6.942840107209530e-03,
-        6.408994188004207e-03, 5.951370112758848e-03,
-        5.554733551962801e-03, 5.207655919609640e-03,
-        4.901395948434738e-03, 4.629153749334029e-03,
-        4.385560249232324e-03, 4.166319691996922e-03,
-        3.967954218640860e-03, 3.787618068444430e-03,
-        3.622960224683090e-03, 3.472021382978770e-03,
-        3.333155636728090e-03, 3.204970228055040e-03,
-        3.086278682608780e-03, 2.976063983550410e-03,
-        2.873449362352470e-03, 2.777674929752690e-03,
-    };
-
-    /** */ private static final double[] LOG_FACTORIALS = {
-        0.00000000000000000, 0.00000000000000000, 0.69314718055994531,
-        1.79175946922805500, 3.17805383034794562, 4.78749174278204599,
-        6.57925121201010100, 8.52516136106541430, 10.60460290274525023,
-        12.80182748008146961, 15.10441257307551530, 17.50230784587388584,
-        19.98721449566188615, 22.55216385312342289, 25.19122118273868150,
-        27.89927138384089157, 30.67186010608067280, 33.50507345013688888,
-        36.39544520803305358, 39.33988418719949404, 42.33561646075348503,
-        45.38013889847690803, 48.47118135183522388, 51.60667556776437357,
-        54.78472939811231919, 58.00360522298051994, 61.26170176100200198,
-        64.55753862700633106, 67.88974313718153498, 71.25703896716800901
-    };
-
-    /** */ private static final long[] LONG_FACTORIALS = {
-        1L,
-        1L,
-        2L,
-        6L,
-        24L,
-        120L,
-        720L,
-        5040L,
-        40320L,
-        362880L,
-        3628800L,
-        39916800L,
-        479001600L,
-        6227020800L,
-        87178291200L,
-        1307674368000L,
-        20922789888000L,
-        355687428096000L,
-        6402373705728000L,
-        121645100408832000L,
-        2432902008176640000L
-    };
-
-    /** */ private static final double[] DOUBLE_FACTORIALS = {
-        5.109094217170944E19,
-        1.1240007277776077E21,
-        2.585201673888498E22,
-        6.204484017332394E23,
-        1.5511210043330984E25,
-        4.032914611266057E26,
-        1.0888869450418352E28,
-        3.048883446117138E29,
-        8.841761993739701E30,
-        2.652528598121911E32,
-        8.222838654177924E33,
-        2.6313083693369355E35,
-        8.68331761881189E36,
-        2.952327990396041E38,
-        1.0333147966386144E40,
-        3.719933267899013E41,
-        1.3763753091226346E43,
-        5.23022617466601E44,
-        2.0397882081197447E46,
-        8.15915283247898E47,
-        3.34525266131638E49,
-        1.4050061177528801E51,
-        6.041526306337384E52,
-        2.6582715747884495E54,
-        1.196222208654802E56,
-        5.502622159812089E57,
-        2.5862324151116827E59,
-        1.2413915592536068E61,
-        6.082818640342679E62,
-        3.0414093201713376E64,
-        1.5511187532873816E66,
-        8.06581751709439E67,
-        4.274883284060024E69,
-        2.308436973392413E71,
-        1.2696403353658264E73,
-        7.109985878048632E74,
-        4.052691950487723E76,
-        2.350561331282879E78,
-        1.386831185456898E80,
-        8.32098711274139E81,
-        5.075802138772246E83,
-        3.146997326038794E85,
-        1.9826083154044396E87,
-        1.2688693218588414E89,
-        8.247650592082472E90,
-        5.443449390774432E92,
-        3.6471110918188705E94,
-        2.48003554243683E96,
-        1.7112245242814127E98,
-        1.1978571669969892E100,
-        8.504785885678624E101,
-        6.123445837688612E103,
-        4.470115461512686E105,
-        3.307885441519387E107,
-        2.4809140811395404E109,
-        1.8854947016660506E111,
-        1.451830920282859E113,
-        1.1324281178206295E115,
-        8.94618213078298E116,
-        7.15694570462638E118,
-        5.797126020747369E120,
-        4.7536433370128435E122,
-        3.94552396972066E124,
-        3.314240134565354E126,
-        2.8171041143805494E128,
-        2.4227095383672744E130,
-        2.107757298379527E132,
-        1.854826422573984E134,
-        1.6507955160908465E136,
-        1.4857159644817605E138,
-        1.3520015276784033E140,
-        1.2438414054641305E142,
-        1.156772507081641E144,
-        1.0873661566567426E146,
-        1.0329978488239061E148,
-        9.916779348709491E149,
-        9.619275968248216E151,
-        9.426890448883248E153,
-        9.332621544394415E155,
-        9.332621544394418E157,
-        9.42594775983836E159,
-        9.614466715035125E161,
-        9.902900716486178E163,
-        1.0299016745145631E166,
-        1.0813967582402912E168,
-        1.1462805637347086E170,
-        1.2265202031961373E172,
-        1.324641819451829E174,
-        1.4438595832024942E176,
-        1.5882455415227423E178,
-        1.7629525510902457E180,
-        1.974506857221075E182,
-        2.2311927486598138E184,
-        2.543559733472186E186,
-        2.925093693493014E188,
-        3.393108684451899E190,
-        3.96993716080872E192,
-        4.6845258497542896E194,
-        5.574585761207606E196,
-        6.689502913449135E198,
-        8.094298525273444E200,
-        9.875044200833601E202,
-        1.2146304367025332E205,
-        1.506141741511141E207,
-        1.882677176888926E209,
-        2.3721732428800483E211,
-        3.0126600184576624E213,
-        3.856204823625808E215,
-        4.974504222477287E217,
-        6.466855489220473E219,
-        8.471580690878813E221,
-        1.1182486511960037E224,
-        1.4872707060906847E226,
-        1.99294274616152E228,
-        2.690472707318049E230,
-        3.6590428819525483E232,
-        5.0128887482749884E234,
-        6.917786472619482E236,
-        9.615723196941089E238,
-        1.3462012475717523E241,
-        1.8981437590761713E243,
-        2.6953641378881633E245,
-        3.8543707171800694E247,
-        5.550293832739308E249,
-        8.047926057471989E251,
-        1.1749972043909107E254,
-        1.72724589045464E256,
-        2.5563239178728637E258,
-        3.8089226376305687E260,
-        5.7133839564458575E262,
-        8.627209774233244E264,
-        1.3113358856834527E267,
-        2.0063439050956838E269,
-        3.0897696138473515E271,
-        4.789142901463393E273,
-        7.471062926282892E275,
-        1.1729568794264134E278,
-        1.8532718694937346E280,
-        2.946702272495036E282,
-        4.714723635992061E284,
-        7.590705053947223E286,
-        1.2296942187394494E289,
-        2.0044015765453032E291,
-        3.287218585534299E293,
-        5.423910666131583E295,
-        9.003691705778434E297,
-        1.5036165148649983E300,
-        2.5260757449731988E302,
-        4.2690680090047056E304,
-        7.257415615308004E306
-    };
-
-    /**
-     * Efficiently returns the binomial coefficient, often also referred to as
-     * "n over k" or "n choose k". The binomial coefficient is defined as
-     * {@code (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )}.
-     * <ul> <li>{@code k&lt;0}: {@code 0}.</li>
-     * <li>{@code k==0}: {@code 1}.</li>
-     * <li>{@code k==1}: {@code n}.</li>
-     * <li>else: {@code (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k)}.</li>
-     * </ul>
-     *
-     * @param n
-     * @param k
-     * @return Binomial coefficient.
-     */
-    public static double binomial(double n, long k) {
-        if (k < 0)
-            return 0;
-
-        if (k == 0)
-            return 1;
-
-        if (k == 1)
-            return n;
-
-        // binomial(n,k) = (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )
-        double a = n - k + 1;
-        double b = 1;
-        double binomial = 1;
-
-        for (long i = k; i-- > 0; )
-            binomial *= (a++) / (b++);
-
-        return binomial;
-    }
-
-    /**
-     * Efficiently returns the binomial coefficient, often also referred to as "n over k" or "n choose k".
-     * The binomial coefficient is defined as
-     * <ul> <li>{@code k&lt;0}: {@code 0}. <li>{@code k==0 || k==n}: {@code 1}. <li>{@code k==1 || k==n-1}:
-     * {@code n}. <li>else: {@code (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )}. </ul>
-     *
-     * @param n
-     * @param k
-     * @return Binomial coefficient.
-     */
-    public static double binomial(long n, long k) {
-        if (k < 0)
-            return 0;
-
-        if (k == 0 || k == n)
-            return 1;
-
-        if (k == 1 || k == n - 1)
-            return n;
-
-        if (n > k) {
-            int max = LONG_FACTORIALS.length + DOUBLE_FACTORIALS.length;
-
-            if (n < max) {
-                double nFac = factorial((int)n);
-                double kFac = factorial((int)k);
-                double nMinusKFac = factorial((int)(n - k));
-                double nk = nMinusKFac * kFac;
-
-                if (nk != Double.POSITIVE_INFINITY) // No numeric overflow?
-                    return nFac / nk;
-            }
-
-            if (k > n / 2)
-                k = n - k;
-        }
-
-        // binomial(n,k) = (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )
-        long a = n - k + 1;
-        long b = 1;
-        double binomial = 1;
-
-        for (long i = k; i-- > 0; )
-            binomial *= (double)a++ / (b++);
-
-        return binomial;
-    }
-
-    /**
-     * Returns the smallest <code>long &gt;= value</code>.
-     * <dl><dt>Examples: {@code 1.0 -> 1, 1.2 -> 2, 1.9 -> 2}. This
-     * method is safer than using (long) Math.ceil(value), because of possible rounding error.</dt></dl>
-     *
-     * @param val
-     */
-    public static long ceil(double val) {
-        return Math.round(Math.ceil(val));
-    }
-
-    /**
-     * Evaluates the series of Chebyshev polynomials Ti at argument x/2. The series is given by
-     * <pre>
-     *        N-1
-     *         - '
-     *  y  =   &gt;   coef[i] T (x/2)
-     *         -            i
-     *        i=0
-     * </pre>
-     * Coefficients are stored in reverse order, i.e. the zero order term is last in the array.  Note N is the number of
-     * coefficients, not the order. <p> If coefficients are for the interval a to b, x must have been transformed to x
-     * -&lt; 2(2x - b - a)/(b-a) before entering the routine.  This maps x from (a, b) to (-1, 1), over which the
-     * Chebyshev polynomials are defined. <p> If the coefficients are for the inverted interval, in which (a, b) is
-     * mapped to (1/b, 1/a), the transformation required is {@code x -> 2(2ab/x - b - a)/(b-a)}.  If b is infinity, this
-     * becomes {@code x -> 4a/x - 1}. <p> SPEED: <p> Taking advantage of the recurrence properties of the Chebyshev
-     * polynomials, the routine requires one more addition per loop than evaluating a nested polynomial of the same
-     * degree.
-     *
-     * @param x Argument to the polynomial.
-     * @param coef Coefficients of the polynomial.
-     * @param N Number of coefficients.
-     */
-    public static double chbevl(double x, double[] coef, int N) {
-        int p = 0;
-
-        double b0 = coef[p++];
-        double b1 = 0.0;
-        int i = N - 1;
-
-        double b2;
-
-        do {
-            b2 = b1;
-            b1 = b0;
-            b0 = x * b1 - b2 + coef[p++];
-        }
-        while (--i > 0);
-
-        return 0.5 * (b0 - b2);
-    }
-
-    /**
-     * Instantly returns the factorial {@code k!}.
-     *
-     * @param k must hold {@code k &gt;= 0}.
-     */
-    private static double factorial(int k) {
-        if (k < 0)
-            throw new IllegalArgumentException();
-
-        int len1 = LONG_FACTORIALS.length;
-
-        if (k < len1)
-            return LONG_FACTORIALS[k];
-
-        int len2 = DOUBLE_FACTORIALS.length;
-
-        return (k < len1 + len2) ? DOUBLE_FACTORIALS[k - len1] : Double.POSITIVE_INFINITY;
-    }
-
-    /**
-     * Returns the largest <code>long &lt;= value</code>.
-     * <dl><dt>Examples: {@code 1.0 -> 1, 1.2 -> 1, 1.9 -> 1 <dt> 2.0 -> 2, 2.2 -> 2, 2.9 -> 2}</dt></dl>
-     * This method is safer than using (long) Math.floor(value), because of possible rounding error.
-     */
-    public static long floor(double val) {
-        return Math.round(Math.floor(val));
-    }
-
-    /**
-     * Returns {@code log<sub>base</sub>value}.
-     */
-    public static double log(double base, double val) {
-        return Math.log(val) / Math.log(base);
-    }
-
-    /**
-     * Returns {@code log<sub>10</sub>value}.
-     */
-    public static double log10(double val) {
-        // 1.0 / Math.log(10) == 0.43429448190325176
-        return Math.log(val) * 0.43429448190325176;
-    }
-
-    /**
-     * Returns {@code log<sub>2</sub>value}.
-     */
-    public static double log2(double val) {
-        // 1.0 / Math.log(2) == 1.4426950408889634
-        return Math.log(val) * 1.4426950408889634;
-    }
-
-    /**
-     * Returns {@code log(k!)}. Tries to avoid overflows. For {@code k&lt;30} simply looks up a table in O(1).
-     * For {@code k&gt;=30} uses stirlings approximation.
-     *
-     * @param k must hold {@code k &gt;= 0}.
-     */
-    public static double logFactorial(int k) {
-        if (k >= 30) {
-            double r = 1.0 / k;
-            double rr = r * r;
-            double C7 = -5.95238095238095238e-04;
-            double C5 = 7.93650793650793651e-04;
-            double C3 = -2.77777777777777778e-03;
-            double C1 = 8.33333333333333333e-02;
-            double C0 = 9.18938533204672742e-01;
-
-            return (k + 0.5) * Math.log(k) - k + C0 + r * (C1 + rr * (C3 + rr * (C5 + rr * C7)));
-        }
-        else
-            return LOG_FACTORIALS[k];
-    }
-
-    /**
-     * Instantly returns the factorial {@code k!}.
-     *
-     * @param k must hold {@code k >= 0 && k < 21}
-     */
-    public static long longFactorial(int k) {
-        if (k < 0)
-            throw new IllegalArgumentException("Negative k");
-
-        if (k < LONG_FACTORIALS.length)
-            return LONG_FACTORIALS[k];
-
-        throw new IllegalArgumentException("Overflow");
-    }
-
-    /**
-     * Returns the StirlingCorrection.
-     *
-     * Correction term of the Stirling approximation for {@code log(k!)} (series in
-     * 1/k, or table values for small k) with int parameter k. </p> {@code  log k! = (k + 1/2)log(k + 1) - (k + 1) +
-     * (1/2)log(2Pi) + STIRLING_CORRECTION(k + 1) log k! = (k + 1/2)log(k)     -  k      + (1/2)log(2Pi) +
-     * STIRLING_CORRECTION(k) }
-     */
-    public static double stirlingCorrection(int k) {
-        if (k > 30) {
-            double r = 1.0 / k;
-            double rr = r * r;
-            double C7 = -5.95238095238095238e-04;
-            double C5 = 7.93650793650793651e-04;
-            double C3 = -2.77777777777777778e-03;
-            double C1 = 8.33333333333333333e-02;
-
-            return r * (C1 + rr * (C3 + rr * (C5 + rr * C7)));
-        }
-        else
-            return STIRLING_CORRECTION[k];
-    }
-
-    /**
-     * Evaluates the given polynomial of degree {@code N} at {@code x}, assuming coefficient of N is 1.0. Otherwise same
-     * as {@link #evalPoly(double, double[], int)}.
-     * <pre>
-     *                     2          N
-     * y  =  C  + C x + C x  +...+ C x
-     *        0    1     2          N
-     *
-     * where C  = 1 and hence is omitted from the array.
-     *        N
-     *
-     * Coefficients are stored in reverse order:
-     *
-     * coef[0] = C  , ..., coef[N-1] = C  .
-     *            N-1                   0
-     *
-     * Calling arguments are otherwise the same as {@link #evalPoly(double, double[], int)}.
-     * </pre>
-     * In the interest of speed, there are no checks for out of bounds arithmetic.
-     *
-     * @param x Argument to the polynomial.
-     * @param coef Coefficients of the polynomial.
-     * @param n Degree of the polynomial.
-     */
-    public static double evalPoly1(double x, double[] coef, int n) {
-        double res = x + coef[0];
-
-        for (int i = 1; i < n; i++)
-            res = res * x + coef[i];
-
-        return res;
-    }
-
-    /**
-     * Evaluates the given polynomial of degree {@code N} at {@code x}.
-     * <pre>
-     *                     2          N
-     * y  =  C  + C x + C x  +...+ C x
-     *        0    1     2          N
-     *
-     * Coefficients are stored in reverse order:
-     *
-     * coef[0] = C  , ..., coef[N] = C  .
-     *            N                   0
-     * </pre>
-     * In the interest of speed, there are no checks for out of bounds arithmetic.
-     *
-     * @param x Argument to the polynomial.
-     * @param coef Coefficients of the polynomial.
-     * @param n Degree of the polynomial.
-     */
-    public static double evalPoly(double x, double[] coef, int n) {
-        double res = coef[0];
-
-        for (int i = 1; i <= n; i++)
-            res = res * x + coef[i];
-
-        return res;
-    }
-
-    /**
-     * Gets <code>sqrt(a^2 + b^2)</code> without under/overflow.
-     *
-     * @param a
-     * @param b
-     */
-    public static double hypot(double a, double b) {
-        double r;
-
-        if (Math.abs(a) > Math.abs(b)) {
-            r = b / a;
-            r = Math.abs(a) * Math.sqrt(1 + r * r);
-        }
-        else if (b != 0) {
-            r = a / b;
-            r = Math.abs(b) * Math.sqrt(1 + r * r);
-        }
-        else
-            r = 0.0;
-
-        return r;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/Constants.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/Constants.java b/modules/ml/src/main/java/org/apache/ignite/math/Constants.java
deleted file mode 100644
index 02756b6..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/Constants.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
-Copyright 1999 CERN - European Organization for Nuclear Research.
-Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
-is hereby granted without fee, provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear in supporting documentation.
-CERN makes no representations about the suitability of this software for any purpose.
-It is provided "as is" without expressed or implied warranty.
-*/
-
-package org.apache.ignite.math;
-
-/**
- * Math constants. Lifted from Apache Mahout.
- */
-public class Constants {
-    /** */ public static final double MACHEP = 1.11022302462515654042E-16;
-    /** */ public static final double MAXLOG = 7.09782712893383996732E2;
-    /** */ public static final double MINLOG = -7.451332191019412076235E2;
-    /** */ public static final double MAXGAM = 171.624376956302725;
-    /** */ public static final double SQTPI = 2.50662827463100050242E0;
-    /** */ public static final double SQRTH = 7.07106781186547524401E-1;
-    /** */ public static final double LOGPI = 1.14472988584940017414;
-    /** */ public static final double BIG = 4.503599627370496e15;
-    /** */ public static final double BIGINV = 2.22044604925031308085e-16;
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/Destroyable.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/Destroyable.java b/modules/ml/src/main/java/org/apache/ignite/math/Destroyable.java
deleted file mode 100644
index f3b467c..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/Destroyable.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-/**
- * Support for destroying objects that are managed outside of JVM.
- */
-public interface Destroyable {
-    /**
-     * Destroys object if managed outside of JVM. It's a no-op in all other cases.
-     */
-    public default void destroy() {
-        // No-op.
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/IdentityValueMapper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/IdentityValueMapper.java b/modules/ml/src/main/java/org/apache/ignite/math/IdentityValueMapper.java
deleted file mode 100644
index 65c7024..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/IdentityValueMapper.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-/**
- * Identity value mapper.
- */
-public class IdentityValueMapper implements ValueMapper<Double> {
-    /** */ private static final long serialVersionUID = -8010078306142216389L;
-
-    /** {@inheritDoc} */
-    @Override public Double fromDouble(double v) {
-        return v;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double toDouble(Double v) {
-        assert v != null;
-
-        return v;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        return Long.hashCode(serialVersionUID);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/KeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/KeyMapper.java b/modules/ml/src/main/java/org/apache/ignite/math/KeyMapper.java
deleted file mode 100644
index f4f9a39..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/KeyMapper.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-import java.io.Serializable;
-
-/**
- * Maps key objects to index in {@link Vector} or {@link Matrix}.
- */
-public interface KeyMapper<K> extends Serializable {
-    /**
-     * Checks given cache key corresponds to a valid index in vector or matrix.
-     *
-     * @param k Key to check.
-     * @return {@code true} if there is a valid index, {@code false} otherwise.
-     */
-    public boolean isValid(K k);
-}


[41/65] [abbrv] ignite git commit: IGNITE-4952 - Delete swap-related functionality - Fixes #1794.

Posted by ag...@apache.org.
IGNITE-4952 - Delete swap-related functionality - Fixes #1794.

Signed-off-by: Alexey Goncharuk <al...@gmail.com>


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

Branch: refs/heads/ignite-5024
Commit: 0da8c70ad77a57328d2ece26bfa4d9c09eef70f3
Parents: 1f382af
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Fri Apr 21 11:57:13 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Apr 21 11:57:13 2017 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/IgniteCache.java     |  11 -
 .../org/apache/ignite/events/CacheEvent.java    |   3 -
 .../java/org/apache/ignite/events/Event.java    |   1 -
 .../org/apache/ignite/events/EventType.java     | 109 -----
 .../apache/ignite/events/SwapSpaceEvent.java    | 105 ----
 .../managers/indexing/GridIndexingManager.java  |  44 --
 .../processors/cache/CacheMetricsImpl.java      |  21 -
 .../processors/cache/GridCacheContext.java      |  23 -
 .../GridCacheEntryInfoCollectSwapListener.java  |  70 ---
 .../processors/cache/GridCacheSwapListener.java |  33 --
 .../processors/cache/IgniteCacheProxy.java      |   6 -
 .../cache/query/GridCacheQueryManager.java      |  59 ---
 .../platform/PlatformContextImpl.java           |  11 -
 .../platform/cache/PlatformCache.java           |   9 -
 .../processors/query/GridQueryIndexing.java     |  19 -
 .../processors/query/GridQueryProcessor.java    |  55 ---
 .../apache/ignite/spi/indexing/IndexingSpi.java |  19 -
 .../spi/indexing/noop/NoopIndexingSpi.java      |  10 -
 .../resources/META-INF/classnames.properties    |   1 -
 .../cache/GridCacheAbstractFullApiSelfTest.java |  45 --
 .../IgniteCacheConfigVariationsFullApiTest.java |  45 --
 .../IgniteCacheStoreValueAbstractTest.java      |   4 -
 .../IgniteTxExceptionAbstractSelfTest.java      |  10 -
 ...tractDistributedByteArrayValuesSelfTest.java |  43 --
 ...tomicClientOnlyMultiNodeFullApiSelfTest.java |  51 +-
 ...achePartitionedMultiNodeFullApiSelfTest.java |  59 ---
 ...idCacheReplicatedUnswapAdvancedSelfTest.java | 151 ------
 .../cache/query/IndexingSpiQuerySelfTest.java   |  22 -
 .../cache/query/IndexingSpiQueryTxSelfTest.java |  10 -
 .../loadtests/cache/GridCacheSwapLoadTest.java  | 320 -------------
 .../multijvm/IgniteCacheProcessProxy.java       |   5 -
 .../testsuites/IgniteCacheTestSuite3.java       |   2 -
 .../processors/query/h2/IgniteH2Indexing.java   |  67 ---
 .../query/h2/opt/GridH2AbstractKeyValueRow.java |  89 +---
 .../query/h2/opt/GridH2KeyValueRowOffheap.java  |  70 ---
 .../query/h2/opt/GridH2RowDescriptor.java       |  11 -
 .../processors/query/h2/opt/GridH2Table.java    |  87 +---
 ...ryDuplicateIndexObjectsAbstractSelfTest.java | 159 -------
 .../cache/GridCacheOffHeapSelfTest.java         | 476 -------------------
 .../IgniteCacheQueryMultiThreadedSelfTest.java  |  25 -
 ...ateIndexObjectPartitionedAtomicSelfTest.java |  38 --
 ...xObjectPartitionedTransactionalSelfTest.java |  41 --
 .../query/IgniteQueryDedicatedPoolTest.java     |  10 -
 .../IgniteBinaryCacheQueryTestSuite.java        |   5 -
 .../stream/kafka/connect/IgniteSourceTask.java  |   4 -
 .../Cache/CacheAbstractTest.cs                  |  58 ---
 .../Cache/CacheTestAsyncWrapper.cs              |   6 -
 .../dotnet/Apache.Ignite.Core/Cache/ICache.cs   |   6 -
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |   8 -
 .../Apache.Ignite.Core/Impl/Cache/CacheOp.cs    |   1 -
 50 files changed, 3 insertions(+), 2534 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index 97bb6b0..9c8c090 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -429,17 +429,6 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
     public V localPeek(K key, CachePeekMode... peekModes);
 
     /**
-     * This method unswaps cache entries by given keys, if any, from swap storage
-     * into memory.
-     * <h2 class="header">Transactions</h2>
-     * This method is not transactional.
-     *
-     * @param keys Keys to promote entries for.
-     * @throws CacheException If promote failed.
-     */
-    public void localPromote(Set<? extends K> keys) throws CacheException;
-
-    /**
      * Gets the number of all entries cached across all nodes. By default, if {@code peekModes} value isn't defined,
      * only size of primary copies across all nodes will be returned. This behavior is identical to calling
      * this method with {@link CachePeekMode#PRIMARY} peek mode.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/events/CacheEvent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/events/CacheEvent.java b/modules/core/src/main/java/org/apache/ignite/events/CacheEvent.java
index 30f4b37..5aa9d06 100644
--- a/modules/core/src/main/java/org/apache/ignite/events/CacheEvent.java
+++ b/modules/core/src/main/java/org/apache/ignite/events/CacheEvent.java
@@ -69,14 +69,11 @@ import org.jetbrains.annotations.Nullable;
  * @see EventType#EVT_CACHE_ENTRY_DESTROYED
  * @see EventType#EVT_CACHE_ENTRY_EVICTED
  * @see EventType#EVT_CACHE_OBJECT_EXPIRED
- * @see EventType#EVT_CACHE_OBJECT_FROM_OFFHEAP
  * @see EventType#EVT_CACHE_OBJECT_LOCKED
  * @see EventType#EVT_CACHE_OBJECT_PUT
  * @see EventType#EVT_CACHE_OBJECT_READ
  * @see EventType#EVT_CACHE_OBJECT_REMOVED
- * @see EventType#EVT_CACHE_OBJECT_SWAPPED
  * @see EventType#EVT_CACHE_OBJECT_UNLOCKED
- * @see EventType#EVT_CACHE_OBJECT_UNSWAPPED
  * @see EventType#EVTS_CACHE
  */
 public class CacheEvent extends EventAdapter {

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/events/Event.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/events/Event.java b/modules/core/src/main/java/org/apache/ignite/events/Event.java
index 9ba24ab..e4a02cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/events/Event.java
+++ b/modules/core/src/main/java/org/apache/ignite/events/Event.java
@@ -75,7 +75,6 @@ import org.jetbrains.annotations.Nullable;
  * @see JobEvent
  * @see CacheEvent
  * @see CacheRebalancingEvent
- * @see SwapSpaceEvent
  * @see CheckpointEvent
  * @see DeploymentEvent
  * @see DiscoveryEvent

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/events/EventType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/events/EventType.java b/modules/core/src/main/java/org/apache/ignite/events/EventType.java
index 103dbd4..e506371 100644
--- a/modules/core/src/main/java/org/apache/ignite/events/EventType.java
+++ b/modules/core/src/main/java/org/apache/ignite/events/EventType.java
@@ -43,7 +43,6 @@ import org.apache.ignite.lang.IgnitePredicate;
  * <li>{@link #EVTS_ERROR}</li>
  * <li>{@link #EVTS_IGFS}</li>
  * <li>{@link #EVTS_JOB_EXECUTION}</li>
- * <li>{@link #EVTS_SWAPSPACE}</li>
  * <li>{@link #EVTS_TASK_EXECUTION}</li>
  * </ul>
  * <p>
@@ -495,26 +494,6 @@ public interface EventType {
      public static final int EVT_CACHE_OBJECT_UNLOCKED = 67;
 
     /**
-     * Built-in event type: cache object swapped from swap storage.
-     * <p>
-     * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
-     * internal Ignite events and should not be used by user-defined events.
-     *
-     * @see CacheEvent
-     */
-    public static final int EVT_CACHE_OBJECT_SWAPPED = 68;
-
-    /**
-     * Built-in event type: cache object unswapped from swap storage.
-     * <p>
-     * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
-     * internal Ignite events and should not be used by user-defined events.
-     *
-     * @see CacheEvent
-     */
-    public static final int EVT_CACHE_OBJECT_UNSWAPPED = 69;
-
-    /**
      * Built-in event type: cache object was expired when reading it.
      * <p>
      * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
@@ -523,77 +502,6 @@ public interface EventType {
      * @see CacheEvent
      */
     public static final int EVT_CACHE_OBJECT_EXPIRED = 70;
-
-    /**
-     * Built-in event type: swap space data read.
-     * <p>
-     * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
-     * internal Ignite events and should not be used by user-defined events.
-     *
-     * @see SwapSpaceEvent
-     */
-    public static final int EVT_SWAP_SPACE_DATA_READ = 71;
-
-    /**
-     * Built-in event type: swap space data stored.
-     * <p>
-     * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
-     * internal Ignite events and should not be used by user-defined events.
-     *
-     * @see SwapSpaceEvent
-     */
-    public static final int EVT_SWAP_SPACE_DATA_STORED = 72;
-
-    /**
-     * Built-in event type: swap space data removed.
-     * <p>
-     * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
-     * internal Ignite events and should not be used by user-defined events.
-     *
-     * @see SwapSpaceEvent
-     */
-    public static final int EVT_SWAP_SPACE_DATA_REMOVED = 73;
-
-    /**
-     * Built-in event type: swap space cleared.
-     * <p>
-     * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
-     * internal Ignite events and should not be used by user-defined events.
-     *
-     * @see SwapSpaceEvent
-     */
-    public static final int EVT_SWAP_SPACE_CLEARED = 74;
-
-    /**
-     * Built-in event type: swap space data evicted.
-     * <p>
-     * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
-     * internal Ignite events and should not be used by user-defined events.
-     *
-     * @see SwapSpaceEvent
-     */
-    public static final int EVT_SWAP_SPACE_DATA_EVICTED = 75;
-
-    /**
-     * Built-in event type: cache object stored in off-heap storage.
-     * <p>
-     * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
-     * internal Ignite events and should not be used by user-defined events.
-     *
-     * @see CacheEvent
-     */
-    public static final int EVT_CACHE_OBJECT_TO_OFFHEAP = 76;
-
-    /**
-     * Built-in event type: cache object moved from off-heap storage back into memory.
-     * <p>
-     * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
-     * internal Ignite events and should not be used by user-defined events.
-     *
-     * @see CacheEvent
-     */
-    public static final int EVT_CACHE_OBJECT_FROM_OFFHEAP = 77;
-
     /**
      * Built-in event type: cache rebalance started.
      * <p>
@@ -994,8 +902,6 @@ public interface EventType {
         EVT_CACHE_OBJECT_REMOVED,
         EVT_CACHE_OBJECT_LOCKED,
         EVT_CACHE_OBJECT_UNLOCKED,
-        EVT_CACHE_OBJECT_SWAPPED,
-        EVT_CACHE_OBJECT_UNSWAPPED,
         EVT_CACHE_OBJECT_EXPIRED
     };
 
@@ -1036,21 +942,6 @@ public interface EventType {
     };
 
     /**
-     * All swap space events. This array can be directly passed into
-     * {@link IgniteEvents#localListen(IgnitePredicate, int...)} method to
-     * subscribe to all cloud events.
-     *
-     * @see SwapSpaceEvent
-     */
-    public static final int[] EVTS_SWAPSPACE = {
-        EVT_SWAP_SPACE_CLEARED,
-        EVT_SWAP_SPACE_DATA_REMOVED,
-        EVT_SWAP_SPACE_DATA_READ,
-        EVT_SWAP_SPACE_DATA_STORED,
-        EVT_SWAP_SPACE_DATA_EVICTED
-    };
-
-    /**
      * All Igfs events. This array can be directly passed into
      * {@link IgniteEvents#localListen(IgnitePredicate, int...)} method to
      * subscribe to all cloud events.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/events/SwapSpaceEvent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/events/SwapSpaceEvent.java b/modules/core/src/main/java/org/apache/ignite/events/SwapSpaceEvent.java
deleted file mode 100644
index 8e7d9e5..0000000
--- a/modules/core/src/main/java/org/apache/ignite/events/SwapSpaceEvent.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.events;
-
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Grid swap space event.
- * <p>
- * Grid events are used for notification about what happens within the grid. Note that by
- * design Ignite keeps all events generated on the local node locally and it provides
- * APIs for performing a distributed queries across multiple nodes:
- * <ul>
- *      <li>
- *          {@link org.apache.ignite.IgniteEvents#remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)} -
- *          asynchronously querying events occurred on the nodes specified, including remote nodes.
- *      </li>
- *      <li>
- *          {@link org.apache.ignite.IgniteEvents#localQuery(org.apache.ignite.lang.IgnitePredicate, int...)} -
- *          querying only local events stored on this local node.
- *      </li>
- *      <li>
- *          {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} -
- *          listening to local grid events (events from remote nodes not included).
- *      </li>
- * </ul>
- * User can also wait for events using method {@link org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)}.
- * <h1 class="header">Events and Performance</h1>
- * Note that by default all events in Ignite are enabled and therefore generated and stored
- * by whatever event storage SPI is configured. Ignite can and often does generate thousands events per seconds
- * under the load and therefore it creates a significant additional load on the system. If these events are
- * not needed by the application this load is unnecessary and leads to significant performance degradation.
- * <p>
- * It is <b>highly recommended</b> to enable only those events that your application logic requires
- * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in Ignite configuration. Note that certain
- * events are required for Ignite's internal operations and such events will still be generated but not stored by
- * event storage SPI if they are disabled in Ignite configuration.
- * @see EventType#EVT_SWAP_SPACE_DATA_READ
- * @see EventType#EVT_SWAP_SPACE_DATA_STORED
- * @see EventType#EVT_SWAP_SPACE_DATA_REMOVED
- * @see EventType#EVT_SWAP_SPACE_CLEARED
- * @see EventType#EVT_SWAP_SPACE_DATA_EVICTED
- */
-public class SwapSpaceEvent extends EventAdapter {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Swap space name. */
-    private String space;
-
-    /**
-     * Creates swap space event.
-     *
-     * @param node Node.
-     * @param msg Optional message.
-     * @param type Event type.
-     * @param space Swap space name ({@code null} for default space).
-     */
-    public SwapSpaceEvent(ClusterNode node, String msg, int type, @Nullable String space) {
-        super(node, msg, type);
-
-        this.space = space;
-    }
-
-    /**
-     * Gets swap space name.
-     *
-     * @return Swap space name or {@code null} for default space.
-     */
-    @Nullable public String space() {
-        return space;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String shortDisplay() {
-        return name() + ": space=" + space;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(SwapSpaceEvent.class, this,
-            "nodeId8", U.id8(node().id()),
-            "msg", message(),
-            "type", name(),
-            "tstamp", timestamp());
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/internal/managers/indexing/GridIndexingManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/indexing/GridIndexingManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/indexing/GridIndexingManager.java
index a18b6b0..a60cdbd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/indexing/GridIndexingManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/indexing/GridIndexingManager.java
@@ -177,48 +177,4 @@ public class GridIndexingManager extends GridManagerAdapter<IndexingSpi> {
             busyLock.leaveBusy();
         }
     }
-
-    /**
-     * Will be called when entry for key will be swapped.
-     *
-     * @param spaceName Space name.
-     * @param key key.
-     * @throws IgniteSpiException If failed.
-     */
-    public void onSwap(String spaceName, Object key) throws IgniteSpiException {
-        assert enabled();
-
-        if (!busyLock.enterBusy())
-            throw new IllegalStateException("Failed to process swap event (grid is stopping).");
-
-        try {
-            getSpi().onSwap(spaceName, key);
-        }
-        finally {
-            busyLock.leaveBusy();
-        }
-    }
-
-    /**
-     * Will be called when entry for key will be unswapped.
-     *
-     * @param spaceName Space name.
-     * @param key Key.
-     * @param val Value.
-     * @throws IgniteSpiException If failed.
-     */
-    public void onUnswap(String spaceName, Object key, Object val)
-        throws IgniteSpiException {
-        assert enabled();
-
-        if (!busyLock.enterBusy())
-            throw new IllegalStateException("Failed to process swap event (grid is stopping).");
-
-        try {
-            getSpi().onUnswap(spaceName, key, val);
-        }
-        finally {
-            busyLock.leaveBusy();
-        }
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
index aceef97..1d03e64 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
@@ -89,21 +89,6 @@ public class CacheMetricsImpl implements CacheMetrics {
     /** Number of off-heap misses. */
     private AtomicLong offHeapMisses = new AtomicLong();
 
-    /** Number of reads from swap. */
-    private AtomicLong swapGets = new AtomicLong();
-
-    /** Number of writes to swap. */
-    private AtomicLong swapPuts = new AtomicLong();
-
-    /** Number of removed entries from swap. */
-    private AtomicLong swapRemoves = new AtomicLong();
-
-    /** Number of swap hits. */
-    private AtomicLong swapHits = new AtomicLong();
-
-    /** Number of swap misses. */
-    private AtomicLong swapMisses = new AtomicLong();
-
     /** Cache metrics. */
     @GridToStringExclude
     private transient CacheMetricsImpl delegate;
@@ -435,12 +420,6 @@ public class CacheMetricsImpl implements CacheMetrics {
         offHeapMisses.set(0);
         offHeapEvicts.set(0);
 
-        swapGets.set(0);
-        swapPuts.set(0);
-        swapRemoves.set(0);
-        swapHits.set(0);
-        swapMisses.set(0);
-
         if (delegate != null)
             delegate.clear();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 9e6fc3776..92c144c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -1812,29 +1812,6 @@ public class GridCacheContext<K, V> implements Externalizable {
     }
 
     /**
-     * @param type Type.
-     * @param bytes Bytes.
-     * @param clsLdrId Class loader ID.
-     * @return Cache object.
-     * @throws IgniteCheckedException If failed.
-     */
-    @Nullable public CacheObject unswapCacheObject(byte type, byte[] bytes, @Nullable IgniteUuid clsLdrId)
-        throws IgniteCheckedException {
-        if (ctx.config().isPeerClassLoadingEnabled() && type != CacheObject.TYPE_BYTE_ARR) {
-            ClassLoader ldr = clsLdrId != null ? deploy().getClassLoader(clsLdrId) : deploy().localLoader();
-
-            if (ldr == null)
-                return null;
-
-            return ctx.cacheObjects().toCacheObject(cacheObjCtx,
-                ctx.cacheObjects().unmarshal(cacheObjCtx, bytes, ldr),
-                false);
-        }
-
-        return ctx.cacheObjects().toCacheObject(cacheObjCtx, type, bytes);
-    }
-
-    /**
      * @param map Map.
      * @param key Key.
      * @param val Value.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfoCollectSwapListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfoCollectSwapListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfoCollectSwapListener.java
deleted file mode 100644
index e8cc01d..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfoCollectSwapListener.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import java.util.Collection;
-import java.util.Map;
-import org.apache.ignite.IgniteLogger;
-import org.jsr166.ConcurrentHashMap8;
-
-/**
- *
- */
-public class GridCacheEntryInfoCollectSwapListener implements GridCacheSwapListener {
-    /** */
-    private final Map<KeyCacheObject, GridCacheEntryInfo> swappedEntries = new ConcurrentHashMap8<>();
-
-    /** */
-    private final IgniteLogger log;
-
-    /**
-     * @param log Logger.
-     */
-    public GridCacheEntryInfoCollectSwapListener(IgniteLogger log) {
-        this.log = log;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onEntryUnswapped(int part,
-        KeyCacheObject key,
-        GridCacheSwapEntry swapEntry)
-    {
-        if (log.isDebugEnabled())
-            log.debug("Received unswapped event for key: " + key);
-
-        assert key != null;
-        assert swapEntry != null;
-
-        GridCacheEntryInfo info = new GridCacheEntryInfo();
-
-        info.key(key);
-        info.ttl(swapEntry.ttl());
-        info.expireTime(swapEntry.expireTime());
-        info.version(swapEntry.version());
-        info.value(swapEntry.value());
-
-        swappedEntries.put(key, info);
-    }
-
-    /**
-     * @return Entries, received by listener.
-     */
-    public Collection<GridCacheEntryInfo> entries() {
-        return swappedEntries.values();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapListener.java
deleted file mode 100644
index 2e6b3ff..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapListener.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.IgniteCheckedException;
-
-/**
- * Provides ability to listen to swap events in cache which is necessary for preloading.
- */
-public interface GridCacheSwapListener {
-    /**
-     * @param part Partition.
-     * @param key Cache key.
-     * @param e Entry.
-     * @throws IgniteCheckedException If failed.
-     */
-    public void onEntryUnswapped(int part, KeyCacheObject key, GridCacheSwapEntry e) throws IgniteCheckedException;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 98f2f93..186212d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -1014,12 +1014,6 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
     }
 
     /** {@inheritDoc} */
-    @Override public void localPromote(Set<? extends K> keys) throws CacheException {
-        // TODO GG-11148.
-        throw new UnsupportedOperationException("localPromote will be removed");
-    }
-
-    /** {@inheritDoc} */
     @Override public int size(CachePeekMode... peekModes) throws CacheException {
         GridCacheGateway<K, V> gate = this.gate;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 94ff0d2..900e96f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -355,33 +355,6 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
     }
 
     /**
-     * Entry for given key unswapped.
-     *
-     * @param key Key.
-     * @throws IgniteCheckedException If failed.
-     */
-    public void onSwap(KeyCacheObject key, int partId) throws IgniteCheckedException {
-        if(!enabled)
-            return;
-        if (!enterBusy())
-            return; // Ignore index update when node is stopping.
-
-        try {
-            if (isIndexingSpiEnabled()) {
-                Object key0 = unwrapIfNeeded(key, cctx.cacheObjectContext());
-
-                cctx.kernalContext().indexing().onSwap(space, key0);
-            }
-
-            if(qryProcEnabled)
-                qryProc.onSwap(space, key, partId);
-        }
-        finally {
-            leaveBusy();
-        }
-    }
-
-    /**
      * Checks if IndexinSPI is enabled.
      * @return IndexingSPI enabled flag.
      */
@@ -390,38 +363,6 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
     }
 
     /**
-     * Entry for given key unswapped.
-     *
-     * @param key Key.
-     * @param val Value
-     * @throws IgniteCheckedException If failed.
-     */
-    public void onUnswap(KeyCacheObject key, int partId, CacheObject val) throws IgniteCheckedException {
-        if(!enabled)
-            return;
-        if (!enterBusy())
-            return; // Ignore index update when node is stopping.
-
-        try {
-            if (isIndexingSpiEnabled()) {
-                CacheObjectContext coctx = cctx.cacheObjectContext();
-
-                Object key0 = unwrapIfNeeded(key, coctx);
-
-                Object val0 = unwrapIfNeeded(val, coctx);
-
-                cctx.kernalContext().indexing().onUnswap(space, key0, val0);
-            }
-
-            if(qryProcEnabled)
-                qryProc.onUnswap(space, key, partId, val);
-        }
-        finally {
-            leaveBusy();
-        }
-    }
-
-    /**
      *
      */
     private void invalidateResultCache() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
index bdcb88c..090f382 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
@@ -31,7 +31,6 @@ import org.apache.ignite.events.Event;
 import org.apache.ignite.events.EventAdapter;
 import org.apache.ignite.events.EventType;
 import org.apache.ignite.events.JobEvent;
-import org.apache.ignite.events.SwapSpaceEvent;
 import org.apache.ignite.events.TaskEvent;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.binary.BinaryContext;
@@ -73,7 +72,6 @@ import org.apache.ignite.internal.processors.platform.messaging.PlatformMessageF
 import org.apache.ignite.internal.processors.platform.utils.PlatformReaderBiClosure;
 import org.apache.ignite.internal.processors.platform.utils.PlatformReaderClosure;
 import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
-import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.lang.IgniteBiTuple;
 import org.jetbrains.annotations.Nullable;
 
@@ -128,7 +126,6 @@ public class PlatformContextImpl implements PlatformContext {
         addEventTypes(evtTyps0, EventType.EVTS_CHECKPOINT);
         addEventTypes(evtTyps0, EventType.EVTS_DISCOVERY_ALL);
         addEventTypes(evtTyps0, EventType.EVTS_JOB_EXECUTION);
-        addEventTypes(evtTyps0, EventType.EVTS_SWAPSPACE);
         addEventTypes(evtTyps0, EventType.EVTS_TASK_EXECUTION);
 
         evtTyps = Collections.unmodifiableSet(evtTyps0);
@@ -610,14 +607,6 @@ public class PlatformContextImpl implements PlatformContext {
             writeNode(writer, event0.taskNode());
             writer.writeUuid(event0.taskSubjectId());
         }
-        else if (evt0 instanceof SwapSpaceEvent) {
-            writer.writeInt(9);
-            writeCommonEventData(writer, evt0);
-
-            SwapSpaceEvent event0 = (SwapSpaceEvent)evt0;
-
-            writer.writeString(event0.space());
-        }
         else if (evt0 instanceof TaskEvent) {
             writer.writeInt(10);
             writeCommonEventData(writer, evt0);

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
index a60d364..2847813 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
@@ -132,9 +132,6 @@ public class PlatformCache extends PlatformAbstractTarget {
     public static final int OP_LOC_LOAD_CACHE = 17;
 
     /** */
-    public static final int OP_LOC_PROMOTE = 18;
-
-    /** */
     public static final int OP_LOCAL_CLEAR = 20;
 
     /** */
@@ -433,12 +430,6 @@ public class PlatformCache extends PlatformAbstractTarget {
                 case OP_CONTAINS_KEYS:
                     return cache.containsKeys(PlatformUtils.readSet(reader)) ? TRUE : FALSE;
 
-                case OP_LOC_PROMOTE: {
-                    cache.localPromote(PlatformUtils.readSet(reader));
-
-                    return TRUE;
-                }
-
                 case OP_REPLACE_3:
                     return cache.replace(reader.readObjectDetached(), reader.readObjectDetached(),
                         reader.readObjectDetached()) ? TRUE : FALSE;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
index 7746ba5..23f4343 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
@@ -238,25 +238,6 @@ public interface GridQueryIndexing {
         GridCacheVersion ver) throws IgniteCheckedException;
 
     /**
-     * Will be called when entry with given key is swapped.
-     *
-     * @param spaceName Space name.
-     * @param key Key.
-     * @throws IgniteCheckedException If failed.
-     */
-    public void onSwap(@Nullable String spaceName, KeyCacheObject key, int partId) throws IgniteCheckedException;
-
-    /**
-     * Will be called when entry with given key is unswapped.
-     *
-     * @param spaceName Space name.
-     * @param key Key.
-     * @param val Value.
-     * @throws IgniteCheckedException If failed.
-     */
-    public void onUnswap(@Nullable String spaceName, KeyCacheObject key, int partId, CacheObject val) throws IgniteCheckedException;
-
-    /**
      * Rebuilds all indexes of given type from hash index.
      *
      * @param spaceName Space name.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index e0dc387..0ac55e6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -2031,61 +2031,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     }
 
     /**
-     * Will be called when entry for key will be swapped.
-     *
-     * @param spaceName Space name.
-     * @param key key.
-     * @throws IgniteCheckedException If failed.
-     */
-    public void onSwap(String spaceName, KeyCacheObject key, int partId) throws IgniteCheckedException {
-        if (log.isDebugEnabled())
-            log.debug("Swap [space=" + spaceName + ", key=" + key + "]");
-
-        if (idx == null)
-            return;
-
-        if (!busyLock.enterBusy())
-            throw new IllegalStateException("Failed to process swap event (grid is stopping).");
-
-        try {
-            idx.onSwap(
-                spaceName,
-                key,
-                partId);
-        }
-        finally {
-            busyLock.leaveBusy();
-        }
-    }
-
-    /**
-     * Will be called when entry for key will be unswapped.
-     *
-     * @param spaceName Space name.
-     * @param key Key.
-     * @param val Value.
-     * @throws IgniteCheckedException If failed.
-     */
-    public void onUnswap(String spaceName, KeyCacheObject key, int partId, CacheObject val)
-        throws IgniteCheckedException {
-        if (log.isDebugEnabled())
-            log.debug("Unswap [space=" + spaceName + ", key=" + key + ", val=" + val + "]");
-
-        if (idx == null)
-            return;
-
-        if (!busyLock.enterBusy())
-            throw new IllegalStateException("Failed to process swap event (grid is stopping).");
-
-        try {
-            idx.onUnswap(spaceName, key, partId, val);
-        }
-        finally {
-            busyLock.leaveBusy();
-        }
-    }
-
-    /**
      * Gets types for space.
      *
      * @param space Space name.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/spi/indexing/IndexingSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/indexing/IndexingSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/indexing/IndexingSpi.java
index bbe27c0..4d53bea 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/indexing/IndexingSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/indexing/IndexingSpi.java
@@ -95,23 +95,4 @@ public interface IndexingSpi extends IgniteSpi {
      * @throws IgniteSpiException If failed.
      */
     public void remove(@Nullable String spaceName, Object key) throws IgniteSpiException;
-
-    /**
-     * Will be called when entry with given key is swapped.
-     *
-     * @param spaceName Space name.
-     * @param key Key.
-     * @throws IgniteSpiException If failed.
-     */
-    public void onSwap(@Nullable String spaceName, Object key) throws IgniteSpiException;
-
-    /**
-     * Will be called when entry with given key is unswapped.
-     *
-     * @param spaceName Space name.
-     * @param key Key.
-     * @param val Value.
-     * @throws IgniteSpiException If failed.
-     */
-    public void onUnswap(@Nullable String spaceName, Object key, Object val) throws IgniteSpiException;
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/java/org/apache/ignite/spi/indexing/noop/NoopIndexingSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/indexing/noop/NoopIndexingSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/indexing/noop/NoopIndexingSpi.java
index a8683a1..0ed7e33 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/indexing/noop/NoopIndexingSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/indexing/noop/NoopIndexingSpi.java
@@ -50,16 +50,6 @@ public class NoopIndexingSpi extends IgniteSpiAdapter implements IndexingSpi {
     }
 
     /** {@inheritDoc} */
-    @Override public void onSwap(@Nullable String spaceName, Object key) throws IgniteSpiException {
-        assert false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onUnswap(@Nullable String spaceName, Object key, Object val) throws IgniteSpiException {
-        assert false;
-    }
-
-    /** {@inheritDoc} */
     @Override public void spiStart(@Nullable String igniteInstanceName) throws IgniteSpiException {
         // No-op.
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index 6b548c7..e45f84a 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -151,7 +151,6 @@ org.apache.ignite.events.Event
 org.apache.ignite.events.EventAdapter
 org.apache.ignite.events.IgfsEvent
 org.apache.ignite.events.JobEvent
-org.apache.ignite.events.SwapSpaceEvent
 org.apache.ignite.events.TaskEvent
 org.apache.ignite.hadoop.HadoopInputSplit
 org.apache.ignite.hadoop.HadoopMapReducePlan

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index f7054b7..93ed7a1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -110,13 +110,10 @@ import static org.apache.ignite.cache.CacheMode.LOCAL;
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
 import static org.apache.ignite.cache.CachePeekMode.ALL;
-import static org.apache.ignite.cache.CachePeekMode.OFFHEAP;
 import static org.apache.ignite.cache.CachePeekMode.ONHEAP;
 import static org.apache.ignite.cache.CachePeekMode.PRIMARY;
 import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_LOCKED;
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_SWAPPED;
 import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_UNLOCKED;
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_UNSWAPPED;
 import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
 import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
 import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
@@ -6525,48 +6522,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
     /**
      *
      */
-    private static class SwapEvtsLocalListener implements IgnitePredicate<Event> {
-        /** */
-        @LoggerResource
-        private IgniteLogger log;
-
-        /** Swap events. */
-        private final AtomicInteger swapEvts;
-
-        /** Unswap events. */
-        private final AtomicInteger unswapEvts;
-
-        /**
-         * @param swapEvts Swap events.
-         * @param unswapEvts Unswap events.
-         */
-        public SwapEvtsLocalListener(AtomicInteger swapEvts, AtomicInteger unswapEvts) {
-            this.swapEvts = swapEvts;
-            this.unswapEvts = unswapEvts;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean apply(Event evt) {
-            log.info("Received event: " + evt);
-
-            switch (evt.type()) {
-                case EVT_CACHE_OBJECT_SWAPPED:
-                    swapEvts.incrementAndGet();
-
-                    break;
-                case EVT_CACHE_OBJECT_UNSWAPPED:
-                    unswapEvts.incrementAndGet();
-
-                    break;
-            }
-
-            return true;
-        }
-    }
-
-    /**
-     *
-     */
     private static class CheckEntriesDeletedTask extends TestIgniteIdxRunnable {
         /** */
         private final int cnt;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
index 674996d..dcba92f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
@@ -102,9 +102,7 @@ import static org.apache.ignite.cache.CachePeekMode.OFFHEAP;
 import static org.apache.ignite.cache.CachePeekMode.ONHEAP;
 import static org.apache.ignite.cache.CachePeekMode.PRIMARY;
 import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_LOCKED;
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_SWAPPED;
 import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_UNLOCKED;
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_UNSWAPPED;
 import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
 import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
 import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
@@ -4103,8 +4101,6 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
 
         assertNull(cache.localPeek("key"));
 
-        cache.localPromote(Collections.singleton(key));
-
         assertNull(cache.localPeek(key, ONHEAP));
 
         assertTrue(cache.localSize() == 0);
@@ -6425,47 +6421,6 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
     /**
      *
      */
-    private static class SwapEvtsLocalListener implements IgnitePredicate<Event> {
-        @LoggerResource
-        private IgniteLogger log;
-
-        /** Swap events. */
-        private final AtomicInteger swapEvts;
-
-        /** Unswap events. */
-        private final AtomicInteger unswapEvts;
-
-        /**
-         * @param swapEvts Swap events.
-         * @param unswapEvts Unswap events.
-         */
-        public SwapEvtsLocalListener(AtomicInteger swapEvts, AtomicInteger unswapEvts) {
-            this.swapEvts = swapEvts;
-            this.unswapEvts = unswapEvts;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean apply(Event evt) {
-            log.info("Received event: " + evt);
-
-            switch (evt.type()) {
-                case EVT_CACHE_OBJECT_SWAPPED:
-                    swapEvts.incrementAndGet();
-
-                    break;
-                case EVT_CACHE_OBJECT_UNSWAPPED:
-                    unswapEvts.incrementAndGet();
-
-                    break;
-            }
-
-            return true;
-        }
-    }
-
-    /**
-     *
-     */
     private static class CheckEntriesDeletedTask extends TestIgniteIdxRunnable {
         private final int cnt;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
index a1a2f89..224d1fe 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
@@ -189,8 +189,6 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
 
                 assertNull(cache.localPeek(key, CachePeekMode.ONHEAP));
 
-                cache.localPromote(Collections.singleton(key));
-
                 assertNotNull(cache.localPeek(key, CachePeekMode.ONHEAP));
 
                 checkNoValue(aff, key);
@@ -356,8 +354,6 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
 
                 assertNull(cache.localPeek(key, CachePeekMode.ONHEAP));
 
-                cache.localPromote(Collections.singleton(key));
-
                 assertNotNull(cache.localPeek(key, CachePeekMode.ONHEAP));
 
                 checkHasValue(aff, key);

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
index 221b670..c60d718 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
@@ -690,16 +690,6 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
         }
 
         /** {@inheritDoc} */
-        @Override public void onSwap(@Nullable String spaceName, Object key) throws IgniteSpiException {
-            // No-op.
-        }
-
-        /** {@inheritDoc} */
-        @Override public void onUnswap(@Nullable String spaceName, Object key, Object val) throws IgniteSpiException {
-            // No-op.
-        }
-
-        /** {@inheritDoc} */
         @Override public void spiStart(@Nullable String igniteInstanceName) throws IgniteSpiException {
             // No-op.
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java
index 75aadc5..01202fd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java
@@ -148,49 +148,6 @@ public abstract class GridCacheAbstractDistributedByteArrayValuesSelfTest extend
     }
 
     /**
-     * Test swapping.
-     *
-     * @throws Exception If failed.
-     */
-    public void testSwap() throws Exception {
-// TODO: GG-11148 check if test makes sense.
-//        for (IgniteCache<Integer, Object> cache : caches)
-//            assert cache.getConfiguration(CacheConfiguration.class).isSwapEnabled();
-        if (true)
-            return;
-
-        byte[] val1 = wrap(1);
-
-        IgniteCache<Integer, Object> primaryCache = null;
-
-        int i = 0;
-
-        for (IgniteCache<Integer, Object> cache : caches) {
-            Ignite ignite = ignites[i++];
-
-            if (affinity(cache).isPrimary(ignite.cluster().localNode(), SWAP_TEST_KEY)) {
-                primaryCache = cache;
-
-                break;
-            }
-        }
-
-        assert primaryCache != null;
-
-        primaryCache.put(SWAP_TEST_KEY, val1);
-
-        assert Arrays.equals(val1, (byte[])primaryCache.get(SWAP_TEST_KEY));
-
-        primaryCache.localEvict(Collections.singleton(SWAP_TEST_KEY));
-
-        assert primaryCache.localPeek(SWAP_TEST_KEY, CachePeekMode.ONHEAP) == null;
-
-        primaryCache.localPromote(Collections.singleton(SWAP_TEST_KEY));
-
-        assert Arrays.equals(val1, (byte[])primaryCache.localPeek(SWAP_TEST_KEY, CachePeekMode.ONHEAP));
-    }
-
-    /**
      * Test transaction behavior.
      *
      * @param caches Caches.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
index 0b8ccdf..15eec59 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.internal.processors.cache.distributed.near;
 
-import com.google.common.collect.ImmutableSet;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -26,26 +25,20 @@ import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
 import javax.cache.expiry.Duration;
 import javax.cache.expiry.TouchedExpiryPolicy;
+import com.google.common.collect.ImmutableSet;
 import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
-import org.apache.ignite.events.Event;
 import org.apache.ignite.internal.util.lang.GridAbsPredicate;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.resources.LoggerResource;
 
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_SWAPPED;
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_UNSWAPPED;
 import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
 
 /**
@@ -310,46 +303,4 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
 
         assert c.localSize() == 0 : "Cache is not empty.";
     }
-
-    /**
-     *
-     */
-    private static class LocalListener implements IgnitePredicate<Event> {
-        /** Logger. */
-        @LoggerResource
-        private IgniteLogger log;
-
-        /** Swap events. */
-        private final AtomicInteger swapEvts;
-
-        /** Unswap events. */
-        private final AtomicInteger unswapEvts;
-
-        /**
-         * @param swapEvts Swap events.
-         * @param unswapEvts Unswap events.
-         */
-        public LocalListener(AtomicInteger swapEvts, AtomicInteger unswapEvts) {
-            this.swapEvts = swapEvts;
-            this.unswapEvts = unswapEvts;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean apply(Event evt) {
-            log.info("Received event: " + evt);
-
-            switch (evt.type()) {
-                case EVT_CACHE_OBJECT_SWAPPED:
-                    swapEvts.incrementAndGet();
-
-                    break;
-                case EVT_CACHE_OBJECT_UNSWAPPED:
-                    unswapEvts.incrementAndGet();
-
-                    break;
-            }
-
-            return true;
-        }
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
index d5c5635..e5b72f8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
@@ -19,40 +19,26 @@ package org.apache.ignite.internal.processors.cache.distributed.near;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.Callable;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteAtomicLong;
 import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.cache.affinity.AffinityKeyMapped;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.events.Event;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.util.lang.GridAbsPredicate;
 import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.resources.LoggerResource;
-import org.apache.ignite.testframework.GridTestUtils;
 
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
 import static org.apache.ignite.cache.CachePeekMode.BACKUP;
 import static org.apache.ignite.cache.CachePeekMode.NEAR;
-import static org.apache.ignite.cache.CachePeekMode.ONHEAP;
 import static org.apache.ignite.cache.CachePeekMode.PRIMARY;
 import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_SWAPPED;
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_UNSWAPPED;
 
 /**
  * Multi-node tests for partitioned cache.
@@ -413,51 +399,6 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
     /**
      *
      */
-    private static class SwapUnswapLocalListener implements IgnitePredicate<Event> {
-        /** Logger. */
-        @LoggerResource
-        private IgniteLogger log;
-
-        /** Ignite. */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** {@inheritDoc} */
-        @Override public boolean apply(Event evt) {
-            log.info("Received event: " + evt);
-
-            switch (evt.type()) {
-                case EVT_CACHE_OBJECT_SWAPPED:
-                    // Run from another thread to avoid deadlock with striped pool.
-                    GridTestUtils.runAsync(new Callable<Void>() {
-                        @Override public Void call() throws Exception {
-                            ignite.atomicLong("swapEvts", 0, false).incrementAndGet();
-
-                            return null;
-                        }
-                    });
-
-                    break;
-                case EVT_CACHE_OBJECT_UNSWAPPED:
-                    // Run from another thread to avoid deadlock with striped pool.
-                    GridTestUtils.runAsync(new Callable<Void>() {
-                        @Override public Void call() throws Exception {
-                            ignite.atomicLong("unswapEvts", 0, false).incrementAndGet();
-
-                            return null;
-                        }
-                    });
-
-                    break;
-            }
-
-            return true;
-        }
-    }
-
-    /**
-     *
-     */
     private static class CheckAffinityTask extends TestIgniteIdxRunnable {
         /** Size. */
         private final int size;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedUnswapAdvancedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedUnswapAdvancedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedUnswapAdvancedSelfTest.java
deleted file mode 100644
index 39e326a..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedUnswapAdvancedSelfTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache.distributed.replicated;
-
-import java.util.Collections;
-import java.util.concurrent.CountDownLatch;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.events.Event;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.apache.ignite.cache.CacheMode.REPLICATED;
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT;
-
-/**
- * Advanced promote test for replicated cache.
- */
-public class GridCacheReplicatedUnswapAdvancedSelfTest extends GridCommonAbstractTest {
-    /** IP finder. */
-    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
-        discoSpi.setIpFinder(IP_FINDER);
-
-        cfg.setDiscoverySpi(discoSpi);
-
-        CacheConfiguration cacheCfg = defaultCacheConfiguration();
-
-        cacheCfg.setCacheMode(REPLICATED);
-
-        cfg.setCacheConfiguration(cacheCfg);
-
-        if (getTestIgniteInstanceName(1).equals(igniteInstanceName) || cfg.getMarshaller() instanceof BinaryMarshaller)
-            cfg.setClassLoader(getExternalClassLoader());
-
-        return cfg;
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testUnswapAdvanced() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-4551");
-
-        Ignite g1 = startGrid(1);
-        Ignite g2 = startGrid(2);
-
-        assert g1.cluster().nodes().size() > 1 : "This test needs at least two grid nodes started.";
-
-        IgniteCache<Object, Object> cache1 = g1.cache(null);
-        IgniteCache<Object, Object> cache2 = g2.cache(null);
-
-        try {
-            ClassLoader ldr = grid(1).configuration().getClassLoader();
-
-            Object v = ldr.loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestValue3").newInstance();
-
-            info("v loader: " + v.getClass().getClassLoader());
-
-            final CountDownLatch putLatch = new CountDownLatch(1);
-
-            g2.events().localListen(new IgnitePredicate<Event>() {
-                @Override public boolean apply(Event evt) {
-                    assert evt.type() == EVT_CACHE_OBJECT_PUT;
-
-                    putLatch.countDown();
-
-                    return true;
-                }
-            }, EVT_CACHE_OBJECT_PUT);
-
-            String key = null;
-
-            for (int i = 0; i < 1000; i++) {
-                String k = "key-" + i;
-
-                if (affinity(cache1).isPrimary(g1.cluster().localNode(), k)) {
-                    key = k;
-
-                    break;
-                }
-            }
-
-            assertNotNull(key);
-
-            // Put value into cache of the first grid.
-            cache1.put(key, v);
-
-            assert putLatch.await(10, SECONDS);
-
-            assert cache2.containsKey(key);
-
-            Object v2 = cache2.get(key);
-
-            info("v2 loader: " + v2.getClass().getClassLoader());
-
-            assert v2 != null;
-            assert v2.toString().equals(v.toString());
-            assert !v2.getClass().getClassLoader().equals(getClass().getClassLoader());
-            assert v2.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader")||
-                grid(2).configuration().getMarshaller() instanceof BinaryMarshaller;
-
-            // To swap storage.
-            cache2.localEvict(Collections.<Object>singleton(key));
-
-            cache2.localPromote(Collections.singleton(key));
-
-            v2 = cache2.localPeek(key, CachePeekMode.ONHEAP);
-
-            log.info("Unswapped entry value: " + v2);
-
-            assert v2 != null;
-
-            assert v2.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader")|
-                grid(2).configuration().getMarshaller() instanceof BinaryMarshaller;
-        }
-        finally {
-            stopGrid(1);
-            stopGrid(2);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
index 06a89a4..62adb77 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
@@ -290,16 +290,6 @@ public class IndexingSpiQuerySelfTest extends TestCase {
         @Override public void remove(@Nullable String spaceName, Object key) throws IgniteSpiException {
             // No-op.
         }
-
-        /** {@inheritDoc} */
-        @Override public void onSwap(@Nullable String spaceName, Object key) throws IgniteSpiException {
-            // No-op.
-        }
-
-        /** {@inheritDoc} */
-        @Override public void onUnswap(@Nullable String spaceName, Object key, Object val) throws IgniteSpiException {
-            // No-op.
-        }
     }
 
     /**
@@ -321,18 +311,6 @@ public class IndexingSpiQuerySelfTest extends TestCase {
         @Override public void remove(@Nullable String spaceName, Object key) throws IgniteSpiException {
             assertTrue(key instanceof BinaryObject);
         }
-
-        /** {@inheritDoc} */
-        @Override public void onSwap(@Nullable String spaceName, Object key) throws IgniteSpiException {
-            assertTrue(key instanceof BinaryObject);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void onUnswap(@Nullable String spaceName, Object key, Object val) throws IgniteSpiException {
-            assertTrue(key instanceof BinaryObject);
-
-            assertTrue(val instanceof BinaryObject);
-        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryTxSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryTxSelfTest.java
index 5ce48aa..9d2b31c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryTxSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryTxSelfTest.java
@@ -148,15 +148,5 @@ public class IndexingSpiQueryTxSelfTest extends GridCacheAbstractSelfTest {
         @Override public void remove(@Nullable String spaceName, Object key) throws IgniteSpiException {
             // No-op.
         }
-
-        /** {@inheritDoc} */
-        @Override public void onSwap(@Nullable String spaceName, Object key) throws IgniteSpiException {
-            // No-op.
-        }
-
-        /** {@inheritDoc} */
-        @Override public void onUnswap(@Nullable String spaceName, Object key, Object val) throws IgniteSpiException {
-            // No-op.
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheSwapLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheSwapLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheSwapLoadTest.java
deleted file mode 100644
index 436bc73..0000000
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheSwapLoadTest.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.loadtests.cache;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.events.CacheEvent;
-import org.apache.ignite.events.Event;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.util.typedef.CAX;
-import org.apache.ignite.internal.util.typedef.CIX1;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.X;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.jetbrains.annotations.Nullable;
-
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_SWAPPED;
-
-/**
- * Cache+swap load test.
- */
-public class GridCacheSwapLoadTest {
-    /** */
-    private static final int LOG_MOD = 10000;
-
-    /** */
-    private static final int DFLT_KEY_CNT = 100000;
-
-    /** */
-    private static final float DFLT_GET_REMOVE_RATIO = 0.2f;
-
-    /** */
-    private static final int DFLT_PUT_THREAD_CNT = 5;
-
-    /** */
-    private static final int DFLT_GET_THREAD_CNT = 2;
-
-    /** */
-    private static final int DFLT_REMOVE_THREAD_CNT = 2;
-
-    /** */
-    private static final boolean DFLT_GET_REMOVE_ENABLED = true;
-
-    /** */
-    private static int keyCnt = DFLT_KEY_CNT;
-
-    /** */
-    private static float getRmvRatio = DFLT_GET_REMOVE_RATIO;
-
-    /** */
-    private static int putThreadCnt = DFLT_PUT_THREAD_CNT;
-
-    /** */
-    private static int getThreadCnt = DFLT_GET_THREAD_CNT;
-
-    /** */
-    private static int rmvThreadCnt = DFLT_REMOVE_THREAD_CNT;
-
-    /** */
-    private static boolean getRmvEnabled = DFLT_GET_REMOVE_ENABLED;
-
-    /** */
-    private static final CountDownLatch getRemoveStartedLatch = new CountDownLatch(1);
-
-    /** */
-    private static final BlockingQueue<Integer> swappedKeys = new LinkedBlockingQueue<>();
-
-    /** */
-    private GridCacheSwapLoadTest() {
-        // No-op
-    }
-
-    /**
-     * @param args Command line arguments.
-     */
-    public static void main(String[] args) {
-        parseArgs(args);
-
-        try (Ignite g = G.start("modules/core/src/test/config/spring-cache-swap.xml")) {
-            g.events().localListen(new IgnitePredicate<Event>() {
-                private final AtomicInteger cnt = new AtomicInteger(0);
-
-                private final AtomicBoolean getRmvStartedGuard = new AtomicBoolean(false);
-
-                @Override public boolean apply(Event evt) {
-                    int cnt = this.cnt.incrementAndGet();
-
-                    if (cnt % LOG_MOD == 0)
-                        X.println(">>> Swap count: " + cnt);
-
-                    if (getRmvEnabled) {
-                        CacheEvent ce = (CacheEvent) evt;
-
-                        Integer key = ce.key();
-
-                        swappedKeys.add(key);
-
-                        if (swappedKeys.size() > keyCnt * getRmvRatio &&
-                            getRmvStartedGuard.compareAndSet(false, true)) {
-                            getRemoveStartedLatch.countDown();
-
-                            X.println(">>> Started get/remove.");
-                        }
-                    }
-
-                    return true;
-                }
-            }, EVT_CACHE_OBJECT_SWAPPED);
-
-            Collection<IgniteInternalFuture<?>> futs = new ArrayList<>(3);
-
-            long start = System.currentTimeMillis();
-
-            futs.add(doPut(g));
-
-            if (getRmvEnabled)
-                futs.addAll(doGetRemove(g));
-
-            wait(futs);
-
-            X.println("Test finished in: " + (System.currentTimeMillis() - start));
-        }
-    }
-
-    /**
-     * @param args Command line arguments.
-     */
-    private static void parseArgs(String[] args) {
-        try {
-            for (int i = 0; i < args.length; i++) {
-                String arg = args[i];
-
-                switch (arg) {
-                    case "-k":
-                        keyCnt = Integer.valueOf(args[++i]); break;
-                    case "-r":
-                        getRmvRatio = Float.valueOf(args[++i]); break;
-                    case "-pt":
-                        putThreadCnt = Integer.valueOf(args[++i]); break;
-                    case "-gt":
-                        getThreadCnt = Integer.valueOf(args[++i]); break;
-                    case "-rt":
-                        rmvThreadCnt = Integer.valueOf(args[++i]); break;
-                    case "-dgr":
-                        getRmvEnabled = false; break;
-                    default:
-                        usage();
-                }
-            }
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-
-            usage();
-        }
-
-        X.println(">>>");
-        X.println(">>> Key count: " + keyCnt);
-        X.println(">>> Get/remove ratio: " + getRmvRatio);
-        X.println(">>> Put threads count: " + putThreadCnt);
-        X.println(">>> Get threads count: " + getThreadCnt);
-        X.println(">>> Remove threads count: " + rmvThreadCnt);
-        X.println(">>> Get/remove " + (getRmvEnabled ? "enabled" : "disabled") + ".");
-        X.println(">>>");
-    }
-
-    /** */
-    private static void usage() {
-        X.println(">>>");
-        X.println(">>> Usage: swaploadtest.sh -k <number of keys> -r <get/remove ratio> -pt <number of put threads>");
-        X.println(">>>                        -gt <number of get threads> -rt <number of remove threads> -dgr");
-        X.println(">>>");
-        X.println(">>> -dgr disables get/remove threads.");
-        X.println(">>>");
-        X.println(">>> All arguments are optional.");
-        X.println(">>>");
-
-        System.exit(1);
-    }
-
-    /**
-     * @return Future.
-     */
-    private static IgniteInternalFuture<?> doPut(final Ignite g) {
-        final AtomicInteger putKey = new AtomicInteger(0);
-
-        return GridTestUtils.runMultiThreadedAsync(new CAX() {
-            @Override public void applyx() {
-                IgniteCache<Integer, Integer> cache = g.cache(null);
-
-                assert cache != null;
-
-                while (true) {
-                    int i = putKey.incrementAndGet();
-
-                    if (i % LOG_MOD == 0)
-                        X.println(">>> Put count: " + i);
-
-                    if (i > keyCnt)
-                        break;
-
-                    cache.put(i, i);
-                }
-
-                X.println(">>> Thread '" + Thread.currentThread().getName() + "' stopped.");
-            }
-        }, putThreadCnt, "put-thread");
-    }
-
-    /**
-     * @return Futures.
-     */
-    private static Collection<IgniteInternalFuture<Long>> doGetRemove(final Ignite g) {
-        final AtomicBoolean stop = new AtomicBoolean(false);
-
-        return F.asList(
-            GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
-                @Nullable @Override public Object call() throws Exception {
-                    getRemoveStartedLatch.await();
-
-                    IgniteCache<Integer, Integer> cache = g.cache(null);
-
-                    assert cache != null;
-
-                    while (true) {
-                        Integer i = swappedKeys.take();
-
-                        if (i == null)
-                            continue;
-
-                        Integer val = cache.get(i);
-
-                        assert val != null && val.equals(i);
-
-                        if (i % LOG_MOD == 0)
-                            X.println(">>> Get/remove count: " + i);
-
-                        if (i == keyCnt || stop.get()) {
-                            stop.set(true);
-
-                            break;
-                        }
-                    }
-
-                    X.println(">>> Thread '" + Thread.currentThread().getName() + "' stopped.");
-
-                    return null;
-                }
-            }, getThreadCnt, "get-thread"),
-
-            GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
-                @Nullable @Override public Object call() throws Exception {
-                    getRemoveStartedLatch.await();
-
-                    IgniteCache<Integer, Integer> cache = g.cache(null);
-
-                    assert cache != null;
-
-                    while (true) {
-                        Integer i = swappedKeys.take();
-
-                        Integer val = cache.getAndRemove(i);
-
-                        assert val != null && val.equals(i);
-
-                        if (i % LOG_MOD == 0)
-                            X.println(">>> Get/remove count: " + i);
-
-                        if (i == keyCnt || stop.get()) {
-                            stop.set(true);
-
-                            break;
-                        }
-                    }
-
-                    X.println(">>> Thread '" + Thread.currentThread().getName() + "' stopped.");
-
-                    return null;
-                }
-            }, rmvThreadCnt, "remove-thread")
-        );
-    }
-
-    /**
-     * @param futs Futures.
-     */
-    private static void wait(Iterable<IgniteInternalFuture<?>> futs) {
-        F.forEach(futs, new CIX1<IgniteInternalFuture<?>>() {
-            @Override public void applyx(IgniteInternalFuture<?> fut) throws IgniteCheckedException {
-                fut.get();
-            }
-        });
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index e37b572..d203794 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -231,11 +231,6 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Override public void localPromote(Set<? extends K> keys) throws CacheException {
-        throw new UnsupportedOperationException("Method should be supported.");
-    }
-
-    /** {@inheritDoc} */
     @Override public int size(CachePeekMode... peekModes) throws CacheException {
         return compute.call(new SizeTask(cacheName, isAsync, peekModes, false));
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
index 3876951..d0b74d6 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
@@ -71,7 +71,6 @@ import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCa
 import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxMultiThreadedSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxSingleThreadedSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxTimeoutSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedUnswapAdvancedSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheSyncReplicatedPreloadSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.GridReplicatedTxPreloadTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.preloader.GridCacheReplicatedPreloadLifecycleSelfTest;
@@ -128,7 +127,6 @@ public class IgniteCacheTestSuite3 extends TestSuite {
         suite.addTestSuite(IgniteCacheScanPredicateDeploymentSelfTest.class);
 
         suite.addTestSuite(GridCachePutArrayValueSelfTest.class);
-        suite.addTestSuite(GridCacheReplicatedUnswapAdvancedSelfTest.class);
         suite.addTestSuite(GridCacheReplicatedEvictionEventSelfTest.class);
         suite.addTestSuite(GridCacheReplicatedTxMultiThreadedSelfTest.class);
         suite.addTestSuite(GridCacheReplicatedPreloadEventsSelfTest.class);


[31/65] [abbrv] ignite git commit: IGNITE-3386 Reverted: "Reentrant lock is lost when lock owner leaves topology"

Posted by ag...@apache.org.
IGNITE-3386 Reverted: "Reentrant lock is lost when lock owner leaves topology"

Signed-off-by: nikolay_tikhonov <nt...@gridgain.com>


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

Branch: refs/heads/ignite-5024
Commit: d20f4588f5b26ba7f36111329211e8ed6e4188dc
Parents: a826c61
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Thu Apr 20 18:25:35 2017 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Thu Apr 20 18:25:35 2017 +0300

----------------------------------------------------------------------
 .../src/main/java/org/apache/ignite/Ignite.java |  1 -
 .../datastructures/DataStructuresProcessor.java |  3 +-
 .../datastructures/GridCacheLockImpl.java       | 17 +----
 .../internal/GridCacheRecreateLockTest.java     | 78 --------------------
 .../testsuites/IgniteComputeGridTestSuite.java  |  2 -
 5 files changed, 3 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d20f4588/modules/core/src/main/java/org/apache/ignite/Ignite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/Ignite.java b/modules/core/src/main/java/org/apache/ignite/Ignite.java
index aba224f..d8addcd 100644
--- a/modules/core/src/main/java/org/apache/ignite/Ignite.java
+++ b/modules/core/src/main/java/org/apache/ignite/Ignite.java
@@ -524,7 +524,6 @@ public interface Ignite extends AutoCloseable {
      *      all threads on other nodes waiting to acquire lock are interrupted.
      * @param fair If {@code True}, fair lock will be created.
      * @param create Boolean flag indicating whether data structure should be created if does not exist.
-     *      Will re-create lock if the node that stored the lock left topology and there are no backups left.
      * @return ReentrantLock for the given name.
      * @throws IgniteException If reentrant lock could not be fetched or created.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/d20f4588/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index 0a439dc..eb0981b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -1443,8 +1443,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter implemen
                         name,
                         key,
                         reentrantLockView,
-                        dsCacheCtx,
-                        create);
+                        dsCacheCtx);
 
                     dsMap.put(key, reentrantLock0);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d20f4588/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
index e154850..3f1a0dd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
@@ -107,9 +107,6 @@ public final class GridCacheLockImpl implements GridCacheLockEx, IgniteChangeGlo
     /** Flag indicating that every operation on this lock should be interrupted. */
     private volatile boolean interruptAll;
 
-    /** Re-create flag. */
-    private volatile boolean reCreate;
-
     /**
      * Empty constructor required by {@link Externalizable}.
      */
@@ -525,14 +522,7 @@ public final class GridCacheLockImpl implements GridCacheLockEx, IgniteChangeGlo
                                 GridCacheLockState val = lockView.get(key);
 
                                 if (val == null)
-                                    if (reCreate) {
-                                        val = new GridCacheLockState(0, ctx.nodeId(), 0, failoverSafe, fair);
-
-                                        lockView.put(key, val);
-                                    }
-                                    else
-                                        throw new IgniteCheckedException("Failed to find reentrant lock with " +
-                                            "the given name: " + name);
+                                    throw new IgniteCheckedException("Failed to find reentrant lock with given name: " + name);
 
                                 final long newThreadID = newThread.getId();
 
@@ -1051,14 +1041,12 @@ public final class GridCacheLockImpl implements GridCacheLockEx, IgniteChangeGlo
      * @param key Reentrant lock key.
      * @param lockView Reentrant lock projection.
      * @param ctx Cache context.
-     * @param reCreate If {@code true} reentrant lock will be re-created in case it is not in cache.
      */
     @SuppressWarnings("unchecked")
     public GridCacheLockImpl(String name,
         GridCacheInternalKey key,
         IgniteInternalCache<GridCacheInternalKey, GridCacheLockState> lockView,
-        GridCacheContext ctx,
-        boolean reCreate) {
+        GridCacheContext ctx) {
         assert name != null;
         assert key != null;
         assert ctx != null;
@@ -1068,7 +1056,6 @@ public final class GridCacheLockImpl implements GridCacheLockEx, IgniteChangeGlo
         this.key = key;
         this.lockView = lockView;
         this.ctx = ctx;
-        this.reCreate = reCreate;
 
         log = ctx.logger(getClass());
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d20f4588/modules/core/src/test/java/org/apache/ignite/internal/GridCacheRecreateLockTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridCacheRecreateLockTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridCacheRecreateLockTest.java
deleted file mode 100644
index cb1052c..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridCacheRecreateLockTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteLock;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.apache.ignite.testframework.junits.common.GridCommonTest;
-
-/**
- * Create lock after owner node left topology test
- */
-@GridCommonTest(group = "Kernal Self")
-public class GridCacheRecreateLockTest extends GridCommonAbstractTest {
-    /**
-     * @throws IgniteCheckedException If failed.
-     */
-    public void test() throws Exception {
-        final Ignite ignite = startNodeAndLock("node1");
-
-        new Thread(new Runnable() {
-            @Override public void run() {
-                try {
-                    Thread.sleep(2000);
-                }
-                catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-
-                ignite.close();
-            }
-        }).start();
-
-        startNodeAndLock("node2");
-    }
-
-    private Ignite startNodeAndLock(String name) {
-        try {
-            IgniteConfiguration cfg = new IgniteConfiguration();
-            cfg.setIgniteInstanceName(name);
-
-            Ignite ignite = Ignition.start(cfg);
-
-            IgniteLock lock = ignite.reentrantLock("lock", true, true, true);
-
-            System.out.println("acquiring lock");
-
-            lock.lock();
-
-            System.out.println("acquired lock");
-
-            return ignite;
-        }
-        catch (Exception e) {
-            assertTrue(false);
-        }
-
-        return null;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/d20f4588/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
index ac98104..abd74b3 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
@@ -22,7 +22,6 @@ import org.apache.ignite.internal.ClusterNodeMetricsSelfTest;
 import org.apache.ignite.internal.GridAffinityNoCacheSelfTest;
 import org.apache.ignite.internal.GridAffinitySelfTest;
 import org.apache.ignite.internal.GridAlwaysFailoverSpiFailSelfTest;
-import org.apache.ignite.internal.GridCacheRecreateLockTest;
 import org.apache.ignite.internal.GridCancelOnGridStopSelfTest;
 import org.apache.ignite.internal.GridCancelUnusedJobSelfTest;
 import org.apache.ignite.internal.GridCancelledJobsMetricsSelfTest;
@@ -158,7 +157,6 @@ public class IgniteComputeGridTestSuite {
         suite.addTestSuite(IgniteRoundRobinErrorAfterClientReconnectTest.class);
         suite.addTestSuite(PublicThreadpoolStarvationTest.class);
         suite.addTestSuite(StripedExecutorTest.class);
-        suite.addTestSuite(GridCacheRecreateLockTest.class);
 
         return suite;
     }


[44/65] [abbrv] ignite git commit: Merge remote-tracking branch 'origin/ignite-2.0' into ignite-2.0

Posted by ag...@apache.org.
Merge remote-tracking branch 'origin/ignite-2.0' into ignite-2.0


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

Branch: refs/heads/ignite-5024
Commit: d5a2ca218e696b51e317ca0cb1b32289df881f9c
Parents: f871b0d 0da8c70
Author: devozerov <vo...@gridgain.com>
Authored: Fri Apr 21 14:40:46 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Fri Apr 21 14:40:46 2017 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/IgniteCache.java     |  11 -
 .../org/apache/ignite/events/CacheEvent.java    |   3 -
 .../java/org/apache/ignite/events/Event.java    |   1 -
 .../org/apache/ignite/events/EventType.java     | 109 -----
 .../apache/ignite/events/SwapSpaceEvent.java    | 105 ----
 .../managers/indexing/GridIndexingManager.java  |  44 --
 .../processors/cache/CacheMetricsImpl.java      |  21 -
 .../processors/cache/GridCacheContext.java      |  23 -
 .../GridCacheEntryInfoCollectSwapListener.java  |  70 ---
 .../processors/cache/GridCacheSwapListener.java |  33 --
 .../processors/cache/IgniteCacheProxy.java      |   6 -
 .../cache/query/GridCacheQueryManager.java      |  59 ---
 .../platform/PlatformContextImpl.java           |  11 -
 .../platform/cache/PlatformCache.java           |   9 -
 .../processors/query/GridQueryIndexing.java     |  19 -
 .../processors/query/GridQueryProcessor.java    |  55 ---
 .../apache/ignite/spi/indexing/IndexingSpi.java |  19 -
 .../spi/indexing/noop/NoopIndexingSpi.java      |  10 -
 .../resources/META-INF/classnames.properties    |   1 -
 .../cache/GridCacheAbstractFullApiSelfTest.java |  45 --
 .../IgniteCacheConfigVariationsFullApiTest.java |  45 --
 .../IgniteCacheStoreValueAbstractTest.java      |   4 -
 .../IgniteTxExceptionAbstractSelfTest.java      |  10 -
 ...tractDistributedByteArrayValuesSelfTest.java |  43 --
 .../atomic/IgniteCacheAtomicProtocolTest.java   | 175 ++++++-
 ...tomicClientOnlyMultiNodeFullApiSelfTest.java |  51 +-
 ...achePartitionedMultiNodeFullApiSelfTest.java |  59 ---
 ...idCacheReplicatedUnswapAdvancedSelfTest.java | 151 ------
 .../cache/query/IndexingSpiQuerySelfTest.java   |  22 -
 .../cache/query/IndexingSpiQueryTxSelfTest.java |  10 -
 .../loadtests/cache/GridCacheSwapLoadTest.java  | 320 -------------
 .../multijvm/IgniteCacheProcessProxy.java       |   5 -
 .../testsuites/IgniteCacheTestSuite3.java       |   2 -
 .../processors/query/h2/IgniteH2Indexing.java   |  67 ---
 .../query/h2/opt/GridH2AbstractKeyValueRow.java |  89 +---
 .../query/h2/opt/GridH2KeyValueRowOffheap.java  |  70 ---
 .../query/h2/opt/GridH2RowDescriptor.java       |  11 -
 .../processors/query/h2/opt/GridH2Table.java    |  87 +---
 ...ryDuplicateIndexObjectsAbstractSelfTest.java | 159 -------
 .../cache/GridCacheOffHeapSelfTest.java         | 476 -------------------
 .../IgniteCacheQueryMultiThreadedSelfTest.java  |  25 -
 ...ateIndexObjectPartitionedAtomicSelfTest.java |  38 --
 ...xObjectPartitionedTransactionalSelfTest.java |  41 --
 .../query/IgniteQueryDedicatedPoolTest.java     |  10 -
 .../IgniteBinaryCacheQueryTestSuite.java        |   5 -
 .../stream/kafka/connect/IgniteSourceTask.java  |   4 -
 .../Cache/CacheAbstractTest.cs                  |  58 ---
 .../Cache/CacheTestAsyncWrapper.cs              |   6 -
 .../dotnet/Apache.Ignite.Core/Cache/ICache.cs   |   6 -
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |   8 -
 .../Apache.Ignite.Core/Impl/Cache/CacheOp.cs    |   1 -
 51 files changed, 159 insertions(+), 2553 deletions(-)
----------------------------------------------------------------------



[15/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/UnsupportedOperationException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/UnsupportedOperationException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/UnsupportedOperationException.java
new file mode 100644
index 0000000..0fea255
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/UnsupportedOperationException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.exceptions;
+
+import org.apache.ignite.IgniteException;
+
+/**
+ * Indicate that a specific operation is not supported by the underlying implementation.
+ * In some cases, an operation may be unsupported only in certain cases where, for example,
+ * it could not be deterministically completed in polynomial time.
+ */
+public class UnsupportedOperationException extends IgniteException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /**
+     * @param errMsg Error message.
+     */
+    public UnsupportedOperationException(String errMsg) {
+        super(errMsg);
+    }
+
+    /**
+     *
+     */
+    public UnsupportedOperationException() {
+        this("Unsupported operation.");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/package-info.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/package-info.java
new file mode 100644
index 0000000..1990a8a
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Contains exceptions for distributed code algebra.
+ */
+package org.apache.ignite.ml.math.exceptions;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
new file mode 100644
index 0000000..cd48daa
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.functions;
+
+/**
+ * Compatibility with Apache Mahout.
+ */
+public final class Functions {
+    /** Function that returns {@code Math.abs(a)}. */
+    public static final IgniteDoubleFunction<Double> ABS = Math::abs;
+
+    /** Function that returns its argument. */
+    public static final IgniteDoubleFunction<Double> IDENTITY = (a) -> a;
+
+    /** Function that returns {@code Math.log(a) / Math.log(2)}. */
+    public static final IgniteDoubleFunction<Double> LOG2 = (a) -> Math.log(a) * 1.4426950408889634;
+
+    /** Function that returns {@code -a}. */
+    public static final IgniteDoubleFunction<Double> NEGATE = (a) -> -a;
+
+    /** Function that returns {@code  a < 0 ? -1 : a > 0 ? 1 : 0 }. */
+    public static final IgniteDoubleFunction<Double> SIGN = (a) -> a < 0.0 ? -1.0 : a > 0.0 ? 1.0 : 0.0;
+
+    /** Function that returns {@code a * a}. */
+    public static final IgniteDoubleFunction<Double> SQUARE = (a) -> a * a;
+
+    /** Function that returns {@code  1 / (1 + exp(-a) } */
+    public static final IgniteDoubleFunction<Double> SIGMOID = (a) -> 1.0 / (1.0 + Math.exp(-a));
+
+    /** Function that returns {@code  1 / a } */
+    public static final IgniteDoubleFunction<Double> INV = (a) -> 1.0 / a;
+
+    /** Function that returns {@code  a * (1-a) } */
+    public static final IgniteDoubleFunction<Double> SIGMOIDGRADIENT = (a) -> a * (1.0 - a);
+
+    /** Function that returns {@code a % b}. */
+    public static final IgniteBiFunction<Double, Double, Double> MOD = (a, b) -> a % b;
+
+    /** Function that returns {@code a * b}. */
+    public static final IgniteBiFunction<Double, Double, Double> MULT = (a, b) -> a * b;
+
+    /** Function that returns {@code Math.log(a) / Math.log(b)}. */
+    public static final IgniteBiFunction<Double, Double, Double> LG = (a, b) -> Math.log(a) / Math.log(b);
+
+    /** Function that returns {@code a + b}. */
+    public static final IgniteBiFunction<Double, Double, Double> PLUS = (a, b) -> a + b;
+
+    /** Function that returns {@code a - b}. */
+    public static final IgniteBiFunction<Double, Double, Double> MINUS = (a, b) -> a - b;
+
+    /** Function that returns {@code abs(a - b)}. */
+    public static final IgniteBiFunction<Double, Double, Double> MINUS_ABS = (a, b) -> Math.abs(a - b);
+
+    /** Function that returns {@code max(abs(a), abs(b))}. */
+    public static final IgniteBiFunction<Double, Double, Double> MAX_ABS = (a, b) -> Math.max(Math.abs(a), Math.abs(b));
+
+    /** Function that returns {@code min(abs(a), abs(b))}. */
+    public static final IgniteBiFunction<Double, Double, Double> MIN_ABS = (a, b) -> Math.min(Math.abs(a), Math.abs(b));
+
+    /** Function that returns {@code Math.abs(a) + Math.abs(b)}. */
+    public static final IgniteBiFunction<Double, Double, Double> PLUS_ABS = (a, b) -> Math.abs(a) + Math.abs(b);
+
+    /** Function that returns {@code (a - b) * (a - b)} */
+    public static final IgniteBiFunction<Double, Double, Double> MINUS_SQUARED = (a, b) -> (a - b) * (a - b);
+
+    /**
+     * Function that returns {@code a &lt; b ? -1 : a &gt; b ? 1 : 0}.
+     */
+    public static final IgniteBiFunction<Double, Double, Double> COMPARE = (a, b) -> a < b ? -1.0 : a > b ? 1.0 : 0.0;
+
+    /**
+     * Function that returns {@code a + b}. {@code a} is a variable, {@code b} is fixed.
+     *
+     * @param b
+     */
+    public static IgniteDoubleFunction<Double> plus(final double b) {
+        return (a) -> a + b;
+    }
+
+    /**
+     * Function that returns {@code a * b}. {@code a} is a variable, {@code b} is fixed.
+     *
+     * @param b
+     */
+    public static IgniteDoubleFunction<Double> mult(final double b) {
+        return (a) -> a * b;
+    }
+
+    /** Function that returns {@code a / b}. {@code a} is a variable, {@code b} is fixed. */
+    public static IgniteDoubleFunction<Double> div(double b) {
+        return mult(1 / b);
+    }
+
+    /**
+     * Function that returns {@code a + b*constant}. {@code a} and {@code b} are variables,
+     * {@code constant} is fixed.
+     */
+    public static IgniteBiFunction<Double, Double, Double> plusMult(double constant) {
+        return (a, b) -> a + b * constant;
+    }
+
+    /**
+     * Function that returns {@code a - b*constant}. {@code a} and {@code b} are variables,
+     * {@code constant} is fixed.
+     */
+    public static IgniteBiFunction<Double, Double, Double> minusMult(double constant) {
+        return (a, b) -> a - b * constant;
+    }
+
+    /**
+     * @param b
+     */
+    public static IgniteDoubleFunction<Double> pow(final double b) {
+        return (a) -> {
+            if (b == 2)
+                return a * a;
+            else
+                return Math.pow(a, b);
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteBiConsumer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteBiConsumer.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteBiConsumer.java
new file mode 100644
index 0000000..f3303cd
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteBiConsumer.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.functions;
+
+import java.io.Serializable;
+import java.util.function.BiConsumer;
+
+/**
+ * Serializable binary consumer.
+ *
+ * @see java.util.function.BiConsumer
+ */
+public interface IgniteBiConsumer<T, U> extends BiConsumer<T, U>, Serializable {
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteBiFunction.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteBiFunction.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteBiFunction.java
new file mode 100644
index 0000000..dc49739
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteBiFunction.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.functions;
+
+import java.io.Serializable;
+import java.util.function.BiFunction;
+
+/**
+ * Serializable binary function.
+ *
+ * @see java.util.function.BiFunction
+ */
+public interface IgniteBiFunction<A, B, T> extends BiFunction<A, B, T>, Serializable {
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteConsumer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteConsumer.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteConsumer.java
new file mode 100644
index 0000000..1d52e1d
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteConsumer.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.functions;
+
+import java.io.Serializable;
+import java.util.function.Consumer;
+
+/**
+ * Serializable consumer.
+ *
+ * @see java.util.function.Consumer
+ */
+public interface IgniteConsumer<T> extends Consumer<T>, Serializable {
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteDoubleFunction.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteDoubleFunction.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteDoubleFunction.java
new file mode 100644
index 0000000..dfbf393
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteDoubleFunction.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.functions;
+
+import java.io.Serializable;
+import java.util.function.DoubleFunction;
+
+/**
+ * Serializable double function.
+ *
+ * @see java.util.function.DoubleFunction
+ */
+public interface IgniteDoubleFunction<Double> extends DoubleFunction<Double>, Serializable {
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteFunction.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteFunction.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteFunction.java
new file mode 100644
index 0000000..9d19592
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IgniteFunction.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.functions;
+
+import java.io.Serializable;
+import java.util.function.Function;
+
+/**
+ * Serializable function.
+ *
+ * @see java.util.function.Function
+ */
+public interface IgniteFunction<T, R> extends Function<T, R>, Serializable {
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IntDoubleToVoidFunction.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IntDoubleToVoidFunction.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IntDoubleToVoidFunction.java
new file mode 100644
index 0000000..981e0c5
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IntDoubleToVoidFunction.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.functions;
+
+/**
+ * Setter function for the vector.
+ */
+public interface IntDoubleToVoidFunction extends IgniteBiConsumer<Integer, Double> {
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IntIntDoubleToVoidFunction.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IntIntDoubleToVoidFunction.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IntIntDoubleToVoidFunction.java
new file mode 100644
index 0000000..a9b3f9c
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IntIntDoubleToVoidFunction.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.functions;
+
+import java.io.Serializable;
+
+/**
+ * Setter function for matrices.
+ */
+public interface IntIntDoubleToVoidFunction extends Serializable {
+    /** */
+    public void apply(int x, int y, double v);
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IntIntToDoubleFunction.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IntIntToDoubleFunction.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IntIntToDoubleFunction.java
new file mode 100644
index 0000000..5fabfb7
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/IntIntToDoubleFunction.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.functions;
+
+/**
+ * Getters functions for matrices.
+ */
+public interface IntIntToDoubleFunction extends IgniteBiFunction<Integer, Integer, Double> {
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/package-info.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/package-info.java
new file mode 100644
index 0000000..d41f94d
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Contains serializable functions for distributed code algebra.
+ */
+package org.apache.ignite.ml.math.functions;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/CacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/CacheUtils.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/CacheUtils.java
new file mode 100644
index 0000000..cfb01be
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/CacheUtils.java
@@ -0,0 +1,356 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.ml.math.KeyMapper;
+import org.apache.ignite.ml.math.ValueMapper;
+import org.apache.ignite.ml.math.functions.IgniteBiFunction;
+import org.apache.ignite.ml.math.functions.IgniteConsumer;
+import org.apache.ignite.ml.math.functions.IgniteFunction;
+
+/**
+ * Distribution-related misc. support.
+ */
+public class CacheUtils {
+    /**
+     * Cache entry support.
+     *
+     * @param <K>
+     * @param <V>
+     */
+    public static class CacheEntry<K, V> {
+        /** */
+        private Cache.Entry<K, V> entry;
+        /** */
+        private IgniteCache<K, V> cache;
+
+        /**
+         * @param entry Original cache entry.
+         * @param cache Cache instance.
+         */
+        CacheEntry(Cache.Entry<K, V> entry, IgniteCache<K, V> cache) {
+            this.entry = entry;
+            this.cache = cache;
+        }
+
+        /**
+         *
+         *
+         */
+        public Cache.Entry<K, V> entry() {
+            return entry;
+        }
+
+        /**
+         *
+         *
+         */
+        public IgniteCache<K, V> cache() {
+            return cache;
+        }
+    }
+
+    /**
+     * Gets local Ignite instance.
+     */
+    public static Ignite ignite() {
+        return Ignition.localIgnite();
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @param k Key into the cache.
+     * @param <K> Key type.
+     * @return Cluster group for given key.
+     */
+    public static <K> ClusterGroup groupForKey(String cacheName, K k) {
+        return ignite().cluster().forNode(ignite().affinity(cacheName).mapKeyToNode(k));
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @param keyMapper {@link KeyMapper} to validate cache key.
+     * @param valMapper {@link ValueMapper} to obtain double value for given cache key.
+     * @param <K> Cache key object type.
+     * @param <V> Cache value object type.
+     * @return Sum of the values obtained for valid keys.
+     */
+    public static <K, V> double sum(String cacheName, KeyMapper<K> keyMapper, ValueMapper<V> valMapper) {
+        Collection<Double> subSums = fold(cacheName, (CacheEntry<K, V> ce, Double acc) -> {
+            if (keyMapper.isValid(ce.entry().getKey())) {
+                double v = valMapper.toDouble(ce.entry().getValue());
+
+                return acc == null ? v : acc + v;
+            }
+            else
+                return acc;
+        });
+
+        return sum(subSums);
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @return Sum obtained using sparse logic.
+     */
+    public static <K, V> double sparseSum(String cacheName) {
+        Collection<Double> subSums = fold(cacheName, (CacheEntry<Integer, Map<Integer, Double>> ce, Double acc) -> {
+            Map<Integer, Double> map = ce.entry().getValue();
+
+            double sum = sum(map.values());
+
+            return acc == null ? sum : acc + sum;
+        });
+
+        return sum(subSums);
+    }
+
+    /**
+     * @param c {@link Collection} of double values to sum.
+     * @return Sum of the values.
+     */
+    private static double sum(Collection<Double> c) {
+        double sum = 0.0;
+
+        for (double d : c)
+            sum += d;
+
+        return sum;
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @param keyMapper {@link KeyMapper} to validate cache key.
+     * @param valMapper {@link ValueMapper} to obtain double value for given cache key.
+     * @param <K> Cache key object type.
+     * @param <V> Cache value object type.
+     * @return Minimum value for valid keys.
+     */
+    public static <K, V> double min(String cacheName, KeyMapper<K> keyMapper, ValueMapper<V> valMapper) {
+        Collection<Double> mins = fold(cacheName, (CacheEntry<K, V> ce, Double acc) -> {
+            if (keyMapper.isValid(ce.entry().getKey())) {
+                double v = valMapper.toDouble(ce.entry().getValue());
+
+                if (acc == null)
+                    return v;
+                else
+                    return Math.min(acc, v);
+            }
+            else
+                return acc;
+        });
+
+        return Collections.min(mins);
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @return Minimum value obtained using sparse logic.
+     */
+    public static <K, V> double sparseMin(String cacheName) {
+        Collection<Double> mins = fold(cacheName, (CacheEntry<Integer, Map<Integer, Double>> ce, Double acc) -> {
+            Map<Integer, Double> map = ce.entry().getValue();
+
+            double min = Collections.min(map.values());
+
+            if (acc == null)
+                return min;
+            else
+                return Math.min(acc, min);
+        });
+
+        return Collections.min(mins);
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @return Maximum value obtained using sparse logic.
+     */
+    public static <K, V> double sparseMax(String cacheName) {
+        Collection<Double> maxes = fold(cacheName, (CacheEntry<Integer, Map<Integer, Double>> ce, Double acc) -> {
+            Map<Integer, Double> map = ce.entry().getValue();
+
+            double max = Collections.max(map.values());
+
+            if (acc == null)
+                return max;
+            else
+                return Math.max(acc, max);
+        });
+
+        return Collections.max(maxes);
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @param keyMapper {@link KeyMapper} to validate cache key.
+     * @param valMapper {@link ValueMapper} to obtain double value for given cache key.
+     * @param <K> Cache key object type.
+     * @param <V> Cache value object type.
+     * @return Maximum value for valid keys.
+     */
+    public static <K, V> double max(String cacheName, KeyMapper<K> keyMapper, ValueMapper<V> valMapper) {
+        Collection<Double> maxes = fold(cacheName, (CacheEntry<K, V> ce, Double acc) -> {
+            if (keyMapper.isValid(ce.entry().getKey())) {
+                double v = valMapper.toDouble(ce.entry().getValue());
+
+                if (acc == null)
+                    return v;
+                else
+                    return Math.max(acc, v);
+            }
+            else
+                return acc;
+        });
+
+        return Collections.max(maxes);
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @param keyMapper {@link KeyMapper} to validate cache key.
+     * @param valMapper {@link ValueMapper} to obtain double value for given cache key.
+     * @param mapper Mapping {@link IgniteFunction}.
+     * @param <K> Cache key object type.
+     * @param <V> Cache value object type.
+     */
+    public static <K, V> void map(String cacheName, KeyMapper<K> keyMapper, ValueMapper<V> valMapper,
+        IgniteFunction<Double, Double> mapper) {
+        foreach(cacheName, (CacheEntry<K, V> ce) -> {
+            K k = ce.entry().getKey();
+
+            if (keyMapper.isValid(k))
+                // Actual assignment.
+                ce.cache().put(k, valMapper.fromDouble(mapper.apply(valMapper.toDouble(ce.entry().getValue()))));
+        });
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @param mapper Mapping {@link IgniteFunction}.
+     */
+    public static <K, V> void sparseMap(String cacheName, IgniteFunction<Double, Double> mapper) {
+        foreach(cacheName, (CacheEntry<Integer, Map<Integer, Double>> ce) -> {
+            Integer k = ce.entry().getKey();
+            Map<Integer, Double> v = ce.entry().getValue();
+
+            for (Map.Entry<Integer, Double> e : v.entrySet())
+                e.setValue(mapper.apply(e.getValue()));
+
+            ce.cache().put(k, v);
+        });
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @param fun An operation that accepts a cache entry and processes it.
+     * @param <K> Cache key object type.
+     * @param <V> Cache value object type.
+     */
+    public static <K, V> void foreach(String cacheName, IgniteConsumer<CacheEntry<K, V>> fun) {
+        bcast(cacheName, () -> {
+            Ignite ignite = Ignition.localIgnite();
+            IgniteCache<K, V> cache = ignite.getOrCreateCache(cacheName);
+
+            int partsCnt = ignite.affinity(cacheName).partitions();
+
+            // Use affinity in filter for scan query. Otherwise we accept consumer in each node which is wrong.
+            Affinity affinity = ignite.affinity(cacheName);
+            ClusterNode locNode = ignite.cluster().localNode();
+
+            // Iterate over all partitions. Some of them will be stored on that local node.
+            for (int part = 0; part < partsCnt; part++) {
+                int p = part;
+
+                // 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)))
+                    fun.accept(new CacheEntry<>(entry, cache));
+            }
+        });
+    }
+
+    /**
+     * <b>Currently fold supports only commutative operations.<b/>
+     *
+     * @param cacheName Cache name.
+     * @param folder Fold function operating over cache entries.
+     * @param <K> Cache key object type.
+     * @param <V> Cache value object type.
+     * @param <A> Fold result type.
+     * @return Fold operation result.
+     */
+    public static <K, V, A> Collection<A> fold(String cacheName, IgniteBiFunction<CacheEntry<K, V>, A, A> folder) {
+        return bcast(cacheName, () -> {
+            Ignite ignite = Ignition.localIgnite();
+            IgniteCache<K, V> cache = ignite.getOrCreateCache(cacheName);
+
+            int partsCnt = ignite.affinity(cacheName).partitions();
+
+            // Use affinity in filter for ScanQuery. Otherwise we accept consumer in each node which is wrong.
+            Affinity affinity = ignite.affinity(cacheName);
+            ClusterNode locNode = ignite.cluster().localNode();
+
+            A a = null;
+
+            // Iterate over all partitions. Some of them will be stored on that local node.
+            for (int part = 0; part < partsCnt; part++) {
+                int p = part;
+
+                // 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)))
+                    a = folder.apply(new CacheEntry<>(entry, cache), a);
+            }
+
+            return a;
+        });
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @param run {@link Runnable} to broadcast to cache nodes for given cache name.
+     */
+    public static void bcast(String cacheName, IgniteRunnable run) {
+        ignite().compute(ignite().cluster().forCacheNodes(cacheName)).broadcast(run);
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @param call {@link IgniteCallable} to broadcast to cache nodes for given cache name.
+     * @param <A> Type returned by the callable.
+     */
+    public static <A> Collection<A> bcast(String cacheName, IgniteCallable<A> call) {
+        return ignite().compute(ignite().cluster().forCacheNodes(cacheName)).broadcast(call);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/AbstractMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/AbstractMatrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/AbstractMatrix.java
new file mode 100644
index 0000000..c5edeb1
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/AbstractMatrix.java
@@ -0,0 +1,880 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.decompositions.LUDecomposition;
+import org.apache.ignite.ml.math.exceptions.CardinalityException;
+import org.apache.ignite.ml.math.exceptions.ColumnIndexException;
+import org.apache.ignite.ml.math.exceptions.RowIndexException;
+import org.apache.ignite.ml.math.functions.Functions;
+import org.apache.ignite.ml.math.functions.IgniteBiFunction;
+import org.apache.ignite.ml.math.functions.IgniteDoubleFunction;
+import org.apache.ignite.ml.math.functions.IgniteFunction;
+import org.apache.ignite.ml.math.functions.IntIntToDoubleFunction;
+import org.apache.ignite.ml.math.impls.vector.MatrixVectorView;
+
+/**
+ * This class provides a helper implementation of the {@link Matrix}
+ * interface to minimize the effort required to implement it.
+ * Subclasses may override some of the implemented methods if a more
+ * specific or optimized implementation is desirable.
+ *
+ * TODO: add row/column optimization.
+ */
+public abstract class AbstractMatrix implements Matrix {
+    // Stochastic sparsity analysis.
+    /** */
+    private static final double Z95 = 1.959964;
+    /** */
+    private static final double Z80 = 1.281552;
+    /** */
+    private static final int MAX_SAMPLES = 500;
+    /** */
+    private static final int MIN_SAMPLES = 15;
+
+    /** Cached minimum element. */
+    private Element minElm;
+    /** Cached maximum element. */
+    private Element maxElm = null;
+
+    /** Matrix storage implementation. */
+    private MatrixStorage sto;
+
+    /** Meta attributes storage. */
+    private Map<String, Object> meta = new HashMap<>();
+
+    /** Matrix's GUID. */
+    private IgniteUuid guid = IgniteUuid.randomUuid();
+
+    /**
+     * @param sto Backing {@link MatrixStorage}.
+     */
+    public AbstractMatrix(MatrixStorage sto) {
+        this.sto = sto;
+    }
+
+    /**
+     *
+     */
+    public AbstractMatrix() {
+        // No-op.
+    }
+
+    /**
+     * @param sto Backing {@link MatrixStorage}.
+     */
+    protected void setStorage(MatrixStorage sto) {
+        assert sto != null;
+
+        this.sto = sto;
+    }
+
+    /**
+     * @param row Row index in the matrix.
+     * @param col Column index in the matrix.
+     * @param v Value to set.
+     */
+    protected void storageSet(int row, int col, double v) {
+        sto.set(row, col, v);
+
+        // Reset cached values.
+        minElm = maxElm = null;
+    }
+
+    /**
+     * @param row Row index in the matrix.
+     * @param col Column index in the matrix.
+     */
+    protected double storageGet(int row, int col) {
+        return sto.get(row, col);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Element maxElement() {
+        if (maxElm == null) {
+            double max = Double.NEGATIVE_INFINITY;
+            int row = 0, col = 0;
+
+            int rows = rowSize();
+            int cols = columnSize();
+
+            for (int x = 0; x < rows; x++)
+                for (int y = 0; y < cols; y++) {
+                    double d = storageGet(x, y);
+
+                    if (d > max) {
+                        max = d;
+                        row = x;
+                        col = y;
+                    }
+                }
+
+            maxElm = mkElement(row, col);
+        }
+
+        return maxElm;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Element minElement() {
+        if (minElm == null) {
+            double min = Double.MAX_VALUE;
+            int row = 0, col = 0;
+
+            int rows = rowSize();
+            int cols = columnSize();
+
+            for (int x = 0; x < rows; x++)
+                for (int y = 0; y < cols; y++) {
+                    double d = storageGet(x, y);
+
+                    if (d < min) {
+                        min = d;
+                        row = x;
+                        col = y;
+                    }
+                }
+
+            minElm = mkElement(row, col);
+        }
+
+        return minElm;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double maxValue() {
+        return maxElement().get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double minValue() {
+        return minElement().get();
+    }
+
+    /**
+     * @param row Row index in the matrix.
+     * @param col Column index in the matrix.
+     */
+    private Element mkElement(int row, int col) {
+        return new Element() {
+            /** {@inheritDoc} */
+            @Override public double get() {
+                return storageGet(row, col);
+            }
+
+            /** {@inheritDoc} */
+            @Override public int row() {
+                return row;
+            }
+
+            /** {@inheritDoc} */
+            @Override public int column() {
+                return col;
+            }
+
+            /** {@inheritDoc} */
+            @Override public void set(double d) {
+                storageSet(row, col, d);
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override public Element getElement(int row, int col) {
+        return mkElement(row, col);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix swapRows(int row1, int row2) {
+        checkRowIndex(row1);
+        checkRowIndex(row2);
+
+        int cols = columnSize();
+
+        for (int y = 0; y < cols; y++) {
+            double v = getX(row1, y);
+
+            setX(row1, y, getX(row2, y));
+            setX(row2, y, v);
+        }
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix swapColumns(int col1, int col2) {
+        checkColumnIndex(col1);
+        checkColumnIndex(col2);
+
+        int rows = rowSize();
+
+        for (int x = 0; x < rows; x++) {
+            double v = getX(x, col1);
+
+            setX(x, col1, getX(x, col2));
+            setX(x, col2, v);
+        }
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public MatrixStorage getStorage() {
+        return sto;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return sto.isSequentialAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return sto.isDense();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return sto.isRandomAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return sto.isDistributed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return sto.isArrayBased();
+    }
+
+    /**
+     * Check row index bounds.
+     *
+     * @param row Row index.
+     */
+    private void checkRowIndex(int row) {
+        if (row < 0 || row >= rowSize())
+            throw new RowIndexException(row);
+    }
+
+    /**
+     * Check column index bounds.
+     *
+     * @param col Column index.
+     */
+    private void checkColumnIndex(int col) {
+        if (col < 0 || col >= columnSize())
+            throw new ColumnIndexException(col);
+    }
+
+    /**
+     * Check column and row index bounds.
+     *
+     * @param row Row index.
+     * @param col Column index.
+     */
+    protected void checkIndex(int row, int col) {
+        checkRowIndex(row);
+        checkColumnIndex(col);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(sto);
+        out.writeObject(meta);
+        out.writeObject(guid);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Map<String, Object> getMetaStorage() {
+        return meta;
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        sto = (MatrixStorage)in.readObject();
+        meta = (Map<String, Object>)in.readObject();
+        guid = (IgniteUuid)in.readObject();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix assign(double val) {
+        if (sto.isArrayBased())
+            for (double[] column : sto.data())
+                Arrays.fill(column, val);
+        else {
+            int rows = rowSize();
+            int cols = columnSize();
+
+            for (int x = 0; x < rows; x++)
+                for (int y = 0; y < cols; y++)
+                    storageSet(x, y, val);
+        }
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix assign(IntIntToDoubleFunction fun) {
+        int rows = rowSize();
+        int cols = columnSize();
+
+        for (int x = 0; x < rows; x++)
+            for (int y = 0; y < cols; y++)
+                storageSet(x, y, fun.apply(x, y));
+
+        return this;
+    }
+
+    /** */
+    private void checkCardinality(Matrix mtx) {
+        checkCardinality(mtx.rowSize(), mtx.columnSize());
+    }
+
+    /** */
+    private void checkCardinality(int rows, int cols) {
+        if (rows != rowSize())
+            throw new CardinalityException(rowSize(), rows);
+
+        if (cols != columnSize())
+            throw new CardinalityException(columnSize(), cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix assign(double[][] vals) {
+        checkCardinality(vals.length, vals[0].length);
+
+        int rows = rowSize();
+        int cols = columnSize();
+
+        for (int x = 0; x < rows; x++)
+            for (int y = 0; y < cols; y++)
+                storageSet(x, y, vals[x][y]);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix assign(Matrix mtx) {
+        checkCardinality(mtx);
+
+        int rows = rowSize();
+        int cols = columnSize();
+
+        for (int x = 0; x < rows; x++)
+            for (int y = 0; y < cols; y++)
+                storageSet(x, y, mtx.getX(x, y));
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix map(IgniteDoubleFunction<Double> fun) {
+        int rows = rowSize();
+        int cols = columnSize();
+
+        for (int x = 0; x < rows; x++)
+            for (int y = 0; y < cols; y++)
+                storageSet(x, y, fun.apply(storageGet(x, y)));
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix map(Matrix mtx, IgniteBiFunction<Double, Double, Double> fun) {
+        checkCardinality(mtx);
+
+        int rows = rowSize();
+        int cols = columnSize();
+
+        for (int x = 0; x < rows; x++)
+            for (int y = 0; y < cols; y++)
+                storageSet(x, y, fun.apply(storageGet(x, y), mtx.getX(x, y)));
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix assignColumn(int col, Vector vec) {
+        checkColumnIndex(col);
+
+        int rows = rowSize();
+
+        for (int x = 0; x < rows; x++)
+            storageSet(x, col, vec.getX(x));
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix assignRow(int row, Vector vec) {
+        checkRowIndex(row);
+
+        int cols = columnSize();
+
+        if (cols != vec.size())
+            throw new CardinalityException(cols, vec.size());
+
+        if (sto.isArrayBased() && vec.getStorage().isArrayBased())
+            System.arraycopy(vec.getStorage().data(), 0, sto.data()[row], 0, cols);
+        else
+            for (int y = 0; y < cols; y++)
+                storageSet(row, y, vec.getX(y));
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector foldRows(IgniteFunction<Vector, Double> fun) {
+        int rows = rowSize();
+
+        Vector vec = likeVector(rows);
+
+        for (int i = 0; i < rows; i++)
+            vec.setX(i, fun.apply(viewRow(i)));
+
+        return vec;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector foldColumns(IgniteFunction<Vector, Double> fun) {
+        int cols = columnSize();
+
+        Vector vec = likeVector(cols);
+
+        for (int i = 0; i < cols; i++)
+            vec.setX(i, fun.apply(viewColumn(i)));
+
+        return vec;
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T foldMap(IgniteBiFunction<T, Double, T> foldFun, IgniteDoubleFunction<Double> mapFun,
+        T zeroVal) {
+        T res = zeroVal;
+
+        int rows = rowSize();
+        int cols = columnSize();
+
+        for (int x = 0; x < rows; x++)
+            for (int y = 0; y < cols; y++)
+                res = foldFun.apply(res, mapFun.apply(storageGet(x, y)));
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int columnSize() {
+        return sto.columnSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int rowSize() {
+        return sto.rowSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double determinant() {
+        //TODO: This decomposition should be cached
+        LUDecomposition dec = new LUDecomposition(this);
+        double res = dec.determinant();
+        dec.destroy();
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix inverse() {
+        if (rowSize() != columnSize())
+            throw new CardinalityException(rowSize(), columnSize());
+
+        //TODO: This decomposition should be cached
+        LUDecomposition dec = new LUDecomposition(this);
+
+        Matrix res = dec.solve(likeIdentity());
+        dec.destroy();
+
+        return res;
+    }
+
+    /** */
+    protected Matrix likeIdentity() {
+        int n = rowSize();
+        Matrix res = like(n, n);
+
+        for (int i = 0; i < n; i++)
+            res.setX(i, i, 1.0);
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix divide(double d) {
+        int rows = rowSize();
+        int cols = columnSize();
+
+        for (int x = 0; x < rows; x++)
+            for (int y = 0; y < cols; y++)
+                setX(x, y, getX(x, y) / d);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int row, int col) {
+        checkIndex(row, col);
+
+        return storageGet(row, col);
+    }
+
+    /** {@inheritDoc} */
+    @Override public double getX(int row, int col) {
+        return storageGet(row, col);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix minus(Matrix mtx) {
+        int rows = rowSize();
+        int cols = columnSize();
+
+        checkCardinality(rows, cols);
+
+        Matrix res = like(rows, cols);
+
+        for (int x = 0; x < rows; x++)
+            for (int y = 0; y < cols; y++)
+                res.setX(x, y, getX(x, y) - mtx.getX(x, y));
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix plus(double x) {
+        Matrix cp = copy();
+
+        cp.map(Functions.plus(x));
+
+        return cp;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix plus(Matrix mtx) {
+        int rows = rowSize();
+        int cols = columnSize();
+
+        checkCardinality(rows, cols);
+
+        Matrix res = like(rows, cols);
+
+        for (int x = 0; x < rows; x++)
+            for (int y = 0; y < cols; y++)
+                res.setX(x, y, getX(x, y) + mtx.getX(x, y));
+
+        return res;
+
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteUuid guid() {
+        return guid;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix set(int row, int col, double val) {
+        checkIndex(row, col);
+
+        storageSet(row, col, val);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix setRow(int row, double[] data) {
+        checkRowIndex(row);
+
+        int cols = columnSize();
+
+        if (cols != data.length)
+            throw new CardinalityException(cols, data.length);
+
+        if (sto.isArrayBased())
+            System.arraycopy(data, 0, sto.data()[row], 0, cols);
+        else
+            for (int y = 0; y < cols; y++)
+                setX(row, y, data[y]);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix setColumn(int col, double[] data) {
+        checkColumnIndex(col);
+
+        int rows = rowSize();
+
+        if (rows != data.length)
+            throw new CardinalityException(rows, data.length);
+
+        for (int x = 0; x < rows; x++)
+            setX(x, col, data[x]);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix setX(int row, int col, double val) {
+        storageSet(row, col, val);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix times(double x) {
+        Matrix cp = copy();
+
+        cp.map(Functions.mult(x));
+
+        return cp;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double maxAbsRowSumNorm() {
+        double max = 0.0;
+
+        int rows = rowSize();
+        int cols = columnSize();
+
+        for (int x = 0; x < rows; x++) {
+            double sum = 0;
+
+            for (int y = 0; y < cols; y++)
+                sum += Math.abs(getX(x, y));
+
+            if (sum > max)
+                max = sum;
+        }
+
+        return max;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector times(Vector vec) {
+        int cols = columnSize();
+
+        if (cols != vec.size())
+            throw new CardinalityException(cols, vec.size());
+
+        int rows = rowSize();
+
+        Vector res = likeVector(rows);
+
+        for (int x = 0; x < rows; x++)
+            res.setX(x, vec.dot(viewRow(x)));
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix times(Matrix mtx) {
+        int cols = columnSize();
+
+        if (cols != mtx.rowSize())
+            throw new CardinalityException(cols, mtx.rowSize());
+
+        int rows = rowSize();
+
+        int mtxCols = mtx.columnSize();
+
+        Matrix res = like(rows, mtxCols);
+
+        for (int x = 0; x < rows; x++)
+            for (int y = 0; y < mtxCols; y++) {
+                double sum = 0.0;
+
+                for (int k = 0; k < cols; k++)
+                    sum += getX(x, k) * mtx.getX(k, y);
+
+                res.setX(x, y, sum);
+            }
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double sum() {
+        int rows = rowSize();
+        int cols = columnSize();
+
+        double sum = 0.0;
+
+        for (int x = 0; x < rows; x++)
+            for (int y = 0; y < cols; y++)
+                sum += getX(x, y);
+
+        return sum;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix transpose() {
+        int rows = rowSize();
+        int cols = columnSize();
+
+        Matrix mtx = like(cols, rows);
+
+        for (int x = 0; x < rows; x++)
+            for (int y = 0; y < cols; y++)
+                mtx.setX(y, x, getX(x, y));
+
+        return mtx;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean density(double threshold) {
+        assert threshold >= 0.0 && threshold <= 1.0;
+
+        int n = MIN_SAMPLES;
+        int rows = rowSize();
+        int cols = columnSize();
+
+        double mean = 0.0;
+        double pq = threshold * (1 - threshold);
+
+        Random rnd = new Random();
+
+        for (int i = 0; i < MIN_SAMPLES; i++)
+            if (getX(rnd.nextInt(rows), rnd.nextInt(cols)) != 0.0)
+                mean++;
+
+        mean /= MIN_SAMPLES;
+
+        double iv = Z80 * Math.sqrt(pq / n);
+
+        if (mean < threshold - iv)
+            return false; // Sparse.
+        else if (mean > threshold + iv)
+            return true; // Dense.
+
+        while (n < MAX_SAMPLES) {
+            // Determine upper bound we may need for 'n' to likely relinquish the uncertainty.
+            // Here, we use confidence interval formula but solved for 'n'.
+            double ivX = Math.max(Math.abs(threshold - mean), 1e-11);
+
+            double stdErr = ivX / Z80;
+            double nX = Math.min(Math.max((int)Math.ceil(pq / (stdErr * stdErr)), n), MAX_SAMPLES) - n;
+
+            if (nX < 1.0) // IMPL NOTE this can happen with threshold 1.0
+                nX = 1.0;
+
+            double meanNext = 0.0;
+
+            for (int i = 0; i < nX; i++)
+                if (getX(rnd.nextInt(rows), rnd.nextInt(cols)) != 0.0)
+                    meanNext++;
+
+            mean = (n * mean + meanNext) / (n + nX);
+
+            n += nX;
+
+            // Are we good now?
+            iv = Z80 * Math.sqrt(pq / n);
+
+            if (mean < threshold - iv)
+                return false; // Sparse.
+            else if (mean > threshold + iv)
+                return true; // Dense.
+        }
+
+        return mean > threshold; // Dense if mean > threshold.
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix viewPart(int[] off, int[] size) {
+        return new MatrixView(this, off[0], off[1], size[0], size[1]);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix viewPart(int rowOff, int rows, int colOff, int cols) {
+        return viewPart(new int[] {rowOff, colOff}, new int[] {rows, cols});
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector viewRow(int row) {
+        return new MatrixVectorView(this, row, 0, 0, 1);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector viewColumn(int col) {
+        return new MatrixVectorView(this, 0, col, 1, 0);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector viewDiagonal() {
+        return new MatrixVectorView(this, 0, 0, 1, 1);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix copy() {
+        Matrix cp = like(rowSize(), columnSize());
+
+        cp.assign(this);
+
+        return cp;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + guid.hashCode();
+        res = res * 37 + sto.hashCode();
+        res = res * 37 + meta.hashCode();
+
+        return res;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * We ignore guid's for comparisons.
+     */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        AbstractMatrix that = (AbstractMatrix)o;
+
+        MatrixStorage sto = getStorage();
+
+        return (sto != null ? sto.equals(that.getStorage()) : that.getStorage() == null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrix.java
new file mode 100644
index 0000000..73a3493
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrix.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.MatrixKeyMapper;
+import org.apache.ignite.ml.math.ValueMapper;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.IgniteDoubleFunction;
+import org.apache.ignite.ml.math.functions.IgniteFunction;
+import org.apache.ignite.ml.math.impls.CacheUtils;
+import org.apache.ignite.ml.math.impls.storage.matrix.CacheMatrixStorage;
+
+/**
+ * Matrix based on existing cache and key and value mapping functions.
+ */
+public class CacheMatrix<K, V> extends AbstractMatrix {
+    /**
+     *
+     */
+    public CacheMatrix() {
+        // No-op.
+    }
+
+    /**
+     * Creates new matrix over existing cache.
+     *
+     * @param rows
+     * @param cols
+     * @param cache
+     * @param keyMapper
+     * @param valMapper
+     */
+    public CacheMatrix(
+        int rows,
+        int cols,
+        IgniteCache<K, V> cache,
+        MatrixKeyMapper<K> keyMapper,
+        ValueMapper<V> valMapper) {
+        assert rows > 0;
+        assert cols > 0;
+        assert cache != null;
+        assert keyMapper != null;
+        assert valMapper != null;
+
+        setStorage(new CacheMatrixStorage<>(rows, cols, cache, keyMapper, valMapper));
+    }
+
+    /**
+     *
+     *
+     */
+    @SuppressWarnings({"unchecked"})
+    private CacheMatrixStorage<K, V> storage() {
+        return (CacheMatrixStorage<K, V>)getStorage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix copy() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix like(int rows, int cols) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector likeVector(int crd) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Return the same matrix with updates values (broken contract).
+     *
+     * @param d
+     */
+    @Override public Matrix divide(double d) {
+        return mapOverValues((Double v) -> v / d);
+    }
+
+    /**
+     * Return the same matrix with updates values (broken contract).
+     *
+     * @param x
+     */
+    @Override public Matrix plus(double x) {
+        return mapOverValues((Double v) -> v + x);
+    }
+
+    /**
+     * Return the same matrix with updates values (broken contract).
+     *
+     * @param x
+     */
+    @Override public Matrix times(double x) {
+        return mapOverValues((Double v) -> v * x);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix assign(double val) {
+        return mapOverValues((Double v) -> val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix map(IgniteDoubleFunction<Double> fun) {
+        return mapOverValues(fun::apply);
+    }
+
+    /** {@inheritDoc} */
+    @Override public double sum() {
+        CacheMatrixStorage<K, V> sto = storage();
+
+        return CacheUtils.sum(sto.cache().getName(), sto.keyMapper(), sto.valueMapper());
+    }
+
+    /** {@inheritDoc} */
+    @Override public double maxValue() {
+        CacheMatrixStorage<K, V> sto = storage();
+
+        return CacheUtils.max(sto.cache().getName(), sto.keyMapper(), sto.valueMapper());
+    }
+
+    /** {@inheritDoc} */
+    @Override public double minValue() {
+        CacheMatrixStorage<K, V> sto = storage();
+
+        return CacheUtils.min(sto.cache().getName(), sto.keyMapper(), sto.valueMapper());
+    }
+
+    /**
+     * @param mapper
+     */
+    private Matrix mapOverValues(IgniteFunction<Double, Double> mapper) {
+        CacheMatrixStorage<K, V> sto = storage();
+
+        CacheUtils.map(sto.cache().getName(), sto.keyMapper(), sto.valueMapper(), mapper);
+
+        return this;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOffHeapMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOffHeapMatrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOffHeapMatrix.java
new file mode 100644
index 0000000..4161228
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOffHeapMatrix.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.storage.matrix.DenseOffHeapMatrixStorage;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOffHeapVector;
+
+/**
+ * Dense local off-heap implementation of the {@link Matrix} interface.
+ */
+public class DenseLocalOffHeapMatrix extends AbstractMatrix {
+    /** */
+    public DenseLocalOffHeapMatrix() {
+        // No-op.
+    }
+
+    /**
+     * @param data Backing data array.
+     */
+    public DenseLocalOffHeapMatrix(double[][] data) {
+        assert data != null;
+
+        setStorage(new DenseOffHeapMatrixStorage(data));
+    }
+
+    /**
+     * @param rows Amount of rows in matrix.
+     * @param cols Amount of columns in matrix.
+     */
+    public DenseLocalOffHeapMatrix(int rows, int cols) {
+        assert rows > 0;
+        assert cols > 0;
+
+        setStorage(new DenseOffHeapMatrixStorage(rows, cols));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix copy() {
+        DenseLocalOffHeapMatrix cp = new DenseLocalOffHeapMatrix(getStorage().rowSize(), getStorage().columnSize());
+
+        cp.assign(this);
+
+        return cp;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix like(int rows, int cols) {
+        return new DenseLocalOffHeapMatrix(rows, cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector likeVector(int crd) {
+        return new DenseLocalOffHeapVector(crd);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void destroy() {
+        getStorage().destroy();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Matrix likeIdentity() {
+        int n = rowSize();
+        Matrix res = like(n, n);
+
+        // IMPL NOTE as opposed to on-heap matrices this one isn't initialized with zeroes
+        for (int i = 0; i < n; i++)
+            for (int j = 0; j < n; j++)
+                res.setX(i, j, i == j ? 1.0 : 0.0);
+
+        return res;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOnHeapMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOnHeapMatrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOnHeapMatrix.java
new file mode 100644
index 0000000..f95e0cc
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOnHeapMatrix.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.storage.matrix.ArrayMatrixStorage;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+
+/**
+ * Basic implementation for matrix.
+ *
+ * This is a trivial implementation for matrix assuming dense logic, local on-heap JVM storage
+ * based on <code>double[][]</code> array. It is only suitable for data sets where
+ * local, non-distributed execution is satisfactory and on-heap JVM storage is enough
+ * to keep the entire data set.
+ */
+public class DenseLocalOnHeapMatrix extends AbstractMatrix {
+    /**
+     *
+     */
+    public DenseLocalOnHeapMatrix() {
+        // No-op.
+    }
+
+    /**
+     * @param rows Amount of rows in matrix.
+     * @param cols Amount of columns in matrix.
+     */
+    public DenseLocalOnHeapMatrix(int rows, int cols) {
+        assert rows > 0;
+        assert cols > 0;
+
+        setStorage(new ArrayMatrixStorage(rows, cols));
+    }
+
+    /**
+     * @param mtx Backing data array.
+     */
+    public DenseLocalOnHeapMatrix(double[][] mtx) {
+        assert mtx != null;
+
+        setStorage(new ArrayMatrixStorage(mtx));
+    }
+
+    /**
+     * @param orig Original matrix.
+     */
+    private DenseLocalOnHeapMatrix(DenseLocalOnHeapMatrix orig) {
+        assert orig != null;
+
+        setStorage(new ArrayMatrixStorage(orig.rowSize(), orig.columnSize()));
+
+        assign(orig);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix copy() {
+        return new DenseLocalOnHeapMatrix(this);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix like(int rows, int cols) {
+        return new DenseLocalOnHeapMatrix(rows, cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector likeVector(int crd) {
+        return new DenseLocalOnHeapVector(crd);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/DiagonalMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/DiagonalMatrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/DiagonalMatrix.java
new file mode 100644
index 0000000..bd9a4a1
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/DiagonalMatrix.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.storage.matrix.DiagonalMatrixStorage;
+import org.apache.ignite.ml.math.impls.vector.ConstantVector;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.apache.ignite.ml.math.impls.vector.SingleElementVectorView;
+
+/**
+ * Implementation of diagonal view of the {@link Matrix}.
+ *
+ * <p>See also: <a href="https://en.wikipedia.org/wiki/Diagonal_matrix">Wikipedia article</a>.</p>
+ */
+public class DiagonalMatrix extends AbstractMatrix {
+    /**
+     *
+     */
+    public DiagonalMatrix() {
+        // No-op.
+    }
+
+    /**
+     * @param diagonal Backing {@link Vector}.
+     */
+    public DiagonalMatrix(Vector diagonal) {
+        super(new DiagonalMatrixStorage(diagonal));
+    }
+
+    /**
+     * @param mtx Backing {@link Matrix}.
+     */
+    public DiagonalMatrix(Matrix mtx) {
+        super(new DiagonalMatrixStorage(mtx == null ? null : mtx.viewDiagonal()));
+    }
+
+    /**
+     * @param vals Backing array of values at diagonal.
+     */
+    public DiagonalMatrix(double[] vals) {
+        super(new DiagonalMatrixStorage(new DenseLocalOnHeapVector(vals)));
+    }
+
+    /**
+     *
+     *
+     */
+    private DiagonalMatrixStorage storage() {
+        return (DiagonalMatrixStorage)getStorage();
+    }
+
+    /**
+     * @param size Size of diagonal.
+     * @param val Constant value at diagonal.
+     */
+    public DiagonalMatrix(int size, double val) {
+        super(new DiagonalMatrixStorage(new ConstantVector(size, val)));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector viewRow(int row) {
+        return new SingleElementVectorView(storage().diagonal(), row);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector viewColumn(int col) {
+        return new SingleElementVectorView(storage().diagonal(), col);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix copy() {
+        return new DiagonalMatrix(storage().diagonal());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix like(int rows, int cols) {
+        return storage().diagonal().likeMatrix(rows, cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector likeVector(int crd) {
+        return storage().diagonal().like(crd);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/FunctionMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/FunctionMatrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/FunctionMatrix.java
new file mode 100644
index 0000000..020d50a
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/FunctionMatrix.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.IntIntDoubleToVoidFunction;
+import org.apache.ignite.ml.math.functions.IntIntToDoubleFunction;
+import org.apache.ignite.ml.math.impls.storage.matrix.FunctionMatrixStorage;
+
+/**
+ * Implementation of {@link Matrix} that maps row and column index to {@link java.util.function} interfaces.
+ */
+public class FunctionMatrix extends AbstractMatrix {
+    /**
+     *
+     */
+    public FunctionMatrix() {
+        // No-op.
+    }
+
+    /**
+     * Creates read-write or read-only function matrix.
+     *
+     * @param rows Amount of rows in the matrix.
+     * @param cols Amount of columns in the matrix.
+     * @param getFunc Function that returns value corresponding to given row and column index.
+     * @param setFunc Set function. If {@code null} - this will be a read-only matrix.
+     */
+    public FunctionMatrix(int rows, int cols, IntIntToDoubleFunction getFunc, IntIntDoubleToVoidFunction setFunc) {
+        assert rows > 0;
+        assert cols > 0;
+        assert getFunc != null;
+
+        setStorage(new FunctionMatrixStorage(rows, cols, getFunc, setFunc));
+    }
+
+    /**
+     * Creates read-only function matrix.
+     *
+     * @param rows Amount of rows in the matrix.
+     * @param cols Amount of columns in the matrix.
+     * @param getFunc Function that returns value corresponding to given row and column index.
+     */
+    public FunctionMatrix(int rows, int cols, IntIntToDoubleFunction getFunc) {
+        assert rows > 0;
+        assert cols > 0;
+        assert getFunc != null;
+
+        setStorage(new FunctionMatrixStorage(rows, cols, getFunc));
+    }
+
+    /**
+     *
+     *
+     */
+    private FunctionMatrixStorage storage() {
+        return (FunctionMatrixStorage)getStorage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix copy() {
+        FunctionMatrixStorage sto = storage();
+
+        return new FunctionMatrix(sto.rowSize(), sto.columnSize(), sto.getFunction(), sto.setFunction());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix like(int rows, int cols) {
+        FunctionMatrixStorage sto = storage();
+
+        return new FunctionMatrix(rows, cols, sto.getFunction(), sto.setFunction());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector likeVector(int crd) {
+        throw new UnsupportedOperationException();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/MatrixView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/MatrixView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/MatrixView.java
new file mode 100644
index 0000000..89b031e
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/MatrixView.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import java.io.Externalizable;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.storage.matrix.MatrixDelegateStorage;
+
+/**
+ * Implements the rectangular view into the parent {@link Matrix}.
+ */
+public class MatrixView extends AbstractMatrix {
+    /**
+     * Constructor for {@link Externalizable} interface.
+     */
+    public MatrixView() {
+        // No-op.
+    }
+
+    /**
+     * @param parent Backing parent {@link Matrix}.
+     * @param rowOff Row offset to parent matrix.
+     * @param colOff Column offset to parent matrix.
+     * @param rows Amount of rows in the view.
+     * @param cols Amount of columns in the view.
+     */
+    public MatrixView(Matrix parent, int rowOff, int colOff, int rows, int cols) {
+        this(parent == null ? null : parent.getStorage(), rowOff, colOff, rows, cols);
+    }
+
+    /**
+     * @param sto Backing parent {@link MatrixStorage}.
+     * @param rowOff Row offset to parent storage.
+     * @param colOff Column offset to parent storage.
+     * @param rows Amount of rows in the view.
+     * @param cols Amount of columns in the view.
+     */
+    public MatrixView(MatrixStorage sto, int rowOff, int colOff, int rows, int cols) {
+        super(new MatrixDelegateStorage(sto, rowOff, colOff, rows, cols));
+    }
+
+    /**
+     *
+     *
+     */
+    private MatrixDelegateStorage storage() {
+        return (MatrixDelegateStorage)getStorage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix copy() {
+        MatrixDelegateStorage sto = storage();
+
+        return new MatrixView(sto.delegate(), sto.rowOffset(), sto.columnOffset(), sto.rowSize(), sto.columnSize());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix like(int rows, int cols) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector likeVector(int crd) {
+        throw new UnsupportedOperationException();
+    }
+}


[23/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/Matrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/Matrix.java b/modules/ml/src/main/java/org/apache/ignite/math/Matrix.java
deleted file mode 100644
index ee7a807..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/Matrix.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-import java.io.Externalizable;
-import org.apache.ignite.lang.IgniteUuid;
-import org.apache.ignite.math.exceptions.CardinalityException;
-import org.apache.ignite.math.exceptions.IndexException;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.IgniteBiFunction;
-import org.apache.ignite.math.functions.IgniteDoubleFunction;
-import org.apache.ignite.math.functions.IgniteFunction;
-import org.apache.ignite.math.functions.IntIntToDoubleFunction;
-
-/**
- * A matrix interface.
- *
- * Based on its flavor it can have vastly different implementations tailored for
- * for different types of data (e.g. dense vs. sparse), different sizes of data or different operation
- * optimizations.
- *
- * Note also that not all operations can be supported by all underlying implementations. If an operation is not
- * supported a {@link UnsupportedOperationException} is thrown. This exception can also be thrown in partial cases
- * where an operation is unsupported only in special cases, e.g. where a given operation cannot be deterministically
- * completed in polynomial time.
- *
- * Based on ideas from <a href="http://mahout.apache.org/">Apache Mahout</a>.
- */
-public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetrics, Destroyable {
-    /**
-     * Holder for matrix's element.
-     */
-    interface Element {
-        /**
-         * Gets element's value.
-         *
-         * @return The value of this matrix element.
-         */
-        double get();
-
-        /**
-         * Gets element's row index.
-         *
-         * @return The row index of this element.
-         */
-        int row();
-
-        /**
-         * Gets element's column index.
-         *
-         * @return The column index of this element.
-         */
-        int column();
-
-        /**
-         * Sets element's value.
-         *
-         * @param val Value to set.
-         */
-        void set(double val);
-    }
-
-    /**
-     * Gets the maximum value in this matrix.
-     *
-     * @return Maximum value in this matrix.
-     */
-    public double maxValue();
-
-    /**
-     * Gets the minimum value in this matrix.
-     *
-     * @return Minimum value in this matrix.
-     */
-    public double minValue();
-
-    /**
-     * Gets the maximum element in this matrix.
-     *
-     * @return Maximum element in this matrix.
-     */
-    public Element maxElement();
-
-    /**
-     * Gets the minimum element in this matrix.
-     *
-     * @return Minimum element in this matrix.
-     */
-    public Element minElement();
-
-    /**
-     * Gets the matrix's element at the given coordinates.
-     *
-     * @param row Row index.
-     * @param col Column index.
-     * @return Element at the given coordinates.
-     */
-    public Element getElement(int row, int col);
-
-    /**
-     * Swaps two rows in this matrix.
-     *
-     * @param row1 Row #1.
-     * @param row2 Row #2.
-     * @return This matrix.
-     */
-    public Matrix swapRows(int row1, int row2);
-
-    /**
-     * Swaps two columns in this matrix.
-     *
-     * @param col1 Column #1.
-     * @param col2 Column #2.
-     * @return This matrix.
-     */
-    public Matrix swapColumns(int col1, int col2);
-
-    /**
-     * Assigns given value to all elements of this matrix.
-     *
-     * @param val Value to assign to all elements.
-     * @return This matrix.
-     */
-    public Matrix assign(double val);
-
-    /**
-     * Assigns given values to this matrix.
-     *
-     * @param vals Values to assign.
-     * @return This matrix.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Matrix assign(double[][] vals);
-
-    /**
-     * Assigns values from given matrix to this matrix.
-     *
-     * @param mtx Matrix to assign to this matrix.
-     * @return This matrix.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Matrix assign(Matrix mtx);
-
-    /**
-     * Assigns each matrix element to the value generated by given function.
-     *
-     * @param fun Function that takes the row and column and returns the value to assign.
-     * @return This matrix.
-     */
-    public Matrix assign(IntIntToDoubleFunction fun);
-
-    /**
-     * Maps all values in this matrix through a given function.
-     *
-     * @param fun Mapping function.
-     * @return This matrix.
-     */
-    public Matrix map(IgniteDoubleFunction<Double> fun);
-
-    /**
-     * Maps all values in this matrix through a given function.
-     *
-     * For this matrix <code>A</code>, argument matrix <code>B</code> and the
-     * function <code>F</code> this method maps every cell <code>x, y</code> as:
-     * <code>A(x,y) = fun(A(x,y), B(x,y))</code>
-     *
-     * @param mtx Argument matrix.
-     * @param fun Mapping function.
-     * @return This function.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Matrix map(Matrix mtx, IgniteBiFunction<Double, Double, Double> fun);
-
-    /**
-     * Assigns values from given vector to the specified column in this matrix.
-     *
-     * @param col Column index.
-     * @param vec Vector to get values from.
-     * @return This matrix.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Matrix assignColumn(int col, Vector vec);
-
-    /**
-     * Assigns values from given vector to the specified row in this matrix.
-     *
-     * @param row Row index.
-     * @param vec Vector to get values from.
-     * @return This matrix.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Matrix assignRow(int row, Vector vec);
-
-    /**
-     * Collects the results of applying a given function to all rows in this matrix.
-     *
-     * @param fun Aggregating function.
-     * @return Vector of row aggregates.
-     */
-    public Vector foldRows(IgniteFunction<Vector, Double> fun);
-
-    /**
-     * Collects the results of applying a given function to all columns in this matrix.
-     *
-     * @param fun Aggregating function.
-     * @return Vector of column aggregates.
-     */
-    public Vector foldColumns(IgniteFunction<Vector, Double> fun);
-
-    /**
-     * Folds this matrix into a single value.
-     *
-     * @param foldFun Folding function that takes two parameters: accumulator and the current value.
-     * @param mapFun Mapping function that is called on each matrix cell before its passed to the accumulator (as its
-     * second parameter).
-     * @param <T> Type of the folded value.
-     * @param zeroVal Zero value for fold function.
-     * @return Folded value of this matrix.
-     */
-    public <T> T foldMap(IgniteBiFunction<T, Double, T> foldFun, IgniteDoubleFunction<Double> mapFun, T zeroVal);
-
-    /**
-     * Calculates the density of the matrix based on supplied criteria.
-     * Returns {@code true} if this matrix is denser than threshold with at least 80% confidence.
-     *
-     * @param threshold the threshold value [0, 1] of non-zero elements above which the matrix is considered dense.
-     */
-    public boolean density(double threshold);
-
-    /**
-     * Gets number of columns in this matrix.
-     *
-     * @return The number of columns in this matrix.
-     */
-    public int columnSize();
-
-    /**
-     * Gets number of rows in this matrix.
-     *
-     * @return The number of rows in this matrix.
-     */
-    public int rowSize();
-
-    /**
-     * Returns matrix determinant using Laplace theorem.
-     *
-     * @return A determinant for this matrix.
-     * @throws CardinalityException Thrown if matrix is not square.
-     */
-    public double determinant();
-
-    /**
-     * Returns the inverse matrix of this matrix
-     *
-     * @return Inverse of this matrix
-     */
-    public Matrix inverse();
-
-    /**
-     * Divides each value in this matrix by the argument.
-     *
-     * @param x Divider value.
-     * @return This matrix.
-     */
-    public Matrix divide(double x);
-
-    /**
-     * Gets the matrix value at the provided location.
-     *
-     * @param row Row index.
-     * @param col Column index.
-     * @return Matrix value.
-     * @throws IndexException Thrown in case of index is out of bound.
-     */
-    public double get(int row, int col);
-
-    /**
-     * Gets the matrix value at the provided location without checking boundaries.
-     * This method is marginally quicker than its {@link #get(int, int)} sibling.
-     *
-     * @param row Row index.
-     * @param col Column index.
-     * @return Matrix value.
-     */
-    public double getX(int row, int col);
-
-    /**
-     * Gets matrix storage model.
-     */
-    public MatrixStorage getStorage();
-
-    /**
-     * Clones this matrix.
-     *
-     * NOTE: new matrix will have the same flavor as the this matrix but a different ID.
-     *
-     * @return New matrix of the same underlying class, the same size and the same values.
-     */
-    public Matrix copy();
-
-    /**
-     * Creates new empty matrix of the same underlying class but of different size.
-     *
-     * NOTE: new matrix will have the same flavor as the this matrix but a different ID.
-     *
-     * @param rows Number of rows for new matrix.
-     * @param cols Number of columns for new matrix.
-     * @return New matrix of the same underlying class and size.
-     */
-    public Matrix like(int rows, int cols);
-
-    /**
-     * Creates new empty vector of compatible properties (similar or the same flavor) to this matrix.
-     *
-     * @param crd Cardinality of the vector.
-     * @return Newly created empty vector "compatible" to this matrix.
-     */
-    public Vector likeVector(int crd);
-
-    /**
-     * Creates new matrix where each value is a difference between corresponding value of this matrix and
-     * passed in argument matrix.
-     *
-     * @param mtx Argument matrix.
-     * @return New matrix of the same underlying class and size.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Matrix minus(Matrix mtx);
-
-    /**
-     * Creates new matrix where each value is a sum of the corresponding value of this matrix and
-     * argument value.
-     *
-     * @param x Value to add.
-     * @return New matrix of the same underlying class and size.
-     */
-    public Matrix plus(double x);
-
-    /**
-     * Creates new matrix where each value is a sum of corresponding values of this matrix and
-     * passed in argument matrix.
-     *
-     * @param mtx Argument matrix.
-     * @return New matrix of the same underlying class and size.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Matrix plus(Matrix mtx);
-
-    /**
-     * Auto-generated globally unique matrix ID.
-     *
-     * @return Matrix GUID.
-     */
-    public IgniteUuid guid();
-
-    /**
-     * Sets given value.
-     *
-     * @param row Row index.
-     * @param col Column index.
-     * @param val Value to set.
-     * @return This matrix.
-     * @throws IndexException Thrown in case of either index is out of bound.
-     */
-    public Matrix set(int row, int col, double val);
-
-    /**
-     * Sets values for given row.
-     *
-     * @param row Row index.
-     * @param data Row data to set.
-     * @return This matrix.
-     * @throws IndexException Thrown in case of index is out of bound.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Matrix setRow(int row, double[] data);
-
-    /**
-     * Sets values for given column.
-     *
-     * @param col Column index.
-     * @param data Column data to set.
-     * @return This matrix.
-     * @throws IndexException Thrown in case of index is out of bound.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Matrix setColumn(int col, double[] data);
-
-    /**
-     * Sets given value without checking for index bounds. This method is marginally faster
-     * than its {@link #set(int, int, double)} sibling.
-     *
-     * @param row Row index.
-     * @param col Column index.
-     * @param val Value to set.
-     * @return This matrix.
-     */
-    public Matrix setX(int row, int col, double val);
-
-    /**
-     * Creates new matrix containing the product of given value and values in this matrix.
-     *
-     * @param x Value to multiply.
-     * @return New matrix.
-     */
-    public Matrix times(double x);
-
-    /**
-     * Creates new matrix that is the product of multiplying this matrix and the argument matrix.
-     *
-     * @param mtx Argument matrix.
-     * @return New matrix.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Matrix times(Matrix mtx);
-
-    /**
-     * Creates new matrix that is the product of multiplying this matrix and the argument vector.
-     *
-     * @param vec Argument vector.
-     * @return New matrix.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Vector times(Vector vec);
-
-    /**
-     * Gets maximum absolute row sum norm of this matrix.
-     * See http://mathworld.wolfram.com/MaximumAbsoluteRowSumNorm.html
-     *
-     * @return Maximum absolute row sum norm of this matrix.
-     */
-    public double maxAbsRowSumNorm();
-
-    /**
-     * Gets sum of all elements in the matrix.
-     *
-     * @return Sum of all elements in this matrix.
-     */
-    public double sum();
-
-    /**
-     * Creates new matrix that is transpose of this matrix.
-     *
-     * @return New transposed matrix.
-     */
-    public Matrix transpose();
-
-    /**
-     * Creates new view into this matrix. Changes to the view will be propagated to this matrix.
-     *
-     * @param off View offset as <code>int[x,y]</code>.
-     * @param size View size as <code>int[rows, cols]</code>
-     * @return New view.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     * @throws IndexException Thrown in case of offset is out of bound.
-     */
-    public Matrix viewPart(int[] off, int[] size);
-
-    /**
-     * Creates new view into this matrix. Changes to the view will be propagated to this matrix.
-     *
-     * @param rowOff
-     * @param rows
-     * @param colOff
-     * @param cols
-     * @return New view.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     * @throws IndexException Thrown in case of offset is out of bound.
-     */
-    public Matrix viewPart(int rowOff, int rows, int colOff, int cols);
-
-    /**
-     * Creates new view into matrix row. Changes to the view will be propagated to this matrix.
-     *
-     * @param row Row index.
-     * @return New view.
-     * @throws IndexException Thrown in case of index is out of bound.
-     */
-    public Vector viewRow(int row);
-
-    /**
-     * Creates new view into matrix column . Changes to the view will be propagated to this matrix.
-     *
-     * @param col Column index.
-     * @return New view.
-     * @throws IndexException Thrown in case of index is out of bound.
-     */
-    public Vector viewColumn(int col);
-
-    /**
-     * Creates new view into matrix diagonal. Changes to the view will be propagated to this matrix.
-     *
-     * @return New view.
-     */
-    public Vector viewDiagonal();
-
-    /**
-     * Destroys matrix if managed outside of JVM. It's a no-op in all other cases.
-     */
-    public default void destroy() {
-        // No-op.
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/MatrixKeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/MatrixKeyMapper.java b/modules/ml/src/main/java/org/apache/ignite/math/MatrixKeyMapper.java
deleted file mode 100644
index d6ae06f..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/MatrixKeyMapper.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-/**
- * Maps {@link Matrix} row and column index to cache key.
- */
-public interface MatrixKeyMapper<K> extends KeyMapper<K> {
-    /**
-     * @param x Matrix row index.
-     * @param y Matrix column index.
-     * @return Cache key for given row and column.
-     */
-    public K apply(int x, int y);
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/MatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/MatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/MatrixStorage.java
deleted file mode 100644
index 11eced7..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/MatrixStorage.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-import java.io.Externalizable;
-
-/**
- * Data storage support for {@link Matrix}.
- */
-public interface MatrixStorage extends Externalizable, StorageOpsMetrics, Destroyable {
-    /**
-     * @param x Matrix row index.
-     * @param y Matrix column index.
-     * @return Value corresponding to given row and column.
-     */
-    public double get(int x, int y);
-
-    /**
-     * @param x Matrix row index.
-     * @param y Matrix column index.
-     * @param v Value to set at given row and column.
-     */
-    public void set(int x, int y, double v);
-
-    /**
-     *
-     */
-    public int columnSize();
-
-    /**
-     *
-     */
-    public int rowSize();
-
-    /**
-     * Gets underlying array if {@link StorageOpsMetrics#isArrayBased()} returns {@code true}.
-     *
-     * @see StorageOpsMetrics#isArrayBased()
-     */
-    default public double[][] data() {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/MetaAttributes.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/MetaAttributes.java b/modules/ml/src/main/java/org/apache/ignite/math/MetaAttributes.java
deleted file mode 100644
index 8973b55..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/MetaAttributes.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-import java.util.Map;
-
-/**
- * Interface provides support for meta attributes on vectors and matrices.
- */
-public interface MetaAttributes {
-    /**
-     * Implementation should return an instance of the map to store meta attributes.
-     */
-    public Map<String, Object> getMetaStorage();
-
-    /**
-     * Gets meta attribute with given name.
-     *
-     * @param name Name of the vector meta attribute to get.
-     * @param <T> Attribute's type.
-     */
-    @SuppressWarnings("unchecked")
-    public default <T> T getAttribute(String name) {
-        return (T)getMetaStorage().get(name);
-    }
-
-    /**
-     * Sets meta attribute with given name and value.
-     *
-     * @param name Name of the meta attribute.
-     * @param val Attribute value.
-     * @param <T> Attribute's type.
-     */
-    public default <T> void setAttribute(String name, T val) {
-        getMetaStorage().put(name, val);
-    }
-
-    /**
-     * Removes meta attribute with given name.
-     *
-     * @param name Name of the meta attribute.
-     * @return {@code true} if attribute was present and was removed, {@code false} otherwise.
-     */
-    public default boolean removeAttribute(String name) {
-        boolean is = getMetaStorage().containsKey(name);
-
-        if (is)
-            getMetaStorage().remove(name);
-
-        return is;
-    }
-
-    /**
-     * Checks if given meta attribute is present.
-     *
-     * @param name Attribute name to check.
-     */
-    public default boolean hasAttribute(String name) {
-        return getMetaStorage().containsKey(name);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/MurmurHash.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/MurmurHash.java b/modules/ml/src/main/java/org/apache/ignite/math/MurmurHash.java
deleted file mode 100644
index 3d1252e..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/MurmurHash.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * This is a very fast, non-cryptographic hash suitable for general hash-based lookup.
- *
- * See http://murmurhash.googlepages.com/ for mre details.
- */
-public class MurmurHash {
-    /** Hide it. */
-    private MurmurHash() {
-    }
-
-    /**
-     * This produces exactly the same hash values as the final C+ version of MurmurHash3 and is
-     * thus suitable for producing the same hash values across platforms.
-     *
-     * The 32 bit x86 version of this hash should be the fastest variant for relatively short keys like IDs.
-     *
-     * Note - The x86 and x64 versions do _not_ produce the same results, as the algorithms are
-     * optimized for their respective platforms.
-     *
-     * See also http://github.com/yonik/java_util for future updates to this method.
-     *
-     * @param data
-     * @param off
-     * @param len
-     * @param seed
-     * @return 32 bit hash platform compatible with C++ MurmurHash3 implementation on x86.
-     */
-    public static int hash3X86(byte[] data, int off, int len, int seed) {
-        int c1 = 0xcc9e2d51;
-        int c2 = 0x1b873593;
-
-        int h1 = seed;
-        int roundedEnd = off + (len & 0xfffffffc);  // Round down to 4 byte block.
-
-        for (int i = off; i < roundedEnd; i += 4) {
-            int k1 = (data[i] & 0xff) | ((data[i + 1] & 0xff) << 8) | ((data[i + 2] & 0xff) << 16) | (data[i + 3] << 24);
-
-            k1 *= c1;
-            k1 = (k1 << 15) | (k1 >>> 17);
-            k1 *= c2;
-
-            h1 ^= k1;
-            h1 = (h1 << 13) | (h1 >>> 19);
-            h1 = h1 * 5 + 0xe6546b64;
-        }
-
-        // Tail.
-        int k1 = 0;
-
-        switch (len & 0x03) {
-            case 3:
-                k1 = (data[roundedEnd + 2] & 0xff) << 16;
-                // Fallthrough - WTF?
-            case 2:
-                k1 |= (data[roundedEnd + 1] & 0xff) << 8;
-                // Fallthrough - WTF?
-            case 1:
-                k1 |= data[roundedEnd] & 0xff;
-                k1 *= c1;
-                k1 = (k1 << 15) | (k1 >>> 17);
-                k1 *= c2;
-                h1 ^= k1;
-            default:
-        }
-
-        // Finalization.
-        h1 ^= len;
-
-        h1 ^= h1 >>> 16;
-        h1 *= 0x85ebca6b;
-        h1 ^= h1 >>> 13;
-        h1 *= 0xc2b2ae35;
-        h1 ^= h1 >>> 16;
-
-        return h1;
-    }
-
-    /**
-     * Hashes an int.
-     *
-     * @param data The int to hash.
-     * @param seed The seed for the hash.
-     * @return The 32 bit hash of the bytes in question.
-     */
-    public static int hash(int data, int seed) {
-        byte[] arr = new byte[] {
-            (byte)(data >>> 24),
-            (byte)(data >>> 16),
-            (byte)(data >>> 8),
-            (byte)data
-        };
-
-        return hash(ByteBuffer.wrap(arr), seed);
-    }
-
-    /**
-     * Hashes bytes in an array.
-     *
-     * @param data The bytes to hash.
-     * @param seed The seed for the hash.
-     * @return The 32 bit hash of the bytes in question.
-     */
-    public static int hash(byte[] data, int seed) {
-        return hash(ByteBuffer.wrap(data), seed);
-    }
-
-    /**
-     * Hashes bytes in part of an array.
-     *
-     * @param data The data to hash.
-     * @param off Where to start munging.
-     * @param len How many bytes to process.
-     * @param seed The seed to start with.
-     * @return The 32-bit hash of the data in question.
-     */
-    public static int hash(byte[] data, int off, int len, int seed) {
-        return hash(ByteBuffer.wrap(data, off, len), seed);
-    }
-
-    /**
-     * Hashes the bytes in a buffer from the current position to the limit.
-     *
-     * @param buf The bytes to hash.
-     * @param seed The seed for the hash.
-     * @return The 32 bit murmur hash of the bytes in the buffer.
-     */
-    public static int hash(ByteBuffer buf, int seed) {
-        ByteOrder byteOrder = buf.order();
-        buf.order(ByteOrder.LITTLE_ENDIAN);
-
-        int m = 0x5bd1e995;
-        int r = 24;
-
-        int h = seed ^ buf.remaining();
-
-        while (buf.remaining() >= 4) {
-            int k = buf.getInt();
-
-            k *= m;
-            k ^= k >>> r;
-            k *= m;
-
-            h *= m;
-            h ^= k;
-        }
-
-        if (buf.remaining() > 0) {
-            ByteBuffer finish = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN);
-
-            finish.put(buf).rewind();
-
-            h ^= finish.getInt();
-            h *= m;
-        }
-
-        h ^= h >>> 13;
-        h *= m;
-        h ^= h >>> 15;
-
-        buf.order(byteOrder);
-
-        return h;
-    }
-
-    /**
-     * @param data
-     * @param seed
-     */
-    public static long hash64A(byte[] data, int seed) {
-        return hash64A(ByteBuffer.wrap(data), seed);
-    }
-
-    /**
-     * @param data
-     * @param off
-     * @param len
-     * @param seed
-     */
-    public static long hash64A(byte[] data, int off, int len, int seed) {
-        return hash64A(ByteBuffer.wrap(data, off, len), seed);
-    }
-
-    /**
-     * @param buf
-     * @param seed
-     */
-    public static long hash64A(ByteBuffer buf, int seed) {
-        ByteOrder byteOrder = buf.order();
-        buf.order(ByteOrder.LITTLE_ENDIAN);
-
-        long m = 0xc6a4a7935bd1e995L;
-        int r = 47;
-
-        long h = seed ^ (buf.remaining() * m);
-
-        while (buf.remaining() >= 8) {
-            long k = buf.getLong();
-
-            k *= m;
-            k ^= k >>> r;
-            k *= m;
-
-            h ^= k;
-            h *= m;
-        }
-
-        if (buf.remaining() > 0) {
-            ByteBuffer finish = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN);
-
-            finish.put(buf).rewind();
-
-            h ^= finish.getLong();
-            h *= m;
-        }
-
-        h ^= h >>> r;
-        h *= m;
-        h ^= h >>> r;
-
-        buf.order(byteOrder);
-
-        return h;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/StorageConstants.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/StorageConstants.java b/modules/ml/src/main/java/org/apache/ignite/math/StorageConstants.java
deleted file mode 100644
index e8bfdf6..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/StorageConstants.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-/**
- * Support for different modes of accessing data storage.
- */
-public interface StorageConstants {
-    /** Storage mode optimized for sequential access. */
-    public static final int SEQUENTIAL_ACCESS_MODE = 1001;
-
-    /** Storage mode optimized for random access. */
-    public static final int RANDOM_ACCESS_MODE = 1002;
-
-    /** Storage mode optimized for row access. */
-    public static final int ROW_STORAGE_MODE = 2001;
-
-    /** Storage mode optimized for column access. */
-    public static final int COLUMN_STORAGE_MODE = 2002;
-
-    /**
-     * @param mode Access mode to verify.
-     */
-    public default void assertAccessMode(int mode) {
-        assert mode == SEQUENTIAL_ACCESS_MODE || mode == RANDOM_ACCESS_MODE;
-    }
-
-    /**
-     * @param mode Storage mode to verify.
-     */
-    public default void assertStorageMode(int mode) {
-        assert mode == ROW_STORAGE_MODE || mode == COLUMN_STORAGE_MODE;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/StorageOpsMetrics.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/StorageOpsMetrics.java b/modules/ml/src/main/java/org/apache/ignite/math/StorageOpsMetrics.java
deleted file mode 100644
index c3252ba..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/StorageOpsMetrics.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-/**
- * Storage and operation cost characteristics.
- */
-public interface StorageOpsMetrics {
-    /**
-     * Checks if this implementation should be considered to be iterable in index order in an efficient way.
-     */
-    public boolean isSequentialAccess();
-
-    /**
-     * Checks if this implementation is optimized for random access.
-     */
-    public boolean isRandomAccess();
-
-    /**
-     * Checks if this implementation should be considered dense so that it explicitly
-     * represents every value.
-     */
-    public boolean isDense();
-
-    /**
-     * Checks if implementation is based on Java arrays.
-     */
-    public boolean isArrayBased();
-
-    /**
-     * Checks whether implementation is JVM-local or distributed (multi-JVM).
-     */
-    public boolean isDistributed();
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/Tracer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/Tracer.java b/modules/ml/src/main/java/org/apache/ignite/math/Tracer.java
deleted file mode 100644
index 89d4669..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/Tracer.java
+++ /dev/null
@@ -1,456 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-import java.awt.Color;
-import java.awt.Desktop;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.StandardOpenOption;
-import java.util.Locale;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.lang.IgniteUuid;
-
-/**
- * Utility methods to support output of {@link Vector} and {@link Matrix} instances to plain text or HTML.
- */
-public class Tracer {
-    /**
-     * Double to color mapper.
-     */
-    public interface ColorMapper extends Function<Double, Color> {
-    }
-
-    /** Continuous red-to-blue color mapping. */
-    static private ColorMapper defaultColorMapper(double min, double max) {
-        double range = max - min;
-
-        return new ColorMapper() {
-            /** {@inheritDoc} */
-            @Override public Color apply(Double d) {
-                int r = (int)Math.round(255 * d);
-                int g = 0;
-                int b = (int)Math.round(255 * (1 - d));
-
-                return new Color(r, g, b);
-            }
-        };
-    }
-
-    /**
-     * Default vector color mapper implementation that map given double value
-     * to continuous red-blue (R_B) specter.
-     *
-     * @param vec Vector to map.
-     * @return {@link ColorMapper} for the given vector.
-     */
-    static private ColorMapper mkVectorColorMapper(Vector vec) {
-        return defaultColorMapper(vec.minValue(), vec.maxValue());
-    }
-
-    /** Default matrix color mapper implementation that map given double value
-     * to continuous red-blue (R_B) specter.
-     * @param mtx Matrix to be mapped.
-     * @return Color mapper for given matrix.
-     */
-    static private ColorMapper mkMatrixColorMapper(Matrix mtx) {
-        return defaultColorMapper(mtx.minValue(), mtx.maxValue());
-    }
-
-    /**
-     * @param vec Vector to show.
-     * @param log {@link IgniteLogger} instance for output.
-     * @param fmt Format string for vector elements.
-     */
-    public static void showAscii(Vector vec, IgniteLogger log, String fmt) {
-        String cls = vec.getClass().getSimpleName();
-
-        log.info(String.format("%s(%d) [%s]", cls, vec.size(), mkString(vec, fmt)));
-    }
-
-    /**
-     * @param vec Vector to show as plain text.
-     * @param log {@link IgniteLogger} instance for output.
-     */
-    public static void showAscii(Vector vec, IgniteLogger log) {
-        showAscii(vec, log, "%4f");
-    }
-
-    /**
-     * @param vec Vector to show as plain text.
-     * @param fmt Format string for vector elements.
-     */
-    public static void showAscii(Vector vec, String fmt) {
-        String cls = vec.getClass().getSimpleName();
-
-        System.out.println(String.format("%s(%d) [%s]", cls, vec.size(), mkString(vec, fmt)));
-    }
-
-    /**
-     * @param mtx Matrix to show as plain text.
-     */
-    public static void showAscii(Matrix mtx) {
-        showAscii(mtx, "%4f");
-    }
-
-    /**
-     * @param mtx Matrix to show.
-     * @param row Matrix row to output.
-     * @param fmt Format string for matrix elements in the row.
-     * @return String representation of given matrix row according to given format.
-     */
-    static private String rowStr(Matrix mtx, int row, String fmt) {
-        StringBuilder buf = new StringBuilder();
-
-        boolean first = true;
-
-        int cols = mtx.columnSize();
-
-        for (int col = 0; col < cols; col++) {
-            String s = String.format(fmt, mtx.get(row, col));
-
-            if (!first)
-                buf.append(", ");
-
-            buf.append(s);
-
-            first = false;
-        }
-
-        return buf.toString();
-    }
-
-    /**
-     * @param mtx {@link Matrix} object to show as a plain text.
-     * @param fmt Format string for matrix rows.
-     */
-    public static void showAscii(Matrix mtx, String fmt) {
-        String cls = mtx.getClass().getSimpleName();
-
-        int rows = mtx.rowSize();
-        int cols = mtx.columnSize();
-
-        System.out.println(String.format("%s(%dx%d)", cls, rows, cols));
-
-        for (int row = 0; row < rows; row++)
-            System.out.println(rowStr(mtx, row, fmt));
-    }
-
-    /**
-     * @param mtx {@link Matrix} object to show as a plain text.
-     * @param log {@link IgniteLogger} instance to output the logged matrix.
-     * @param fmt Format string for matrix rows.
-     */
-    public static void showAscii(Matrix mtx, IgniteLogger log, String fmt) {
-        String cls = mtx.getClass().getSimpleName();
-
-        int rows = mtx.rowSize();
-        int cols = mtx.columnSize();
-
-        log.info(String.format("%s(%dx%d)", cls, rows, cols));
-
-        for (int row = 0; row < rows; row++)
-            log.info(rowStr(mtx, row, fmt));
-    }
-
-    /**
-     * @param vec {@link Vector} object to show as a plain text.
-     */
-    public static void showAscii(Vector vec) {
-        showAscii(vec, "%4f");
-    }
-
-    /**
-     * Saves given vector as CSV file.
-     *
-     * @param vec Vector to save.
-     * @param fmt Format to use.
-     * @param filePath Path of the file to save to.
-     */
-    public static void saveAsCsv(Vector vec, String fmt, String filePath) throws IOException {
-        String s = mkString(vec, fmt);
-
-        Files.write(Paths.get(filePath), s.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
-    }
-
-    /**
-     * Saves given matrix as CSV file.
-     *
-     * @param mtx Matrix to save.
-     * @param fmt Format to use.
-     * @param filePath Path of the file to save to.
-     */
-    public static void saveAsCsv(Matrix mtx, String fmt, String filePath) throws IOException {
-        String s = mkString(mtx, fmt);
-
-        Files.write(Paths.get(filePath), s.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
-    }
-
-    /**
-     * Shows given matrix in the browser with D3-based visualization.
-     *
-     * @param mtx Matrix to show.
-     * @throws IOException Thrown in case of any errors.
-     */
-    public static void showHtml(Matrix mtx) throws IOException {
-        showHtml(mtx, mkMatrixColorMapper(mtx));
-    }
-
-    /**
-     * Shows given matrix in the browser with D3-based visualization.
-     *
-     * @param mtx Matrix to show.
-     * @param cm Optional color mapper. If not provided - red-to-blue (R_B) mapper will be used.
-     * @throws IOException Thrown in case of any errors.
-     */
-    public static void showHtml(Matrix mtx, ColorMapper cm) throws IOException {
-        // Read it every time so that we can change it at runtime.
-        String tmpl = fileToString("d3-matrix-template.html");
-
-        String cls = mtx.getClass().getSimpleName();
-
-        double min = mtx.minValue();
-        double max = mtx.maxValue();
-
-        openHtmlFile(tmpl.
-            replaceAll("/\\*@NAME@\\*/.*\n", "var name = \"" + cls + "\";\n").
-            replaceAll("/\\*@MIN@\\*/.*\n", "var min = " + dataColorJson(min, cm.apply(min)) + ";\n").
-            replaceAll("/\\*@MAX@\\*/.*\n", "var max = " + dataColorJson(max, cm.apply(max)) + ";\n").
-            replaceAll("/\\*@DATA@\\*/.*\n", "var data = " + mkJsArrayString(mtx, cm) + ";\n")
-        );
-    }
-
-    /**
-     * Shows given vector in the browser with D3-based visualization.
-     *
-     * @param vec Vector to show.
-     * @throws IOException Thrown in case of any errors.
-     */
-    public static void showHtml(Vector vec) throws IOException {
-        showHtml(vec, mkVectorColorMapper(vec));
-    }
-
-    /**
-     * @param d Value of {@link Matrix} or {@link Vector} element.
-     * @param clr {@link Color} to paint.
-     * @return JSON representation for given value and color.
-     */
-    static private String dataColorJson(double d, Color clr) {
-        return "{" +
-            "d: " + String.format("%4f", d) +
-            ", r: " + clr.getRed() +
-            ", g: " + clr.getGreen() +
-            ", b: " + clr.getBlue() +
-            "}";
-    }
-
-    /**
-     * Shows given vector in the browser with D3-based visualization.
-     *
-     * @param vec Vector to show.
-     * @param cm Optional color mapper. If not provided - red-to-blue (R_B) mapper will be used.
-     * @throws IOException Thrown in case of any errors.
-     */
-    public static void showHtml(Vector vec, ColorMapper cm) throws IOException {
-        // Read it every time so that we can change it at runtime.
-        String tmpl = fileToString("d3-vector-template.html");
-
-        String cls = vec.getClass().getSimpleName();
-
-        double min = vec.minValue();
-        double max = vec.maxValue();
-
-        openHtmlFile(tmpl.
-            replaceAll("/\\*@NAME@\\*/.*\n", "var name = \"" + cls + "\";\n").
-            replaceAll("/\\*@MIN@\\*/.*\n", "var min = " + dataColorJson(min, cm.apply(min)) + ";\n").
-            replaceAll("/\\*@MAX@\\*/.*\n", "var max = " + dataColorJson(max, cm.apply(max)) + ";\n").
-            replaceAll("/\\*@DATA@\\*/.*\n", "var data = " + mkJsArrayString(vec, cm) + ";\n")
-        );
-    }
-
-    /**
-     * Reads file content into the string.
-     *
-     * @param fileName Name of the file (on classpath) to read.
-     * @return Content of the file.
-     * @throws IOException If an I/O error of some sort has occurred.
-     */
-    private static String fileToString(String fileName) throws IOException {
-        assert Tracer.class.getResourceAsStream(fileName) != null : "Can't get resource: " + fileName;
-
-        InputStreamReader is = new InputStreamReader(Tracer.class.getResourceAsStream(fileName));
-
-        String str = new BufferedReader(is).lines().collect(Collectors.joining("\n"));
-
-        is.close();
-
-        return str;
-    }
-
-    /**
-     * Opens file in the browser with given HTML content.
-     *
-     * @param html HTML content.
-     * @throws IOException Thrown in case of any errors.
-     */
-    static private void openHtmlFile(String html) throws IOException {
-        File temp = File.createTempFile(IgniteUuid.randomUuid().toString(), ".html");
-
-        BufferedWriter bw = new BufferedWriter(new FileWriter(temp));
-
-        bw.write(html);
-
-        bw.close();
-
-        Desktop.getDesktop().browse(temp.toURI());
-    }
-
-    /**
-     * Gets string presentation of this vector.
-     *
-     * @param vec Vector to string-ify.
-     * @param fmt {@link String#format(Locale, String, Object...)} format.
-     */
-    private static String mkString(Vector vec, String fmt) {
-        boolean first = true;
-
-        StringBuilder buf = new StringBuilder();
-
-        for (Vector.Element x : vec.all()) {
-            String s = String.format(Locale.US, fmt, x.get());
-
-            if (!first) {
-                buf.append(", ");
-                buf.append(s);
-            }
-            else {
-                buf.append(s);
-                first = false;
-            }
-        }
-
-        return buf.toString();
-    }
-
-    /**
-     * Gets JavaScript array presentation of this vector.
-     *
-     * @param vec Vector to JavaScript-ify.
-     * @param cm Color mapper to user.
-     */
-    private static String mkJsArrayString(Vector vec, ColorMapper cm) {
-        boolean first = true;
-
-        StringBuilder buf = new StringBuilder();
-
-        for (Vector.Element x : vec.all()) {
-            double d = x.get();
-
-            String s = dataColorJson(d, cm.apply(d));
-
-            if (!first)
-                buf.append(", ");
-
-            buf.append(s);
-
-            first = false;
-        }
-
-        return '[' + buf.toString() + ']';
-    }
-
-    /**
-     * Gets JavaScript array presentation of this vector.
-     *
-     * @param mtx Matrix to JavaScript-ify.
-     * @param cm Color mapper to user.
-     */
-    private static String mkJsArrayString(Matrix mtx, ColorMapper cm) {
-        boolean first = true;
-
-        StringBuilder buf = new StringBuilder();
-
-        int rows = mtx.rowSize();
-        int cols = mtx.columnSize();
-
-        for (int row = 0; row < rows; row++) {
-            StringBuilder rowBuf = new StringBuilder();
-
-            boolean rowFirst = true;
-
-            for (int col = 0; col < cols; col++) {
-                double d = mtx.get(row, col);
-
-                String s = dataColorJson(d, cm.apply(d));
-
-                if (!rowFirst)
-                    rowBuf.append(", ");
-
-                rowBuf.append(s);
-
-                rowFirst = false;
-            }
-
-            if (!first)
-                buf.append(", ");
-
-            buf.append('[').append(rowBuf.toString()).append(']');
-
-            first = false;
-        }
-
-        return '[' + buf.toString() + ']';
-    }
-
-    /**
-     * @param mtx Matrix to log.
-     * @param fmt Output format.
-     * @return Formatted representation of a matrix.
-     */
-    private static String mkString(Matrix mtx, String fmt) {
-        StringBuilder buf = new StringBuilder();
-
-        int rows = mtx.rowSize();
-        int cols = mtx.columnSize();
-
-        for (int row = 0; row < rows; row++) {
-            for (int col = 0; col < cols; col++) {
-                String s = String.format(Locale.US, fmt, mtx.get(row, col));
-
-                if (col != 0)
-                    buf.append(", ");
-
-                buf.append(s);
-
-                if (col == cols - 1 && row != rows - 1)
-                    buf.append(",\n");
-
-            }
-        }
-
-        return buf.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/ValueMapper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/ValueMapper.java b/modules/ml/src/main/java/org/apache/ignite/math/ValueMapper.java
deleted file mode 100644
index 9459bd1..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/ValueMapper.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// @java.file.header
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.apache.ignite.math;
-
-import java.io.Serializable;
-
-/**
- * Utility mapper that can be used to map arbitrary values types to and from double.
- */
-public interface ValueMapper<V> extends Serializable {
-    /**
-     * @param v
-     */
-    public V fromDouble(double v);
-
-    /**
-     * @param v
-     */
-    public double toDouble(V v);
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/Vector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/Vector.java b/modules/ml/src/main/java/org/apache/ignite/math/Vector.java
deleted file mode 100644
index ac2a6c7..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/Vector.java
+++ /dev/null
@@ -1,498 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-import java.io.Externalizable;
-import java.util.Spliterator;
-import java.util.function.IntToDoubleFunction;
-import org.apache.ignite.lang.IgniteUuid;
-import org.apache.ignite.math.exceptions.CardinalityException;
-import org.apache.ignite.math.exceptions.IndexException;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.IgniteBiFunction;
-import org.apache.ignite.math.functions.IgniteDoubleFunction;
-
-/**
- * A vector interface.
- *
- * Based on its flavor it can have vastly different implementations tailored for
- * for different types of data (e.g. dense vs. sparse), different sizes of data or different operation
- * optimizations.
- *
- * Note also that not all operations can be supported by all underlying implementations. If an operation is not
- * supported a {@link UnsupportedOperationException} is thrown. This exception can also be thrown in partial cases
- * where an operation is unsupported only in special cases, e.g. where a given operation cannot be deterministically
- * completed in polynomial time.
- *
- * Based on ideas from <a href="http://mahout.apache.org/">Apache Mahout</a>.
- */
-public interface Vector extends MetaAttributes, Externalizable, StorageOpsMetrics, Destroyable {
-    /**
-     * Holder for vector's element.
-     */
-    interface Element {
-        /**
-         * Gets element's value.
-         *
-         * @return The value of this vector element.
-         */
-        double get();
-
-        /**
-         * Gets element's index in the vector.
-         *
-         * @return The index of this vector element.
-         */
-        int index();
-
-        /**
-         * Sets element's value.
-         *
-         * @param val Value to set.
-         */
-        void set(double val);
-    }
-
-    /**
-     * Gets cardinality of this vector (maximum number of the elements).
-     *
-     * @return This vector's cardinality.
-     */
-    public int size();
-
-    /**
-     * Creates new copy of this vector.
-     *
-     * @return New copy vector.
-     */
-    public Vector copy();
-
-    /**
-     * Gets iterator over all elements in this vector.
-     *
-     * NOTE: implementation can choose to reuse {@link Element} instance so you need to copy it
-     * if you want to retain it outside of iteration.
-     *
-     * @return Iterator.
-     */
-    public Iterable<Element> all();
-
-    /**
-     * Iterates ove all non-zero elements in this vector.
-     *
-     * NOTE: implementation can choose to reuse {@link Element} instance so you need to copy it
-     * if you want to retain it outside of iteration.
-     *
-     * @return Iterator.
-     */
-    public Iterable<Element> nonZeroes();
-
-    /**
-     * Gets spliterator for all values in this vector.
-     *
-     * @return Spliterator for all values.
-     */
-    public Spliterator<Double> allSpliterator();
-
-    /**
-     * Gets spliterator for all non-zero values in this vector.
-     *
-     * @return Spliterator for all non-zero values.
-     */
-    public Spliterator<Double> nonZeroSpliterator();
-
-    /**
-     * Sorts this vector in ascending order.
-     */
-    public Vector sort();
-
-    /**
-     * Gets element at the given index.
-     *
-     * NOTE: implementation can choose to reuse {@link Element} instance so you need to copy it
-     * if you want to retain it outside of iteration.
-     *
-     * @param idx Element's index.
-     * @return Vector's element at the given index.
-     * @throws IndexException Throw if index is out of bounds.
-     */
-    public Element getElement(int idx);
-
-    /**
-     * Assigns given value to all elements of this vector.
-     *
-     * @param val Value to assign.
-     * @return This vector.
-     */
-    public Vector assign(double val);
-
-    /**
-     * Assigns values from given array to this vector.
-     *
-     * @param vals Values to assign.
-     * @return This vector.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Vector assign(double[] vals);
-
-    /**
-     * Copies values from the argument vector to this one.
-     *
-     * @param vec Argument vector.
-     * @return This vector.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Vector assign(Vector vec);
-
-    /**
-     * Assigns each vector element to the value generated by given function.
-     *
-     * @param fun Function that takes the index and returns value.
-     * @return This vector.
-     */
-    public Vector assign(IntToDoubleFunction fun);
-
-    /**
-     * Maps all values in this vector through a given function.
-     *
-     * @param fun Mapping function.
-     * @return This vector.
-     */
-    public Vector map(IgniteDoubleFunction<Double> fun);
-
-    /**
-     * Maps all values in this vector through a given function.
-     *
-     * For this vector <code>A</code>, argument vector <code>B</code> and the
-     * function <code>F</code> this method maps every element <code>x</code> as:
-     * <code>A(x) = F(A(x), B(x))</code>
-     *
-     * @param vec Argument vector.
-     * @param fun Mapping function.
-     * @return This function.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Vector map(Vector vec, IgniteBiFunction<Double, Double, Double> fun);
-
-    /**
-     * Maps all elements of this vector by applying given function to each element with a constant
-     * second parameter <code>y</code>.
-     *
-     * @param fun Mapping function.
-     * @param y Second parameter for mapping function.
-     * @return This vector.
-     */
-    public Vector map(IgniteBiFunction<Double, Double, Double> fun, double y);
-
-    /**
-     * Creates new vector containing values from this vector divided by the argument.
-     *
-     * @param x Division argument.
-     * @return New vector.
-     */
-    public Vector divide(double x);
-
-    /**
-     * Gets dot product of two vectors.
-     *
-     * @param vec Argument vector.
-     * @return Dot product of two vectors.
-     */
-    public double dot(Vector vec);
-
-    /**
-     * Gets the value at specified index.
-     *
-     * @param idx Vector index.
-     * @return Vector value.
-     * @throws IndexException Throw if index is out of bounds.
-     */
-    public double get(int idx);
-
-    /**
-     * Gets the value at specified index without checking for index boundaries.
-     *
-     * @param idx Vector index.
-     * @return Vector value.
-     */
-    public double getX(int idx);
-
-    /**
-     * Creates new empty vector of the same underlying class but of different cardinality.
-     *
-     * @param crd Cardinality for new vector.
-     * @return New vector.
-     */
-    public Vector like(int crd);
-
-    /**
-     * Creates new matrix of compatible flavor with given size.
-     *
-     * @param rows Number of rows.
-     * @param cols Number of columns.
-     * @return New matrix.
-     */
-    public Matrix likeMatrix(int rows, int cols);
-
-    /**
-     * Converts this vector into [N x 1] or [1 x N] matrix where N is this vector cardinality.
-     *
-     * @param rowLike {@code true} for rowLike [N x 1], or {@code false} for column [1 x N] matrix.
-     * @return Newly created matrix.
-     */
-    public Matrix toMatrix(boolean rowLike);
-
-    /**
-     * Converts this vector into [N+1 x 1] or [1 x N+1] matrix where N is this vector cardinality.
-     * (0,0) element of this matrix will be {@code zeroVal} parameter.
-     *
-     * @param rowLike {@code true} for rowLike [N+1 x 1], or {@code false} for column [1 x N+1] matrix.
-     * @return Newly created matrix.
-     */
-    public Matrix toMatrixPlusOne(boolean rowLike, double zeroVal);
-
-    /**
-     * Creates new vector containing element by element difference between this vector and the argument one.
-     *
-     * @param vec Argument vector.
-     * @return New vector.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Vector minus(Vector vec);
-
-    /**
-     * Creates new vector containing the normalized (L_2 norm) values of this vector.
-     *
-     * @return New vector.
-     */
-    public Vector normalize();
-
-    /**
-     * Creates new vector containing the normalized (L_power norm) values of this vector.
-     * See http://en.wikipedia.org/wiki/Lp_space for details.
-     *
-     * @param power The power to use. Must be >= 0. May also be {@link Double#POSITIVE_INFINITY}.
-     * @return New vector {@code x} such that {@code norm(x, power) == 1}
-     */
-    public Vector normalize(double power);
-
-    /**
-     * Creates new vector containing the {@code log(1 + entry) / L_2 norm} values of this vector.
-     *
-     * @return New vector.
-     */
-    public Vector logNormalize();
-
-    /**
-     * Creates new vector with a normalized value calculated as {@code log_power(1 + entry) / L_power norm}.
-     *
-     * @param power The power to use. Must be > 1. Cannot be {@link Double#POSITIVE_INFINITY}.
-     * @return New vector
-     */
-    public Vector logNormalize(double power);
-
-    /**
-     * Gets the k-norm of the vector. See http://en.wikipedia.org/wiki/Lp_space for more details.
-     *
-     * @param power The power to use.
-     * @see #normalize(double)
-     */
-    public double kNorm(double power);
-
-    /**
-     * Gets minimal value in this vector.
-     *
-     * @return Minimal value.
-     */
-    public double minValue();
-
-    /**
-     * Gets maximum value in this vector.
-     *
-     * @return Maximum c.
-     */
-    public double maxValue();
-
-    /**
-     * Gets minimal element in this vector.
-     *
-     * @return Minimal element.
-     */
-    public Element minElement();
-
-    /**
-     * Gets maximum element in this vector.
-     *
-     * @return Maximum element.
-     */
-    public Element maxElement();
-
-    /**
-     * Creates new vector containing sum of each element in this vector and argument.
-     *
-     * @param x Argument value.
-     * @return New vector.
-     */
-    public Vector plus(double x);
-
-    /**
-     * Creates new vector containing element by element sum from both vectors.
-     *
-     * @param vec Other argument vector to add.
-     * @return New vector.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Vector plus(Vector vec);
-
-    /**
-     * Sets value.
-     *
-     * @param idx Vector index to set value at.
-     * @param val Value to set.
-     * @return This vector.
-     * @throws IndexException Throw if index is out of bounds.
-     */
-    public Vector set(int idx, double val);
-
-    /**
-     * Sets value without checking for index boundaries.
-     *
-     * @param idx Vector index to set value at.
-     * @param val Value to set.
-     * @return This vector.
-     */
-    public Vector setX(int idx, double val);
-
-    /**
-     * Increments value at given index without checking for index boundaries.
-     *
-     * @param idx Vector index.
-     * @param val Increment value.
-     * @return This vector.
-     */
-    public Vector incrementX(int idx, double val);
-
-    /**
-     * Increments value at given index.
-     *
-     * @param idx Vector index.
-     * @param val Increment value.
-     * @return This vector.
-     * @throws IndexException Throw if index is out of bounds.
-     */
-    public Vector increment(int idx, double val);
-
-    /**
-     * Gets number of non-zero elements in this vector.
-     *
-     * @return Number of non-zero elements in this vector.
-     */
-    public int nonZeroElements();
-
-    /**
-     * Gets a new vector that contains product of each element and the argument.
-     *
-     * @param x Multiply argument.
-     * @return New vector.
-     */
-    public Vector times(double x);
-
-    /**
-     * Gets a new vector that is an element-wie product of this vector and the argument.
-     *
-     * @param vec Vector to multiply by.
-     * @return New vector.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public Vector times(Vector vec);
-
-    /**
-     * @param off Offset into parent vector.
-     * @param len Length of the view.
-     */
-    public Vector viewPart(int off, int len);
-
-    /**
-     * Gets vector storage model.
-     */
-    public VectorStorage getStorage();
-
-    /**
-     * Gets the sum of all elements in this vector.
-     *
-     * @return Vector's sum
-     */
-    public double sum();
-
-    /**
-     * Gets the cross product of this vector and the other vector.
-     *
-     * @param vec Second vector.
-     * @return New matrix as a cross product of two vectors.
-     */
-    public Matrix cross(Vector vec);
-
-    /**
-     * Folds this vector into a single value.
-     *
-     * @param foldFun Folding function that takes two parameters: accumulator and the current value.
-     * @param mapFun Mapping function that is called on each vector element before its passed to the accumulator (as its
-     * second parameter).
-     * @param <T> Type of the folded value.
-     * @param zeroVal Zero value for fold operation.
-     * @return Folded value of this vector.
-     */
-    public <T> T foldMap(IgniteBiFunction<T, Double, T> foldFun, IgniteDoubleFunction<Double> mapFun, T zeroVal);
-
-    /**
-     * Combines & maps two vector and folds them into a single value.
-     *
-     * @param vec Another vector to combine with.
-     * @param foldFun Folding function.
-     * @param combFun Combine function.
-     * @param <T> Type of the folded value.
-     * @param zeroVal Zero value for fold operation.
-     * @return Folded value of these vectors.
-     * @throws CardinalityException Thrown when cardinalities mismatch.
-     */
-    public <T> T foldMap(Vector vec, IgniteBiFunction<T, Double, T> foldFun, IgniteBiFunction<Double, Double, Double> combFun,
-        T zeroVal);
-
-    /**
-     * Gets the sum of squares of all elements in this vector.
-     *
-     * @return Length squared value.
-     */
-    public double getLengthSquared();
-
-    /**
-     * Get the square of the distance between this vector and the argument vector.
-     *
-     * @param vec Another vector.
-     * @return Distance squared.
-     * @throws CardinalityException Thrown if cardinalities mismatch.
-     */
-    public double getDistanceSquared(Vector vec);
-
-    /**
-     * Auto-generated globally unique vector ID.
-     *
-     * @return Vector GUID.
-     */
-    public IgniteUuid guid();
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/VectorKeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/VectorKeyMapper.java b/modules/ml/src/main/java/org/apache/ignite/math/VectorKeyMapper.java
deleted file mode 100644
index 17d76f5..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/VectorKeyMapper.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-/**
- * Maps {@link Vector} element index to cache key.
- */
-public interface VectorKeyMapper<K> extends KeyMapper<K> {
-    /**
-     * @param i Vector element index.
-     * @return Cache key for given element index.
-     */
-    public K apply(int i);
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/VectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/VectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/VectorStorage.java
deleted file mode 100644
index f410254..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/VectorStorage.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-import java.io.Externalizable;
-
-/**
- * Data storage support for {@link Vector}.
- */
-public interface VectorStorage extends Externalizable, StorageOpsMetrics, Destroyable {
-    /**
-     *
-     *
-     */
-    public int size();
-
-    /**
-     * @param i Vector element index.
-     * @return Value obtained for given element index.
-     */
-    public double get(int i);
-
-    /**
-     * @param i Vector element index.
-     * @param v Value to set at given index.
-     */
-    public void set(int i, double v);
-
-    /**
-     * Gets underlying array if {@link StorageOpsMetrics#isArrayBased()} returns {@code true}.
-     * Returns {@code null} if in other cases.
-     *
-     * @see StorageOpsMetrics#isArrayBased()
-     */
-    public default double[] data() {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/decompositions/CholeskyDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/CholeskyDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/math/decompositions/CholeskyDecomposition.java
deleted file mode 100644
index 9554737..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/CholeskyDecomposition.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.decompositions;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.CardinalityException;
-import org.apache.ignite.math.exceptions.NonPositiveDefiniteMatrixException;
-import org.apache.ignite.math.exceptions.NonSymmetricMatrixException;
-
-/**
- * Calculates the Cholesky decomposition of a matrix.
- *
- * This class inspired by class from Apache Common Math with similar name.
- *
- * @see <a href="http://mathworld.wolfram.com/CholeskyDecomposition.html">MathWorld</a>
- * @see <a href="http://en.wikipedia.org/wiki/Cholesky_decomposition">Wikipedia</a>
- */
-public class CholeskyDecomposition extends DecompositionSupport {
-    /**
-     * Default threshold above which off-diagonal elements are considered too different
-     * and matrix not symmetric.
-     */
-    public static final double DFLT_REL_SYMMETRY_THRESHOLD = 1.0e-15;
-
-    /**
-     * Default threshold below which diagonal elements are considered null
-     * and matrix not positive definite.
-     */
-    public static final double DFLT_ABS_POSITIVITY_THRESHOLD = 1.0e-10;
-
-    /** Row-oriented storage for L<sup>T</sup> matrix data. */
-    private double[][] lTData;
-    /** Cached value of L. */
-    private Matrix cachedL;
-    /** Cached value of LT. */
-    private Matrix cachedLT;
-    /** Origin matrix */
-    private Matrix origin;
-
-    /**
-     * Calculates the Cholesky decomposition of the given matrix.
-     *
-     * Calling this constructor is equivalent to call {@link #CholeskyDecomposition(Matrix, double, double)} with the
-     * thresholds set to the default values {@link #DFLT_REL_SYMMETRY_THRESHOLD} and
-     * {@link #DFLT_ABS_POSITIVITY_THRESHOLD}.
-     *
-     * @param mtx the matrix to decompose.
-     * @throws CardinalityException if matrix is not square.
-     * @see #CholeskyDecomposition(Matrix, double, double)
-     * @see #DFLT_REL_SYMMETRY_THRESHOLD
-     * @see #DFLT_ABS_POSITIVITY_THRESHOLD
-     */
-    public CholeskyDecomposition(final Matrix mtx) {
-        this(mtx, DFLT_REL_SYMMETRY_THRESHOLD, DFLT_ABS_POSITIVITY_THRESHOLD);
-    }
-
-    /**
-     * Calculates the Cholesky decomposition of the given matrix.
-     *
-     * @param mtx the matrix to decompose.
-     * @param relSymmetryThreshold threshold above which off-diagonal elements are considered too different and matrix
-     * not symmetric
-     * @param absPositivityThreshold threshold below which diagonal elements are considered null and matrix not positive
-     * definite
-     * @see #CholeskyDecomposition(Matrix)
-     * @see #DFLT_REL_SYMMETRY_THRESHOLD
-     * @see #DFLT_ABS_POSITIVITY_THRESHOLD
-     */
-    public CholeskyDecomposition(final Matrix mtx, final double relSymmetryThreshold,
-        final double absPositivityThreshold) {
-        assert mtx != null;
-
-        if (mtx.columnSize() != mtx.rowSize())
-            throw new CardinalityException(mtx.rowSize(), mtx.columnSize());
-
-        origin = mtx;
-
-        final int order = mtx.rowSize();
-
-        lTData = toDoubleArr(mtx);
-        cachedL = null;
-        cachedLT = null;
-
-        // Check the matrix before transformation.
-        for (int i = 0; i < order; ++i) {
-            final double[] lI = lTData[i];
-
-            // Check off-diagonal elements (and reset them to 0).
-            for (int j = i + 1; j < order; ++j) {
-                final double[] lJ = lTData[j];
-
-                final double lIJ = lI[j];
-                final double lJI = lJ[i];
-
-                final double maxDelta = relSymmetryThreshold * Math.max(Math.abs(lIJ), Math.abs(lJI));
-
-                if (Math.abs(lIJ - lJI) > maxDelta)
-                    throw new NonSymmetricMatrixException(i, j, relSymmetryThreshold);
-
-                lJ[i] = 0;
-            }
-        }
-
-        // Transform the matrix.
-        for (int i = 0; i < order; ++i) {
-            final double[] ltI = lTData[i];
-
-            // Check diagonal element.
-            if (ltI[i] <= absPositivityThreshold)
-                throw new NonPositiveDefiniteMatrixException(ltI[i], i, absPositivityThreshold);
-
-            ltI[i] = Math.sqrt(ltI[i]);
-            final double inverse = 1.0 / ltI[i];
-
-            for (int q = order - 1; q > i; --q) {
-                ltI[q] *= inverse;
-                final double[] ltQ = lTData[q];
-
-                for (int p = q; p < order; ++p)
-                    ltQ[p] -= ltI[q] * ltI[p];
-            }
-        }
-    }
-
-    /** */
-    @Override public void destroy() {
-        if (cachedL != null)
-            cachedL.destroy();
-        if (cachedLT != null)
-            cachedLT.destroy();
-    }
-
-    /**
-     * Returns the matrix L of the decomposition.
-     * <p>L is an lower-triangular matrix</p>
-     *
-     * @return the L matrix
-     */
-    public Matrix getL() {
-        if (cachedL == null)
-            cachedL = getLT().transpose();
-
-        return cachedL;
-    }
-
-    /**
-     * Returns the transpose of the matrix L of the decomposition.
-     * <p>L<sup>T</sup> is an upper-triangular matrix</p>
-     *
-     * @return the transpose of the matrix L of the decomposition
-     */
-    public Matrix getLT() {
-
-        if (cachedLT == null) {
-            Matrix like = like(origin, origin.rowSize(), origin.columnSize());
-            like.assign(lTData);
-
-            cachedLT = like;
-        }
-
-        // return the cached matrix
-        return cachedLT;
-    }
-
-    /**
-     * Return the determinant of the matrix
-     *
-     * @return determinant of the matrix
-     */
-    public double getDeterminant() {
-        double determinant = 1.0;
-
-        for (int i = 0; i < lTData.length; ++i) {
-            double lTii = lTData[i][i];
-            determinant *= lTii * lTii;
-        }
-
-        return determinant;
-    }
-
-    /**
-     * Solve the linear equation A &times; X = B for matrices A.
-     *
-     * @param b right-hand side of the equation A &times; X = B
-     * @return a vector X that minimizes the two norm of A &times; X - B
-     * @throws CardinalityException if the vectors dimensions do not match
-     */
-    public Vector solve(final Vector b) {
-        final int m = lTData.length;
-
-        if (b.size() != m)
-            throw new CardinalityException(b.size(), m);
-
-        final double[] x = b.getStorage().data();
-
-        // Solve LY = b
-        for (int j = 0; j < m; j++) {
-            final double[] lJ = lTData[j];
-
-            x[j] /= lJ[j];
-
-            final double xJ = x[j];
-
-            for (int i = j + 1; i < m; i++)
-                x[i] -= xJ * lJ[i];
-        }
-
-        // Solve LTX = Y
-        for (int j = m - 1; j >= 0; j--) {
-            x[j] /= lTData[j][j];
-
-            final double xJ = x[j];
-
-            for (int i = 0; i < j; i++)
-                x[i] -= xJ * lTData[i][j];
-        }
-
-        return likeVector(origin, m).assign(x);
-    }
-
-    /**
-     * Solve the linear equation A &times; X = B for matrices A.
-     *
-     * @param b right-hand side of the equation A &times; X = B
-     * @return a matrix X that minimizes the two norm of A &times; X - B
-     * @throws CardinalityException if the matrices dimensions do not match
-     */
-    public Matrix solve(final Matrix b) {
-        final int m = lTData.length;
-
-        if (b.rowSize() != m)
-            throw new CardinalityException(b.rowSize(), m);
-
-        final int nColB = b.columnSize();
-        final double[][] x = b.getStorage().data();
-
-        // Solve LY = b
-        for (int j = 0; j < m; j++) {
-            final double[] lJ = lTData[j];
-            final double lJJ = lJ[j];
-            final double[] xJ = x[j];
-
-            for (int k = 0; k < nColB; ++k)
-                xJ[k] /= lJJ;
-
-            for (int i = j + 1; i < m; i++) {
-                final double[] xI = x[i];
-                final double lJI = lJ[i];
-
-                for (int k = 0; k < nColB; ++k)
-                    xI[k] -= xJ[k] * lJI;
-            }
-        }
-
-        // Solve LTX = Y
-        for (int j = m - 1; j >= 0; j--) {
-            final double lJJ = lTData[j][j];
-            final double[] xJ = x[j];
-
-            for (int k = 0; k < nColB; ++k)
-                xJ[k] /= lJJ;
-
-            for (int i = 0; i < j; i++) {
-                final double[] xI = x[i];
-                final double lIJ = lTData[i][j];
-
-                for (int k = 0; k < nColB; ++k)
-                    xI[k] -= xJ[k] * lIJ;
-            }
-        }
-
-        return like(origin, m, b.columnSize()).assign(x);
-    }
-
-    /** */
-    private double[][] toDoubleArr(Matrix mtx) {
-        if (mtx.isArrayBased())
-            return mtx.getStorage().data();
-
-        double[][] res = new double[mtx.rowSize()][];
-
-        for (int row = 0; row < mtx.rowSize(); row++) {
-            res[row] = new double[mtx.columnSize()];
-            for (int col = 0; col < mtx.columnSize(); col++)
-                res[row][col] = mtx.get(row, col);
-        }
-
-        return res;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/decompositions/DecompositionSupport.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/DecompositionSupport.java b/modules/ml/src/main/java/org/apache/ignite/math/decompositions/DecompositionSupport.java
deleted file mode 100644
index 2c76284..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/DecompositionSupport.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.decompositions;
-
-import org.apache.ignite.math.Destroyable;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.matrix.CacheMatrix;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.math.impls.matrix.PivotedMatrixView;
-import org.apache.ignite.math.impls.matrix.RandomMatrix;
-import org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector;
-
-/**
- * Helper methods to support decomposition of matrix types having some functionality limited.
- */
-public abstract class DecompositionSupport implements Destroyable {
-    /**
-     * Create the like matrix with read-only matrices support.
-     *
-     * @param matrix Matrix for like.
-     * @return Like matrix.
-     */
-    protected Matrix like(Matrix matrix) {
-        if (isCopyLikeSupport(matrix))
-            return new DenseLocalOnHeapMatrix(matrix.rowSize(), matrix.columnSize());
-        else
-            return matrix.like(matrix.rowSize(), matrix.columnSize());
-    }
-
-    /**
-     * Create the like matrix with specified size with read-only matrices support.
-     *
-     * @param matrix Matrix for like.
-     * @return Like matrix.
-     */
-    protected Matrix like(Matrix matrix, int rows, int cols) {
-        if (isCopyLikeSupport(matrix))
-            return new DenseLocalOnHeapMatrix(rows, cols);
-        else
-            return matrix.like(rows, cols);
-    }
-
-    /**
-     * Create the like vector with read-only matrices support.
-     *
-     * @param matrix Matrix for like.
-     * @param crd Cardinality of the vector.
-     * @return Like vector.
-     */
-    protected Vector likeVector(Matrix matrix, int crd) {
-        if (isCopyLikeSupport(matrix))
-            return new DenseLocalOnHeapVector(crd);
-        else
-            return matrix.likeVector(crd);
-    }
-
-    /**
-     * Create the like vector with read-only matrices support.
-     *
-     * @param matrix Matrix for like.
-     * @return Like vector.
-     */
-    protected Vector likeVector(Matrix matrix) {
-        return likeVector(matrix, matrix.rowSize());
-    }
-
-    /**
-     * Create the copy of matrix with read-only matrices support.
-     *
-     * @param matrix Matrix for copy.
-     * @return Copy.
-     */
-    protected Matrix copy(Matrix matrix) {
-        if (isCopyLikeSupport(matrix)) {
-            DenseLocalOnHeapMatrix cp = new DenseLocalOnHeapMatrix(matrix.rowSize(), matrix.columnSize());
-
-            cp.assign(matrix);
-
-            return cp;
-        }
-        else
-            return matrix.copy();
-    }
-
-    /** */
-    private boolean isCopyLikeSupport(Matrix matrix) {
-        return matrix instanceof RandomMatrix || matrix instanceof PivotedMatrixView || matrix instanceof CacheMatrix;
-    }
-}


[14/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
new file mode 100644
index 0000000..b9a3b17
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
@@ -0,0 +1,243 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.IndexException;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.storage.matrix.PivotedMatrixStorage;
+import org.apache.ignite.ml.math.impls.vector.PivotedVectorView;
+
+/**
+ * Pivoted (index mapped) view over another matrix implementation.
+ */
+public class PivotedMatrixView extends AbstractMatrix {
+    /** Pivoted matrix. */
+    private Matrix mtx;
+
+    /**
+     *
+     */
+    public PivotedMatrixView() {
+        // No-op.
+    }
+
+    /**
+     * @param mtx
+     * @param rowPivot
+     * @param colPivot
+     */
+    public PivotedMatrixView(Matrix mtx, int[] rowPivot, int[] colPivot) {
+        super(new PivotedMatrixStorage(mtx == null ? null : mtx.getStorage(), rowPivot, colPivot));
+
+        this.mtx = mtx;
+    }
+
+    /**
+     * @param mtx
+     */
+    public PivotedMatrixView(Matrix mtx) {
+        super(new PivotedMatrixStorage(mtx == null ? null : mtx.getStorage()));
+
+        this.mtx = mtx;
+    }
+
+    /**
+     * @param mtx
+     * @param pivot
+     */
+    public PivotedMatrixView(Matrix mtx, int[] pivot) {
+        super(new PivotedMatrixStorage(mtx == null ? null : mtx.getStorage(), pivot));
+
+        this.mtx = mtx;
+    }
+
+    /**
+     * Swaps indexes {@code i} and {@code j} for both both row and column.
+     *
+     * @param i First index to swap.
+     * @param j Second index to swap.
+     */
+    public Matrix swap(int i, int j) {
+        swapRows(i, j);
+        swapColumns(i, j);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix swapRows(int i, int j) {
+        if (i < 0 || i >= storage().rowPivot().length)
+            throw new IndexException(i);
+        if (j < 0 || j >= storage().rowPivot().length)
+            throw new IndexException(j);
+
+        storage().swapRows(i, j);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix swapColumns(int i, int j) {
+        if (i < 0 || i >= storage().columnPivot().length)
+            throw new IndexException(i);
+        if (j < 0 || j >= storage().columnPivot().length)
+            throw new IndexException(j);
+
+        storage().swapColumns(i, j);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector viewRow(int row) {
+        return new PivotedVectorView(
+            mtx.viewRow(storage().rowPivot()[row]),
+            storage().columnPivot(),
+            storage().columnUnpivot()
+        );
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector viewColumn(int col) {
+        return new PivotedVectorView(
+            mtx.viewColumn(storage().columnPivot()[col]),
+            storage().rowPivot(),
+            storage().rowUnpivot()
+        );
+    }
+
+    /**
+     *
+     *
+     */
+    public Matrix getBaseMatrix() {
+        return mtx;
+    }
+
+    /**
+     *
+     *
+     */
+    public int[] rowPivot() {
+        return storage().rowPivot();
+    }
+
+    /**
+     *
+     *
+     */
+    public int[] columnPivot() {
+        return storage().columnPivot();
+    }
+
+    /**
+     * @param i
+     */
+    public int rowPivot(int i) {
+        return storage().rowPivot()[i];
+    }
+
+    /**
+     * @param i
+     */
+    public int columnPivot(int i) {
+        return storage().columnPivot()[i];
+    }
+
+    /**
+     * @param i
+     */
+    public int rowUnpivot(int i) {
+        return storage().rowUnpivot()[i];
+    }
+
+    /**
+     * @param i
+     */
+    public int columnUnpivot(int i) {
+        return storage().columnUnpivot()[i];
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        super.writeExternal(out);
+
+        out.writeObject(mtx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        super.readExternal(in);
+
+        mtx = (Matrix)in.readObject();
+    }
+
+    /**
+     *
+     *
+     */
+    private PivotedMatrixStorage storage() {
+        return (PivotedMatrixStorage)getStorage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix copy() {
+        return new PivotedMatrixView(mtx, storage().rowPivot(), storage().columnPivot());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix like(int rows, int cols) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector likeVector(int crd) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + mtx.hashCode();
+        res = res * 37 + getStorage().hashCode();
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        PivotedMatrixView that = (PivotedMatrixView)o;
+
+        MatrixStorage sto = storage();
+
+        return mtx.equals(that.mtx) && sto.equals(that.storage());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/RandomMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/RandomMatrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/RandomMatrix.java
new file mode 100644
index 0000000..ece4ca9
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/RandomMatrix.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.storage.matrix.RandomMatrixStorage;
+import org.apache.ignite.ml.math.impls.vector.RandomVector;
+
+/**
+ * Implementation of {@link Matrix} with random values in the elements.
+ */
+public class RandomMatrix extends AbstractMatrix {
+    /** Whether fast hash is used, see {@link RandomMatrixStorage}. */
+    private boolean fastHash;
+
+    /**
+     * @param rows Amount of rows in the matrix.
+     * @param cols Amount of columns in the matrix.
+     * @param fastHash Whether fast hash is used.
+     */
+    private MatrixStorage mkStorage(int rows, int cols, boolean fastHash) {
+        this.fastHash = fastHash;
+
+        return new RandomMatrixStorage(rows, cols, fastHash);
+    }
+
+    /**
+     * @param rows Amount of rows in the matrix.
+     * @param cols Amount of columns in the matrix.
+     * @param fastHash Whether fast hash is used.
+     */
+    public RandomMatrix(int rows, int cols, boolean fastHash) {
+        setStorage(mkStorage(rows, cols, fastHash));
+    }
+
+    /**
+     * @param rows Amount of rows in the matrix.
+     * @param cols Amount of columns in the matrix.
+     */
+    public RandomMatrix(int rows, int cols) {
+        this(rows, cols, true);
+    }
+
+    /** */
+    public RandomMatrix() {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix copy() {
+        return new RandomMatrix(rowSize(), columnSize(), fastHash);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix like(int rows, int cols) {
+        return new RandomMatrix(rows, cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector likeVector(int crd) {
+        return new RandomVector(crd);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        super.writeExternal(out);
+
+        out.writeBoolean(fastHash);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        super.readExternal(in);
+
+        fastHash = in.readBoolean();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
new file mode 100644
index 0000000..8a7cffe
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
@@ -0,0 +1,155 @@
+// @java.file.header
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.IgniteDoubleFunction;
+import org.apache.ignite.ml.math.functions.IgniteFunction;
+import org.apache.ignite.ml.math.impls.CacheUtils;
+import org.apache.ignite.ml.math.impls.storage.matrix.SparseDistributedMatrixStorage;
+
+/**
+ * Sparse distributed matrix implementation based on data grid.
+ *
+ * Unlike {@link CacheMatrix} that is based on existing cache, this implementation creates distributed
+ * cache internally and doesn't rely on pre-existing cache.
+ *
+ * You also need to call {@link #destroy()} to remove the underlying cache when you no longer need this
+ * matrix.
+ *
+ * <b>Currently fold supports only commutative operations.<b/>
+ */
+public class SparseDistributedMatrix extends AbstractMatrix implements StorageConstants {
+    /**
+     *
+     */
+    public SparseDistributedMatrix() {
+        // No-op.
+    }
+
+    /**
+     * @param rows
+     * @param cols
+     * @param stoMode
+     * @param acsMode
+     */
+    public SparseDistributedMatrix(int rows, int cols, int stoMode, int acsMode) {
+        assert rows > 0;
+        assert cols > 0;
+        assertAccessMode(acsMode);
+        assertStorageMode(stoMode);
+
+        setStorage(new SparseDistributedMatrixStorage(rows, cols, stoMode, acsMode));
+    }
+
+    /**
+     *
+     *
+     */
+    private SparseDistributedMatrixStorage storage() {
+        return (SparseDistributedMatrixStorage)getStorage();
+    }
+
+    /**
+     * Return the same matrix with updates values (broken contract).
+     *
+     * @param d
+     */
+    @Override public Matrix divide(double d) {
+        return mapOverValues((Double v) -> v / d);
+    }
+
+    /**
+     * Return the same matrix with updates values (broken contract).
+     *
+     * @param x
+     */
+    @Override public Matrix plus(double x) {
+        return mapOverValues((Double v) -> v + x);
+    }
+
+    /**
+     * Return the same matrix with updates values (broken contract).
+     *
+     * @param x
+     */
+    @Override public Matrix times(double x) {
+        return mapOverValues((Double v) -> v * x);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix assign(double val) {
+        return mapOverValues((Double v) -> val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix map(IgniteDoubleFunction<Double> fun) {
+        return mapOverValues(fun::apply);
+    }
+
+    /**
+     * @param mapper
+     */
+    private Matrix mapOverValues(IgniteFunction<Double, Double> mapper) {
+        CacheUtils.sparseMap(storage().cache().getName(), mapper);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double sum() {
+        return CacheUtils.sparseSum(storage().cache().getName());
+    }
+
+    /** {@inheritDoc} */
+    @Override public double maxValue() {
+        return CacheUtils.sparseMax(storage().cache().getName());
+    }
+
+    /** {@inheritDoc} */
+    @Override public double minValue() {
+        return CacheUtils.sparseMin(storage().cache().getName());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix copy() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix like(int rows, int cols) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector likeVector(int crd) {
+        throw new UnsupportedOperationException();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseLocalOnHeapMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseLocalOnHeapMatrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseLocalOnHeapMatrix.java
new file mode 100644
index 0000000..d711295
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseLocalOnHeapMatrix.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.storage.matrix.SparseLocalOnHeapMatrixStorage;
+import org.apache.ignite.ml.math.impls.vector.SparseLocalVector;
+
+/**
+ * Sparse local onheap matrix with {@link SparseLocalVector} as rows.
+ */
+public class SparseLocalOnHeapMatrix extends AbstractMatrix implements StorageConstants {
+    /**
+     *
+     */
+    public SparseLocalOnHeapMatrix() {
+        // No-op.
+    }
+
+    /**
+     * Construct new {@link SparseLocalOnHeapMatrix}.
+     *
+     * By default storage sets in row optimized mode and in random access mode.
+     */
+    public SparseLocalOnHeapMatrix(int rows, int cols) {
+        setStorage(mkStorage(rows, cols));
+    }
+
+    /**
+     * Create new {@link SparseLocalOnHeapMatrixStorage}.
+     */
+    private MatrixStorage mkStorage(int rows, int cols) {
+        return new SparseLocalOnHeapMatrixStorage(rows, cols, StorageConstants.RANDOM_ACCESS_MODE, StorageConstants.ROW_STORAGE_MODE);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix like(int rows, int cols) {
+        return new SparseLocalOnHeapMatrix(rows, cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector likeVector(int crd) {
+        return new SparseLocalVector(crd, StorageConstants.RANDOM_ACCESS_MODE);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix copy() {
+        Matrix cp = like(rowSize(), columnSize());
+
+        cp.assign(this);
+
+        return cp;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/TransposedMatrixView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/TransposedMatrixView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/TransposedMatrixView.java
new file mode 100644
index 0000000..309570b
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/TransposedMatrixView.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.storage.matrix.MatrixDelegateStorage;
+
+/**
+ * Implements transposed view of the parent {@link Matrix}.
+ */
+public class TransposedMatrixView extends AbstractMatrix {
+    /** */
+    public TransposedMatrixView() {
+        //No-op.
+    }
+
+    /**
+     * @param mtx Parent matrix.
+     */
+    public TransposedMatrixView(Matrix mtx) {
+        this(mtx == null ? null : mtx.getStorage());
+    }
+
+    /** */
+    private TransposedMatrixView(MatrixStorage sto) {
+        super(new MatrixDelegateStorage(sto, 0, 0,
+            sto == null ? 0 : sto.rowSize(), sto == null ? 0 : sto.columnSize()));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void storageSet(int row, int col, double v) {
+        super.storageSet(col, row, v);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected double storageGet(int row, int col) {
+        return super.storageGet(col, row);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int rowSize() {
+        return getStorage().columnSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int columnSize() {
+        return getStorage().rowSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix copy() {
+        MatrixDelegateStorage sto = (MatrixDelegateStorage)getStorage();
+
+        return new TransposedMatrixView(sto.delegate());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix like(int rows, int cols) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector likeVector(int crd) {
+        throw new UnsupportedOperationException();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/package-info.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/package-info.java
new file mode 100644
index 0000000..9eabf80
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Contains several matrix implementations.
+ */
+package org.apache.ignite.ml.math.impls.matrix;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/package-info.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/package-info.java
new file mode 100644
index 0000000..d531014
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Contains specific implementations for core algebra.
+ */
+package org.apache.ignite.ml.math.impls;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/ArrayMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/ArrayMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/ArrayMatrixStorage.java
new file mode 100644
index 0000000..397bf93
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/ArrayMatrixStorage.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Arrays;
+import org.apache.ignite.ml.math.MatrixStorage;
+
+/**
+ * Array based {@link MatrixStorage} implementation.
+ */
+public class ArrayMatrixStorage implements MatrixStorage {
+    /** Backing data array. */
+    private double[][] data;
+    /** Amount of rows in the matrix. */
+    private int rows;
+    /** Amount of columns in the matrix. */
+    private int cols;
+
+    /**
+     *
+     */
+    public ArrayMatrixStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param rows Amount of rows in the matrix.
+     * @param cols Amount of columns in the matrix.
+     */
+    public ArrayMatrixStorage(int rows, int cols) {
+        assert rows > 0;
+        assert cols > 0;
+
+        this.data = new double[rows][cols];
+        this.rows = rows;
+        this.cols = cols;
+    }
+
+    /**
+     * @param data Backing data array.
+     */
+    public ArrayMatrixStorage(double[][] data) {
+        assert data != null;
+        assert data[0] != null;
+
+        this.data = data;
+        this.rows = data.length;
+        this.cols = data[0].length;
+
+        assert rows > 0;
+        assert cols > 0;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int x, int y) {
+        return data[x][y];
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int x, int y, double v) {
+        data[x][y] = v;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int columnSize() {
+        return cols;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int rowSize() {
+        return rows;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double[][] data() {
+        return data;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(rows);
+        out.writeInt(cols);
+
+        out.writeObject(data);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        rows = in.readInt();
+        cols = in.readInt();
+
+        data = (double[][])in.readObject();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res += res * 37 + rows;
+        res += res * 37 + cols;
+        res += res * 37 + Arrays.deepHashCode(data);
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        ArrayMatrixStorage that = (ArrayMatrixStorage)o;
+
+        return Arrays.deepEquals(data, that.data);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
new file mode 100644
index 0000000..510c4cf
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.ml.math.MatrixKeyMapper;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.ValueMapper;
+
+/**
+ * Matrix storage based on arbitrary cache and key and value mapping functions.
+ */
+public class CacheMatrixStorage<K, V> implements MatrixStorage {
+    /** */ private int rows;
+    /** */  private int cols;
+    /** */ private IgniteCache<K, V> cache;
+    /** */ private MatrixKeyMapper<K> keyMapper;
+    /** */ private ValueMapper<V> valMapper;
+
+    /**
+     *
+     */
+    public CacheMatrixStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param rows
+     * @param cols
+     * @param cache
+     * @param keyMapper
+     * @param valMapper
+     */
+    public CacheMatrixStorage(int rows, int cols, IgniteCache<K, V> cache, MatrixKeyMapper<K> keyMapper,
+        ValueMapper<V> valMapper) {
+        assert rows > 0;
+        assert cols > 0;
+        assert cache != null;
+        assert keyMapper != null;
+        assert valMapper != null;
+
+        this.rows = rows;
+        this.cols = cols;
+        this.cache = cache;
+        this.keyMapper = keyMapper;
+        this.valMapper = valMapper;
+    }
+
+    /**
+     * @return Ignite cache.
+     */
+    public IgniteCache<K, V> cache() {
+        return cache;
+    }
+
+    /**
+     * @return Key mapper.
+     */
+    public MatrixKeyMapper<K> keyMapper() {
+        return keyMapper;
+    }
+
+    /**
+     * @return Value mapper.
+     */
+    public ValueMapper<V> valueMapper() {
+        return valMapper;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int x, int y) {
+        return valMapper.toDouble(cache.get(keyMapper.apply(x, y)));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int x, int y, double v) {
+        cache.put(keyMapper.apply(x, y), valMapper.fromDouble(v));
+    }
+
+    /** {@inheritDoc} */
+    @Override public int columnSize() {
+        return cols;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int rowSize() {
+        return rows;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(rows);
+        out.writeInt(cols);
+        out.writeUTF(cache.getName());
+        out.writeObject(keyMapper);
+        out.writeObject(valMapper);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings({"unchecked"})
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        rows = in.readInt();
+        cols = in.readInt();
+        cache = Ignition.localIgnite().getOrCreateCache(in.readUTF());
+        keyMapper = (MatrixKeyMapper<K>)in.readObject();
+        valMapper = (ValueMapper<V>)in.readObject();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + rows;
+        res = res * 37 + cols;
+        res = res * 37 + cache.hashCode();
+        res = res * 37 + keyMapper.hashCode();
+        res = res * 37 + valMapper.hashCode();
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        CacheMatrixStorage that = (CacheMatrixStorage)o;
+
+        return (cache != null ? cache.equals(that.cache) : that.cache == null) &&
+            (keyMapper != null ? keyMapper.equals(that.keyMapper) : that.keyMapper == null) &&
+            (valMapper != null ? valMapper.equals(that.valMapper) : that.valMapper == null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
new file mode 100644
index 0000000..74952a9
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.ml.math.MatrixStorage;
+
+/**
+ * Local, dense off-heap matrix storage.
+ */
+public class DenseOffHeapMatrixStorage implements MatrixStorage {
+    /** */ private int rows;
+    /** */ private int cols;
+    /** */ private transient long ptr;
+    //TODO: temp solution.
+    /** */ private int ptrInitHash;
+
+    /** */
+    public DenseOffHeapMatrixStorage() {
+        // No-op.
+    }
+
+    /** */
+    public DenseOffHeapMatrixStorage(int rows, int cols) {
+        assert rows > 0;
+        assert cols > 0;
+
+        this.rows = rows;
+        this.cols = cols;
+
+        allocateMemory(rows, cols);
+    }
+
+    /** */
+    public DenseOffHeapMatrixStorage(double[][] data) {
+        assert data != null;
+        assert data[0] != null;
+
+        this.rows = data.length;
+        this.cols = data[0].length;
+
+        assert rows > 0;
+        assert cols > 0;
+
+        allocateMemory(rows, cols);
+
+        for (int i = 0; i < rows; i++)
+            for (int j = 0; j < cols; j++)
+                set(i, j, data[i][j]);
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int x, int y) {
+        return GridUnsafe.getDouble(pointerOffset(x, y));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int x, int y, double v) {
+        GridUnsafe.putDouble(pointerOffset(x, y), v);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int columnSize() {
+        return cols;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int rowSize() {
+        return rows;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double[][] data() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(rows);
+        out.writeInt(cols);
+        out.writeInt(ptrInitHash);
+
+        for (int i = 0; i < rows; i++)
+            for (int j = 0; j < cols; j++)
+                out.writeDouble(get(i, j));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        rows = in.readInt();
+        cols = in.readInt();
+
+        allocateMemory(rows, cols);
+
+        ptrInitHash = in.readInt();
+
+        for (int i = 0; i < rows; i++)
+            for (int j = 0; j < cols; j++)
+                set(i, j, in.readDouble());
+    }
+
+    /** {@inheritDoc} */
+    @Override public void destroy() {
+        GridUnsafe.freeMemory(ptr);
+    }
+
+    /** {@inheritDoc} */
+    private long pointerOffset(int x, int y) {
+        return ptr + x * cols * Double.BYTES + y * Double.BYTES;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object obj) {
+        return obj != null &&
+            getClass().equals(obj.getClass()) &&
+            (rows == ((DenseOffHeapMatrixStorage)obj).rows) &&
+            (cols == ((DenseOffHeapMatrixStorage)obj).cols) &&
+            (rows == 0 || cols == 0 || ptr == ((DenseOffHeapMatrixStorage)obj).ptr || isMemoryEquals((DenseOffHeapMatrixStorage)obj));
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + rows;
+        res = res * 37 + cols;
+        res = res * 37 + ptrInitHash;
+
+        return res;
+    }
+
+    /** */
+    private boolean isMemoryEquals(DenseOffHeapMatrixStorage otherStorage) {
+        boolean res = true;
+
+        for (int i = 0; i < otherStorage.rows; i++) {
+            for (int j = 0; j < otherStorage.cols; j++) {
+                if (Double.compare(get(i, j), otherStorage.get(i, j)) != 0) {
+                    res = false;
+                    break;
+                }
+            }
+        }
+
+        return res;
+    }
+
+    /** */
+    private void allocateMemory(int rows, int cols) {
+        ptr = GridUnsafe.allocateMemory(rows * cols * Double.BYTES);
+
+        ptrInitHash = Long.hashCode(ptr);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DiagonalMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DiagonalMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DiagonalMatrixStorage.java
new file mode 100644
index 0000000..9daacee
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DiagonalMatrixStorage.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+
+/**
+ * {@link MatrixStorage} implementation for diagonal Matrix view.
+ */
+public class DiagonalMatrixStorage implements MatrixStorage {
+    /** Backing vector for matrix diagonal. */
+    private Vector diagonal;
+
+    /**
+     *
+     */
+    public DiagonalMatrixStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param diagonal Backing {@link Vector} for matrix diagonal.
+     */
+    public DiagonalMatrixStorage(Vector diagonal) {
+        assert diagonal != null;
+
+        this.diagonal = diagonal;
+    }
+
+    /**
+     *
+     */
+    public Vector diagonal() {
+        return diagonal;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int x, int y) {
+        return x == y ? diagonal.get(x) : 0.0;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int x, int y, double v) {
+        if (x == y)
+            diagonal.set(x, v);
+        else
+            throw new UnsupportedOperationException("Can't set off-diagonal element.");
+    }
+
+    /** {@inheritDoc} */
+    @Override public int columnSize() {
+        return diagonal.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int rowSize() {
+        return diagonal.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(diagonal);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        diagonal = (Vector)in.readObject();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return diagonal.isSequentialAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return diagonal.isDense();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return diagonal.isRandomAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return diagonal.isDistributed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + diagonal.hashCode();
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        DiagonalMatrixStorage that = (DiagonalMatrixStorage)o;
+
+        return diagonal.equals(that.diagonal);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
new file mode 100644
index 0000000..acd7c29
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.IntIntDoubleToVoidFunction;
+import org.apache.ignite.ml.math.functions.IntIntToDoubleFunction;
+
+/**
+ * Read-only or read-write function-based matrix storage.
+ */
+public class FunctionMatrixStorage implements MatrixStorage {
+    /** */ private int rows;
+    /** */ private int cols;
+
+    /** */ private IntIntToDoubleFunction getFunc;
+    /** */ private IntIntDoubleToVoidFunction setFunc;
+
+    /**
+     *
+     */
+    public FunctionMatrixStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param rows Amount of rows in the matrix.
+     * @param cols Amount of columns in the matrix.
+     * @param getFunc Function that returns value corresponding to given row and column index.
+     * @param setFunc Set function. If {@code null} - this will be a read-only matrix.
+     */
+    public FunctionMatrixStorage(int rows, int cols, IntIntToDoubleFunction getFunc,
+        IntIntDoubleToVoidFunction setFunc) {
+        assert rows > 0;
+        assert cols > 0;
+        assert getFunc != null;
+
+        this.rows = rows;
+        this.cols = cols;
+        this.getFunc = getFunc;
+        this.setFunc = setFunc;
+    }
+
+    /**
+     * @param rows Amount of rows in the matrix.
+     * @param cols Amount of columns in the matrix.
+     * @param getFunc Function that returns value corresponding to given row and column index.
+     */
+    public FunctionMatrixStorage(int rows, int cols, IntIntToDoubleFunction getFunc) {
+        this(rows, cols, getFunc, null);
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int x, int y) {
+        return getFunc.apply(x, y);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int x, int y, double v) {
+        if (setFunc != null)
+            setFunc.apply(x, y, v);
+        else
+            throw new UnsupportedOperationException("Cannot set into read-only matrix.");
+    }
+
+    /**
+     *
+     */
+    public IntIntToDoubleFunction getFunction() {
+        return getFunc;
+    }
+
+    /**
+     *
+     */
+    public IntIntDoubleToVoidFunction setFunction() {
+        return setFunc;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int columnSize() {
+        return cols;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int rowSize() {
+        return rows;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(setFunc);
+        out.writeObject(getFunc);
+        out.writeInt(rows);
+        out.writeInt(cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        setFunc = (IntIntDoubleToVoidFunction)in.readObject();
+        getFunc = (IntIntToDoubleFunction)in.readObject();
+        rows = in.readInt();
+        cols = in.readInt();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        FunctionMatrixStorage that = (FunctionMatrixStorage)o;
+
+        return rows == that.rows && cols == that.cols
+            && (getFunc != null ? getFunc.equals(that.getFunc) : that.getFunc == null)
+            && (setFunc != null ? setFunc.equals(that.setFunc) : that.setFunc == null);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = rows;
+
+        res = 31 * res + cols;
+        res = 31 * res + (getFunc != null ? getFunc.hashCode() : 0);
+        res = 31 * res + (setFunc != null ? setFunc.hashCode() : 0);
+
+        return res;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixDelegateStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixDelegateStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixDelegateStorage.java
new file mode 100644
index 0000000..1f77d0f
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixDelegateStorage.java
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.ml.math.MatrixStorage;
+
+/**
+ * {@link MatrixStorage} implementation that delegates to parent matrix.
+ */
+public class MatrixDelegateStorage implements MatrixStorage {
+    /** Parent matrix storage. */
+    private MatrixStorage sto;
+
+    /** Row offset in the parent matrix. */
+    private int rowOff;
+    /** Column offset in the parent matrix. */
+    private int colOff;
+
+    /** Amount of rows in the matrix. */
+    private int rows;
+    /** Amount of columns in the matrix. */
+    private int cols;
+
+    /**
+     *
+     */
+    public MatrixDelegateStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param sto Backing parent storage.
+     * @param rowOff Row offset to parent matrix.
+     * @param colOff Column offset to parent matrix.
+     * @param rows Amount of rows in the view.
+     * @param cols Amount of columns in the view.
+     */
+    public MatrixDelegateStorage(MatrixStorage sto, int rowOff, int colOff, int rows, int cols) {
+        assert sto != null;
+        assert rowOff >= 0;
+        assert colOff >= 0;
+        assert rows > 0;
+        assert cols > 0;
+
+        this.sto = sto;
+
+        this.rowOff = rowOff;
+        this.colOff = colOff;
+
+        this.rows = rows;
+        this.cols = cols;
+    }
+
+    /**
+     *
+     */
+    public MatrixStorage delegate() {
+        return sto;
+    }
+
+    /**
+     *
+     */
+    public int rowOffset() {
+        return rowOff;
+    }
+
+    /**
+     *
+     */
+    public int columnOffset() {
+        return colOff;
+    }
+
+    /**
+     *
+     */
+    public int rowsLength() {
+        return rows;
+    }
+
+    /**
+     *
+     */
+    public int columnsLength() {
+        return cols;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int x, int y) {
+        return sto.get(rowOff + x, colOff + y);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int x, int y, double v) {
+        sto.set(rowOff + x, colOff + y, v);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int columnSize() {
+        return cols;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int rowSize() {
+        return rows;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return sto.isArrayBased() && rowOff == 0 && colOff == 0;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return sto.isSequentialAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return sto.isDense();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return sto.isRandomAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return sto.isDistributed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double[][] data() {
+        return sto.data();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(sto);
+
+        out.writeInt(rowOff);
+        out.writeInt(colOff);
+
+        out.writeInt(rows);
+        out.writeInt(cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        sto = (MatrixStorage)in.readObject();
+
+        rowOff = in.readInt();
+        colOff = in.readInt();
+
+        rows = in.readInt();
+        cols = in.readInt();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + rows;
+        res = res * 37 + cols;
+        res = res * 37 + rowOff;
+        res = res * 37 + colOff;
+        res = res * 37 + sto.hashCode();
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        MatrixDelegateStorage that = (MatrixDelegateStorage)o;
+
+        return rows == that.rows && cols == that.cols && rowOff == that.rowOff && colOff == that.colOff &&
+            (sto != null ? sto.equals(that.sto) : that.sto == null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/PivotedMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/PivotedMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/PivotedMatrixStorage.java
new file mode 100644
index 0000000..ab9b871
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/PivotedMatrixStorage.java
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Arrays;
+import org.apache.ignite.ml.math.MatrixStorage;
+
+/**
+ * Pivoted (index mapped) view over another matrix storage implementation.
+ */
+public class PivotedMatrixStorage implements MatrixStorage {
+    /** Matrix storage. */
+    private MatrixStorage sto;
+
+    /** */
+    private int[] rowPivot;
+    /** */
+    private int[] colPivot;
+    /** */
+    private int[] rowUnpivot;
+    /** */
+    private int[] colUnpivot;
+
+    /**
+     *
+     */
+    public PivotedMatrixStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param sto Matrix storage.
+     * @param rowPivot Pivot array for rows.
+     * @param colPivot Pivot array for columns.
+     */
+    public PivotedMatrixStorage(MatrixStorage sto, int[] rowPivot, int[] colPivot) {
+        assert sto != null;
+        assert rowPivot != null;
+        assert colPivot != null;
+
+        this.sto = sto;
+        this.rowPivot = rowPivot;
+        this.colPivot = colPivot;
+
+        rowUnpivot = invert(rowPivot);
+        colUnpivot = invert(colPivot);
+    }
+
+    /**
+     *
+     */
+    public int[] rowPivot() {
+        return rowPivot;
+    }
+
+    /**
+     *
+     */
+    public int[] columnPivot() {
+        return colPivot;
+    }
+
+    /**
+     *
+     */
+    public int[] rowUnpivot() {
+        return rowUnpivot;
+    }
+
+    /**
+     *
+     */
+    public int[] columnUnpivot() {
+        return colUnpivot;
+    }
+
+    /**
+     * @param sto Matrix storage.
+     * @param pivot Pivot array.
+     */
+    public PivotedMatrixStorage(MatrixStorage sto, int[] pivot) {
+        this(sto, pivot, pivot == null ? null : java.util.Arrays.copyOf(pivot, pivot.length));
+    }
+
+    /**
+     * @param sto Matrix storage.
+     */
+    public PivotedMatrixStorage(MatrixStorage sto) {
+        this(sto, sto == null ? null : identityPivot(sto.rowSize()), sto == null ? null : identityPivot(sto.columnSize()));
+    }
+
+    /**
+     * @param i First row index to swap.
+     * @param j Second row index to swap.
+     */
+    public void swapRows(int i, int j) {
+        if (i != j) {
+            int tmp = rowPivot[i];
+
+            rowPivot[i] = rowPivot[j];
+            rowPivot[j] = tmp;
+
+            rowUnpivot[rowPivot[i]] = i;
+            rowUnpivot[rowPivot[j]] = j;
+        }
+    }
+
+    /**
+     * @param i First column index to swap.
+     * @param j Second column index to swap.
+     */
+    public void swapColumns(int i, int j) {
+        if (i != j) {
+            int tmp = colPivot[i];
+
+            colPivot[i] = colPivot[j];
+            colPivot[j] = tmp;
+
+            colUnpivot[colPivot[i]] = i;
+            colUnpivot[colPivot[j]] = j;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int x, int y) {
+        return sto.get(rowPivot[x], colPivot[y]);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int x, int y, double v) {
+        sto.set(rowPivot[x], colPivot[y], v);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int columnSize() {
+        return sto.columnSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int rowSize() {
+        return sto.rowSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(sto);
+        out.writeObject(rowPivot);
+        out.writeObject(colPivot);
+        out.writeObject(rowUnpivot);
+        out.writeObject(colUnpivot);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        sto = (MatrixStorage)in.readObject();
+        rowPivot = (int[])in.readObject();
+        colPivot = (int[])in.readObject();
+        rowUnpivot = (int[])in.readObject();
+        colUnpivot = (int[])in.readObject();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return sto.isSequentialAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return sto.isDense();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return sto.isRandomAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return sto.isDistributed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + sto.hashCode();
+        res = res * 37 + Arrays.hashCode(rowPivot);
+        res = res * 37 + Arrays.hashCode(rowUnpivot);
+        res = res * 37 + Arrays.hashCode(colPivot);
+        res = res * 37 + Arrays.hashCode(colUnpivot);
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+
+        if (obj == null || getClass() != obj.getClass())
+            return false;
+
+        PivotedMatrixStorage that = (PivotedMatrixStorage)obj;
+
+        return Arrays.equals(rowPivot, that.rowPivot) && Arrays.equals(rowUnpivot, that.rowUnpivot)
+            && Arrays.equals(colPivot, that.colPivot) && Arrays.equals(colUnpivot, that.colUnpivot)
+            && (sto != null ? sto.equals(that.sto) : that.sto == null);
+    }
+
+    /**
+     * @param n Pivot array length.
+     */
+    private static int[] identityPivot(int n) {
+        int[] pivot = new int[n];
+
+        for (int i = 0; i < n; i++)
+            pivot[i] = i;
+
+        return pivot;
+    }
+
+    /**
+     * @param pivot Pivot array to be inverted.
+     */
+    private static int[] invert(int[] pivot) {
+        int[] x = new int[pivot.length];
+
+        for (int i = 0; i < pivot.length; i++)
+            x[pivot[i]] = i;
+
+        return x;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/RandomMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/RandomMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/RandomMatrixStorage.java
new file mode 100644
index 0000000..7e0ef27
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/RandomMatrixStorage.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.nio.ByteBuffer;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.MurmurHash;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+
+/**
+ * {@link MatrixStorage} implementation with random values in the matrix elements.
+ */
+public class RandomMatrixStorage implements MatrixStorage {
+    /** */
+    private static final int PRIME1 = 104047;
+    /** */
+    private static final int PRIME2 = 101377;
+    /** */
+    private static final int PRIME3 = 64661;
+    /** */
+    private static final long SCALE = 1L << 32;
+
+    /** Random generation seed. */
+    private int seed;
+
+    /** Amount of rows in the matrix. */
+    private int rows;
+    /** Amount of columns in the matrix. */
+    private int cols;
+
+    /** Whether fast hash is used, in {@link #get(int, int)}. */
+    private boolean fastHash;
+
+    /**
+     * For externalization.
+     */
+    public RandomMatrixStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param rows Amount of rows in the matrix.
+     * @param cols Amount of columns in the matrix.
+     * @param fastHash Whether fast hash is used.
+     */
+    public RandomMatrixStorage(int rows, int cols, boolean fastHash) {
+        assert rows > 0;
+        assert cols > 0;
+
+        this.rows = rows;
+        this.cols = cols;
+        this.fastHash = fastHash;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int x, int y) {
+        if (!fastHash) {
+            ByteBuffer buf = ByteBuffer.allocate(8);
+
+            buf.putInt(x);
+            buf.putInt(y);
+            buf.flip();
+
+            return (MurmurHash.hash64A(buf, seed) & (SCALE - 1)) / (double)SCALE;
+        }
+        else
+            // This isn't a fantastic random number generator, but it is just fine for random projections.
+            return ((((x * PRIME1) + y * PRIME2 + x * y * PRIME3) & 8) * 0.25) - 1;
+    }
+
+    /**
+     *
+     */
+    public boolean isFastHash() {
+        return fastHash;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int x, int y, double v) {
+        throw new UnsupportedOperationException("Random matrix storage is a read-only storage.");
+    }
+
+    /** {@inheritDoc} */
+    @Override public int columnSize() {
+        return cols;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int rowSize() {
+        return rows;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(rows);
+        out.writeInt(cols);
+        out.writeInt(seed);
+        out.writeBoolean(fastHash);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        rows = in.readInt();
+        cols = in.readInt();
+        seed = in.readInt();
+        fastHash = in.readBoolean();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + Boolean.hashCode(fastHash);
+        res = res * 37 + seed;
+        res = res * 37 + cols;
+        res = res * 37 + rows;
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        RandomMatrixStorage that = (RandomMatrixStorage)o;
+
+        return rows == that.rows && cols == that.cols && seed == that.seed && fastHash == that.fastHash;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseDistributedMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseDistributedMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseDistributedMatrixStorage.java
new file mode 100644
index 0000000..cf200c7
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseDistributedMatrixStorage.java
@@ -0,0 +1,290 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Map;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.impls.CacheUtils;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
+
+/**
+ * {@link MatrixStorage} implementation for {@link SparseDistributedMatrix}.
+ */
+public class SparseDistributedMatrixStorage extends CacheUtils implements MatrixStorage, StorageConstants {
+    /** Amount of rows in the matrix. */
+    private int rows;
+    /** Amount of columns in the matrix. */
+    private int cols;
+
+    /** Row or column based storage mode. */
+    private int stoMode;
+    /** Random or sequential access mode. */
+    private int acsMode;
+
+    /** Actual distributed storage. */
+    private IgniteCache<
+        Integer /* Row or column index. */,
+        Map<Integer, Double> /* Map-based row or column. */
+        > cache = null;
+
+    /**
+     *
+     */
+    public SparseDistributedMatrixStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param rows Amount of rows in the matrix.
+     * @param cols Amount of columns in the matrix.
+     * @param stoMode Row or column based storage mode.
+     * @param acsMode Random or sequential access mode.
+     */
+    public SparseDistributedMatrixStorage(int rows, int cols, int stoMode, int acsMode) {
+        assert rows > 0;
+        assert cols > 0;
+        assertAccessMode(acsMode);
+        assertStorageMode(stoMode);
+
+        this.rows = rows;
+        this.cols = cols;
+        this.stoMode = stoMode;
+        this.acsMode = acsMode;
+
+        cache = newCache();
+    }
+
+    /**
+     *
+     *
+     */
+    private IgniteCache<Integer, Map<Integer, Double>> newCache() {
+        CacheConfiguration<Integer, Map<Integer, Double>> cfg = new CacheConfiguration<>();
+
+        // Assume 10% density.
+        cfg.setStartSize(Math.max(1024, (rows * cols) / 10));
+
+        // Write to primary.
+        cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
+
+        // Atomic transactions only.
+        cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+
+        // No eviction.
+        cfg.setEvictionPolicy(null);
+
+        // No copying of values.
+        cfg.setCopyOnRead(false);
+
+        // Cache is partitioned.
+        cfg.setCacheMode(CacheMode.PARTITIONED);
+
+        // Random cache name.
+        cfg.setName(new IgniteUuid().shortString());
+
+        return Ignition.localIgnite().getOrCreateCache(cfg);
+    }
+
+    /**
+     *
+     *
+     */
+    public IgniteCache<Integer, Map<Integer, Double>> cache() {
+        return cache;
+    }
+
+    /**
+     *
+     *
+     */
+    public int accessMode() {
+        return acsMode;
+    }
+
+    /**
+     *
+     *
+     */
+    public int storageMode() {
+        return stoMode;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int x, int y) {
+        if (stoMode == ROW_STORAGE_MODE)
+            return matrixGet(cache.getName(), x, y);
+        else
+            return matrixGet(cache.getName(), y, x);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int x, int y, double v) {
+        if (stoMode == ROW_STORAGE_MODE)
+            matrixSet(cache.getName(), x, y, v);
+        else
+            matrixSet(cache.getName(), y, x, v);
+    }
+
+    /**
+     * Distributed matrix get.
+     *
+     * @param cacheName Matrix's cache.
+     * @param a Row or column index.
+     * @param b Row or column index.
+     * @return Matrix value at (a, b) index.
+     */
+    private double matrixGet(String cacheName, int a, int b) {
+        // Remote get from the primary node (where given row or column is stored locally).
+        return ignite().compute(groupForKey(cacheName, a)).call(() -> {
+            IgniteCache<Integer, Map<Integer, Double>> cache = Ignition.localIgnite().getOrCreateCache(cacheName);
+
+            // Local get.
+            Map<Integer, Double> map = cache.localPeek(a, CachePeekMode.PRIMARY);
+
+            return (map == null || !map.containsKey(b)) ? 0.0 : map.get(b);
+        });
+    }
+
+    /**
+     * Distributed matrix set.
+     *
+     * @param cacheName Matrix's cache.
+     * @param a Row or column index.
+     * @param b Row or column index.
+     * @param v New value to set.
+     */
+    private void matrixSet(String cacheName, int a, int b, double v) {
+        // Remote set on the primary node (where given row or column is stored locally).
+        ignite().compute(groupForKey(cacheName, a)).run(() -> {
+            IgniteCache<Integer, Map<Integer, Double>> cache = Ignition.localIgnite().getOrCreateCache(cacheName);
+
+            // Local get.
+            Map<Integer, Double> map = cache.localPeek(a, CachePeekMode.PRIMARY);
+
+            if (map == null)
+                map = acsMode == SEQUENTIAL_ACCESS_MODE ? new Int2DoubleRBTreeMap() : new Int2DoubleOpenHashMap();
+
+            if (v != 0.0)
+                map.put(b, v);
+            else if (map.containsKey(b))
+                map.remove(b);
+
+            // Local put.
+            cache.put(a, map);
+        });
+    }
+
+    /** {@inheritDoc} */
+    @Override public int columnSize() {
+        return cols;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int rowSize() {
+        return rows;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(rows);
+        out.writeInt(cols);
+        out.writeInt(acsMode);
+        out.writeInt(stoMode);
+        out.writeUTF(cache.getName());
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        rows = in.readInt();
+        cols = in.readInt();
+        acsMode = in.readInt();
+        stoMode = in.readInt();
+        cache = ignite().getOrCreateCache(in.readUTF());
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return acsMode == SEQUENTIAL_ACCESS_MODE;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return acsMode == RANDOM_ACCESS_MODE;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** Destroy underlying cache. */
+    @Override public void destroy() {
+        cache.destroy();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + cols;
+        res = res * 37 + rows;
+        res = res * 37 + acsMode;
+        res = res * 37 + stoMode;
+        res = res * 37 + cache.hashCode();
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+
+        if (obj == null || getClass() != obj.getClass())
+            return false;
+
+        SparseDistributedMatrixStorage that = (SparseDistributedMatrixStorage)obj;
+
+        return rows == that.rows && cols == that.cols && acsMode == that.acsMode && stoMode == that.stoMode
+            && (cache != null ? cache.equals(that.cache) : that.cache == null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
new file mode 100644
index 0000000..4530900
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.StorageConstants;
+
+/**
+ * Storage for sparse, local, on-heap matrix.
+ */
+public class SparseLocalOnHeapMatrixStorage implements MatrixStorage, StorageConstants {
+    /** Default zero value. */
+    private static final double DEFAULT_VALUE = 0.0;
+
+    /** */ private int rows;
+    /** */ private int cols;
+
+    /** */ private int acsMode;
+    /** */ private int stoMode;
+
+    /** Actual map storage. */
+    private Map<Integer, Map<Integer, Double>> sto;
+
+    /** */
+    public SparseLocalOnHeapMatrixStorage() {
+        // No-op.
+    }
+
+    /** */
+    public SparseLocalOnHeapMatrixStorage(int rows, int cols, int acsMode, int stoMode) {
+        assert rows > 0;
+        assert cols > 0;
+        assertAccessMode(acsMode);
+        assertStorageMode(stoMode);
+
+        this.rows = rows;
+        this.cols = cols;
+        this.acsMode = acsMode;
+        this.stoMode = stoMode;
+
+        sto = new HashMap<>();
+    }
+
+    /**
+     *
+     *
+     */
+    public int getStorageMode() {
+        return stoMode;
+    }
+
+    /**
+     *
+     *
+     */
+    public int getAccessMode() {
+        return acsMode;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int x, int y) {
+        if (stoMode == ROW_STORAGE_MODE) {
+            Map<Integer, Double> row = sto.get(x);
+
+            if (row != null) {
+                Double val = row.get(y);
+
+                if (val != null)
+                    return val;
+            }
+
+            return DEFAULT_VALUE;
+        }
+        else {
+            Map<Integer, Double> col = sto.get(y);
+
+            if (col != null) {
+                Double val = col.get(x);
+
+                if (val != null)
+                    return val;
+            }
+
+            return DEFAULT_VALUE;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int x, int y, double v) {
+        // Ignore default values (currently 0.0).
+        if (v != DEFAULT_VALUE) {
+            if (stoMode == ROW_STORAGE_MODE) {
+                Map<Integer, Double> row = sto.computeIfAbsent(x, k ->
+                    acsMode == SEQUENTIAL_ACCESS_MODE ? new Int2DoubleRBTreeMap() : new Int2DoubleOpenHashMap());
+
+                row.put(y, v);
+            }
+            else {
+                Map<Integer, Double> col = sto.computeIfAbsent(y, k ->
+                    acsMode == SEQUENTIAL_ACCESS_MODE ? new Int2DoubleRBTreeMap() : new Int2DoubleOpenHashMap());
+
+                col.put(x, v);
+            }
+        }
+        else {
+            if (stoMode == ROW_STORAGE_MODE) {
+                if (sto.containsKey(x)) {
+                    Map<Integer, Double> row = sto.get(x);
+
+                    if (row.containsKey(y))
+                        row.remove(y);
+                }
+
+            }
+            else {
+                if (sto.containsKey(y)) {
+                    Map<Integer, Double> col = sto.get(y);
+
+                    if (col.containsKey(x))
+                        col.remove(x);
+                }
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public int columnSize() {
+        return cols;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int rowSize() {
+        return rows;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(rows);
+        out.writeInt(cols);
+        out.writeInt(acsMode);
+        out.writeInt(stoMode);
+        out.writeObject(sto);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings({"unchecked"})
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        rows = in.readInt();
+        cols = in.readInt();
+        acsMode = in.readInt();
+        stoMode = in.readInt();
+        sto = (Map<Integer, Map<Integer, Double>>)in.readObject();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return acsMode == SEQUENTIAL_ACCESS_MODE;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return acsMode == RANDOM_ACCESS_MODE;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + rows;
+        res = res * 37 + cols;
+        res = res * 37 + sto.hashCode();
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        SparseLocalOnHeapMatrixStorage that = (SparseLocalOnHeapMatrixStorage)o;
+
+        return rows == that.rows && cols == that.cols && acsMode == that.acsMode && stoMode == that.stoMode
+            && (sto != null ? sto.equals(that.sto) : that.sto == null);
+    }
+}


[61/65] [abbrv] ignite git commit: ignite-2.0 - Do not call primaryByKey() in cache entry synchronized block - Fixes #1824

Posted by ag...@apache.org.
ignite-2.0 - Do not call primaryByKey() in cache entry synchronized block - Fixes #1824


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

Branch: refs/heads/ignite-5024
Commit: f2996710da39063723eda8aa0793d16362a0613f
Parents: 2d7fc51
Author: Dmitriy Govorukhin <dm...@gmail.com>
Authored: Mon Apr 24 10:37:44 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Apr 24 10:38:01 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/distributed/near/GridNearCacheEntry.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f2996710/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
index a23ab4c..fa098df 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
@@ -146,6 +146,8 @@ public class GridNearCacheEntry extends GridDistributedCacheEntry {
                 GridCacheVersion enqueueVer = null;
 
                 try {
+                    ClusterNode primaryNode = cctx.affinity().primaryByKey(key, topVer);
+
                     synchronized (this) {
                         checkObsolete();
 
@@ -164,8 +166,6 @@ public class GridNearCacheEntry extends GridDistributedCacheEntry {
                                 }
                             }
 
-                            ClusterNode primaryNode = cctx.affinity().primaryByKey(key, topVer);
-
                             if (primaryNode == null)
                                 this.topVer = AffinityTopologyVersion.NONE;
                             else


[55/65] [abbrv] ignite git commit: IGNITE-5039 .NET: Improve error message for failed ignite.jni.dll load

Posted by ag...@apache.org.
IGNITE-5039 .NET: Improve error message for failed ignite.jni.dll load


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

Branch: refs/heads/ignite-5024
Commit: 32379ee4c6680a58121a72c7e5b9809a713ef1c3
Parents: 0c1db67
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Fri Apr 21 17:41:37 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Fri Apr 21 17:41:37 2017 +0300

----------------------------------------------------------------------
 .../dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs         | 10 +++++++++-
 .../dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs       |  6 ++++++
 .../Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs   |  8 ++++++--
 3 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/32379ee4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index 414452b..b024345 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -237,7 +237,7 @@ namespace Apache.Ignite.Core.Impl
         /// Formats the Win32 error.
         /// </summary>
         [ExcludeFromCodeCoverage]
-        private static string FormatWin32Error(int errorCode)
+        public static string FormatWin32Error(int errorCode)
         {
             if (errorCode == NativeMethods.ERROR_BAD_EXE_FORMAT)
             {
@@ -248,6 +248,14 @@ namespace Apache.Ignite.Core.Impl
                                      "Current process runs in {0} mode, and DLL is not {0}.", mode);
             }
 
+            if (errorCode == NativeMethods.ERROR_MOD_NOT_FOUND)
+            {
+                return "DLL could not be loaded (126: ERROR_MOD_NOT_FOUND). " +
+                       "This can be caused by missing dependencies. " +
+                       "Make sure that Microsoft Visual C++ 2010 Redistributable Package is installed " +
+                       "(https://www.microsoft.com/en-us/download/details.aspx?id=14632).";
+            }
+
             return string.Format("{0}: {1}", errorCode, new Win32Exception(errorCode).Message);
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/32379ee4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
index d36bf45..3403dee 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
@@ -32,6 +32,12 @@ namespace Apache.Ignite.Core.Impl
         public const int ERROR_BAD_EXE_FORMAT = 193;
 
         /// <summary>
+        /// ERROR_MOD_NOT_FOUND constant.
+        /// </summary>
+        // ReSharper disable once InconsistentNaming
+        public const int ERROR_MOD_NOT_FOUND = 126;
+
+        /// <summary>
         /// Load DLL with WinAPI.
         /// </summary>
         /// <param name="path">Path to dll.</param>

http://git-wip-us.apache.org/repos/asf/ignite/blob/32379ee4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
index 986972f..f76bbac 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
@@ -47,8 +47,12 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             var ptr = NativeMethods.LoadLibrary(path);
 
             if (ptr == IntPtr.Zero)
-                throw new IgniteException(string.Format("Failed to load {0}: {1}", 
-                    IgniteUtils.FileIgniteJniDll, Marshal.GetLastWin32Error()));
+            {
+                var err = Marshal.GetLastWin32Error();
+
+                throw new IgniteException(string.Format("Failed to load {0} from {1}: [{2}]",
+                    IgniteUtils.FileIgniteJniDll, path, IgniteUtils.FormatWin32Error(err)));
+            }
 
             AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;
 


[30/65] [abbrv] ignite git commit: IGNITE-5024 default Memory Policy size was changed to 80% of available RAM

Posted by ag...@apache.org.
IGNITE-5024 default Memory Policy size was changed to 80% of available RAM


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

Branch: refs/heads/ignite-5024
Commit: 83d913c804ab6ecd4fb650e3b09062dca92ccae1
Parents: 9ce62e6
Author: Sergey Chugunov <se...@gmail.com>
Authored: Wed Apr 19 17:03:32 2017 +0300
Committer: Sergey Chugunov <se...@gmail.com>
Committed: Thu Apr 20 12:25:39 2017 +0300

----------------------------------------------------------------------
 .../configuration/MemoryConfiguration.java      | 40 +++++++++-
 .../IgniteCacheDatabaseSharedManager.java       | 33 ++++++++-
 .../ignite/internal/util/IgniteUtils.java       | 26 ++++++-
 .../cache/MemoryPolicyConfigValidationTest.java | 77 +++++++++++++++++++-
 4 files changed, 162 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/83d913c8/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
index de8fdbf..3cccb42 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
@@ -62,8 +62,11 @@ public class MemoryConfiguration implements Serializable {
     /** */
     private static final long serialVersionUID = 0L;
 
-    /** Default memory policy's size (1 GB). */
-    public static final long DFLT_MEMORY_POLICY_SIZE = 1024 * 1024 * 1024;
+    /** Fraction of available memory to allocate for default MemoryPolicy. */
+    private static final double DFLT_MEMORY_POLICY_FRACTION = 0.8;
+
+    /** Default memory policy's size is 80% of physical memory available on current machine. */
+    public static final long DFLT_MEMORY_POLICY_SIZE = (long) DFLT_MEMORY_POLICY_FRACTION * U.getTotalMemoryAvailable();
 
     /** Default size of a memory chunk for the system cache (100 MB). */
     public static final long DFLT_SYS_CACHE_MEM_SIZE = 100 * 1024 * 1024;
@@ -83,6 +86,9 @@ public class MemoryConfiguration implements Serializable {
     /** A name of the memory policy that defines the default memory region. */
     private String dfltMemPlcName;
 
+    /** Size of memory (in bytes) to use for default MemoryPolicy. */
+    private Long dfltMemPlcSize;
+
     /** Memory policies. */
     private MemoryPolicyConfiguration[] memPlcs;
 
@@ -164,8 +170,10 @@ public class MemoryConfiguration implements Serializable {
     public MemoryPolicyConfiguration createDefaultPolicyConfig() {
         MemoryPolicyConfiguration memPlc = new MemoryPolicyConfiguration();
 
+        long size = (dfltMemPlcSize != null) ? dfltMemPlcSize : DFLT_MEMORY_POLICY_SIZE;
+
         memPlc.setName(null);
-        memPlc.setSize(DFLT_MEMORY_POLICY_SIZE);
+        memPlc.setSize(size);
 
         return memPlc;
     }
@@ -189,6 +197,32 @@ public class MemoryConfiguration implements Serializable {
     }
 
     /**
+     * Gets a size for default memory policy overridden by user.
+     *
+     * @return default memory policy size overridden by user or -1 if nothing was specified.
+     */
+    public long getDefaultMemoryPolicySize() {
+        return (dfltMemPlcSize != null) ? dfltMemPlcSize : -1;
+    }
+
+    /**
+     * Overrides size of default memory policy which is created automatically.
+     *
+     * If user doesn't specify any memory policy configuration, a default one with default size
+     * (80% of available RAM) is created by Ignite.
+     *
+     * This property allows user to specify desired size of default memory policy
+     * without having to use more verbose syntax of MemoryPolicyConfiguration elements.
+     *
+     * @param dfltMemPlcSize Size of default memory policy overridden by user.
+     */
+    public MemoryConfiguration setDefaultMemoryPolicySize(long dfltMemPlcSize) {
+        this.dfltMemPlcSize = dfltMemPlcSize;
+
+        return this;
+    }
+
+    /**
      * Gets a name of default memory policy.
      *
      * @return A name of a custom memory policy configured with {@link MemoryConfiguration} or {@code null} of the

http://git-wip-us.apache.org/repos/asf/ignite/blob/83d913c8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
index a34aed2..de882da 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
@@ -296,20 +296,40 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
             }
         }
 
-        checkDefaultPolicyConfiguration(dbCfg.getDefaultMemoryPolicyName(), plcNames);
+        checkDefaultPolicyConfiguration(
+                dbCfg.getDefaultMemoryPolicyName(),
+                dbCfg.getDefaultMemoryPolicySize(),
+                plcNames);
     }
 
     /**
      * @param dfltPlcName Default MemoryPolicy name.
+     * @param dfltPlcSize Default size of MemoryPolicy overridden by user (equals to -1 if wasn't specified by user).
      * @param plcNames All MemoryPolicy names.
      * @throws IgniteCheckedException In case of validation violation.
      */
-    private static void checkDefaultPolicyConfiguration(String dfltPlcName, Set<String> plcNames) throws IgniteCheckedException {
+    private static void checkDefaultPolicyConfiguration(String dfltPlcName,
+                                                        long dfltPlcSize,
+                                                        Set<String> plcNames) throws IgniteCheckedException {
+        if (dfltPlcSize != -1) {
+            if (dfltPlcName != null)
+                throw new IgniteCheckedException("User-defined MemoryPolicy configuration " +
+                        "and defaultMemoryPolicySize properties are set at the same time. " +
+                        "Delete either MemoryConfiguration.defaultMemoryPolicySize property " +
+                        "or configuration of user-defined default MemoryPolicy");
+
+
+            if (dfltPlcSize < MIN_PAGE_MEMORY_SIZE)
+                throw new IgniteCheckedException("User-defined default MemoryPolicy size is less than 1MB. " +
+                        "Use MemoryConfiguration.defaultMemoryPolicySize property to set correct size.");
+        }
+
         if (dfltPlcName != null) {
             if (dfltPlcName.isEmpty())
                 throw new IgniteCheckedException("User-defined default MemoryPolicy name must be non-empty");
             if (!plcNames.contains(dfltPlcName))
-                throw new IgniteCheckedException("User-defined default MemoryPolicy name must be presented among configured MemoryPolices: " + dfltPlcName);
+                throw new IgniteCheckedException("User-defined default MemoryPolicy name " +
+                        "must be presented among configured MemoryPolices: " + dfltPlcName);
         }
     }
 
@@ -319,7 +339,12 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
      */
     private static void checkPolicySize(MemoryPolicyConfiguration plcCfg) throws IgniteCheckedException {
         if (plcCfg.getSize() < MIN_PAGE_MEMORY_SIZE)
-            throw new IgniteCheckedException("MemoryPolicy must have size more than 1MB: " + plcCfg.getName());
+            throw new IgniteCheckedException("MemoryPolicy must have size more than 1MB: MemoryPolicy[name=" +
+                    plcCfg.getName() +
+                    "; size=" +
+                    plcCfg.getSize() +
+                    "]. Use MemoryPolicyConfiguration.size property to set correct size (in bytes)."
+            );
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/83d913c8/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 7d7d071..fde8cbf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -177,8 +177,6 @@ import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.IgniteNodeAttributes;
-import org.apache.ignite.internal.binary.BinaryObjectEx;
-import org.apache.ignite.internal.binary.BinaryUtils;
 import org.apache.ignite.internal.cluster.ClusterGroupEmptyCheckedException;
 import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
 import org.apache.ignite.internal.compute.ComputeTaskCancelledCheckedException;
@@ -5629,6 +5627,28 @@ public abstract class IgniteUtils {
     }
 
     /**
+     * Gets amount of RAM memory available on this machine.
+     *
+     * @return Total amount of memory in bytes or -1 if any exception happened.
+     */
+    public static long getTotalMemoryAvailable() {
+        MBeanServer mBeanSrv = ManagementFactory.getPlatformMBeanServer();
+
+        Object attr;
+
+        try {
+            attr = mBeanSrv.getAttribute(
+                    ObjectName.getInstance("java.lang", "type", "OperatingSystem"),
+                    "TotalPhysicalMemorySize");
+        }
+        catch (Exception e) {
+            return -1;
+        }
+
+        return (attr instanceof Long) ? (Long) attr : -1;
+    }
+
+    /**
      * Gets compilation MBean.
      *
      * @return Compilation MBean.
@@ -9554,7 +9574,7 @@ public abstract class IgniteUtils {
     public static <T extends R, R> List<R> arrayList(Collection<T> c, @Nullable IgnitePredicate<? super T>... p) {
         assert c != null;
 
-        return IgniteUtils.arrayList(c, c.size(), p);
+        return arrayList(c, c.size(), p);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/83d913c8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
index c0f74d0..565ba99 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
@@ -26,6 +26,15 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
  *
  */
 public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
+    /** */
+    private static final String VALID_DEFAULT_MEM_PLC_NAME = "valid_dlft_mem_plc";
+
+    /** */
+    private static final String VALID_USER_MEM_PLC_NAME = "valid_user_mem_plc";
+
+    /** */
+    private static final String MISSING_DEFAULT_MEM_PLC_NAME = "missing_mem_plc";
+
     /** Configuration violation type to check. */
     private ValidationViolationType violationType;
 
@@ -61,9 +70,25 @@ public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
             case MISSING_USER_DEFINED_DEFAULT:
                 plcs = createMissingUserDefinedDefault();
 
-                memCfg.setDefaultMemoryPolicyName("missingMemoryPolicyName");
+                memCfg.setDefaultMemoryPolicyName(MISSING_DEFAULT_MEM_PLC_NAME);
+
+                break;
+
+            case TOO_SMALL_USER_DEFINED_DFLT_MEM_PLC_SIZE:
+                memCfg.setDefaultMemoryPolicySize(1);
 
                 break;
+
+            case DEFAULT_SIZE_IS_DEFINED_TWICE:
+                plcs = createValidUserDefault();
+
+                memCfg.setDefaultMemoryPolicyName(VALID_DEFAULT_MEM_PLC_NAME);
+                memCfg.setDefaultMemoryPolicySize(10 * 1014 * 1024);
+
+                break;
+
+            default:
+                fail("Violation type was not configured: " + violationType);
         }
 
         memCfg.setMemoryPolicies(plcs);
@@ -73,14 +98,31 @@ public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
         return cfg;
     }
 
+    /**
+     *
+     */
+    private MemoryPolicyConfiguration[] createValidUserDefault() {
+        MemoryPolicyConfiguration[] res = new MemoryPolicyConfiguration[1];
+
+        res[0] = createMemoryPolicy(VALID_DEFAULT_MEM_PLC_NAME, 100 * 1024 * 1024);
+
+        return res;
+    }
+
+    /**
+     *
+     */
     private MemoryPolicyConfiguration[] createMissingUserDefinedDefault() {
         MemoryPolicyConfiguration[] res = new MemoryPolicyConfiguration[1];
 
-        res[0] = createMemoryPolicy("presentedPolicyCfg", 10 * 1024 * 1024);
+        res[0] = createMemoryPolicy(VALID_USER_MEM_PLC_NAME, 10 * 1024 * 1024);
 
         return res;
     }
 
+    /**
+     *
+     */
     private MemoryPolicyConfiguration[] createPlcWithNullName() {
         MemoryPolicyConfiguration[] res = new MemoryPolicyConfiguration[1];
 
@@ -95,7 +137,7 @@ public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
     private MemoryPolicyConfiguration[] createTooSmallMemoryCfg() {
         MemoryPolicyConfiguration[] res = new MemoryPolicyConfiguration[1];
 
-        res[0] = createMemoryPolicy("dflt", 10);
+        res[0] = createMemoryPolicy(VALID_DEFAULT_MEM_PLC_NAME, 10);
 
         return res;
     }
@@ -189,6 +231,25 @@ public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
     }
 
     /**
+     * User-defined size of default MemoryPolicy must be at least 1MB.
+     */
+    public void testUserDefinedDefaultMemoryTooSmall() throws Exception {
+        violationType = ValidationViolationType.TOO_SMALL_USER_DEFINED_DFLT_MEM_PLC_SIZE;
+
+        doTest(violationType);
+    }
+
+    /**
+     * Defining size of default MemoryPolicy twice with and through <b>defaultMemoryPolicySize</b> property
+     * and using <b>MemoryPolicyConfiguration</b> description is prohibited.
+     */
+    public void testDefaultMemoryPolicySizeDefinedTwice() throws Exception {
+        violationType = ValidationViolationType.DEFAULT_SIZE_IS_DEFINED_TWICE;
+
+        doTest(violationType);
+    }
+
+    /**
      * Tries to start ignite node with invalid configuration and checks that corresponding exception is thrown.
      *
      * @param violationType Configuration violation type.
@@ -226,7 +287,15 @@ public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
         NULL_NAME_ON_USER_DEFINED_POLICY("User-defined MemoryPolicyConfiguration must have non-null and non-empty name."),
 
         /** */
-        MISSING_USER_DEFINED_DEFAULT("User-defined default MemoryPolicy name must be presented among configured MemoryPolices: ");
+        MISSING_USER_DEFINED_DEFAULT("User-defined default MemoryPolicy name must be presented among configured MemoryPolices: "),
+
+        /** */
+        DEFAULT_SIZE_IS_DEFINED_TWICE("User-defined MemoryPolicy configuration and defaultMemoryPolicySize properties are set at the same time."),
+
+        /** */
+        TOO_SMALL_USER_DEFINED_DFLT_MEM_PLC_SIZE("User-defined default MemoryPolicy size is less than 1MB.");
+
+
 
         /**
          * @param violationMsg Violation message.


[49/65] [abbrv] ignite git commit: Minor codestyle fix

Posted by ag...@apache.org.
Minor codestyle fix


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

Branch: refs/heads/ignite-5024
Commit: a6f8b6940873d880ce8b5052f8bb344c33b56d37
Parents: 0781b1a
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Apr 21 16:34:51 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Apr 21 16:34:51 2017 +0300

----------------------------------------------------------------------
 .../repository/support/IgniteRepositoryFactoryBean.java           | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a6f8b694/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactoryBean.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactoryBean.java b/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactoryBean.java
index dcb1d9a..f87dce5 100644
--- a/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactoryBean.java
+++ b/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactoryBean.java
@@ -49,6 +49,9 @@ public class IgniteRepositoryFactoryBean<T extends Repository<S, ID>, S, ID exte
     /** Application context. */
     private ApplicationContext ctx;
 
+    /**
+     * @param repositoryInterface Repository interface.
+     */
     protected IgniteRepositoryFactoryBean(Class<? extends T> repositoryInterface) {
         super(repositoryInterface);
     }


[60/65] [abbrv] ignite git commit: ignite-2.0 - H2 upgraded to 1.4.195

Posted by ag...@apache.org.
ignite-2.0 - H2 upgraded to 1.4.195


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

Branch: refs/heads/ignite-5024
Commit: 2d7fc5176414f9ab47baad2305b700b5f198e037
Parents: 045ae66
Author: Sergi Vladykin <se...@gmail.com>
Authored: Mon Apr 24 01:52:22 2017 +0300
Committer: Sergi Vladykin <se...@gmail.com>
Committed: Mon Apr 24 01:52:22 2017 +0300

----------------------------------------------------------------------
 .../processors/query/h2/IgniteH2Indexing.java   | 13 +--------
 .../query/h2/opt/GridH2IndexBase.java           |  3 ++
 .../h2/twostep/GridReduceQueryExecutor.java     | 29 --------------------
 .../query/h2/twostep/GridThreadLocalTable.java  |  5 ++--
 parent/pom.xml                                  |  2 +-
 5 files changed, 8 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2d7fc517/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 8296945..bf0276a 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -462,7 +462,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
             PreparedStatement stmt = cache.get(sql);
 
-            if (stmt != null && !stmt.isClosed() && !((JdbcStatement)stmt).wasCancelled()) {
+            if (stmt != null && !stmt.isClosed() && !((JdbcStatement)stmt).isCancelled()) {
                 assert stmt.getConnection() == c;
 
                 return stmt;
@@ -669,17 +669,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /**
-     * @param coctx Cache object context.
-     * @param o Object.
-     * @return Object class.
-     */
-    private Class<?> getClass(CacheObjectContext coctx, CacheObject o) {
-        return isBinary(o) ?
-            Object.class :
-            o.value(coctx, false).getClass();
-    }
-
-    /**
      * @param space Space.
      * @return Cache object context.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/2d7fc517/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
index 9dab752..81a9620 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
@@ -1360,6 +1360,9 @@ public abstract class GridH2IndexBase extends BaseIndex {
          * Start streaming.
          */
         private void start() {
+            assert ctx != null;
+            assert log != null: getName();
+
             remainingRanges = req.bounds().size();
 
             assert remainingRanges > 0;

http://git-wip-us.apache.org/repos/asf/ignite/blob/2d7fc517/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index 0421ca0..d307c00 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.internal.processors.query.h2.twostep;
 
-import java.lang.reflect.Constructor;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -87,9 +86,6 @@ import org.h2.engine.Session;
 import org.h2.index.Cursor;
 import org.h2.index.Index;
 import org.h2.jdbc.JdbcConnection;
-import org.h2.jdbc.JdbcResultSet;
-import org.h2.jdbc.JdbcStatement;
-import org.h2.result.ResultInterface;
 import org.h2.result.Row;
 import org.h2.table.Column;
 import org.h2.util.IntArray;
@@ -138,31 +134,6 @@ public class GridReduceQueryExecutor {
     private final Lock fakeTblsLock = new ReentrantLock();
 
     /** */
-    private static final Constructor<JdbcResultSet> CONSTRUCTOR;
-
-    /**
-     * Init constructor.
-     */
-    static {
-        try {
-            CONSTRUCTOR = JdbcResultSet.class.getDeclaredConstructor(
-                JdbcConnection.class,
-                JdbcStatement.class,
-                ResultInterface.class,
-                Integer.TYPE,
-                Boolean.TYPE,
-                Boolean.TYPE,
-                Boolean.TYPE
-            );
-
-            CONSTRUCTOR.setAccessible(true);
-        }
-        catch (NoSuchMethodException e) {
-            throw new IllegalStateException("Check H2 version in classpath.", e);
-        }
-    }
-
-    /** */
     private final GridSpinBusyLock busyLock;
 
     /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/2d7fc517/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java
index 9bbb9b4..b01c3d4 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java
@@ -122,8 +122,9 @@ public class GridThreadLocalTable extends Table {
     }
 
     /** {@inheritDoc} */
-    @Override public Index getIndexForColumn(Column column) {
-        return innerTable().getIndexForColumn(column);
+    @Override public Index getIndexForColumn(Column column,
+        boolean needGetFirstOrLast, boolean needFindNext) {
+        return innerTable().getIndexForColumn(column, needGetFirstOrLast, needFindNext);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/2d7fc517/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index cb638e1..3d0f413 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -71,7 +71,7 @@
         <guava.version>18.0</guava.version>
         <guava14.version>14.0.1</guava14.version>
         <guava16.version>16.0.1</guava16.version>
-        <h2.version>1.4.194</h2.version>
+        <h2.version>1.4.195</h2.version>
         <httpclient.version>4.5.1</httpclient.version>
         <httpcore.version>4.4.3</httpcore.version>
         <jackson.version>1.9.13</jackson.version>


[50/65] [abbrv] ignite git commit: IGNITE-4594 - SQL Index hints - Fixes #1832.

Posted by ag...@apache.org.
IGNITE-4594 - SQL Index hints - Fixes #1832.

Signed-off-by: Sergi Vladykin <se...@gmail.com>


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

Branch: refs/heads/ignite-5024
Commit: 457c551581ee96891b62b834d8bbc0358679dade
Parents: a6f8b69
Author: skalashnikov <sk...@gridgain.com>
Authored: Fri Apr 21 16:40:32 2017 +0300
Committer: Sergi Vladykin <se...@gmail.com>
Committed: Fri Apr 21 16:40:32 2017 +0300

----------------------------------------------------------------------
 .../query/h2/opt/GridH2SpatialIndex.java        |  8 +++-
 .../query/h2/database/H2PkHashIndex.java        |  6 ++-
 .../query/h2/database/H2TreeIndex.java          |  6 ++-
 .../query/h2/database/InlineIndexHelper.java    | 14 ------
 .../query/h2/opt/GridH2IndexBase.java           |  4 +-
 .../query/h2/opt/GridH2MetaTable.java           |  8 ++--
 .../query/h2/opt/GridH2PrimaryScanIndex.java    |  7 ++-
 .../processors/query/h2/opt/GridH2Row.java      |  2 +-
 .../query/h2/opt/GridH2ScanIndex.java           |  4 +-
 .../processors/query/h2/opt/GridH2Table.java    |  7 ++-
 .../query/h2/opt/GridH2TreeIndex.java           |  7 ++-
 .../processors/query/h2/sql/DmlAstUtils.java    |  3 --
 .../processors/query/h2/sql/GridSqlAlias.java   | 20 ++++++++-
 .../query/h2/sql/GridSqlQueryParser.java        |  4 ++
 .../processors/query/h2/sql/GridSqlTable.java   | 46 ++++++++++++++++++++
 .../query/h2/twostep/GridMergeIndex.java        |  1 +
 .../query/h2/twostep/GridMergeIndexSorted.java  |  6 ++-
 .../h2/twostep/GridMergeIndexUnsorted.java      |  6 ++-
 .../query/h2/twostep/GridMergeTable.java        | 12 +++--
 .../query/h2/twostep/GridThreadLocalTable.java  |  9 ++--
 .../query/IgniteSqlSplitterSelfTest.java        | 34 ++++++++++++++-
 .../h2/database/InlineIndexHelperTest.java      |  8 ----
 .../query/h2/sql/GridQueryParsingTest.java      | 29 +++++++++---
 parent/pom.xml                                  |  2 +-
 24 files changed, 186 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java b/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
index bc27ae7..c8f3f68 100644
--- a/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
+++ b/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
@@ -22,6 +22,7 @@ import com.vividsolutions.jts.geom.Geometry;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -45,6 +46,7 @@ import org.h2.mvstore.rtree.MVRTreeMap;
 import org.h2.mvstore.rtree.SpatialKey;
 import org.h2.result.SearchRow;
 import org.h2.result.SortOrder;
+import org.h2.table.Column;
 import org.h2.table.IndexColumn;
 import org.h2.table.TableFilter;
 import org.h2.value.Value;
@@ -260,7 +262,8 @@ public class GridH2SpatialIndex extends GridH2IndexBase implements SpatialIndex
     }
 
     /** {@inheritDoc} */
-    @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder) {
+    @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter,
+        SortOrder sortOrder, HashSet<Column> cols) {
         return SpatialTreeIndex.getCostRangeIndex(masks,
             table.getRowCountApproximation(), columns) / 10;
     }
@@ -370,7 +373,8 @@ public class GridH2SpatialIndex extends GridH2IndexBase implements SpatialIndex
     }
 
     /** {@inheritDoc} */
-    @Override public Cursor findByGeometry(TableFilter filter, SearchRow intersection) {
+    @Override public Cursor findByGeometry(TableFilter filter, SearchRow first, SearchRow last,
+        SearchRow intersection) {
         Lock l = lock.readLock();
 
         l.lock();

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2PkHashIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2PkHashIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2PkHashIndex.java
index fb6ea95..149eda7 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2PkHashIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2PkHashIndex.java
@@ -19,6 +19,7 @@
 package org.apache.ignite.internal.processors.query.h2.database;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
@@ -40,6 +41,7 @@ import org.h2.message.DbException;
 import org.h2.result.Row;
 import org.h2.result.SearchRow;
 import org.h2.result.SortOrder;
+import org.h2.table.Column;
 import org.h2.table.IndexColumn;
 import org.h2.table.TableFilter;
 import org.jetbrains.annotations.Nullable;
@@ -157,10 +159,10 @@ public class H2PkHashIndex extends GridH2IndexBase {
     }
 
     /** {@inheritDoc} */
-    @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder) {
+    @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, HashSet<Column> allColumnsSet) {
         long rowCnt = getRowCountApproximation();
 
-        double baseCost = getCostRangeIndex(masks, rowCnt, filters, filter, sortOrder, false);
+        double baseCost = getCostRangeIndex(masks, rowCnt, filters, filter, sortOrder, false, allColumnsSet);
 
         int mul = getDistributedMultiplier(ses, filters, filter);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
index 1ea3204..58ab32d 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.query.h2.database;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
@@ -43,6 +44,7 @@ import org.h2.index.SingleRowCursor;
 import org.h2.message.DbException;
 import org.h2.result.SearchRow;
 import org.h2.result.SortOrder;
+import org.h2.table.Column;
 import org.h2.table.IndexColumn;
 import org.h2.table.TableFilter;
 import org.h2.value.Value;
@@ -272,10 +274,10 @@ public class H2TreeIndex extends GridH2IndexBase {
     }
 
     /** {@inheritDoc} */
-    @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder) {
+    @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, HashSet<Column> allColumnsSet) {
         long rowCnt = getRowCountApproximation();
 
-        double baseCost = getCostRangeIndex(masks, rowCnt, filters, filter, sortOrder, false);
+        double baseCost = getCostRangeIndex(masks, rowCnt, filters, filter, sortOrder, false, allColumnsSet);
 
         int mul = getDistributedMultiplier(ses, filters, filter);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java
index 7381924..1fd45f3 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java
@@ -41,7 +41,6 @@ import org.h2.value.ValueStringFixed;
 import org.h2.value.ValueStringIgnoreCase;
 import org.h2.value.ValueTime;
 import org.h2.value.ValueTimestamp;
-import org.h2.value.ValueTimestampUtc;
 import org.h2.value.ValueUuid;
 
 /**
@@ -66,7 +65,6 @@ public class InlineIndexHelper {
         Value.DATE,
         Value.TIME,
         Value.TIMESTAMP,
-        Value.TIMESTAMP_UTC,
         Value.UUID,
         Value.STRING,
         Value.STRING_FIXED,
@@ -134,10 +132,6 @@ public class InlineIndexHelper {
                 this.size = 16;
                 break;
 
-            case Value.TIMESTAMP_UTC:
-                this.size = 8;
-                break;
-
             case Value.UUID:
                 this.size = 16;
                 break;
@@ -276,9 +270,6 @@ public class InlineIndexHelper {
             case Value.TIMESTAMP:
                 return ValueTimestamp.fromDateValueAndNanos(PageUtils.getLong(pageAddr, off + 1), PageUtils.getLong(pageAddr, off + 9));
 
-            case Value.TIMESTAMP_UTC:
-                return ValueTimestampUtc.fromNanos(PageUtils.getLong(pageAddr, off + 1));
-
             case Value.UUID:
                 return ValueUuid.get(PageUtils.getLong(pageAddr, off + 1), PageUtils.getLong(pageAddr, off + 9));
 
@@ -434,11 +425,6 @@ public class InlineIndexHelper {
                 PageUtils.putLong(pageAddr, off + 9, ((ValueTimestamp)val).getTimeNanos());
                 return size + 1;
 
-            case Value.TIMESTAMP_UTC:
-                PageUtils.putByte(pageAddr, off, (byte)val.getType());
-                PageUtils.putLong(pageAddr, off + 1, ((ValueTimestampUtc)val).getUtcDateTimeNanos());
-                return size + 1;
-
             case Value.UUID:
                 PageUtils.putByte(pageAddr, off, (byte)val.getType());
                 PageUtils.putLong(pageAddr, off + 1, ((ValueUuid)val).getHigh());

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
index 0eac559..9dab752 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
@@ -390,7 +390,7 @@ public abstract class GridH2IndexBase extends BaseIndex {
     }
 
     /** {@inheritDoc} */
-    @Override public IndexLookupBatch createLookupBatch(TableFilter filter) {
+    @Override public IndexLookupBatch createLookupBatch(TableFilter[] filters, int filter) {
         GridH2QueryContext qctx = GridH2QueryContext.get();
 
         if (qctx == null || qctx.distributedJoinMode() == OFF || !getTable().isPartitioned())
@@ -403,7 +403,7 @@ public abstract class GridH2IndexBase extends BaseIndex {
 
         if (affCol != null) {
             affColId = affCol.column.getColumnId();
-            int[] masks = filter.getMasks();
+            int[] masks = filters[filter].getMasks();
 
             if (masks != null) {
                 ucast = (masks[affColId] & IndexCondition.EQUALITY) != 0 ||

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2MetaTable.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2MetaTable.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2MetaTable.java
index 3b752bc..d23515b 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2MetaTable.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2MetaTable.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.query.h2.opt;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
@@ -39,6 +40,7 @@ import org.h2.table.Column;
 import org.h2.table.IndexColumn;
 import org.h2.table.TableBase;
 import org.h2.table.TableFilter;
+import org.h2.table.TableType;
 import org.h2.value.Value;
 import org.h2.value.ValueInt;
 import org.jsr166.ConcurrentHashMap8;
@@ -145,8 +147,8 @@ public class GridH2MetaTable extends TableBase {
     }
 
     /** {@inheritDoc} */
-    @Override public String getTableType() {
-        return SYSTEM_TABLE;
+    @Override public TableType getTableType() {
+        return TableType.SYSTEM_TABLE;
     }
 
     /** {@inheritDoc} */
@@ -338,7 +340,7 @@ public class GridH2MetaTable extends TableBase {
 
         /** {@inheritDoc} */
         @Override public double getCost(Session session, int[] masks, TableFilter[] filters,
-            int filter, SortOrder sortOrder) {
+            int filter, SortOrder sortOrder, HashSet<Column> cols) {
             if ((masks[ID] & IndexCondition.EQUALITY) == IndexCondition.EQUALITY)
                 return 1;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2PrimaryScanIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2PrimaryScanIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2PrimaryScanIndex.java
index 097b34e..6c49ac2 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2PrimaryScanIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2PrimaryScanIndex.java
@@ -19,9 +19,12 @@ package org.apache.ignite.internal.processors.query.h2.opt;
 
 import org.h2.engine.Session;
 import org.h2.result.SortOrder;
+import org.h2.table.Column;
 import org.h2.table.TableFilter;
 import org.jetbrains.annotations.Nullable;
 
+import java.util.HashSet;
+
 /**
  * Wrapper type for primary key.
  */
@@ -65,10 +68,10 @@ public class GridH2PrimaryScanIndex extends GridH2ScanIndex<GridH2IndexBase> {
 
     /** {@inheritDoc} */
     @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter,
-        SortOrder sortOrder) {
+        SortOrder sortOrder, HashSet<Column> allColumnsSet) {
         long rows = getRowCountApproximation();
 
-        double baseCost = getCostRangeIndex(masks, rows, filters, filter, sortOrder, true);
+        double baseCost = getCostRangeIndex(masks, rows, filters, filter, sortOrder, true, allColumnsSet);
 
         int mul = delegate().getDistributedMultiplier(ses, filters, filter);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java
index 042e163..7de6740 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java
@@ -29,7 +29,7 @@ import org.h2.value.Value;
 /**
  * Row with locking support needed for unique key conflicts resolution.
  */
-public abstract class GridH2Row extends Row implements GridSearchRowPointer, CacheDataRow {
+public abstract class GridH2Row implements GridSearchRowPointer, CacheDataRow, Row {
     /** */
     public long link; // TODO remove
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ScanIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ScanIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ScanIndex.java
index 3b486c6..b3d3952 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ScanIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ScanIndex.java
@@ -184,8 +184,8 @@ public abstract class GridH2ScanIndex<D extends BaseIndex> extends BaseIndex {
     }
 
     /** {@inheritDoc} */
-    @Override public IndexLookupBatch createLookupBatch(TableFilter filter) {
-        return delegate().createLookupBatch(filter);
+    @Override public IndexLookupBatch createLookupBatch(TableFilter[] filters, int filter) {
+        return delegate().createLookupBatch(filters, filter);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
index c07dce4..b9394ec 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.query.h2.opt;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.TimeUnit;
@@ -44,8 +45,10 @@ import org.h2.message.DbException;
 import org.h2.result.Row;
 import org.h2.result.SearchRow;
 import org.h2.result.SortOrder;
+import org.h2.table.Column;
 import org.h2.table.IndexColumn;
 import org.h2.table.TableBase;
+import org.h2.table.TableType;
 import org.h2.value.Value;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
@@ -803,8 +806,8 @@ public class GridH2Table extends TableBase {
     }
 
     /** {@inheritDoc} */
-    @Override public String getTableType() {
-        return EXTERNAL_TABLE_ENGINE;
+    @Override public TableType getTableType() {
+        return TableType.EXTERNAL_TABLE_ENGINE;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
index cf75395..56f6667 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.query.h2.opt;
 
 import java.util.Collection;
 import java.util.Comparator;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.NavigableMap;
@@ -40,6 +41,7 @@ import org.h2.index.SingleRowCursor;
 import org.h2.message.DbException;
 import org.h2.result.SearchRow;
 import org.h2.result.SortOrder;
+import org.h2.table.Column;
 import org.h2.table.IndexColumn;
 import org.h2.table.TableFilter;
 import org.h2.value.Value;
@@ -258,9 +260,10 @@ public class GridH2TreeIndex extends GridH2IndexBase implements Comparator<GridS
     }
 
     /** {@inheritDoc} */
-    @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder) {
+    @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter,
+        SortOrder sortOrder, HashSet<Column> cols) {
         long rowCnt = getRowCountApproximation();
-        double baseCost = getCostRangeIndex(masks, rowCnt, filters, filter, sortOrder, false);
+        double baseCost = getCostRangeIndex(masks, rowCnt, filters, filter, sortOrder, false, cols);
         int mul = getDistributedMultiplier(ses, filters, filter);
 
         return mul * baseCost;

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/DmlAstUtils.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/DmlAstUtils.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/DmlAstUtils.java
index 974a5b8..91694ae 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/DmlAstUtils.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/DmlAstUtils.java
@@ -46,7 +46,6 @@ import org.h2.value.ValueInt;
 import org.h2.value.ValueString;
 import org.h2.value.ValueTime;
 import org.h2.value.ValueTimestamp;
-import org.h2.value.ValueTimestampUtc;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -397,8 +396,6 @@ public final class DmlAstUtils {
             dfltVal = ValueInt.get(0).convertTo(type);
         else if (dt.type == Value.TIMESTAMP)
             dfltVal = ValueTimestamp.fromMillis(U.currentTimeMillis());
-        else if (dt.type == Value.TIMESTAMP_UTC)
-            dfltVal = ValueTimestampUtc.fromMillis(U.currentTimeMillis());
         else if (dt.type == Value.TIME)
             dfltVal = ValueTime.fromNanos(0);
         else if (dt.type == Value.DATE)

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlAlias.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlAlias.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlAlias.java
index eb84c90..e8c82fd 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlAlias.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlAlias.java
@@ -18,6 +18,8 @@
 package org.apache.ignite.internal.processors.query.h2.sql;
 
 import java.util.ArrayList;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.h2.command.Parser;
 
 /**
@@ -48,6 +50,8 @@ public class GridSqlAlias extends GridSqlElement {
 
         addChild(expr);
 
+        assert !F.isEmpty(alias): alias;
+
         this.useAs = useAs;
         this.alias = alias;
     }
@@ -67,7 +71,21 @@ public class GridSqlAlias extends GridSqlElement {
 
     /** {@inheritDoc} */
     @Override public String getSQL() {
-        return child(0).getSQL() + (useAs ? " AS " : " ") + Parser.quoteIdentifier(alias);
+        SB b = new SB();
+
+        GridSqlAst child = child(0);
+
+        boolean tbl = child instanceof GridSqlTable;
+
+        b.a(tbl ? ((GridSqlTable)child).getBeforeAliasSql() : child.getSQL());
+
+        b.a(useAs ? " AS " : " ");
+        b.a(Parser.quoteIdentifier(alias));
+
+        if (tbl)
+            b.a(((GridSqlTable)child).getAfterAliasSQL());
+
+        return b.toString();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
index 199a157..13d4237 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
@@ -406,6 +406,10 @@ public class GridSqlQueryParser {
         if (res == null) {
             res = parseTable(filter.getTable());
 
+            // Setup index hints.
+            if (res instanceof GridSqlTable && filter.getIndexHints() != null)
+                ((GridSqlTable)res).useIndexes(new ArrayList<>(filter.getIndexHints().getAllowedIndexes()));
+
             String alias = ALIAS.get(filter);
 
             if (alias != null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlTable.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlTable.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlTable.java
index 57ca4df..e531254 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlTable.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlTable.java
@@ -18,7 +18,9 @@
 package org.apache.ignite.internal.processors.query.h2.sql;
 
 import java.util.Collections;
+import java.util.List;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table;
+import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.h2.command.Parser;
 import org.h2.table.Table;
 import org.jetbrains.annotations.Nullable;
@@ -36,6 +38,9 @@ public class GridSqlTable extends GridSqlElement {
     /** */
     private final GridH2Table tbl;
 
+    /** */
+    private List<String> useIndexes;
+
     /**
      * @param schema Schema.
      * @param tblName Table name.
@@ -70,6 +75,13 @@ public class GridSqlTable extends GridSqlElement {
 
     /** {@inheritDoc} */
     @Override public String getSQL() {
+        return getBeforeAliasSql() + getAfterAliasSQL();
+    }
+
+    /**
+     * @return SQL for the table before alias.
+     */
+    public String getBeforeAliasSql() {
         if (schema == null)
             return Parser.quoteIdentifier(tblName);
 
@@ -77,6 +89,40 @@ public class GridSqlTable extends GridSqlElement {
     }
 
     /**
+     * @return SQL for the table after alias.
+     */
+    public String getAfterAliasSQL() {
+        if (useIndexes == null)
+            return "";
+
+        SB b = new SB();
+
+        b.a(" USE INDEX (");
+
+        boolean first = true;
+
+        for (String idx : useIndexes) {
+            if (first)
+                first = false;
+            else
+                b.a(", ");
+
+            b.a(Parser.quoteIdentifier(idx));
+        }
+
+        b.a(')');
+
+        return b.toString();
+    }
+
+    /**
+     * @param useIndexes List of indexes.
+     */
+    public void useIndexes(List<String> useIndexes) {
+        this.useIndexes = useIndexes;
+    }
+
+    /**
      * @return Schema.
      */
     public String schema() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java
index 27622bb..86601cd 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java
@@ -46,6 +46,7 @@ import org.h2.index.IndexType;
 import org.h2.message.DbException;
 import org.h2.result.Row;
 import org.h2.result.SearchRow;
+import org.h2.table.Column;
 import org.h2.table.IndexColumn;
 import org.h2.value.Value;
 import org.jetbrains.annotations.Nullable;

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexSorted.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexSorted.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexSorted.java
index 361bb2d..f2d9de4 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexSorted.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexSorted.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.query.h2.twostep;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Comparator;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -41,6 +42,7 @@ import org.h2.index.IndexType;
 import org.h2.result.Row;
 import org.h2.result.SearchRow;
 import org.h2.result.SortOrder;
+import org.h2.table.Column;
 import org.h2.table.IndexColumn;
 import org.h2.table.TableFilter;
 import org.h2.value.Value;
@@ -184,8 +186,8 @@ public final class GridMergeIndexSorted extends GridMergeIndex {
     }
 
     /** {@inheritDoc} */
-    @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder) {
-        return getCostRangeIndex(masks, getRowCountApproximation(), filters, filter, sortOrder, false);
+    @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, HashSet<Column> allColumnsSet) {
+        return getCostRangeIndex(masks, getRowCountApproximation(), filters, filter, sortOrder, false, allColumnsSet);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexUnsorted.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexUnsorted.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexUnsorted.java
index 430a687..c53b58f 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexUnsorted.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexUnsorted.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.query.h2.twostep;
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -33,6 +34,7 @@ import org.h2.index.IndexType;
 import org.h2.result.Row;
 import org.h2.result.SearchRow;
 import org.h2.result.SortOrder;
+import org.h2.table.Column;
 import org.h2.table.IndexColumn;
 import org.h2.table.TableFilter;
 import org.h2.value.Value;
@@ -116,8 +118,8 @@ public final class GridMergeIndexUnsorted extends GridMergeIndex {
     }
 
     /** {@inheritDoc} */
-    @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder) {
-        return getCostRangeIndex(masks, getRowCountApproximation(), filters, filter, sortOrder, true);
+    @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, HashSet<Column> allColumnsSet) {
+        return getCostRangeIndex(masks, getRowCountApproximation(), filters, filter, sortOrder, true, allColumnsSet);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeTable.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeTable.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeTable.java
index f7495c0..681917f 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeTable.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeTable.java
@@ -18,6 +18,8 @@
 package org.apache.ignite.internal.processors.query.h2.twostep;
 
 import java.util.ArrayList;
+import java.util.HashSet;
+
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2ScanIndex;
 import org.apache.ignite.internal.util.typedef.F;
 import org.h2.command.ddl.CreateTableData;
@@ -27,9 +29,11 @@ import org.h2.index.IndexType;
 import org.h2.message.DbException;
 import org.h2.result.Row;
 import org.h2.result.SortOrder;
+import org.h2.table.Column;
 import org.h2.table.IndexColumn;
 import org.h2.table.TableBase;
 import org.h2.table.TableFilter;
+import org.h2.table.TableType;
 
 /**
  * Merge table for distributed queries.
@@ -111,8 +115,8 @@ public class GridMergeTable extends TableBase {
     }
 
     /** {@inheritDoc} */
-    @Override public String getTableType() {
-        return EXTERNAL_TABLE_ENGINE;
+    @Override public TableType getTableType() {
+        return TableType.EXTERNAL_TABLE_ENGINE;
     }
 
     /** {@inheritDoc} */
@@ -188,10 +192,10 @@ public class GridMergeTable extends TableBase {
 
         /** {@inheritDoc} */
         @Override public double getCost(Session session, int[] masks, TableFilter[] filters, int filter,
-            SortOrder sortOrder) {
+            SortOrder sortOrder, HashSet<Column> allColumnsSet) {
             long rows = getRowCountApproximation();
 
-            return getCostRangeIndex(masks, rows, filters, filter, sortOrder, true);
+            return getCostRangeIndex(masks, rows, filters, filter, sortOrder, true, allColumnsSet);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java
index d46fb2f..9bbb9b4 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java
@@ -37,6 +37,7 @@ import org.h2.table.IndexColumn;
 import org.h2.table.PlanItem;
 import org.h2.table.Table;
 import org.h2.table.TableFilter;
+import org.h2.table.TableType;
 import org.h2.value.Value;
 
 /**
@@ -91,8 +92,8 @@ public class GridThreadLocalTable extends Table {
 
     /** {@inheritDoc} */
     @Override public PlanItem getBestPlanItem(Session session, int[] masks, TableFilter[] filters, int filter,
-        SortOrder sortOrder) {
-        return innerTable().getBestPlanItem(session, masks, filters, filter, sortOrder);
+        SortOrder sortOrder, HashSet<Column> cols) {
+        return innerTable().getBestPlanItem(session, masks, filters, filter, sortOrder, cols);
     }
 
     /** {@inheritDoc} */
@@ -177,8 +178,8 @@ public class GridThreadLocalTable extends Table {
     }
 
     /** {@inheritDoc} */
-    @Override public String getTableType() {
-        return EXTERNAL_TABLE_ENGINE;
+    @Override public TableType getTableType() {
+        return TableType.EXTERNAL_TABLE_ENGINE;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
index 2a03796..4578171 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
@@ -476,6 +476,38 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     */
+    public void testUseIndexHints() {
+        CacheConfiguration ccfg = cacheConfig("pers", true,
+            Integer.class, Person2.class);
+
+        IgniteCache<Integer, Person2> c = ignite(0).getOrCreateCache(ccfg);
+
+        try {
+            String select = "select 1 from Person2 use index (\"PERSON2_ORGID_IDX\") where name = '' and orgId = 1";
+
+            String plan = c.query(new SqlFieldsQuery("explain " + select)).getAll().toString();
+
+            X.println("Plan: \n" + plan);
+
+            assertTrue(plan.contains("USE INDEX (PERSON2_ORGID_IDX)"));
+            assertTrue(plan.contains("/* \"pers\".PERSON2_ORGID_IDX:"));
+
+            select = "select 1 from Person2 use index (\"PERSON2_NAME_IDX\") where name = '' and orgId = 1";
+
+            plan = c.query(new SqlFieldsQuery("explain " + select)).getAll().toString();
+
+            X.println("Plan: \n" + plan);
+
+            assertTrue(plan.contains("USE INDEX (PERSON2_NAME_IDX)"));
+            assertTrue(plan.contains("/* \"pers\".PERSON2_NAME_IDX:"));
+        }
+        finally {
+            c.destroy();
+        }
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testDistributedJoins() throws Exception {
@@ -1917,7 +1949,7 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
         int orgId;
 
         /** */
-        @QuerySqlField
+        @QuerySqlField(index = true)
         String name;
 
         /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java
index f34deae..0317672 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java
@@ -46,7 +46,6 @@ import org.h2.value.ValueShort;
 import org.h2.value.ValueString;
 import org.h2.value.ValueTime;
 import org.h2.value.ValueTimestamp;
-import org.h2.value.ValueTimestampUtc;
 import org.h2.value.ValueUuid;
 
 /**
@@ -286,13 +285,6 @@ public class InlineIndexHelperTest extends TestCase {
     }
 
     /** */
-    public void testTimestampUTC() throws Exception {
-        testPutGet(ValueTimestampUtc.fromMillis(System.currentTimeMillis()),
-            ValueTimestampUtc.fromMillis(System.currentTimeMillis() + 100),
-            ValueTimestampUtc.fromMillis(System.currentTimeMillis() + 200));
-    }
-
-    /** */
     public void testUUID() throws Exception {
         testPutGet(ValueUuid.get(UUID.randomUUID().toString()),
             ValueUuid.get(UUID.randomUUID().toString()),

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
index 631adeb..2085c9f 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
@@ -169,10 +169,10 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         checkQuery("select * from table0('aaa', 100)");
         checkQuery("select * from table0('aaa', 100) t0");
         checkQuery("select x.a, y.b from table0('aaa', 100) x natural join table0('bbb', 100) y");
-        checkQuery("select * from table0('aaa', 100) x join table0('bbb', 100) y on x.a=y.a and x.b = 'bbb'");
-        checkQuery("select * from table0('aaa', 100) x left join table0('bbb', 100) y on x.a=y.a and x.b = 'bbb'");
-        checkQuery("select * from table0('aaa', 100) x left join table0('bbb', 100) y on x.a=y.a where x.b = 'bbb'");
-        checkQuery("select * from table0('aaa', 100) x left join table0('bbb', 100) y where x.b = 'bbb'");
+        checkQuery("select * from table0('aaa', 100) x join table0('bbb', 100) y on x.a=y.a and x.b = 1");
+        checkQuery("select * from table0('aaa', 100) x left join table0('bbb', 100) y on x.a=y.a and x.b = 1");
+        checkQuery("select * from table0('aaa', 100) x left join table0('bbb', 100) y on x.a=y.a where x.b = 1");
+        checkQuery("select * from table0('aaa', 100) x left join table0('bbb', 100) y where x.b = 1");
 
         checkQuery("select avg(old) from Person left join sch2.Address on Person.addrId = Address.id " +
             "where lower(Address.street) = lower(?)");
@@ -314,6 +314,21 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testUseIndexHints() throws Exception {
+        checkQuery("select * from Person use index (\"PERSON_NAME_IDX\")");
+        checkQuery("select * from Person use index (\"PERSON_PARENTNAME_IDX\")");
+        checkQuery("select * from Person use index (\"PERSON_NAME_IDX\", \"PERSON_PARENTNAME_IDX\")");
+        checkQuery("select * from Person use index ()");
+
+        checkQuery("select * from Person p use index (\"PERSON_NAME_IDX\")");
+        checkQuery("select * from Person p use index (\"PERSON_PARENTNAME_IDX\")");
+        checkQuery("select * from Person p use index (\"PERSON_NAME_IDX\", \"PERSON_PARENTNAME_IDX\")");
+        checkQuery("select * from Person p use index ()");
+    }
+
+    /**
      * Query AST transformation heavily depends on this behavior.
      *
      * @throws Exception If failed.
@@ -383,7 +398,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         checkQuery("merge into Person(date, old, name, parentName, addrId) values " +
             "(TRUNCATE(TIMESTAMP '2015-12-31 23:59:59'), POWER(3,12), NULL, DEFAULT, DEFAULT)");
         checkQuery("merge into Person(old, name) select ASCII(parentName), INSERT(parentName, 4, 4, 'Max') from " +
-            "Person where date='20110312'");
+            "Person where date='2011-03-12'");
 
         /* Subqueries. */
         checkQuery("merge into Person(old, name) select old, parentName from Person");
@@ -423,7 +438,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         checkQuery("insert into Person SET name = CONCAT('Fyodor', null, UPPER(CONCAT(SQRT(?), 'dostoevsky'))), old = " +
             "select (5, 6)");
         checkQuery("insert into Person(old, name) select ASCII(parentName), INSERT(parentName, 4, 4, 'Max') from " +
-            "Person where date='20110312'");
+            "Person where date='2011-03-12'");
 
         /* Subqueries. */
         checkQuery("insert into Person(old, name) select old, parentName from Person");
@@ -491,7 +506,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
 
         // Schemas for index and table must match
         assertParseThrows("create index if not exists sch2.idx on sch1.Person (name)",
-            DbException.class, "Schema name must match [90080-191]");
+            DbException.class, "Schema name must match [90080-194]");
 
         assertParseThrows("create hash index if not exists idx on Person (name)",
             IgniteSQLException.class, "Only SPATIAL modifier is supported for CREATE INDEX");

http://git-wip-us.apache.org/repos/asf/ignite/blob/457c5515/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 74e8cf5..cb638e1 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -71,7 +71,7 @@
         <guava.version>18.0</guava.version>
         <guava14.version>14.0.1</guava14.version>
         <guava16.version>16.0.1</guava16.version>
-        <h2.version>1.4.191</h2.version>
+        <h2.version>1.4.194</h2.version>
         <httpclient.version>4.5.1</httpclient.version>
         <httpcore.version>4.4.3</httpcore.version>
         <jackson.version>1.9.13</jackson.version>


[64/65] [abbrv] ignite git commit: Merge branch 'ignite-2.0' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-5024

Posted by ag...@apache.org.
Merge branch 'ignite-2.0' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-5024


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

Branch: refs/heads/ignite-5024
Commit: df7da50fb641bcde607bc3f3be591ea1704fb757
Parents: 14c52e2 8a1ded1
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Apr 24 11:03:00 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Apr 24 11:03:00 2017 +0300

----------------------------------------------------------------------
 .../src/main/java/org/apache/ignite/Ignite.java |   1 -
 .../java/org/apache/ignite/IgniteCache.java     |  11 -
 .../java/org/apache/ignite/IgniteCompute.java   |  14 +
 .../store/jdbc/CacheAbstractJdbcStore.java      |  29 +-
 .../configuration/DataPageEvictionMode.java     |  10 +-
 .../configuration/ExecutorConfiguration.java    | 115 +++++
 .../configuration/IgniteConfiguration.java      |  30 ++
 .../org/apache/ignite/events/CacheEvent.java    |   3 -
 .../java/org/apache/ignite/events/Event.java    |   1 -
 .../org/apache/ignite/events/EventType.java     | 109 -----
 .../apache/ignite/events/SwapSpaceEvent.java    | 105 ----
 .../ignite/internal/ExecutorAwareMessage.java   |  31 ++
 .../ignite/internal/GridJobExecuteRequest.java  |  32 +-
 .../ignite/internal/GridKernalContext.java      |   8 +
 .../ignite/internal/GridKernalContextImpl.java  |  12 +
 .../ignite/internal/GridTaskSessionImpl.java    |  15 +-
 .../ignite/internal/IgniteComputeImpl.java      |  71 ++-
 .../apache/ignite/internal/IgniteKernal.java    |   3 +
 .../org/apache/ignite/internal/IgnitionEx.java  |  66 +++
 .../managers/communication/GridIoManager.java   |  23 +-
 .../managers/communication/GridIoMessage.java   |  13 +
 .../managers/indexing/GridIndexingManager.java  |  44 --
 .../processors/cache/CacheMetricsImpl.java      |  21 -
 .../processors/cache/GridCacheAdapter.java      |   6 -
 .../processors/cache/GridCacheAtomicFuture.java |   5 -
 .../processors/cache/GridCacheContext.java      |  23 -
 .../GridCacheEntryInfoCollectSwapListener.java  |  70 ---
 .../processors/cache/GridCacheMvccManager.java  |  10 +-
 .../processors/cache/GridCacheProcessor.java    |  12 +
 .../processors/cache/GridCacheProxyImpl.java    |  12 -
 .../processors/cache/GridCacheSwapListener.java |  33 --
 .../cache/GridCacheTryPutFailedException.java   |  28 --
 .../processors/cache/IgniteCacheProxy.java      |   6 -
 .../processors/cache/IgniteInternalCache.java   |  11 -
 .../IgniteCacheDatabaseSharedManager.java       |   4 +-
 .../CacheDataStructuresManager.java             |  34 ++
 .../cache/distributed/dht/GridDhtGetFuture.java |  37 +-
 .../dht/GridPartitionedSingleGetFuture.java     |   3 -
 .../GridDhtAtomicAbstractUpdateFuture.java      |   9 +-
 .../dht/atomic/GridDhtAtomicCache.java          |  54 +--
 .../atomic/GridDhtAtomicSingleUpdateFuture.java |   3 -
 .../dht/atomic/GridDhtAtomicUpdateFuture.java   |   3 -
 .../GridNearAtomicAbstractUpdateFuture.java     |  79 ++-
 .../GridNearAtomicSingleUpdateFuture.java       | 134 ++----
 .../dht/atomic/GridNearAtomicUpdateFuture.java  | 159 +++----
 .../dht/preloader/GridDhtPreloader.java         |  18 +-
 .../distributed/near/GridNearAtomicCache.java   |   5 -
 .../distributed/near/GridNearCacheEntry.java    |   4 +-
 .../cache/local/GridLocalLockFuture.java        |   3 -
 .../cache/query/GridCacheQueryManager.java      |  59 ---
 .../cache/store/CacheOsStoreManager.java        |   3 +
 .../store/GridCacheStoreManagerAdapter.java     |  11 +-
 .../closure/GridClosureProcessor.java           | 154 +++---
 .../datastructures/DataStructuresProcessor.java |   3 +-
 .../GridCacheAtomicReferenceImpl.java           | 108 ++++-
 .../GridCacheAtomicStampedImpl.java             |  70 ++-
 .../GridCacheCountDownLatchImpl.java            |   2 +-
 .../datastructures/GridCacheLockImpl.java       |  17 +-
 .../datastructures/GridCacheSemaphoreImpl.java  | 240 +++++-----
 .../processors/job/GridJobProcessor.java        |  23 +-
 .../internal/processors/job/GridJobWorker.java  |  15 +-
 .../platform/PlatformContextImpl.java           |  11 -
 .../platform/cache/PlatformCache.java           |  33 +-
 .../platform/cluster/PlatformClusterGroup.java  |  17 +
 .../utils/PlatformConfigurationUtils.java       | 176 ++++++-
 .../internal/processors/pool/PoolProcessor.java |  25 +
 .../processors/query/GridQueryIndexing.java     |  19 -
 .../processors/query/GridQueryProcessor.java    | 234 ++++-----
 .../session/GridTaskSessionProcessor.java       |  10 +-
 .../processors/task/GridTaskProcessor.java      |  69 ++-
 .../processors/task/GridTaskWorker.java         |   3 +-
 .../visor/cache/VisorCachePartitionsTask.java   |   2 +-
 .../visor/node/VisorNodeDataCollectorTask.java  |   4 +-
 .../node/VisorNodeDataCollectorTaskResult.java  |   4 +-
 .../apache/ignite/spi/indexing/IndexingSpi.java |  19 -
 .../spi/indexing/noop/NoopIndexingSpi.java      |  10 -
 .../resources/META-INF/classnames.properties    |   1 -
 .../CacheJdbcPojoStoreAbstractSelfTest.java     |  19 +-
 ...BinaryMarshallerStoreKeepBinarySelfTest.java |  28 ++
 ...lerStoreKeepBinaryWithSqlEscapeSelfTest.java |  28 ++
 .../store/jdbc/CacheJdbcPojoStoreTest.java      |   4 +-
 .../internal/GridCacheRecreateLockTest.java     |  78 ---
 .../internal/TestRecordingCommunicationSpi.java |  29 +-
 ...CacheExchangeMessageDuplicatedStateTest.java |   8 +-
 .../cache/GridCacheAbstractFullApiSelfTest.java |  45 --
 .../IgniteCacheConfigVariationsFullApiTest.java |  45 --
 .../IgniteCacheStoreValueAbstractTest.java      |   4 -
 .../cache/IgniteOnePhaseCommitInvokeTest.java   |  10 +-
 .../IgniteTxExceptionAbstractSelfTest.java      |  10 -
 ...CacheAtomicReferenceApiSelfAbstractTest.java |   4 +-
 ...IgniteDataStructuresNoClassOnServerTest.java |  30 ++
 .../CacheLateAffinityAssignmentTest.java        |  31 +-
 .../CacheNoValueClassOnServerNodeTest.java      | 112 +----
 ...tractDistributedByteArrayValuesSelfTest.java |  43 --
 ...heClientMultiNodeUpdateTopologyLockTest.java | 193 ++++++++
 .../IgniteCacheReadFromBackupTest.java          |  15 +-
 .../IgniteNoClassOnServerAbstractTest.java      | 135 ++++++
 .../IgniteTxCachePrimarySyncTest.java           |  17 +-
 .../dht/IgniteCacheTxRecoveryRollbackTest.java  |  17 +-
 .../atomic/IgniteCacheAtomicProtocolTest.java   |  58 +--
 ...tomicClientOnlyMultiNodeFullApiSelfTest.java |  51 +-
 ...achePartitionedMultiNodeFullApiSelfTest.java |  59 ---
 .../GridCachePartitionedTxSalvageSelfTest.java  |   2 +-
 ...idCacheReplicatedUnswapAdvancedSelfTest.java | 151 ------
 .../cache/query/IndexingSpiQuerySelfTest.java   |  22 -
 .../cache/query/IndexingSpiQueryTxSelfTest.java |  10 -
 ...puteCustomExecutorConfigurationSelfTest.java |  85 ++++
 .../IgniteComputeCustomExecutorSelfTest.java    | 245 ++++++++++
 .../loadtests/cache/GridCacheSwapLoadTest.java  | 320 -------------
 .../ignite/testframework/GridTestNode.java      |   7 +
 .../junits/GridTestKernalContext.java           |   5 +-
 .../junits/common/GridCommonAbstractTest.java   |  76 ++-
 .../multijvm/IgniteCacheProcessProxy.java       |   5 -
 ...ObjectsCacheDataStructuresSelfTestSuite.java |   7 +-
 .../ignite/testsuites/IgniteCacheTestSuite.java |   4 +
 .../testsuites/IgniteCacheTestSuite3.java       |   2 -
 .../testsuites/IgniteComputeGridTestSuite.java  |   7 +-
 modules/extdata/p2p/pom.xml                     |   6 +
 .../p2p/NoValueClassOnServerAbstractClient.java |  90 ++++
 .../CacheNoValueClassOnServerTestClient.java    |  79 ++-
 ...DataStructuresNoClassOnServerTestClient.java | 181 +++++++
 .../query/h2/opt/GridH2SpatialIndex.java        |  32 +-
 .../cache/hibernate/HibernateCacheProxy.java    |   5 -
 .../cache/hibernate/HibernateCacheProxy.java    |   5 -
 .../processors/query/h2/IgniteH2Indexing.java   |  80 +---
 .../query/h2/database/H2PkHashIndex.java        |   6 +-
 .../query/h2/database/H2TreeIndex.java          |   6 +-
 .../query/h2/database/InlineIndexHelper.java    |  14 -
 .../query/h2/opt/GridH2AbstractKeyValueRow.java |  89 +---
 .../query/h2/opt/GridH2IndexBase.java           |   7 +-
 .../query/h2/opt/GridH2KeyValueRowOffheap.java  |  70 ---
 .../query/h2/opt/GridH2MetaTable.java           |   8 +-
 .../query/h2/opt/GridH2PrimaryScanIndex.java    |   7 +-
 .../processors/query/h2/opt/GridH2Row.java      |   2 +-
 .../query/h2/opt/GridH2RowDescriptor.java       |  11 -
 .../query/h2/opt/GridH2ScanIndex.java           |   4 +-
 .../processors/query/h2/opt/GridH2Table.java    |  94 +---
 .../query/h2/opt/GridH2TreeIndex.java           |   7 +-
 .../processors/query/h2/sql/DmlAstUtils.java    |   3 -
 .../processors/query/h2/sql/GridSqlAlias.java   |  20 +-
 .../query/h2/sql/GridSqlQueryParser.java        |   4 +
 .../processors/query/h2/sql/GridSqlTable.java   |  46 ++
 .../query/h2/twostep/GridMergeIndex.java        |   1 +
 .../query/h2/twostep/GridMergeIndexSorted.java  |   6 +-
 .../h2/twostep/GridMergeIndexUnsorted.java      |   6 +-
 .../query/h2/twostep/GridMergeTable.java        |  12 +-
 .../h2/twostep/GridReduceQueryExecutor.java     |  29 --
 .../query/h2/twostep/GridThreadLocalTable.java  |  14 +-
 ...ryDuplicateIndexObjectsAbstractSelfTest.java | 159 -------
 .../cache/GridCacheOffHeapSelfTest.java         | 476 -------------------
 .../IgniteCacheQueryMultiThreadedSelfTest.java  |  25 -
 ...ateIndexObjectPartitionedAtomicSelfTest.java |  38 --
 ...xObjectPartitionedTransactionalSelfTest.java |  41 --
 .../cache/index/AbstractSchemaSelfTest.java     |  44 +-
 .../DynamicIndexAbstractConcurrentSelfTest.java | 122 +++++
 .../cache/index/SchemaExchangeSelfTest.java     |  57 ++-
 .../query/IgniteQueryDedicatedPoolTest.java     |  10 -
 .../query/IgniteSqlSplitterSelfTest.java        |  34 +-
 .../h2/database/InlineIndexHelperTest.java      |   8 -
 .../query/h2/sql/GridQueryParsingTest.java      |  29 +-
 .../IgniteBinaryCacheQueryTestSuite.java        |   5 -
 .../stream/kafka/connect/IgniteSourceTask.java  |   4 -
 .../ExpiryCacheHolderTest.cs                    |  10 +
 .../Apache.Ignite.Core.Tests.csproj             |   1 +
 .../Cache/Affinity/AffinityFunctionTest.cs      |   2 +-
 .../Cache/CacheAbstractTest.cs                  |  58 ---
 .../Cache/CacheConfigurationTest.cs             |  21 +-
 .../Cache/CacheTestAsyncWrapper.cs              |  22 +-
 .../Cache/PartitionLossTest.cs                  | 260 ++++++++++
 .../IgniteConfigurationSerializerTest.cs        |  57 ++-
 .../IgniteConfigurationTest.cs                  |  56 +++
 .../Apache.Ignite.Core.Tests/TestUtils.cs       |   5 +-
 .../Apache.Ignite.Core.csproj                   |   4 +
 .../Cache/Configuration/CacheConfiguration.cs   |  35 ++
 .../Cache/Configuration/DataPageEvictionMode.cs |  59 +++
 .../Cache/Configuration/MemoryConfiguration.cs  | 151 ++++++
 .../Configuration/MemoryPolicyConfiguration.cs  | 119 +++++
 .../Cache/Configuration/PartitionLossPolicy.cs  |  68 +++
 .../dotnet/Apache.Ignite.Core/Cache/ICache.cs   |  21 +-
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |  12 +
 .../Apache.Ignite.Core/IgniteConfiguration.cs   |  21 +
 .../IgniteConfigurationSection.xsd              | 107 +++++
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |  56 ++-
 .../Apache.Ignite.Core/Impl/Cache/CacheOp.cs    |   6 +-
 .../Impl/Cluster/ClusterGroupImpl.cs            |  27 ++
 .../Impl/Common/DelegateConverter.cs            |   1 +
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |  16 +-
 .../Apache.Ignite.Core/Impl/IgniteUtils.cs      |  10 +-
 .../Apache.Ignite.Core/Impl/NativeMethods.cs    |   6 +
 .../Impl/Unmanaged/UnmanagedUtils.cs            |   8 +-
 modules/spring-data/pom.xml                     |   2 +-
 .../support/IgniteRepositoryFactoryBean.java    |   7 +
 modules/web-console/backend/index.js            |   5 +-
 parent/pom.xml                                  |   6 +-
 194 files changed, 4311 insertions(+), 3819 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/df7da50f/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
index 661e03e,0d1b5b9..2c64d45
--- a/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
@@@ -31,12 -31,12 +31,12 @@@ public enum DataPageEvictionMode 
       * <ul>
       * <li>Once a memory region defined by a memory policy is configured, an off-heap array is allocated to track
       * last usage timestamp for every individual data page. The size of the array is calculated this way - size =
 -     * ({@link MemoryPolicyConfiguration#getSize()} / {@link MemoryConfiguration#pageSize})</li>
 +     * ({@link MemoryPolicyConfiguration#getMaxSize()} / {@link MemoryConfiguration#pageSize})</li>
       * <li>When a data page is accessed, its timestamp gets updated in the tracking array. The page index in the
 -     * tracking array is calculated this way - index = (pageAddress / {@link MemoryPolicyConfiguration#getSize()}</li>
 +     * tracking array is calculated this way - index = (pageAddress / {@link MemoryPolicyConfiguration#getMaxSize()}</li>
       * <li>When it's required to evict some pages, the algorithm randomly chooses 5 indexes from the tracking array and
       * evicts a page with the latest timestamp. If some of the indexes point to non-data pages (index or system pages)
-      * then the algorithm peaks another ones.</li>
+      * then the algorithm picks other pages.</li>
       * </ul>
       */
      RANDOM_LRU,

http://git-wip-us.apache.org/repos/asf/ignite/blob/df7da50f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/df7da50f/modules/extdata/p2p/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/df7da50f/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/df7da50f/modules/spring-data/pom.xml
----------------------------------------------------------------------


[51/65] [abbrv] ignite git commit: IGNITE-5031 .NET: Added Partition Loss APIs

Posted by ag...@apache.org.
IGNITE-5031 .NET: Added Partition Loss APIs

ICache.GetLostPartitions, ICache.WithPartitionRecover, IIgnite.ResetLostPartitions, CacheConfiguration.PartitionLossPolicy


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

Branch: refs/heads/ignite-5024
Commit: ad7e4a092c9efc9cf7417437b7875dc91eee0f8a
Parents: 457c551
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Fri Apr 21 17:08:52 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Fri Apr 21 17:08:52 2017 +0300

----------------------------------------------------------------------
 .../platform/cache/PlatformCache.java           |  24 +-
 .../platform/cluster/PlatformClusterGroup.java  |  17 ++
 .../utils/PlatformConfigurationUtils.java       |   4 +
 .../ExpiryCacheHolderTest.cs                    |  10 +
 .../Apache.Ignite.Core.Tests.csproj             |   1 +
 .../Cache/Affinity/AffinityFunctionTest.cs      |   2 +-
 .../Cache/CacheConfigurationTest.cs             |   3 +
 .../Cache/CacheTestAsyncWrapper.cs              |  16 +-
 .../Cache/PartitionLossTest.cs                  | 260 +++++++++++++++++++
 .../IgniteConfigurationSerializerTest.cs        |   7 +-
 .../Apache.Ignite.Core.Tests/TestUtils.cs       |   5 +-
 .../Apache.Ignite.Core.csproj                   |   1 +
 .../Cache/Configuration/CacheConfiguration.cs   |  13 +
 .../Cache/Configuration/PartitionLossPolicy.cs  |  68 +++++
 .../dotnet/Apache.Ignite.Core/Cache/ICache.cs   |  15 ++
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |  12 +
 .../IgniteConfigurationSection.xsd              |  15 ++
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |  48 +++-
 .../Apache.Ignite.Core/Impl/Cache/CacheOp.cs    |   5 +-
 .../Impl/Cluster/ClusterGroupImpl.cs            |  27 ++
 .../Impl/Common/DelegateConverter.cs            |   1 +
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |  16 +-
 22 files changed, 549 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
index 2847813..9a08b2b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
@@ -67,6 +67,7 @@ import javax.cache.Cache;
 import javax.cache.integration.CompletionListener;
 import javax.cache.processor.EntryProcessorException;
 import javax.cache.processor.EntryProcessorResult;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
@@ -198,7 +199,7 @@ public class PlatformCache extends PlatformAbstractTarget {
     public static final int OP_CLEAR_CACHE = 41;
 
     /** */
-    public static final int OP_WITH_ASYNC = 42;
+    public static final int OP_WITH_PARTITION_RECOVER = 42;
 
     /** */
     public static final int OP_REMOVE_ALL2 = 43;
@@ -323,6 +324,9 @@ public class PlatformCache extends PlatformAbstractTarget {
     /** */
     public static final int OP_GLOBAL_METRICS = 83;
 
+    /** */
+    public static final int OP_GET_LOST_PARTITIONS = 84;
+
     /** Underlying JCache in binary mode. */
     private final IgniteCacheProxy cache;
 
@@ -974,6 +978,17 @@ public class PlatformCache extends PlatformAbstractTarget {
 
                 break;
 
+            case OP_GET_LOST_PARTITIONS:
+                Collection<Integer> parts = cache.lostPartitions();
+
+                writer.writeInt(parts.size());
+
+                for (int p : parts) {
+                    writer.writeInt(p);
+                }
+
+                break;
+
             default:
                 super.processOutStream(type, writer);
         }
@@ -982,11 +997,8 @@ public class PlatformCache extends PlatformAbstractTarget {
     /** {@inheritDoc} */
     @Override public PlatformTarget processOutObject(int type) throws IgniteCheckedException {
         switch (type) {
-            case OP_WITH_ASYNC: {
-                if (cache.isAsync())
-                    return this;
-
-                return copy(rawCache.withAsync(), keepBinary);
+            case OP_WITH_PARTITION_RECOVER: {
+                return copy(rawCache.withPartitionRecover(), keepBinary);
             }
 
             case OP_WITH_KEEP_BINARY: {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
index f49f477..3e14e7a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.processors.platform.cluster;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.UUID;
 
@@ -104,6 +105,9 @@ public class PlatformClusterGroup extends PlatformAbstractTarget {
     /** */
     private static final int OP_CACHE_METRICS = 24;
 
+    /** */
+    private static final int OP_RESET_LOST_PARTITIONS = 25;
+
     /** Projection. */
     private final ClusterGroupEx prj;
 
@@ -223,6 +227,19 @@ public class PlatformClusterGroup extends PlatformAbstractTarget {
             case OP_PING_NODE:
                 return pingNode(reader.readUuid()) ? TRUE : FALSE;
 
+            case OP_RESET_LOST_PARTITIONS:
+                int cnt = reader.readInt();
+
+                Collection<String> cacheNames = new ArrayList<>(cnt);
+
+                for (int i = 0; i < cnt; i++) {
+                    cacheNames.add(reader.readString());
+                }
+
+                platformCtx.kernalContext().grid().resetLostPartitions(cacheNames);
+
+                return TRUE;
+
             default:
                 return super.processInStreamOutLong(type, reader);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index 0fe537f..4186eb9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -41,6 +41,7 @@ import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.CacheRebalanceMode;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.PartitionLossPolicy;
 import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.cache.QueryIndexType;
@@ -178,6 +179,8 @@ public class PlatformConfigurationUtils {
         if (memoryPolicyName != null)
             ccfg.setMemoryPolicyName(memoryPolicyName);
 
+        ccfg.setPartitionLossPolicy(PartitionLossPolicy.fromOrdinal((byte)in.readInt()));
+
         Object storeFactory = in.readObjectDetached();
 
         if (storeFactory != null)
@@ -801,6 +804,7 @@ public class PlatformConfigurationUtils {
         writer.writeBoolean(ccfg.isWriteThrough());
         writer.writeBoolean(ccfg.isStatisticsEnabled());
         writer.writeString(ccfg.getMemoryPolicyName());
+        writer.writeInt(ccfg.getPartitionLossPolicy().ordinal());
 
         if (ccfg.getCacheStoreFactory() instanceof PlatformDotNetCacheStoreFactoryNative)
             writer.writeObject(((PlatformDotNetCacheStoreFactoryNative)ccfg.getCacheStoreFactory()).getNativeFactory());

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
index 9d1a2b5..2fe3309 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
@@ -498,6 +498,16 @@ namespace Apache.Ignite.AspNet.Tests
             {
                 throw new NotImplementedException();
             }
+
+            public ICache<int, int> WithPartitionRecover()
+            {
+                throw new NotImplementedException();
+            }
+
+            public ICollection<int> GetLostPartitions()
+            {
+                throw new NotImplementedException();
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 232b033..f4f5e59 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -95,6 +95,7 @@
     <Compile Include="Cache\CacheTestKey.cs" />
     <Compile Include="Cache\NonSerializableCacheEntryProcessor.cs" />
     <Compile Include="Cache\NonSerializableException.cs" />
+    <Compile Include="Cache\PartitionLossTest.cs" />
     <Compile Include="Cache\Query\CacheDmlQueriesTest.cs" />
     <Compile Include="Cache\CacheAbstractTransactionalTest.cs" />
     <Compile Include="Cache\Query\CacheDmlQueriesTestSimpleName.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionTest.cs
index 22810da..7c6d779 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionTest.cs
@@ -220,7 +220,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Affinity
             }
 
             // Called on both nodes
-            TestUtils.WaitForCondition(() => RemovedNodes.Count > 0, 3000);
+            TestUtils.WaitForCondition(() => RemovedNodes.Count == 6, 3000);
             Assert.GreaterOrEqual(RemovedNodes.Count, 6);
             Assert.AreEqual(expectedNodeId, RemovedNodes.Distinct().Single());
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
index 25ba43e..67184a6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
@@ -215,6 +215,7 @@ namespace Apache.Ignite.Core.Tests.Cache
             Assert.AreEqual(CacheConfiguration.DefaultWriteBehindFlushSize, cfg.WriteBehindFlushSize);
             Assert.AreEqual(CacheConfiguration.DefaultWriteBehindFlushThreadCount, cfg.WriteBehindFlushThreadCount);
             Assert.AreEqual(CacheConfiguration.DefaultWriteBehindCoalescing, cfg.WriteBehindCoalescing);
+            Assert.AreEqual(CacheConfiguration.DefaultPartitionLossPolicy, cfg.PartitionLossPolicy);
         }
 
         /// <summary>
@@ -247,6 +248,7 @@ namespace Apache.Ignite.Core.Tests.Cache
             Assert.AreEqual(x.WriteBehindFlushSize, y.WriteBehindFlushSize);
             Assert.AreEqual(x.EnableStatistics, y.EnableStatistics);
             Assert.AreEqual(x.MemoryPolicyName, y.MemoryPolicyName);
+            Assert.AreEqual(x.PartitionLossPolicy, y.PartitionLossPolicy);
 
             if (x.ExpiryPolicyFactory != null)
                 Assert.AreEqual(x.ExpiryPolicyFactory.CreateInstance().GetType(),
@@ -562,6 +564,7 @@ namespace Apache.Ignite.Core.Tests.Cache
                 ExpiryPolicyFactory = new ExpiryFactory(),
                 EnableStatistics = true,
                 MemoryPolicyName = "myMemPolicy",
+                PartitionLossPolicy = PartitionLossPolicy.ReadOnlySafe,
                 PluginConfigurations = new[] { new MyPluginConfiguration() }
             };
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
index 6c8f0d6..5ba2fc9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -542,6 +542,18 @@ namespace Apache.Ignite.Core.Tests.Cache
         }
 
         /** <inheritDoc /> */
+        public ICache<TK, TV> WithPartitionRecover()
+        {
+            return _cache.WithPartitionRecover();
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<int> GetLostPartitions()
+        {
+            return _cache.GetLostPartitions();
+        }
+
+        /** <inheritDoc /> */
         public IEnumerator<ICacheEntry<TK, TV>> GetEnumerator()
         {
             return _cache.GetEnumerator();
@@ -565,7 +577,7 @@ namespace Apache.Ignite.Core.Tests.Cache
             }
             catch (AggregateException ex)
             {
-                throw ex.InnerException;
+                throw ex.InnerException ?? ex;
             }
         }
 
@@ -580,7 +592,7 @@ namespace Apache.Ignite.Core.Tests.Cache
             }
             catch (Exception ex)
             {
-                throw ex.InnerException;
+                throw ex.InnerException ?? ex;
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PartitionLossTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PartitionLossTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PartitionLossTest.cs
new file mode 100644
index 0000000..333b3f5
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PartitionLossTest.cs
@@ -0,0 +1,260 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using System.Threading;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Affinity.Rendezvous;
+    using Apache.Ignite.Core.Cache.Configuration;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Tests partition loss management functionality:
+    /// <see cref="PartitionLossPolicy"/>, <see cref="IIgnite.ResetLostPartitions(IEnumerable{string})"/>,
+    /// <see cref="ICache{TK,TV}.GetLostPartitions"/>, <see cref="ICache{TK,TV}.WithPartitionRecover"/>.
+    /// </summary>
+    public class PartitionLossTest
+    {
+        /** */
+        private const string CacheName = "lossTestCache";
+
+        /// <summary>
+        /// Fixture set up.
+        /// </summary>
+        [TestFixtureSetUp]
+        public void FixtureSetUp()
+        {
+            Ignition.Start(TestUtils.GetTestConfiguration());
+        }
+
+        /// <summary>
+        /// Fixture tear down.
+        /// </summary>
+        [TestFixtureTearDown]
+        public void FixtureTearDown()
+        {
+            Ignition.StopAll(true);
+        }
+
+        /// <summary>
+        /// Test teardown.
+        /// </summary>
+        [TearDown]
+        public void TearDown()
+        {
+            var ignite = Ignition.GetIgnite();
+
+            ignite.GetCacheNames().ToList().ForEach(ignite.DestroyCache);
+        }
+
+        /// <summary>
+        /// Tests the ReadOnlySafe mode.
+        /// </summary>
+        [Test]
+        public void TestReadOnlySafe()
+        {
+            TestPartitionLoss(PartitionLossPolicy.ReadOnlySafe, false, true);
+        }
+
+        /// <summary>
+        /// Tests the ReadWriteSafe mode.
+        /// </summary>
+        [Test]
+        public void TestReadWriteSafe()
+        {
+            TestPartitionLoss(PartitionLossPolicy.ReadWriteSafe, true, true);
+        }
+
+        /// <summary>
+        /// Tests the ReadOnlyAll mode.
+        /// </summary>
+        [Test]
+        public void TestReadOnlyAll()
+        {
+            TestPartitionLoss(PartitionLossPolicy.ReadOnlyAll, false, false);
+        }
+
+        /// <summary>
+        /// Tests the ReadWriteAll mode.
+        /// </summary>
+        [Test]
+        public void TestReadWriteAll()
+        {
+            TestPartitionLoss(PartitionLossPolicy.ReadWriteAll, true, false);
+        }
+
+        /// <summary>
+        /// Tests the Ignore mode.
+        /// </summary>
+        [Test]
+        public void TestIgnoreLoss()
+        {
+            var ignite = Ignition.GetIgnite();
+
+            var cache = CreateCache(PartitionLossPolicy.Ignore, ignite);
+
+            var lostPart = PrepareTopology();
+
+            Assert.IsEmpty(cache.GetLostPartitions());
+
+            cache[lostPart] = lostPart;
+
+            Assert.AreEqual(lostPart, cache[lostPart]);
+        }
+
+        /// <summary>
+        /// Tests the partition loss.
+        /// </summary>
+        private static void TestPartitionLoss(PartitionLossPolicy policy, bool canWrite, bool safe)
+        {
+            var ignite = Ignition.GetIgnite();
+
+            var cache = CreateCache(policy, ignite);
+
+            // Loose data and verify lost partition.
+            var lostPart = PrepareTopology();
+            var lostParts = cache.GetLostPartitions();
+            Assert.IsTrue(lostParts.Contains(lostPart));
+
+            // Check cache operations.
+            foreach (var part in lostParts)
+            {
+                VerifyCacheOperations(cache, part, canWrite, safe);
+
+                // Check recover cache.
+                var recoverCache = cache.WithPartitionRecover();
+                recoverCache[part] = part;
+                Assert.AreEqual(part, recoverCache[part]);
+            }
+
+            // Reset and verify.
+            ignite.ResetLostPartitions(CacheName);
+            Assert.IsEmpty(cache.GetLostPartitions());
+
+            // Check another ResetLostPartitions overload.
+            PrepareTopology();
+            Assert.IsNotEmpty(cache.GetLostPartitions());
+            ignite.ResetLostPartitions(new List<string> {CacheName, "foo"});
+            Assert.IsEmpty(cache.GetLostPartitions());
+        }
+
+        /// <summary>
+        /// Verifies the cache operations.
+        /// </summary>
+        private static void VerifyCacheOperations(ICache<int, int> cache, int part, bool canWrite, bool safe)
+        {
+            if (safe)
+            {
+                int val;
+                var ex = Assert.Throws<CacheException>(() => cache.TryGet(part, out val));
+                Assert.AreEqual(string.Format(
+                    "class org.apache.ignite.internal.processors.cache.CacheInvalidStateException" +
+                    ": Failed to execute cache operation (all partition owners have left the grid, " +
+                    "partition data has been lost) [cacheName={0}, part={1}," +
+                    " key=UserKeyCacheObjectImpl [part={1}, val={1}, hasValBytes=false]]",
+                    CacheName, part), ex.Message);
+            }
+            else
+            {
+                int val;
+                Assert.IsFalse(cache.TryGet(part, out val));
+            }
+
+            if (canWrite)
+            {
+                if (safe)
+                {
+                    var ex = Assert.Throws<CacheException>(() => cache.Put(part, part));
+                    Assert.AreEqual(string.Format(
+                        "class org.apache.ignite.internal.processors.cache.CacheInvalidStateException: " +
+                        "Failed to execute cache operation (all partition owners have left the grid, " +
+                        "partition data has been lost) [cacheName={0}, part={1}, key={1}]",
+                        CacheName, part), ex.Message);
+                }
+                else
+                {
+                    cache[part] = part;
+                    Assert.AreEqual(part, cache[part]);
+                }
+            }
+            else
+            {
+                var ex = Assert.Throws<CacheException>(() => cache.Put(part, part));
+                Assert.AreEqual(string.Format(
+                    "class org.apache.ignite.IgniteCheckedException: " +
+                    "Failed to write to cache (cache is moved to a read-only state): {0}",
+                    CacheName), ex.Message);
+            }
+        }
+
+        /// <summary>
+        /// Creates the cache.
+        /// </summary>
+        private static ICache<int, int> CreateCache(PartitionLossPolicy policy, IIgnite ignite)
+        {
+            return ignite.CreateCache<int, int>(new CacheConfiguration(CacheName)
+            {
+                CacheMode = CacheMode.Partitioned,
+                Backups = 0,
+                WriteSynchronizationMode = CacheWriteSynchronizationMode.FullSync,
+                PartitionLossPolicy = policy,
+                AffinityFunction = new RendezvousAffinityFunction
+                {
+                    ExcludeNeighbors = false,
+                    Partitions = 32
+                }
+            });
+        }
+
+        /// <summary>
+        /// Prepares the topology: starts a new node and stops it after rebalance to ensure data loss.
+        /// </summary>
+        /// <returns>Lost partition id.</returns>
+        private static int PrepareTopology()
+        {
+            using (var ignite = Ignition.Start(TestUtils.GetTestConfiguration(name: "ignite-2")))
+            {
+                var cache = ignite.GetCache<int, int>(CacheName);
+
+                var affinity = ignite.GetAffinity(CacheName);
+
+                var keys = Enumerable.Range(1, affinity.Partitions).ToArray();
+
+                cache.PutAll(keys.ToDictionary(x => x, x => x));
+
+                cache.Rebalance();
+
+                // Wait for rebalance to complete.
+                var node = ignite.GetCluster().GetLocalNode();
+                Func<int, bool> isPrimary = x => affinity.IsPrimary(node, x);
+
+                while (!keys.Any(isPrimary))
+                {
+                    Thread.Sleep(10);
+                }
+
+                Thread.Sleep(100);  // Some extra wait.
+
+                return keys.First(isPrimary);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index 6b94079..31dd887 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -90,7 +90,7 @@ namespace Apache.Ignite.Core.Tests
                                 <iLifecycleHandler type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+LifecycleBean' foo='15' />
                             </lifecycleHandlers>
                             <cacheConfiguration>
-                                <cacheConfiguration cacheMode='Replicated' readThrough='true' writeThrough='true' enableStatistics='true' writeBehindCoalescing='false'>
+                                <cacheConfiguration cacheMode='Replicated' readThrough='true' writeThrough='true' enableStatistics='true' writeBehindCoalescing='false' partitionLossPolicy='ReadWriteAll'>
                                     <queryEntities>    
                                         <queryEntity keyType='System.Int32' valueType='System.String' tableName='myTable'>    
                                             <fields>
@@ -175,6 +175,7 @@ namespace Apache.Ignite.Core.Tests
             Assert.IsInstanceOf<MyPolicyFactory>(cacheCfg.ExpiryPolicyFactory);
             Assert.IsTrue(cacheCfg.EnableStatistics);
             Assert.IsFalse(cacheCfg.WriteBehindCoalescing);
+            Assert.AreEqual(PartitionLossPolicy.ReadWriteAll, cacheCfg.PartitionLossPolicy);
 
             var queryEntity = cacheCfg.QueryEntities.Single();
             Assert.AreEqual(typeof(int), queryEntity.KeyType);
@@ -700,7 +701,9 @@ namespace Apache.Ignite.Core.Tests
                         PluginConfigurations = new[]
                         {
                             new MyPluginConfiguration()
-                        }
+                        },
+                        MemoryPolicyName = "somePolicy",
+                        PartitionLossPolicy = PartitionLossPolicy.ReadOnlyAll
                     }
                 },
                 ClientMode = true,

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
index 8d9a3d2..ed12efd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
@@ -336,14 +336,15 @@ namespace Apache.Ignite.Core.Tests
         /// <summary>
         /// Gets the default code-based test configuration.
         /// </summary>
-        public static IgniteConfiguration GetTestConfiguration(bool? jvmDebug = null)
+        public static IgniteConfiguration GetTestConfiguration(bool? jvmDebug = null, string name = null)
         {
             return new IgniteConfiguration
             {
                 DiscoverySpi = GetStaticDiscovery(),
                 Localhost = "127.0.0.1",
                 JvmOptions = TestJavaOptions(jvmDebug),
-                JvmClasspath = CreateTestClasspath()
+                JvmClasspath = CreateTestClasspath(),
+                IgniteInstanceName = name
             };
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 9d1f9fc..7cf79dd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -94,6 +94,7 @@
     <Compile Include="Binary\BinaryBasicNameMapper.cs" />
     <Compile Include="Cache\Configuration\DataPageEvictionMode.cs" />
     <Compile Include="Cache\Configuration\MemoryPolicyConfiguration.cs" />
+    <Compile Include="Cache\Configuration\PartitionLossPolicy.cs" />
     <Compile Include="Common\ExceptionFactory.cs" />
     <Compile Include="Events\IEventStorageSpi.cs" />
     <Compile Include="Events\MemoryEventStorageSpi.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
index 87ee255..dd50c3c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
@@ -129,6 +129,9 @@ namespace Apache.Ignite.Core.Cache.Configuration
         /// <summary> Default value for <see cref="WriteBehindCoalescing"/>. </summary>
         public const bool DefaultWriteBehindCoalescing = true;
 
+        /// <summary> Default value for <see cref="PartitionLossPolicy"/>. </summary>
+        public const PartitionLossPolicy DefaultPartitionLossPolicy = PartitionLossPolicy.Ignore;
+
         /// <summary>
         /// Gets or sets the cache name.
         /// </summary>
@@ -173,6 +176,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
             WriteBehindFlushSize = DefaultWriteBehindFlushSize;
             WriteBehindFlushThreadCount= DefaultWriteBehindFlushThreadCount;
             WriteBehindCoalescing = DefaultWriteBehindCoalescing;
+            PartitionLossPolicy = DefaultPartitionLossPolicy;
         }
 
         /// <summary>
@@ -239,6 +243,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
             WriteThrough = reader.ReadBoolean();
             EnableStatistics = reader.ReadBoolean();
             MemoryPolicyName = reader.ReadString();
+            PartitionLossPolicy = (PartitionLossPolicy) reader.ReadInt();
             CacheStoreFactory = reader.ReadObject<IFactory<ICacheStore>>();
 
             var count = reader.ReadInt();
@@ -296,6 +301,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
             writer.WriteBoolean(WriteThrough);
             writer.WriteBoolean(EnableStatistics);
             writer.WriteString(MemoryPolicyName);
+            writer.WriteInt((int) PartitionLossPolicy);
             writer.WriteObject(CacheStoreFactory);
 
             if (QueryEntities != null)
@@ -645,5 +651,12 @@ namespace Apache.Ignite.Core.Cache.Configuration
         /// </summary>
         [DefaultValue(DefaultWriteBehindCoalescing)]
         public bool WriteBehindCoalescing { get; set; }
+
+        /// <summary>
+        /// Gets or sets the partition loss policy. This policy defines how Ignite will react to
+        /// a situation when all nodes for some partition leave the cluster.
+        /// </summary>
+        [DefaultValue(DefaultPartitionLossPolicy)]
+        public PartitionLossPolicy PartitionLossPolicy { get; set; }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/PartitionLossPolicy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/PartitionLossPolicy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/PartitionLossPolicy.cs
new file mode 100644
index 0000000..0bea06f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/PartitionLossPolicy.cs
@@ -0,0 +1,68 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Partition loss policy. Defines how cache will behave in a case when one or more partitions are
+    /// lost because of a node(s) failure.
+    /// <para />
+    /// All *Safe policies prevent a user from interaction with partial data in lost partitions until 
+    /// <see cref="IIgnite.ResetLostPartitions(IEnumerable{string})"/> method is called.
+    /// <para />
+    /// *All policies allow working with partial data in lost partitions.
+    /// <para />
+    /// ReadOnly* and ReadWrite* policies do not automatically change partition state and thus do not change
+    /// rebalancing assignments for such partitions.
+    /// </summary>
+    public enum PartitionLossPolicy
+    {
+        /// <summary>
+        /// All writes to the cache will be failed with an exception, reads will only be allowed for keys in
+        /// non-lost partitions. Reads from lost partitions will be failed with an exception.
+        /// </summary>
+        ReadOnlySafe,
+
+        /// <summary>
+        /// All writes to the cache will be failed with an exception. All reads will proceed as if all partitions
+        /// were in a consistent state. The result of reading from a lost partition is undefined and may be different
+        /// on different nodes in the cluster.
+        /// </summary>
+        ReadOnlyAll,
+
+        /// <summary>
+        /// All reads and writes will be allowed for keys in valid partitions. All reads and writes for keys
+        /// in lost partitions will be failed with an exception.
+        /// </summary>
+        ReadWriteSafe,
+
+        /// <summary>
+        /// All reads and writes will proceed as if all partitions were in a consistent state. The result of
+        /// reading from a lost partition is undefined and may be different on different nodes in the cluster.
+        /// </summary>
+        ReadWriteAll,
+
+        /// <summary>
+        /// If partition is lost, reset it's state and do not clear intermediate data. The result of reading from
+        /// a previously lost and not cleared partition is undefined and may be different on different nodes in the
+        /// cluster.
+        /// </summary>
+        Ignore
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
index b7cb0d5..8c7fcf9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
@@ -883,5 +883,20 @@ namespace Apache.Ignite.Core.Cache
         /// </summary>
         /// <returns>Cache with no-retries behavior enabled.</returns>
         ICache<TK, TV> WithNoRetries();
+
+        /// <summary>
+        /// Gets an instance of cache that will be allowed to execute cache operations (read, write)
+        /// regardless of partition loss policy.
+        /// </summary>
+        /// <returns>Cache without partition loss protection.</returns>
+        ICache<TK, TV> WithPartitionRecover();
+
+        /// <summary>
+        /// Gets lost partitions IDs.
+        /// <para />
+        /// See also <see cref="CacheConfiguration.PartitionLossPolicy"/>
+        /// and <see cref="IIgnite.ResetLostPartitions(IEnumerable{string})"/>.
+        /// </summary>
+        ICollection<int> GetLostPartitions();
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
index 2996039..573cfb3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
@@ -317,5 +317,17 @@ namespace Apache.Ignite.Core
         /// <exception cref="PluginNotFoundException">When plugin with specified name has not been found.</exception>
         /// <returns>Plugin instance.</returns>
         T GetPlugin<T>(string name) where T : class;
+
+        /// <summary>
+        /// Clears partitions' lost state and moves caches to a normal mode.
+        /// </summary>
+        /// <param name="cacheNames">Names of caches to reset partitions for.</param>
+        void ResetLostPartitions(IEnumerable<string> cacheNames);
+
+        /// <summary>
+        /// Clears partitions' lost state and moves caches to a normal mode.
+        /// </summary>
+        /// <param name="cacheNames">Names of caches to reset partitions for.</param>
+        void ResetLostPartitions(params string[] cacheNames);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
index 8b07147..67f2715 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -86,6 +86,16 @@
         </xs:restriction>
     </xs:simpleType>
 
+    <xs:simpleType name="partitionLossPolicy" final="restriction">
+        <xs:restriction base="xs:string">
+            <xs:enumeration value="ReadOnlySafe" />
+            <xs:enumeration value="ReadOnlyAll" />
+            <xs:enumeration value="ReadWriteSafe" />
+            <xs:enumeration value="ReadWriteAll" />
+            <xs:enumeration value="Ignore" />
+        </xs:restriction>
+    </xs:simpleType>
+
     <xs:element name="igniteConfiguration">
         <xs:annotation>
             <xs:documentation>Ignite configuration root.</xs:documentation>
@@ -717,6 +727,11 @@
                                             <xs:documentation>Name of the MemoryPolicyConfiguration for this cache.</xs:documentation>
                                         </xs:annotation>
                                     </xs:attribute>
+                                    <xs:attribute name="partitionLossPolicy" type="partitionLossPolicy">
+                                        <xs:annotation>
+                                            <xs:documentation>Partition loss policy defines how Ignite will react to a situation when all nodes for some partition leave the cluster.</xs:documentation>
+                                        </xs:annotation>
+                                    </xs:attribute>
                                 </xs:complexType>
                             </xs:element>
                         </xs:sequence>

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index 6009659..749409c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -58,6 +58,9 @@ namespace Apache.Ignite.Core.Impl.Cache
         /** Flag: no-retries.*/
         private readonly bool _flagNoRetries;
 
+        /** Flag: partition recover.*/
+        private readonly bool _flagPartitionRecover;
+
         /** Transaction manager. */
         private readonly CacheTransactionManager _txManager;
 
@@ -70,8 +73,10 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// <param name="flagSkipStore">Skip store flag.</param>
         /// <param name="flagKeepBinary">Keep binary flag.</param>
         /// <param name="flagNoRetries">No-retries mode flag.</param>
+        /// <param name="flagPartitionRecover">Partition recover mode flag.</param>
         public CacheImpl(Ignite grid, IUnmanagedTarget target, Marshaller marsh,
-            bool flagSkipStore, bool flagKeepBinary, bool flagNoRetries) : base(target, marsh)
+            bool flagSkipStore, bool flagKeepBinary, bool flagNoRetries, bool flagPartitionRecover)
+            : base(target, marsh)
         {
             Debug.Assert(grid != null);
 
@@ -79,6 +84,7 @@ namespace Apache.Ignite.Core.Impl.Cache
             _flagSkipStore = flagSkipStore;
             _flagKeepBinary = flagKeepBinary;
             _flagNoRetries = flagNoRetries;
+            _flagPartitionRecover = flagPartitionRecover;
 
             _txManager = GetConfiguration().AtomicityMode == CacheAtomicityMode.Transactional
                 ? new CacheTransactionManager(grid.GetTransactions())
@@ -167,7 +173,7 @@ namespace Apache.Ignite.Core.Impl.Cache
                 return this;
 
             return new CacheImpl<TK, TV>(_ignite, DoOutOpObject((int) CacheOp.WithSkipStore), Marshaller,
-                true, _flagKeepBinary, true);
+                true, _flagKeepBinary, true, _flagPartitionRecover);
         }
 
         /// <summary>
@@ -191,7 +197,7 @@ namespace Apache.Ignite.Core.Impl.Cache
             }
 
             return new CacheImpl<TK1, TV1>(_ignite, DoOutOpObject((int) CacheOp.WithKeepBinary), Marshaller,
-                _flagSkipStore, true, _flagNoRetries);
+                _flagSkipStore, true, _flagNoRetries, _flagPartitionRecover);
         }
 
         /** <inheritDoc /> */
@@ -201,7 +207,8 @@ namespace Apache.Ignite.Core.Impl.Cache
 
             var cache0 = DoOutOpObject((int)CacheOp.WithExpiryPolicy, w => ExpiryPolicySerializer.WritePolicy(w, plc));
 
-            return new CacheImpl<TK, TV>(_ignite, cache0, Marshaller, _flagSkipStore, _flagKeepBinary, _flagNoRetries);
+            return new CacheImpl<TK, TV>(_ignite, cache0, Marshaller, _flagSkipStore, _flagKeepBinary, 
+                _flagNoRetries, _flagPartitionRecover);
         }
 
         /** <inheritDoc /> */
@@ -1005,7 +1012,38 @@ namespace Apache.Ignite.Core.Impl.Cache
                 return this;
 
             return new CacheImpl<TK, TV>(_ignite, DoOutOpObject((int) CacheOp.WithNoRetries), Marshaller,
-                _flagSkipStore, _flagKeepBinary, true);
+                _flagSkipStore, _flagKeepBinary, true, _flagPartitionRecover);
+        }
+
+        /** <inheritDoc /> */
+        public ICache<TK, TV> WithPartitionRecover()
+        {
+            if (_flagPartitionRecover)
+                return this;
+
+            return new CacheImpl<TK, TV>(_ignite, DoOutOpObject((int) CacheOp.WithPartitionRecover), Marshaller,
+                _flagSkipStore, _flagKeepBinary, _flagNoRetries, true);
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<int> GetLostPartitions()
+        {
+            return DoInOp((int) CacheOp.GetLostPartitions, s =>
+            {
+                var cnt = s.ReadInt();
+
+                var res = new List<int>(cnt);
+
+                if (cnt > 0)
+                {
+                    for (var i = 0; i < cnt; i++)
+                    {
+                        res.Add(s.ReadInt());
+                    }
+                }
+
+                return res;
+            });
         }
 
         #region Queries

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
index 51fef40..b3cbd95 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
@@ -62,7 +62,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         GetConfig = 39,
         LoadAll = 40,
         ClearCache = 41,
-        WithAsync = 42,
+        WithPartitionRecover = 42,
         RemoveAll2 = 43,
         WithKeepBinary = 44,
         WithExpiryPolicy = 45,
@@ -103,6 +103,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         InvokeAllAsync = 80,
         PutIfAbsentAsync = 81,
         Extension = 82,
-        GlobalMetrics = 83
+        GlobalMetrics = 83,
+        GetLostPartitions = 84
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
index 641b6b4..7e97852 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
@@ -115,6 +115,9 @@ namespace Apache.Ignite.Core.Impl.Cluster
         /** */
         private const int OpCacheMetrics = 24;
         
+        /** */
+        private const int OpResetLostPartitions = 25;
+        
         /** Initial Ignite instance. */
         private readonly Ignite _ignite;
         
@@ -511,6 +514,30 @@ namespace Apache.Ignite.Core.Impl.Cluster
         }
 
         /// <summary>
+        /// Resets the lost partitions.
+        /// </summary>
+        public void ResetLostPartitions(IEnumerable<string> cacheNames)
+        {
+            IgniteArgumentCheck.NotNull(cacheNames, "cacheNames");
+
+            DoOutOp(OpResetLostPartitions, w =>
+            {
+                var pos = w.Stream.Position;
+
+                var count = 0;
+                w.WriteInt(count);  // Reserve space.
+
+                foreach (var cacheName in cacheNames)
+                {
+                    w.WriteString(cacheName);
+                    count++;
+                }
+
+                w.Stream.WriteInt(pos, count);
+            });
+        }
+
+        /// <summary>
         /// Gets the cache metrics within this cluster group.
         /// </summary>
         /// <param name="cacheName">Name of the cache.</param>

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
index 0407b62..4eebbf9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
@@ -504,6 +504,7 @@ namespace Apache.Ignite.Core.Impl.Common
         /// <param name="type">The type.</param>
         /// <param name="types">The argument types.</param>
         /// <returns>Constructor info.</returns>
+        [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods")]
         public static ConstructorInfo GetConstructorExact(Type type, Type[] types)
         {
             Debug.Assert(type != null);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad7e4a09/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index 9cd1aa5..a795459 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -484,7 +484,7 @@ namespace Apache.Ignite.Core.Impl
         /// </returns>
         public ICache<TK, TV> Cache<TK, TV>(IUnmanagedTarget nativeCache, bool keepBinary = false)
         {
-            return new CacheImpl<TK, TV>(this, nativeCache, _marsh, false, keepBinary, false);
+            return new CacheImpl<TK, TV>(this, nativeCache, _marsh, false, keepBinary, false, false);
         }
 
         /** <inheritdoc /> */
@@ -703,6 +703,20 @@ namespace Apache.Ignite.Core.Impl
             return PluginProcessor.GetProvider(name).GetPlugin<T>();
         }
 
+        /** <inheritdoc /> */
+        public void ResetLostPartitions(IEnumerable<string> cacheNames)
+        {
+            IgniteArgumentCheck.NotNull(cacheNames, "cacheNames");
+
+            _prj.ResetLostPartitions(cacheNames);
+        }
+
+        /** <inheritdoc /> */
+        public void ResetLostPartitions(params string[] cacheNames)
+        {
+            ResetLostPartitions((IEnumerable<string>) cacheNames);
+        }
+
         /// <summary>
         /// Gets or creates near cache.
         /// </summary>


[56/65] [abbrv] ignite git commit: ignite-2.0 - Fixed NPE

Posted by ag...@apache.org.
ignite-2.0 - Fixed NPE


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

Branch: refs/heads/ignite-5024
Commit: a4d91484384ff2e0323fa9375083621e87d2f5e2
Parents: 32379ee
Author: Alexander Paschenko <al...@gmail.com>
Authored: Fri Apr 21 18:41:27 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Apr 21 18:41:27 2017 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/query/GridQueryProcessor.java   | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d91484/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 0ac55e6..015646d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -1272,7 +1272,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     private void registerCache0(String space, GridCacheContext<?, ?> cctx, Collection<QueryTypeCandidate> cands)
         throws IgniteCheckedException {
         synchronized (stateMux) {
-            idx.registerCache(space, cctx, cctx.config());
+            if (idx != null)
+                idx.registerCache(space, cctx, cctx.config());
 
             try {
                 for (QueryTypeCandidate cand : cands) {
@@ -1301,7 +1302,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                         }
                     }
 
-                    idx.registerType(space, desc);
+                    if (idx != null)
+                        idx.registerType(space, desc);
                 }
 
                 spaces.add(CU.mask(space));


[17/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
new file mode 100644
index 0000000..00bf915
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+/**
+ * Identity value mapper.
+ */
+public class IdentityValueMapper implements ValueMapper<Double> {
+    /** */ private static final long serialVersionUID = -8010078306142216389L;
+
+    /** {@inheritDoc} */
+    @Override public Double fromDouble(double v) {
+        return v;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double toDouble(Double v) {
+        assert v != null;
+
+        return v;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        return Long.hashCode(serialVersionUID);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/KeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/KeyMapper.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/KeyMapper.java
new file mode 100644
index 0000000..1ac2f3d
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/KeyMapper.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import java.io.Serializable;
+
+/**
+ * Maps key objects to index in {@link Vector} or {@link Matrix}.
+ */
+public interface KeyMapper<K> extends Serializable {
+    /**
+     * Checks given cache key corresponds to a valid index in vector or matrix.
+     *
+     * @param k Key to check.
+     * @return {@code true} if there is a valid index, {@code false} otherwise.
+     */
+    public boolean isValid(K k);
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
new file mode 100644
index 0000000..1039484
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
@@ -0,0 +1,518 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import java.io.Externalizable;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.ml.math.exceptions.CardinalityException;
+import org.apache.ignite.ml.math.exceptions.IndexException;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.IgniteBiFunction;
+import org.apache.ignite.ml.math.functions.IgniteDoubleFunction;
+import org.apache.ignite.ml.math.functions.IgniteFunction;
+import org.apache.ignite.ml.math.functions.IntIntToDoubleFunction;
+
+/**
+ * A matrix interface.
+ *
+ * Based on its flavor it can have vastly different implementations tailored for
+ * for different types of data (e.g. dense vs. sparse), different sizes of data or different operation
+ * optimizations.
+ *
+ * Note also that not all operations can be supported by all underlying implementations. If an operation is not
+ * supported a {@link UnsupportedOperationException} is thrown. This exception can also be thrown in partial cases
+ * where an operation is unsupported only in special cases, e.g. where a given operation cannot be deterministically
+ * completed in polynomial time.
+ *
+ * Based on ideas from <a href="http://mahout.apache.org/">Apache Mahout</a>.
+ */
+public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetrics, Destroyable {
+    /**
+     * Holder for matrix's element.
+     */
+    interface Element {
+        /**
+         * Gets element's value.
+         *
+         * @return The value of this matrix element.
+         */
+        double get();
+
+        /**
+         * Gets element's row index.
+         *
+         * @return The row index of this element.
+         */
+        int row();
+
+        /**
+         * Gets element's column index.
+         *
+         * @return The column index of this element.
+         */
+        int column();
+
+        /**
+         * Sets element's value.
+         *
+         * @param val Value to set.
+         */
+        void set(double val);
+    }
+
+    /**
+     * Gets the maximum value in this matrix.
+     *
+     * @return Maximum value in this matrix.
+     */
+    public double maxValue();
+
+    /**
+     * Gets the minimum value in this matrix.
+     *
+     * @return Minimum value in this matrix.
+     */
+    public double minValue();
+
+    /**
+     * Gets the maximum element in this matrix.
+     *
+     * @return Maximum element in this matrix.
+     */
+    public Element maxElement();
+
+    /**
+     * Gets the minimum element in this matrix.
+     *
+     * @return Minimum element in this matrix.
+     */
+    public Element minElement();
+
+    /**
+     * Gets the matrix's element at the given coordinates.
+     *
+     * @param row Row index.
+     * @param col Column index.
+     * @return Element at the given coordinates.
+     */
+    public Element getElement(int row, int col);
+
+    /**
+     * Swaps two rows in this matrix.
+     *
+     * @param row1 Row #1.
+     * @param row2 Row #2.
+     * @return This matrix.
+     */
+    public Matrix swapRows(int row1, int row2);
+
+    /**
+     * Swaps two columns in this matrix.
+     *
+     * @param col1 Column #1.
+     * @param col2 Column #2.
+     * @return This matrix.
+     */
+    public Matrix swapColumns(int col1, int col2);
+
+    /**
+     * Assigns given value to all elements of this matrix.
+     *
+     * @param val Value to assign to all elements.
+     * @return This matrix.
+     */
+    public Matrix assign(double val);
+
+    /**
+     * Assigns given values to this matrix.
+     *
+     * @param vals Values to assign.
+     * @return This matrix.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix assign(double[][] vals);
+
+    /**
+     * Assigns values from given matrix to this matrix.
+     *
+     * @param mtx Matrix to assign to this matrix.
+     * @return This matrix.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix assign(Matrix mtx);
+
+    /**
+     * Assigns each matrix element to the value generated by given function.
+     *
+     * @param fun Function that takes the row and column and returns the value to assign.
+     * @return This matrix.
+     */
+    public Matrix assign(IntIntToDoubleFunction fun);
+
+    /**
+     * Maps all values in this matrix through a given function.
+     *
+     * @param fun Mapping function.
+     * @return This matrix.
+     */
+    public Matrix map(IgniteDoubleFunction<Double> fun);
+
+    /**
+     * Maps all values in this matrix through a given function.
+     *
+     * For this matrix <code>A</code>, argument matrix <code>B</code> and the
+     * function <code>F</code> this method maps every cell <code>x, y</code> as:
+     * <code>A(x,y) = fun(A(x,y), B(x,y))</code>
+     *
+     * @param mtx Argument matrix.
+     * @param fun Mapping function.
+     * @return This function.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix map(Matrix mtx, IgniteBiFunction<Double, Double, Double> fun);
+
+    /**
+     * Assigns values from given vector to the specified column in this matrix.
+     *
+     * @param col Column index.
+     * @param vec Vector to get values from.
+     * @return This matrix.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix assignColumn(int col, Vector vec);
+
+    /**
+     * Assigns values from given vector to the specified row in this matrix.
+     *
+     * @param row Row index.
+     * @param vec Vector to get values from.
+     * @return This matrix.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix assignRow(int row, Vector vec);
+
+    /**
+     * Collects the results of applying a given function to all rows in this matrix.
+     *
+     * @param fun Aggregating function.
+     * @return Vector of row aggregates.
+     */
+    public Vector foldRows(IgniteFunction<Vector, Double> fun);
+
+    /**
+     * Collects the results of applying a given function to all columns in this matrix.
+     *
+     * @param fun Aggregating function.
+     * @return Vector of column aggregates.
+     */
+    public Vector foldColumns(IgniteFunction<Vector, Double> fun);
+
+    /**
+     * Folds this matrix into a single value.
+     *
+     * @param foldFun Folding function that takes two parameters: accumulator and the current value.
+     * @param mapFun Mapping function that is called on each matrix cell before its passed to the accumulator (as its
+     * second parameter).
+     * @param <T> Type of the folded value.
+     * @param zeroVal Zero value for fold function.
+     * @return Folded value of this matrix.
+     */
+    public <T> T foldMap(IgniteBiFunction<T, Double, T> foldFun, IgniteDoubleFunction<Double> mapFun, T zeroVal);
+
+    /**
+     * Calculates the density of the matrix based on supplied criteria.
+     * Returns {@code true} if this matrix is denser than threshold with at least 80% confidence.
+     *
+     * @param threshold the threshold value [0, 1] of non-zero elements above which the matrix is considered dense.
+     */
+    public boolean density(double threshold);
+
+    /**
+     * Gets number of columns in this matrix.
+     *
+     * @return The number of columns in this matrix.
+     */
+    public int columnSize();
+
+    /**
+     * Gets number of rows in this matrix.
+     *
+     * @return The number of rows in this matrix.
+     */
+    public int rowSize();
+
+    /**
+     * Returns matrix determinant using Laplace theorem.
+     *
+     * @return A determinant for this matrix.
+     * @throws CardinalityException Thrown if matrix is not square.
+     */
+    public double determinant();
+
+    /**
+     * Returns the inverse matrix of this matrix
+     *
+     * @return Inverse of this matrix
+     */
+    public Matrix inverse();
+
+    /**
+     * Divides each value in this matrix by the argument.
+     *
+     * @param x Divider value.
+     * @return This matrix.
+     */
+    public Matrix divide(double x);
+
+    /**
+     * Gets the matrix value at the provided location.
+     *
+     * @param row Row index.
+     * @param col Column index.
+     * @return Matrix value.
+     * @throws IndexException Thrown in case of index is out of bound.
+     */
+    public double get(int row, int col);
+
+    /**
+     * Gets the matrix value at the provided location without checking boundaries.
+     * This method is marginally quicker than its {@link #get(int, int)} sibling.
+     *
+     * @param row Row index.
+     * @param col Column index.
+     * @return Matrix value.
+     */
+    public double getX(int row, int col);
+
+    /**
+     * Gets matrix storage model.
+     */
+    public MatrixStorage getStorage();
+
+    /**
+     * Clones this matrix.
+     *
+     * NOTE: new matrix will have the same flavor as the this matrix but a different ID.
+     *
+     * @return New matrix of the same underlying class, the same size and the same values.
+     */
+    public Matrix copy();
+
+    /**
+     * Creates new empty matrix of the same underlying class but of different size.
+     *
+     * NOTE: new matrix will have the same flavor as the this matrix but a different ID.
+     *
+     * @param rows Number of rows for new matrix.
+     * @param cols Number of columns for new matrix.
+     * @return New matrix of the same underlying class and size.
+     */
+    public Matrix like(int rows, int cols);
+
+    /**
+     * Creates new empty vector of compatible properties (similar or the same flavor) to this matrix.
+     *
+     * @param crd Cardinality of the vector.
+     * @return Newly created empty vector "compatible" to this matrix.
+     */
+    public Vector likeVector(int crd);
+
+    /**
+     * Creates new matrix where each value is a difference between corresponding value of this matrix and
+     * passed in argument matrix.
+     *
+     * @param mtx Argument matrix.
+     * @return New matrix of the same underlying class and size.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix minus(Matrix mtx);
+
+    /**
+     * Creates new matrix where each value is a sum of the corresponding value of this matrix and
+     * argument value.
+     *
+     * @param x Value to add.
+     * @return New matrix of the same underlying class and size.
+     */
+    public Matrix plus(double x);
+
+    /**
+     * Creates new matrix where each value is a sum of corresponding values of this matrix and
+     * passed in argument matrix.
+     *
+     * @param mtx Argument matrix.
+     * @return New matrix of the same underlying class and size.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix plus(Matrix mtx);
+
+    /**
+     * Auto-generated globally unique matrix ID.
+     *
+     * @return Matrix GUID.
+     */
+    public IgniteUuid guid();
+
+    /**
+     * Sets given value.
+     *
+     * @param row Row index.
+     * @param col Column index.
+     * @param val Value to set.
+     * @return This matrix.
+     * @throws IndexException Thrown in case of either index is out of bound.
+     */
+    public Matrix set(int row, int col, double val);
+
+    /**
+     * Sets values for given row.
+     *
+     * @param row Row index.
+     * @param data Row data to set.
+     * @return This matrix.
+     * @throws IndexException Thrown in case of index is out of bound.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix setRow(int row, double[] data);
+
+    /**
+     * Sets values for given column.
+     *
+     * @param col Column index.
+     * @param data Column data to set.
+     * @return This matrix.
+     * @throws IndexException Thrown in case of index is out of bound.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix setColumn(int col, double[] data);
+
+    /**
+     * Sets given value without checking for index bounds. This method is marginally faster
+     * than its {@link #set(int, int, double)} sibling.
+     *
+     * @param row Row index.
+     * @param col Column index.
+     * @param val Value to set.
+     * @return This matrix.
+     */
+    public Matrix setX(int row, int col, double val);
+
+    /**
+     * Creates new matrix containing the product of given value and values in this matrix.
+     *
+     * @param x Value to multiply.
+     * @return New matrix.
+     */
+    public Matrix times(double x);
+
+    /**
+     * Creates new matrix that is the product of multiplying this matrix and the argument matrix.
+     *
+     * @param mtx Argument matrix.
+     * @return New matrix.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix times(Matrix mtx);
+
+    /**
+     * Creates new matrix that is the product of multiplying this matrix and the argument vector.
+     *
+     * @param vec Argument vector.
+     * @return New matrix.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Vector times(Vector vec);
+
+    /**
+     * Gets maximum absolute row sum norm of this matrix.
+     * See http://mathworld.wolfram.com/MaximumAbsoluteRowSumNorm.html
+     *
+     * @return Maximum absolute row sum norm of this matrix.
+     */
+    public double maxAbsRowSumNorm();
+
+    /**
+     * Gets sum of all elements in the matrix.
+     *
+     * @return Sum of all elements in this matrix.
+     */
+    public double sum();
+
+    /**
+     * Creates new matrix that is transpose of this matrix.
+     *
+     * @return New transposed matrix.
+     */
+    public Matrix transpose();
+
+    /**
+     * Creates new view into this matrix. Changes to the view will be propagated to this matrix.
+     *
+     * @param off View offset as <code>int[x,y]</code>.
+     * @param size View size as <code>int[rows, cols]</code>
+     * @return New view.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     * @throws IndexException Thrown in case of offset is out of bound.
+     */
+    public Matrix viewPart(int[] off, int[] size);
+
+    /**
+     * Creates new view into this matrix. Changes to the view will be propagated to this matrix.
+     *
+     * @param rowOff
+     * @param rows
+     * @param colOff
+     * @param cols
+     * @return New view.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     * @throws IndexException Thrown in case of offset is out of bound.
+     */
+    public Matrix viewPart(int rowOff, int rows, int colOff, int cols);
+
+    /**
+     * Creates new view into matrix row. Changes to the view will be propagated to this matrix.
+     *
+     * @param row Row index.
+     * @return New view.
+     * @throws IndexException Thrown in case of index is out of bound.
+     */
+    public Vector viewRow(int row);
+
+    /**
+     * Creates new view into matrix column . Changes to the view will be propagated to this matrix.
+     *
+     * @param col Column index.
+     * @return New view.
+     * @throws IndexException Thrown in case of index is out of bound.
+     */
+    public Vector viewColumn(int col);
+
+    /**
+     * Creates new view into matrix diagonal. Changes to the view will be propagated to this matrix.
+     *
+     * @return New view.
+     */
+    public Vector viewDiagonal();
+
+    /**
+     * Destroys matrix if managed outside of JVM. It's a no-op in all other cases.
+     */
+    public default void destroy() {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/MatrixKeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/MatrixKeyMapper.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/MatrixKeyMapper.java
new file mode 100644
index 0000000..54d2088
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/MatrixKeyMapper.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+/**
+ * Maps {@link Matrix} row and column index to cache key.
+ */
+public interface MatrixKeyMapper<K> extends KeyMapper<K> {
+    /**
+     * @param x Matrix row index.
+     * @param y Matrix column index.
+     * @return Cache key for given row and column.
+     */
+    public K apply(int x, int y);
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/MatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/MatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/MatrixStorage.java
new file mode 100644
index 0000000..ccfebe5
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/MatrixStorage.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import java.io.Externalizable;
+
+/**
+ * Data storage support for {@link Matrix}.
+ */
+public interface MatrixStorage extends Externalizable, StorageOpsMetrics, Destroyable {
+    /**
+     * @param x Matrix row index.
+     * @param y Matrix column index.
+     * @return Value corresponding to given row and column.
+     */
+    public double get(int x, int y);
+
+    /**
+     * @param x Matrix row index.
+     * @param y Matrix column index.
+     * @param v Value to set at given row and column.
+     */
+    public void set(int x, int y, double v);
+
+    /**
+     *
+     */
+    public int columnSize();
+
+    /**
+     *
+     */
+    public int rowSize();
+
+    /**
+     * Gets underlying array if {@link StorageOpsMetrics#isArrayBased()} returns {@code true}.
+     *
+     * @see StorageOpsMetrics#isArrayBased()
+     */
+    default public double[][] data() {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/MetaAttributes.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/MetaAttributes.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/MetaAttributes.java
new file mode 100644
index 0000000..8befc6a
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/MetaAttributes.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import java.util.Map;
+
+/**
+ * Interface provides support for meta attributes on vectors and matrices.
+ */
+public interface MetaAttributes {
+    /**
+     * Implementation should return an instance of the map to store meta attributes.
+     */
+    public Map<String, Object> getMetaStorage();
+
+    /**
+     * Gets meta attribute with given name.
+     *
+     * @param name Name of the vector meta attribute to get.
+     * @param <T> Attribute's type.
+     */
+    @SuppressWarnings("unchecked")
+    public default <T> T getAttribute(String name) {
+        return (T)getMetaStorage().get(name);
+    }
+
+    /**
+     * Sets meta attribute with given name and value.
+     *
+     * @param name Name of the meta attribute.
+     * @param val Attribute value.
+     * @param <T> Attribute's type.
+     */
+    public default <T> void setAttribute(String name, T val) {
+        getMetaStorage().put(name, val);
+    }
+
+    /**
+     * Removes meta attribute with given name.
+     *
+     * @param name Name of the meta attribute.
+     * @return {@code true} if attribute was present and was removed, {@code false} otherwise.
+     */
+    public default boolean removeAttribute(String name) {
+        boolean is = getMetaStorage().containsKey(name);
+
+        if (is)
+            getMetaStorage().remove(name);
+
+        return is;
+    }
+
+    /**
+     * Checks if given meta attribute is present.
+     *
+     * @param name Attribute name to check.
+     */
+    public default boolean hasAttribute(String name) {
+        return getMetaStorage().containsKey(name);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
new file mode 100644
index 0000000..0cbcbdf
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * This is a very fast, non-cryptographic hash suitable for general hash-based lookup.
+ *
+ * See http://murmurhash.googlepages.com/ for mre details.
+ */
+public class MurmurHash {
+    /** Hide it. */
+    private MurmurHash() {
+    }
+
+    /**
+     * This produces exactly the same hash values as the final C+ version of MurmurHash3 and is
+     * thus suitable for producing the same hash values across platforms.
+     *
+     * The 32 bit x86 version of this hash should be the fastest variant for relatively short keys like IDs.
+     *
+     * Note - The x86 and x64 versions do _not_ produce the same results, as the algorithms are
+     * optimized for their respective platforms.
+     *
+     * See also http://github.com/yonik/java_util for future updates to this method.
+     *
+     * @param data
+     * @param off
+     * @param len
+     * @param seed
+     * @return 32 bit hash platform compatible with C++ MurmurHash3 implementation on x86.
+     */
+    public static int hash3X86(byte[] data, int off, int len, int seed) {
+        int c1 = 0xcc9e2d51;
+        int c2 = 0x1b873593;
+
+        int h1 = seed;
+        int roundedEnd = off + (len & 0xfffffffc);  // Round down to 4 byte block.
+
+        for (int i = off; i < roundedEnd; i += 4) {
+            int k1 = (data[i] & 0xff) | ((data[i + 1] & 0xff) << 8) | ((data[i + 2] & 0xff) << 16) | (data[i + 3] << 24);
+
+            k1 *= c1;
+            k1 = (k1 << 15) | (k1 >>> 17);
+            k1 *= c2;
+
+            h1 ^= k1;
+            h1 = (h1 << 13) | (h1 >>> 19);
+            h1 = h1 * 5 + 0xe6546b64;
+        }
+
+        // Tail.
+        int k1 = 0;
+
+        switch (len & 0x03) {
+            case 3:
+                k1 = (data[roundedEnd + 2] & 0xff) << 16;
+                // Fallthrough - WTF?
+            case 2:
+                k1 |= (data[roundedEnd + 1] & 0xff) << 8;
+                // Fallthrough - WTF?
+            case 1:
+                k1 |= data[roundedEnd] & 0xff;
+                k1 *= c1;
+                k1 = (k1 << 15) | (k1 >>> 17);
+                k1 *= c2;
+                h1 ^= k1;
+            default:
+        }
+
+        // Finalization.
+        h1 ^= len;
+
+        h1 ^= h1 >>> 16;
+        h1 *= 0x85ebca6b;
+        h1 ^= h1 >>> 13;
+        h1 *= 0xc2b2ae35;
+        h1 ^= h1 >>> 16;
+
+        return h1;
+    }
+
+    /**
+     * Hashes an int.
+     *
+     * @param data The int to hash.
+     * @param seed The seed for the hash.
+     * @return The 32 bit hash of the bytes in question.
+     */
+    public static int hash(int data, int seed) {
+        byte[] arr = new byte[] {
+            (byte)(data >>> 24),
+            (byte)(data >>> 16),
+            (byte)(data >>> 8),
+            (byte)data
+        };
+
+        return hash(ByteBuffer.wrap(arr), seed);
+    }
+
+    /**
+     * Hashes bytes in an array.
+     *
+     * @param data The bytes to hash.
+     * @param seed The seed for the hash.
+     * @return The 32 bit hash of the bytes in question.
+     */
+    public static int hash(byte[] data, int seed) {
+        return hash(ByteBuffer.wrap(data), seed);
+    }
+
+    /**
+     * Hashes bytes in part of an array.
+     *
+     * @param data The data to hash.
+     * @param off Where to start munging.
+     * @param len How many bytes to process.
+     * @param seed The seed to start with.
+     * @return The 32-bit hash of the data in question.
+     */
+    public static int hash(byte[] data, int off, int len, int seed) {
+        return hash(ByteBuffer.wrap(data, off, len), seed);
+    }
+
+    /**
+     * Hashes the bytes in a buffer from the current position to the limit.
+     *
+     * @param buf The bytes to hash.
+     * @param seed The seed for the hash.
+     * @return The 32 bit murmur hash of the bytes in the buffer.
+     */
+    public static int hash(ByteBuffer buf, int seed) {
+        ByteOrder byteOrder = buf.order();
+        buf.order(ByteOrder.LITTLE_ENDIAN);
+
+        int m = 0x5bd1e995;
+        int r = 24;
+
+        int h = seed ^ buf.remaining();
+
+        while (buf.remaining() >= 4) {
+            int k = buf.getInt();
+
+            k *= m;
+            k ^= k >>> r;
+            k *= m;
+
+            h *= m;
+            h ^= k;
+        }
+
+        if (buf.remaining() > 0) {
+            ByteBuffer finish = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN);
+
+            finish.put(buf).rewind();
+
+            h ^= finish.getInt();
+            h *= m;
+        }
+
+        h ^= h >>> 13;
+        h *= m;
+        h ^= h >>> 15;
+
+        buf.order(byteOrder);
+
+        return h;
+    }
+
+    /**
+     * @param data
+     * @param seed
+     */
+    public static long hash64A(byte[] data, int seed) {
+        return hash64A(ByteBuffer.wrap(data), seed);
+    }
+
+    /**
+     * @param data
+     * @param off
+     * @param len
+     * @param seed
+     */
+    public static long hash64A(byte[] data, int off, int len, int seed) {
+        return hash64A(ByteBuffer.wrap(data, off, len), seed);
+    }
+
+    /**
+     * @param buf
+     * @param seed
+     */
+    public static long hash64A(ByteBuffer buf, int seed) {
+        ByteOrder byteOrder = buf.order();
+        buf.order(ByteOrder.LITTLE_ENDIAN);
+
+        long m = 0xc6a4a7935bd1e995L;
+        int r = 47;
+
+        long h = seed ^ (buf.remaining() * m);
+
+        while (buf.remaining() >= 8) {
+            long k = buf.getLong();
+
+            k *= m;
+            k ^= k >>> r;
+            k *= m;
+
+            h ^= k;
+            h *= m;
+        }
+
+        if (buf.remaining() > 0) {
+            ByteBuffer finish = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN);
+
+            finish.put(buf).rewind();
+
+            h ^= finish.getLong();
+            h *= m;
+        }
+
+        h ^= h >>> r;
+        h *= m;
+        h ^= h >>> r;
+
+        buf.order(byteOrder);
+
+        return h;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/StorageConstants.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/StorageConstants.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/StorageConstants.java
new file mode 100644
index 0000000..ec2ee65
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/StorageConstants.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+/**
+ * Support for different modes of accessing data storage.
+ */
+public interface StorageConstants {
+    /** Storage mode optimized for sequential access. */
+    public static final int SEQUENTIAL_ACCESS_MODE = 1001;
+
+    /** Storage mode optimized for random access. */
+    public static final int RANDOM_ACCESS_MODE = 1002;
+
+    /** Storage mode optimized for row access. */
+    public static final int ROW_STORAGE_MODE = 2001;
+
+    /** Storage mode optimized for column access. */
+    public static final int COLUMN_STORAGE_MODE = 2002;
+
+    /**
+     * @param mode Access mode to verify.
+     */
+    public default void assertAccessMode(int mode) {
+        assert mode == SEQUENTIAL_ACCESS_MODE || mode == RANDOM_ACCESS_MODE;
+    }
+
+    /**
+     * @param mode Storage mode to verify.
+     */
+    public default void assertStorageMode(int mode) {
+        assert mode == ROW_STORAGE_MODE || mode == COLUMN_STORAGE_MODE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/StorageOpsMetrics.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/StorageOpsMetrics.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/StorageOpsMetrics.java
new file mode 100644
index 0000000..aa39481
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/StorageOpsMetrics.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+/**
+ * Storage and operation cost characteristics.
+ */
+public interface StorageOpsMetrics {
+    /**
+     * Checks if this implementation should be considered to be iterable in index order in an efficient way.
+     */
+    public boolean isSequentialAccess();
+
+    /**
+     * Checks if this implementation is optimized for random access.
+     */
+    public boolean isRandomAccess();
+
+    /**
+     * Checks if this implementation should be considered dense so that it explicitly
+     * represents every value.
+     */
+    public boolean isDense();
+
+    /**
+     * Checks if implementation is based on Java arrays.
+     */
+    public boolean isArrayBased();
+
+    /**
+     * Checks whether implementation is JVM-local or distributed (multi-JVM).
+     */
+    public boolean isDistributed();
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
new file mode 100644
index 0000000..007a8fe
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
@@ -0,0 +1,456 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import java.awt.Color;
+import java.awt.Desktop;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.util.Locale;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.lang.IgniteUuid;
+
+/**
+ * Utility methods to support output of {@link Vector} and {@link Matrix} instances to plain text or HTML.
+ */
+public class Tracer {
+    /**
+     * Double to color mapper.
+     */
+    public interface ColorMapper extends Function<Double, Color> {
+    }
+
+    /** Continuous red-to-blue color mapping. */
+    static private ColorMapper defaultColorMapper(double min, double max) {
+        double range = max - min;
+
+        return new ColorMapper() {
+            /** {@inheritDoc} */
+            @Override public Color apply(Double d) {
+                int r = (int)Math.round(255 * d);
+                int g = 0;
+                int b = (int)Math.round(255 * (1 - d));
+
+                return new Color(r, g, b);
+            }
+        };
+    }
+
+    /**
+     * Default vector color mapper implementation that map given double value
+     * to continuous red-blue (R_B) specter.
+     *
+     * @param vec Vector to map.
+     * @return {@link ColorMapper} for the given vector.
+     */
+    static private ColorMapper mkVectorColorMapper(Vector vec) {
+        return defaultColorMapper(vec.minValue(), vec.maxValue());
+    }
+
+    /** Default matrix color mapper implementation that map given double value
+     * to continuous red-blue (R_B) specter.
+     * @param mtx Matrix to be mapped.
+     * @return Color mapper for given matrix.
+     */
+    static private ColorMapper mkMatrixColorMapper(Matrix mtx) {
+        return defaultColorMapper(mtx.minValue(), mtx.maxValue());
+    }
+
+    /**
+     * @param vec Vector to show.
+     * @param log {@link IgniteLogger} instance for output.
+     * @param fmt Format string for vector elements.
+     */
+    public static void showAscii(Vector vec, IgniteLogger log, String fmt) {
+        String cls = vec.getClass().getSimpleName();
+
+        log.info(String.format("%s(%d) [%s]", cls, vec.size(), mkString(vec, fmt)));
+    }
+
+    /**
+     * @param vec Vector to show as plain text.
+     * @param log {@link IgniteLogger} instance for output.
+     */
+    public static void showAscii(Vector vec, IgniteLogger log) {
+        showAscii(vec, log, "%4f");
+    }
+
+    /**
+     * @param vec Vector to show as plain text.
+     * @param fmt Format string for vector elements.
+     */
+    public static void showAscii(Vector vec, String fmt) {
+        String cls = vec.getClass().getSimpleName();
+
+        System.out.println(String.format("%s(%d) [%s]", cls, vec.size(), mkString(vec, fmt)));
+    }
+
+    /**
+     * @param mtx Matrix to show as plain text.
+     */
+    public static void showAscii(Matrix mtx) {
+        showAscii(mtx, "%4f");
+    }
+
+    /**
+     * @param mtx Matrix to show.
+     * @param row Matrix row to output.
+     * @param fmt Format string for matrix elements in the row.
+     * @return String representation of given matrix row according to given format.
+     */
+    static private String rowStr(Matrix mtx, int row, String fmt) {
+        StringBuilder buf = new StringBuilder();
+
+        boolean first = true;
+
+        int cols = mtx.columnSize();
+
+        for (int col = 0; col < cols; col++) {
+            String s = String.format(fmt, mtx.get(row, col));
+
+            if (!first)
+                buf.append(", ");
+
+            buf.append(s);
+
+            first = false;
+        }
+
+        return buf.toString();
+    }
+
+    /**
+     * @param mtx {@link Matrix} object to show as a plain text.
+     * @param fmt Format string for matrix rows.
+     */
+    public static void showAscii(Matrix mtx, String fmt) {
+        String cls = mtx.getClass().getSimpleName();
+
+        int rows = mtx.rowSize();
+        int cols = mtx.columnSize();
+
+        System.out.println(String.format("%s(%dx%d)", cls, rows, cols));
+
+        for (int row = 0; row < rows; row++)
+            System.out.println(rowStr(mtx, row, fmt));
+    }
+
+    /**
+     * @param mtx {@link Matrix} object to show as a plain text.
+     * @param log {@link IgniteLogger} instance to output the logged matrix.
+     * @param fmt Format string for matrix rows.
+     */
+    public static void showAscii(Matrix mtx, IgniteLogger log, String fmt) {
+        String cls = mtx.getClass().getSimpleName();
+
+        int rows = mtx.rowSize();
+        int cols = mtx.columnSize();
+
+        log.info(String.format("%s(%dx%d)", cls, rows, cols));
+
+        for (int row = 0; row < rows; row++)
+            log.info(rowStr(mtx, row, fmt));
+    }
+
+    /**
+     * @param vec {@link Vector} object to show as a plain text.
+     */
+    public static void showAscii(Vector vec) {
+        showAscii(vec, "%4f");
+    }
+
+    /**
+     * Saves given vector as CSV file.
+     *
+     * @param vec Vector to save.
+     * @param fmt Format to use.
+     * @param filePath Path of the file to save to.
+     */
+    public static void saveAsCsv(Vector vec, String fmt, String filePath) throws IOException {
+        String s = mkString(vec, fmt);
+
+        Files.write(Paths.get(filePath), s.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
+    }
+
+    /**
+     * Saves given matrix as CSV file.
+     *
+     * @param mtx Matrix to save.
+     * @param fmt Format to use.
+     * @param filePath Path of the file to save to.
+     */
+    public static void saveAsCsv(Matrix mtx, String fmt, String filePath) throws IOException {
+        String s = mkString(mtx, fmt);
+
+        Files.write(Paths.get(filePath), s.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
+    }
+
+    /**
+     * Shows given matrix in the browser with D3-based visualization.
+     *
+     * @param mtx Matrix to show.
+     * @throws IOException Thrown in case of any errors.
+     */
+    public static void showHtml(Matrix mtx) throws IOException {
+        showHtml(mtx, mkMatrixColorMapper(mtx));
+    }
+
+    /**
+     * Shows given matrix in the browser with D3-based visualization.
+     *
+     * @param mtx Matrix to show.
+     * @param cm Optional color mapper. If not provided - red-to-blue (R_B) mapper will be used.
+     * @throws IOException Thrown in case of any errors.
+     */
+    public static void showHtml(Matrix mtx, ColorMapper cm) throws IOException {
+        // Read it every time so that we can change it at runtime.
+        String tmpl = fileToString("d3-matrix-template.html");
+
+        String cls = mtx.getClass().getSimpleName();
+
+        double min = mtx.minValue();
+        double max = mtx.maxValue();
+
+        openHtmlFile(tmpl.
+            replaceAll("/\\*@NAME@\\*/.*\n", "var name = \"" + cls + "\";\n").
+            replaceAll("/\\*@MIN@\\*/.*\n", "var min = " + dataColorJson(min, cm.apply(min)) + ";\n").
+            replaceAll("/\\*@MAX@\\*/.*\n", "var max = " + dataColorJson(max, cm.apply(max)) + ";\n").
+            replaceAll("/\\*@DATA@\\*/.*\n", "var data = " + mkJsArrayString(mtx, cm) + ";\n")
+        );
+    }
+
+    /**
+     * Shows given vector in the browser with D3-based visualization.
+     *
+     * @param vec Vector to show.
+     * @throws IOException Thrown in case of any errors.
+     */
+    public static void showHtml(Vector vec) throws IOException {
+        showHtml(vec, mkVectorColorMapper(vec));
+    }
+
+    /**
+     * @param d Value of {@link Matrix} or {@link Vector} element.
+     * @param clr {@link Color} to paint.
+     * @return JSON representation for given value and color.
+     */
+    static private String dataColorJson(double d, Color clr) {
+        return "{" +
+            "d: " + String.format("%4f", d) +
+            ", r: " + clr.getRed() +
+            ", g: " + clr.getGreen() +
+            ", b: " + clr.getBlue() +
+            "}";
+    }
+
+    /**
+     * Shows given vector in the browser with D3-based visualization.
+     *
+     * @param vec Vector to show.
+     * @param cm Optional color mapper. If not provided - red-to-blue (R_B) mapper will be used.
+     * @throws IOException Thrown in case of any errors.
+     */
+    public static void showHtml(Vector vec, ColorMapper cm) throws IOException {
+        // Read it every time so that we can change it at runtime.
+        String tmpl = fileToString("d3-vector-template.html");
+
+        String cls = vec.getClass().getSimpleName();
+
+        double min = vec.minValue();
+        double max = vec.maxValue();
+
+        openHtmlFile(tmpl.
+            replaceAll("/\\*@NAME@\\*/.*\n", "var name = \"" + cls + "\";\n").
+            replaceAll("/\\*@MIN@\\*/.*\n", "var min = " + dataColorJson(min, cm.apply(min)) + ";\n").
+            replaceAll("/\\*@MAX@\\*/.*\n", "var max = " + dataColorJson(max, cm.apply(max)) + ";\n").
+            replaceAll("/\\*@DATA@\\*/.*\n", "var data = " + mkJsArrayString(vec, cm) + ";\n")
+        );
+    }
+
+    /**
+     * Reads file content into the string.
+     *
+     * @param fileName Name of the file (on classpath) to read.
+     * @return Content of the file.
+     * @throws IOException If an I/O error of some sort has occurred.
+     */
+    private static String fileToString(String fileName) throws IOException {
+        assert Tracer.class.getResourceAsStream(fileName) != null : "Can't get resource: " + fileName;
+
+        InputStreamReader is = new InputStreamReader(Tracer.class.getResourceAsStream(fileName));
+
+        String str = new BufferedReader(is).lines().collect(Collectors.joining("\n"));
+
+        is.close();
+
+        return str;
+    }
+
+    /**
+     * Opens file in the browser with given HTML content.
+     *
+     * @param html HTML content.
+     * @throws IOException Thrown in case of any errors.
+     */
+    static private void openHtmlFile(String html) throws IOException {
+        File temp = File.createTempFile(IgniteUuid.randomUuid().toString(), ".html");
+
+        BufferedWriter bw = new BufferedWriter(new FileWriter(temp));
+
+        bw.write(html);
+
+        bw.close();
+
+        Desktop.getDesktop().browse(temp.toURI());
+    }
+
+    /**
+     * Gets string presentation of this vector.
+     *
+     * @param vec Vector to string-ify.
+     * @param fmt {@link String#format(Locale, String, Object...)} format.
+     */
+    private static String mkString(Vector vec, String fmt) {
+        boolean first = true;
+
+        StringBuilder buf = new StringBuilder();
+
+        for (Vector.Element x : vec.all()) {
+            String s = String.format(Locale.US, fmt, x.get());
+
+            if (!first) {
+                buf.append(", ");
+                buf.append(s);
+            }
+            else {
+                buf.append(s);
+                first = false;
+            }
+        }
+
+        return buf.toString();
+    }
+
+    /**
+     * Gets JavaScript array presentation of this vector.
+     *
+     * @param vec Vector to JavaScript-ify.
+     * @param cm Color mapper to user.
+     */
+    private static String mkJsArrayString(Vector vec, ColorMapper cm) {
+        boolean first = true;
+
+        StringBuilder buf = new StringBuilder();
+
+        for (Vector.Element x : vec.all()) {
+            double d = x.get();
+
+            String s = dataColorJson(d, cm.apply(d));
+
+            if (!first)
+                buf.append(", ");
+
+            buf.append(s);
+
+            first = false;
+        }
+
+        return '[' + buf.toString() + ']';
+    }
+
+    /**
+     * Gets JavaScript array presentation of this vector.
+     *
+     * @param mtx Matrix to JavaScript-ify.
+     * @param cm Color mapper to user.
+     */
+    private static String mkJsArrayString(Matrix mtx, ColorMapper cm) {
+        boolean first = true;
+
+        StringBuilder buf = new StringBuilder();
+
+        int rows = mtx.rowSize();
+        int cols = mtx.columnSize();
+
+        for (int row = 0; row < rows; row++) {
+            StringBuilder rowBuf = new StringBuilder();
+
+            boolean rowFirst = true;
+
+            for (int col = 0; col < cols; col++) {
+                double d = mtx.get(row, col);
+
+                String s = dataColorJson(d, cm.apply(d));
+
+                if (!rowFirst)
+                    rowBuf.append(", ");
+
+                rowBuf.append(s);
+
+                rowFirst = false;
+            }
+
+            if (!first)
+                buf.append(", ");
+
+            buf.append('[').append(rowBuf.toString()).append(']');
+
+            first = false;
+        }
+
+        return '[' + buf.toString() + ']';
+    }
+
+    /**
+     * @param mtx Matrix to log.
+     * @param fmt Output format.
+     * @return Formatted representation of a matrix.
+     */
+    private static String mkString(Matrix mtx, String fmt) {
+        StringBuilder buf = new StringBuilder();
+
+        int rows = mtx.rowSize();
+        int cols = mtx.columnSize();
+
+        for (int row = 0; row < rows; row++) {
+            for (int col = 0; col < cols; col++) {
+                String s = String.format(Locale.US, fmt, mtx.get(row, col));
+
+                if (col != 0)
+                    buf.append(", ");
+
+                buf.append(s);
+
+                if (col == cols - 1 && row != rows - 1)
+                    buf.append(",\n");
+
+            }
+        }
+
+        return buf.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/ValueMapper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/ValueMapper.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/ValueMapper.java
new file mode 100644
index 0000000..2b62c0b
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/ValueMapper.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import java.io.Serializable;
+
+/**
+ * Utility mapper that can be used to map arbitrary values types to and from double.
+ */
+public interface ValueMapper<V> extends Serializable {
+    /**
+     * @param v
+     */
+    public V fromDouble(double v);
+
+    /**
+     * @param v
+     */
+    public double toDouble(V v);
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
new file mode 100644
index 0000000..b5e1d69
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
@@ -0,0 +1,498 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import java.io.Externalizable;
+import java.util.Spliterator;
+import java.util.function.IntToDoubleFunction;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.ml.math.exceptions.CardinalityException;
+import org.apache.ignite.ml.math.exceptions.IndexException;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.IgniteBiFunction;
+import org.apache.ignite.ml.math.functions.IgniteDoubleFunction;
+
+/**
+ * A vector interface.
+ *
+ * Based on its flavor it can have vastly different implementations tailored for
+ * for different types of data (e.g. dense vs. sparse), different sizes of data or different operation
+ * optimizations.
+ *
+ * Note also that not all operations can be supported by all underlying implementations. If an operation is not
+ * supported a {@link UnsupportedOperationException} is thrown. This exception can also be thrown in partial cases
+ * where an operation is unsupported only in special cases, e.g. where a given operation cannot be deterministically
+ * completed in polynomial time.
+ *
+ * Based on ideas from <a href="http://mahout.apache.org/">Apache Mahout</a>.
+ */
+public interface Vector extends MetaAttributes, Externalizable, StorageOpsMetrics, Destroyable {
+    /**
+     * Holder for vector's element.
+     */
+    interface Element {
+        /**
+         * Gets element's value.
+         *
+         * @return The value of this vector element.
+         */
+        double get();
+
+        /**
+         * Gets element's index in the vector.
+         *
+         * @return The index of this vector element.
+         */
+        int index();
+
+        /**
+         * Sets element's value.
+         *
+         * @param val Value to set.
+         */
+        void set(double val);
+    }
+
+    /**
+     * Gets cardinality of this vector (maximum number of the elements).
+     *
+     * @return This vector's cardinality.
+     */
+    public int size();
+
+    /**
+     * Creates new copy of this vector.
+     *
+     * @return New copy vector.
+     */
+    public Vector copy();
+
+    /**
+     * Gets iterator over all elements in this vector.
+     *
+     * NOTE: implementation can choose to reuse {@link Element} instance so you need to copy it
+     * if you want to retain it outside of iteration.
+     *
+     * @return Iterator.
+     */
+    public Iterable<Element> all();
+
+    /**
+     * Iterates ove all non-zero elements in this vector.
+     *
+     * NOTE: implementation can choose to reuse {@link Element} instance so you need to copy it
+     * if you want to retain it outside of iteration.
+     *
+     * @return Iterator.
+     */
+    public Iterable<Element> nonZeroes();
+
+    /**
+     * Gets spliterator for all values in this vector.
+     *
+     * @return Spliterator for all values.
+     */
+    public Spliterator<Double> allSpliterator();
+
+    /**
+     * Gets spliterator for all non-zero values in this vector.
+     *
+     * @return Spliterator for all non-zero values.
+     */
+    public Spliterator<Double> nonZeroSpliterator();
+
+    /**
+     * Sorts this vector in ascending order.
+     */
+    public Vector sort();
+
+    /**
+     * Gets element at the given index.
+     *
+     * NOTE: implementation can choose to reuse {@link Element} instance so you need to copy it
+     * if you want to retain it outside of iteration.
+     *
+     * @param idx Element's index.
+     * @return Vector's element at the given index.
+     * @throws IndexException Throw if index is out of bounds.
+     */
+    public Element getElement(int idx);
+
+    /**
+     * Assigns given value to all elements of this vector.
+     *
+     * @param val Value to assign.
+     * @return This vector.
+     */
+    public Vector assign(double val);
+
+    /**
+     * Assigns values from given array to this vector.
+     *
+     * @param vals Values to assign.
+     * @return This vector.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Vector assign(double[] vals);
+
+    /**
+     * Copies values from the argument vector to this one.
+     *
+     * @param vec Argument vector.
+     * @return This vector.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Vector assign(Vector vec);
+
+    /**
+     * Assigns each vector element to the value generated by given function.
+     *
+     * @param fun Function that takes the index and returns value.
+     * @return This vector.
+     */
+    public Vector assign(IntToDoubleFunction fun);
+
+    /**
+     * Maps all values in this vector through a given function.
+     *
+     * @param fun Mapping function.
+     * @return This vector.
+     */
+    public Vector map(IgniteDoubleFunction<Double> fun);
+
+    /**
+     * Maps all values in this vector through a given function.
+     *
+     * For this vector <code>A</code>, argument vector <code>B</code> and the
+     * function <code>F</code> this method maps every element <code>x</code> as:
+     * <code>A(x) = F(A(x), B(x))</code>
+     *
+     * @param vec Argument vector.
+     * @param fun Mapping function.
+     * @return This function.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Vector map(Vector vec, IgniteBiFunction<Double, Double, Double> fun);
+
+    /**
+     * Maps all elements of this vector by applying given function to each element with a constant
+     * second parameter <code>y</code>.
+     *
+     * @param fun Mapping function.
+     * @param y Second parameter for mapping function.
+     * @return This vector.
+     */
+    public Vector map(IgniteBiFunction<Double, Double, Double> fun, double y);
+
+    /**
+     * Creates new vector containing values from this vector divided by the argument.
+     *
+     * @param x Division argument.
+     * @return New vector.
+     */
+    public Vector divide(double x);
+
+    /**
+     * Gets dot product of two vectors.
+     *
+     * @param vec Argument vector.
+     * @return Dot product of two vectors.
+     */
+    public double dot(Vector vec);
+
+    /**
+     * Gets the value at specified index.
+     *
+     * @param idx Vector index.
+     * @return Vector value.
+     * @throws IndexException Throw if index is out of bounds.
+     */
+    public double get(int idx);
+
+    /**
+     * Gets the value at specified index without checking for index boundaries.
+     *
+     * @param idx Vector index.
+     * @return Vector value.
+     */
+    public double getX(int idx);
+
+    /**
+     * Creates new empty vector of the same underlying class but of different cardinality.
+     *
+     * @param crd Cardinality for new vector.
+     * @return New vector.
+     */
+    public Vector like(int crd);
+
+    /**
+     * Creates new matrix of compatible flavor with given size.
+     *
+     * @param rows Number of rows.
+     * @param cols Number of columns.
+     * @return New matrix.
+     */
+    public Matrix likeMatrix(int rows, int cols);
+
+    /**
+     * Converts this vector into [N x 1] or [1 x N] matrix where N is this vector cardinality.
+     *
+     * @param rowLike {@code true} for rowLike [N x 1], or {@code false} for column [1 x N] matrix.
+     * @return Newly created matrix.
+     */
+    public Matrix toMatrix(boolean rowLike);
+
+    /**
+     * Converts this vector into [N+1 x 1] or [1 x N+1] matrix where N is this vector cardinality.
+     * (0,0) element of this matrix will be {@code zeroVal} parameter.
+     *
+     * @param rowLike {@code true} for rowLike [N+1 x 1], or {@code false} for column [1 x N+1] matrix.
+     * @return Newly created matrix.
+     */
+    public Matrix toMatrixPlusOne(boolean rowLike, double zeroVal);
+
+    /**
+     * Creates new vector containing element by element difference between this vector and the argument one.
+     *
+     * @param vec Argument vector.
+     * @return New vector.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Vector minus(Vector vec);
+
+    /**
+     * Creates new vector containing the normalized (L_2 norm) values of this vector.
+     *
+     * @return New vector.
+     */
+    public Vector normalize();
+
+    /**
+     * Creates new vector containing the normalized (L_power norm) values of this vector.
+     * See http://en.wikipedia.org/wiki/Lp_space for details.
+     *
+     * @param power The power to use. Must be >= 0. May also be {@link Double#POSITIVE_INFINITY}.
+     * @return New vector {@code x} such that {@code norm(x, power) == 1}
+     */
+    public Vector normalize(double power);
+
+    /**
+     * Creates new vector containing the {@code log(1 + entry) / L_2 norm} values of this vector.
+     *
+     * @return New vector.
+     */
+    public Vector logNormalize();
+
+    /**
+     * Creates new vector with a normalized value calculated as {@code log_power(1 + entry) / L_power norm}.
+     *
+     * @param power The power to use. Must be > 1. Cannot be {@link Double#POSITIVE_INFINITY}.
+     * @return New vector
+     */
+    public Vector logNormalize(double power);
+
+    /**
+     * Gets the k-norm of the vector. See http://en.wikipedia.org/wiki/Lp_space for more details.
+     *
+     * @param power The power to use.
+     * @see #normalize(double)
+     */
+    public double kNorm(double power);
+
+    /**
+     * Gets minimal value in this vector.
+     *
+     * @return Minimal value.
+     */
+    public double minValue();
+
+    /**
+     * Gets maximum value in this vector.
+     *
+     * @return Maximum c.
+     */
+    public double maxValue();
+
+    /**
+     * Gets minimal element in this vector.
+     *
+     * @return Minimal element.
+     */
+    public Element minElement();
+
+    /**
+     * Gets maximum element in this vector.
+     *
+     * @return Maximum element.
+     */
+    public Element maxElement();
+
+    /**
+     * Creates new vector containing sum of each element in this vector and argument.
+     *
+     * @param x Argument value.
+     * @return New vector.
+     */
+    public Vector plus(double x);
+
+    /**
+     * Creates new vector containing element by element sum from both vectors.
+     *
+     * @param vec Other argument vector to add.
+     * @return New vector.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Vector plus(Vector vec);
+
+    /**
+     * Sets value.
+     *
+     * @param idx Vector index to set value at.
+     * @param val Value to set.
+     * @return This vector.
+     * @throws IndexException Throw if index is out of bounds.
+     */
+    public Vector set(int idx, double val);
+
+    /**
+     * Sets value without checking for index boundaries.
+     *
+     * @param idx Vector index to set value at.
+     * @param val Value to set.
+     * @return This vector.
+     */
+    public Vector setX(int idx, double val);
+
+    /**
+     * Increments value at given index without checking for index boundaries.
+     *
+     * @param idx Vector index.
+     * @param val Increment value.
+     * @return This vector.
+     */
+    public Vector incrementX(int idx, double val);
+
+    /**
+     * Increments value at given index.
+     *
+     * @param idx Vector index.
+     * @param val Increment value.
+     * @return This vector.
+     * @throws IndexException Throw if index is out of bounds.
+     */
+    public Vector increment(int idx, double val);
+
+    /**
+     * Gets number of non-zero elements in this vector.
+     *
+     * @return Number of non-zero elements in this vector.
+     */
+    public int nonZeroElements();
+
+    /**
+     * Gets a new vector that contains product of each element and the argument.
+     *
+     * @param x Multiply argument.
+     * @return New vector.
+     */
+    public Vector times(double x);
+
+    /**
+     * Gets a new vector that is an element-wie product of this vector and the argument.
+     *
+     * @param vec Vector to multiply by.
+     * @return New vector.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Vector times(Vector vec);
+
+    /**
+     * @param off Offset into parent vector.
+     * @param len Length of the view.
+     */
+    public Vector viewPart(int off, int len);
+
+    /**
+     * Gets vector storage model.
+     */
+    public VectorStorage getStorage();
+
+    /**
+     * Gets the sum of all elements in this vector.
+     *
+     * @return Vector's sum
+     */
+    public double sum();
+
+    /**
+     * Gets the cross product of this vector and the other vector.
+     *
+     * @param vec Second vector.
+     * @return New matrix as a cross product of two vectors.
+     */
+    public Matrix cross(Vector vec);
+
+    /**
+     * Folds this vector into a single value.
+     *
+     * @param foldFun Folding function that takes two parameters: accumulator and the current value.
+     * @param mapFun Mapping function that is called on each vector element before its passed to the accumulator (as its
+     * second parameter).
+     * @param <T> Type of the folded value.
+     * @param zeroVal Zero value for fold operation.
+     * @return Folded value of this vector.
+     */
+    public <T> T foldMap(IgniteBiFunction<T, Double, T> foldFun, IgniteDoubleFunction<Double> mapFun, T zeroVal);
+
+    /**
+     * Combines & maps two vector and folds them into a single value.
+     *
+     * @param vec Another vector to combine with.
+     * @param foldFun Folding function.
+     * @param combFun Combine function.
+     * @param <T> Type of the folded value.
+     * @param zeroVal Zero value for fold operation.
+     * @return Folded value of these vectors.
+     * @throws CardinalityException Thrown when cardinalities mismatch.
+     */
+    public <T> T foldMap(Vector vec, IgniteBiFunction<T, Double, T> foldFun, IgniteBiFunction<Double, Double, Double> combFun,
+        T zeroVal);
+
+    /**
+     * Gets the sum of squares of all elements in this vector.
+     *
+     * @return Length squared value.
+     */
+    public double getLengthSquared();
+
+    /**
+     * Get the square of the distance between this vector and the argument vector.
+     *
+     * @param vec Another vector.
+     * @return Distance squared.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public double getDistanceSquared(Vector vec);
+
+    /**
+     * Auto-generated globally unique vector ID.
+     *
+     * @return Vector GUID.
+     */
+    public IgniteUuid guid();
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/VectorKeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/VectorKeyMapper.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/VectorKeyMapper.java
new file mode 100644
index 0000000..4b8fadb
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/VectorKeyMapper.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+/**
+ * Maps {@link Vector} element index to cache key.
+ */
+public interface VectorKeyMapper<K> extends KeyMapper<K> {
+    /**
+     * @param i Vector element index.
+     * @return Cache key for given element index.
+     */
+    public K apply(int i);
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/VectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/VectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/VectorStorage.java
new file mode 100644
index 0000000..3b66e4f
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/VectorStorage.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import java.io.Externalizable;
+
+/**
+ * Data storage support for {@link Vector}.
+ */
+public interface VectorStorage extends Externalizable, StorageOpsMetrics, Destroyable {
+    /**
+     *
+     *
+     */
+    public int size();
+
+    /**
+     * @param i Vector element index.
+     * @return Value obtained for given element index.
+     */
+    public double get(int i);
+
+    /**
+     * @param i Vector element index.
+     * @param v Value to set at given index.
+     */
+    public void set(int i, double v);
+
+    /**
+     * Gets underlying array if {@link StorageOpsMetrics#isArrayBased()} returns {@code true}.
+     * Returns {@code null} if in other cases.
+     *
+     * @see StorageOpsMetrics#isArrayBased()
+     */
+    public default double[] data() {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
new file mode 100644
index 0000000..bc18307
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
@@ -0,0 +1,306 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.decompositions;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.CardinalityException;
+import org.apache.ignite.ml.math.exceptions.NonPositiveDefiniteMatrixException;
+import org.apache.ignite.ml.math.exceptions.NonSymmetricMatrixException;
+
+/**
+ * Calculates the Cholesky decomposition of a matrix.
+ *
+ * This class inspired by class from Apache Common Math with similar name.
+ *
+ * @see <a href="http://mathworld.wolfram.com/CholeskyDecomposition.html">MathWorld</a>
+ * @see <a href="http://en.wikipedia.org/wiki/Cholesky_decomposition">Wikipedia</a>
+ */
+public class CholeskyDecomposition extends DecompositionSupport {
+    /**
+     * Default threshold above which off-diagonal elements are considered too different
+     * and matrix not symmetric.
+     */
+    public static final double DFLT_REL_SYMMETRY_THRESHOLD = 1.0e-15;
+
+    /**
+     * Default threshold below which diagonal elements are considered null
+     * and matrix not positive definite.
+     */
+    public static final double DFLT_ABS_POSITIVITY_THRESHOLD = 1.0e-10;
+
+    /** Row-oriented storage for L<sup>T</sup> matrix data. */
+    private double[][] lTData;
+    /** Cached value of L. */
+    private Matrix cachedL;
+    /** Cached value of LT. */
+    private Matrix cachedLT;
+    /** Origin matrix */
+    private Matrix origin;
+
+    /**
+     * Calculates the Cholesky decomposition of the given matrix.
+     *
+     * Calling this constructor is equivalent to call {@link #CholeskyDecomposition(Matrix, double, double)} with the
+     * thresholds set to the default values {@link #DFLT_REL_SYMMETRY_THRESHOLD} and
+     * {@link #DFLT_ABS_POSITIVITY_THRESHOLD}.
+     *
+     * @param mtx the matrix to decompose.
+     * @throws CardinalityException if matrix is not square.
+     * @see #CholeskyDecomposition(Matrix, double, double)
+     * @see #DFLT_REL_SYMMETRY_THRESHOLD
+     * @see #DFLT_ABS_POSITIVITY_THRESHOLD
+     */
+    public CholeskyDecomposition(final Matrix mtx) {
+        this(mtx, DFLT_REL_SYMMETRY_THRESHOLD, DFLT_ABS_POSITIVITY_THRESHOLD);
+    }
+
+    /**
+     * Calculates the Cholesky decomposition of the given matrix.
+     *
+     * @param mtx the matrix to decompose.
+     * @param relSymmetryThreshold threshold above which off-diagonal elements are considered too different and matrix
+     * not symmetric
+     * @param absPositivityThreshold threshold below which diagonal elements are considered null and matrix not positive
+     * definite
+     * @see #CholeskyDecomposition(Matrix)
+     * @see #DFLT_REL_SYMMETRY_THRESHOLD
+     * @see #DFLT_ABS_POSITIVITY_THRESHOLD
+     */
+    public CholeskyDecomposition(final Matrix mtx, final double relSymmetryThreshold,
+        final double absPositivityThreshold) {
+        assert mtx != null;
+
+        if (mtx.columnSize() != mtx.rowSize())
+            throw new CardinalityException(mtx.rowSize(), mtx.columnSize());
+
+        origin = mtx;
+
+        final int order = mtx.rowSize();
+
+        lTData = toDoubleArr(mtx);
+        cachedL = null;
+        cachedLT = null;
+
+        // Check the matrix before transformation.
+        for (int i = 0; i < order; ++i) {
+            final double[] lI = lTData[i];
+
+            // Check off-diagonal elements (and reset them to 0).
+            for (int j = i + 1; j < order; ++j) {
+                final double[] lJ = lTData[j];
+
+                final double lIJ = lI[j];
+                final double lJI = lJ[i];
+
+                final double maxDelta = relSymmetryThreshold * Math.max(Math.abs(lIJ), Math.abs(lJI));
+
+                if (Math.abs(lIJ - lJI) > maxDelta)
+                    throw new NonSymmetricMatrixException(i, j, relSymmetryThreshold);
+
+                lJ[i] = 0;
+            }
+        }
+
+        // Transform the matrix.
+        for (int i = 0; i < order; ++i) {
+            final double[] ltI = lTData[i];
+
+            // Check diagonal element.
+            if (ltI[i] <= absPositivityThreshold)
+                throw new NonPositiveDefiniteMatrixException(ltI[i], i, absPositivityThreshold);
+
+            ltI[i] = Math.sqrt(ltI[i]);
+            final double inverse = 1.0 / ltI[i];
+
+            for (int q = order - 1; q > i; --q) {
+                ltI[q] *= inverse;
+                final double[] ltQ = lTData[q];
+
+                for (int p = q; p < order; ++p)
+                    ltQ[p] -= ltI[q] * ltI[p];
+            }
+        }
+    }
+
+    /** */
+    @Override public void destroy() {
+        if (cachedL != null)
+            cachedL.destroy();
+        if (cachedLT != null)
+            cachedLT.destroy();
+    }
+
+    /**
+     * Returns the matrix L of the decomposition.
+     * <p>L is an lower-triangular matrix</p>
+     *
+     * @return the L matrix
+     */
+    public Matrix getL() {
+        if (cachedL == null)
+            cachedL = getLT().transpose();
+
+        return cachedL;
+    }
+
+    /**
+     * Returns the transpose of the matrix L of the decomposition.
+     * <p>L<sup>T</sup> is an upper-triangular matrix</p>
+     *
+     * @return the transpose of the matrix L of the decomposition
+     */
+    public Matrix getLT() {
+
+        if (cachedLT == null) {
+            Matrix like = like(origin, origin.rowSize(), origin.columnSize());
+            like.assign(lTData);
+
+            cachedLT = like;
+        }
+
+        // return the cached matrix
+        return cachedLT;
+    }
+
+    /**
+     * Return the determinant of the matrix
+     *
+     * @return determinant of the matrix
+     */
+    public double getDeterminant() {
+        double determinant = 1.0;
+
+        for (int i = 0; i < lTData.length; ++i) {
+            double lTii = lTData[i][i];
+            determinant *= lTii * lTii;
+        }
+
+        return determinant;
+    }
+
+    /**
+     * Solve the linear equation A &times; X = B for matrices A.
+     *
+     * @param b right-hand side of the equation A &times; X = B
+     * @return a vector X that minimizes the two norm of A &times; X - B
+     * @throws CardinalityException if the vectors dimensions do not match
+     */
+    public Vector solve(final Vector b) {
+        final int m = lTData.length;
+
+        if (b.size() != m)
+            throw new CardinalityException(b.size(), m);
+
+        final double[] x = b.getStorage().data();
+
+        // Solve LY = b
+        for (int j = 0; j < m; j++) {
+            final double[] lJ = lTData[j];
+
+            x[j] /= lJ[j];
+
+            final double xJ = x[j];
+
+            for (int i = j + 1; i < m; i++)
+                x[i] -= xJ * lJ[i];
+        }
+
+        // Solve LTX = Y
+        for (int j = m - 1; j >= 0; j--) {
+            x[j] /= lTData[j][j];
+
+            final double xJ = x[j];
+
+            for (int i = 0; i < j; i++)
+                x[i] -= xJ * lTData[i][j];
+        }
+
+        return likeVector(origin, m).assign(x);
+    }
+
+    /**
+     * Solve the linear equation A &times; X = B for matrices A.
+     *
+     * @param b right-hand side of the equation A &times; X = B
+     * @return a matrix X that minimizes the two norm of A &times; X - B
+     * @throws CardinalityException if the matrices dimensions do not match
+     */
+    public Matrix solve(final Matrix b) {
+        final int m = lTData.length;
+
+        if (b.rowSize() != m)
+            throw new CardinalityException(b.rowSize(), m);
+
+        final int nColB = b.columnSize();
+        final double[][] x = b.getStorage().data();
+
+        // Solve LY = b
+        for (int j = 0; j < m; j++) {
+            final double[] lJ = lTData[j];
+            final double lJJ = lJ[j];
+            final double[] xJ = x[j];
+
+            for (int k = 0; k < nColB; ++k)
+                xJ[k] /= lJJ;
+
+            for (int i = j + 1; i < m; i++) {
+                final double[] xI = x[i];
+                final double lJI = lJ[i];
+
+                for (int k = 0; k < nColB; ++k)
+                    xI[k] -= xJ[k] * lJI;
+            }
+        }
+
+        // Solve LTX = Y
+        for (int j = m - 1; j >= 0; j--) {
+            final double lJJ = lTData[j][j];
+            final double[] xJ = x[j];
+
+            for (int k = 0; k < nColB; ++k)
+                xJ[k] /= lJJ;
+
+            for (int i = 0; i < j; i++) {
+                final double[] xI = x[i];
+                final double lIJ = lTData[i][j];
+
+                for (int k = 0; k < nColB; ++k)
+                    xI[k] -= xJ[k] * lIJ;
+            }
+        }
+
+        return like(origin, m, b.columnSize()).assign(x);
+    }
+
+    /** */
+    private double[][] toDoubleArr(Matrix mtx) {
+        if (mtx.isArrayBased())
+            return mtx.getStorage().data();
+
+        double[][] res = new double[mtx.rowSize()][];
+
+        for (int row = 0; row < mtx.rowSize(); row++) {
+            res[row] = new double[mtx.columnSize()];
+            for (int col = 0; col < mtx.columnSize(); col++)
+                res[row][col] = mtx.get(row, col);
+        }
+
+        return res;
+    }
+}


[11/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/resources/org/apache/ignite/math/d3-matrix-template.html
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/resources/org/apache/ignite/math/d3-matrix-template.html b/modules/ml/src/main/resources/org/apache/ignite/math/d3-matrix-template.html
deleted file mode 100644
index 19a907a..0000000
--- a/modules/ml/src/main/resources/org/apache/ignite/math/d3-matrix-template.html
+++ /dev/null
@@ -1,128 +0,0 @@
-<!DOCTYPE html>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements.  See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<meta charset="utf-8">
-<title>IgniteML</title>
-<style>
-    body {
-        margin: 0 15px;
-    }
-
-    p {
-        margin: 10px 0 !important;
-    }
-
-    .name {
-        font-size: 20px;
-        font-weight: 400;
-        font-family: monospace;
-    }
-
-    .swatch {
-        display: inline-block;
-        width: 25px;
-        height: 25px;
-        margin-left: 5px;
-        vertical-align: bottom;
-    }
-</style>
-<body>
-<img style="margin-top: 15px" width="100px" src="https://ignite.apache.org/images/logo3.png">
-<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.5.0/d3.min.js"></script>
-<script>
-    /*@DATA@*/
-    var data = [[{d: 2.256, r: 198, g: 128, b: 128}, {d: 0.123, r: 218, g: 228, b: 18}], [{
-        d: 2.256,
-        r: 108,
-        g: 28,
-        b: 108
-    }, {d: 0.123, r: 228, g: 228, b: 228}]];
-    /*@MAX@*/
-    var max = {d: 2.256, r: 128, g: 128, b: 128};
-    /*@MIN@*/
-    var min = {d: 0.123, r: 228, g: 228, b: 228};
-    /*@NAME@*/
-    var name = "Matrix";
-
-    var rows = data.length;
-    var cols = data[0].length;
-
-    var range = max.d - min.d;
-
-    var rw, rh;
-    var W, H;
-
-    if (cols > W) {
-        rw = 1;
-        W = cols;
-    }
-    else {
-        W = 1000;
-        rw = Math.min(Math.round(W / cols), 10);
-    }
-
-    if (rows > H) {
-        rh = 1;
-        H = rows;
-    }
-    else {
-        H = 1000;
-        rh = Math.min(Math.round(H / rows), 10);
-    }
-
-    d3.selectAll("body")
-        .append("p")
-        .text(name + " (" + rows + "x" + cols + ")")
-        .attr("class", "name");
-
-    d3.selectAll("body")
-        .append("p")
-        .attr("class", "name")
-        .text("Max: " + max.d)
-        .append("span")
-        .attr("class", "swatch")
-        .attr("style", "background-color: rgb(" + max.r + ", " + max.g + ", " + max.b + ")");
-
-    d3.selectAll("body")
-        .append("p")
-        .attr("class", "name")
-        .text("Min: " + min.d)
-        .append("span")
-        .attr("class", "swatch")
-        .attr("style", "background-color: rgb(" + min.r + ", " + min.g + ", " + min.b + ")");
-
-    var svg = d3.select("body").append("svg")
-        .attr("width", W)
-        .attr("height", H);
-
-    var y = 0;
-
-    for (var row = 0; row < rows; row++)
-        svg.selectAll("div")
-            .data(data[row])
-            .enter()
-            .append("rect")
-            .attr("x", function (d, i) {
-                return i * rw
-            })
-            .attr("y", rh * row)
-            .attr("fill", function (d) {
-                return "rgb(" + d.r + ", " + d.g + ", " + d.b + ")";
-            })
-            .attr("width", rw)
-            .attr("height", rh);
-</script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/resources/org/apache/ignite/math/d3-vector-template.html
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/resources/org/apache/ignite/math/d3-vector-template.html b/modules/ml/src/main/resources/org/apache/ignite/math/d3-vector-template.html
deleted file mode 100644
index 7644481..0000000
--- a/modules/ml/src/main/resources/org/apache/ignite/math/d3-vector-template.html
+++ /dev/null
@@ -1,111 +0,0 @@
-<!DOCTYPE html>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements.  See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<meta charset="utf-8">
-<title>IgniteML</title>
-<style>
-    body {
-        margin: 0 15px;
-    }
-
-    p {
-        margin: 10px 0 !important;
-    }
-
-    .name {
-        font-size: 20px;
-        font-weight: 400;
-        font-family: monospace;
-    }
-
-    .swatch {
-        display: inline-block;
-        width: 25px;
-        height: 25px;
-        margin-left: 5px;
-        vertical-align: bottom;
-    }
-</style>
-<body>
-<img style="margin-top: 15px" width="100px" src="https://ignite.apache.org/images/logo3.png">
-<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.5.0/d3.min.js"></script>
-<script>
-    /*@DATA@*/
-    var data = [{d: 2.256, r: 128, g: 128, b: 128}, {d: 0.123, r: 228, g: 228, b: 228}];
-    /*@MAX@*/
-    var max = {d: 2.256, r: 128, g: 128, b: 128};
-    /*@MIN@*/
-    var min = {d: 0.123, r: 228, g: 228, b: 228};
-    /*@NAME@*/
-    var name = "Vector";
-
-    var W, H = 1000;
-
-    var range = max.d - min.d;
-
-    var rh = 20; // Constant.
-
-    var rw;
-
-    if (data.length > W) {
-        rw = 1;
-        W = data.length;
-    }
-    else {
-        W = 1000;
-        rw = Math.min(Math.round(W / data.length), 5);
-    }
-
-    d3.selectAll("body")
-        .append("p")
-        .text(name + " (size: " + data.length + ")")
-        .attr("class", "name");
-
-    d3.selectAll("body")
-        .append("p")
-        .attr("class", "name")
-        .text("Max: " + max.d)
-        .append("span")
-        .attr("class", "swatch")
-        .attr("style", "background-color: rgb(" + max.r + ", " + max.g + ", " + max.b + ")");
-
-    d3.selectAll("body")
-        .append("p")
-        .attr("class", "name")
-        .text("Min: " + min.d)
-        .append("span")
-        .attr("class", "swatch")
-        .attr("style", "background-color: rgb(" + min.r + ", " + min.g + ", " + min.b + ")");
-
-    var svg = d3.select("body").append("svg")
-        .attr("width", W)
-        .attr("height", H);
-
-    svg.selectAll("rect")
-        .data(data)
-        .enter()
-        .append("rect")
-        .attr("x", function (d, i) {
-            return i * rw
-        })
-        .attr("y", 10)
-        .attr("fill", function (d) {
-            return "rgb(" + d.r + ", " + d.g + ", " + d.b + ")";
-        })
-        .attr("width", rw)
-        .attr("height", rh);
-</script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-matrix-template.html
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-matrix-template.html b/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-matrix-template.html
new file mode 100644
index 0000000..19a907a
--- /dev/null
+++ b/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-matrix-template.html
@@ -0,0 +1,128 @@
+<!DOCTYPE html>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<meta charset="utf-8">
+<title>IgniteML</title>
+<style>
+    body {
+        margin: 0 15px;
+    }
+
+    p {
+        margin: 10px 0 !important;
+    }
+
+    .name {
+        font-size: 20px;
+        font-weight: 400;
+        font-family: monospace;
+    }
+
+    .swatch {
+        display: inline-block;
+        width: 25px;
+        height: 25px;
+        margin-left: 5px;
+        vertical-align: bottom;
+    }
+</style>
+<body>
+<img style="margin-top: 15px" width="100px" src="https://ignite.apache.org/images/logo3.png">
+<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.5.0/d3.min.js"></script>
+<script>
+    /*@DATA@*/
+    var data = [[{d: 2.256, r: 198, g: 128, b: 128}, {d: 0.123, r: 218, g: 228, b: 18}], [{
+        d: 2.256,
+        r: 108,
+        g: 28,
+        b: 108
+    }, {d: 0.123, r: 228, g: 228, b: 228}]];
+    /*@MAX@*/
+    var max = {d: 2.256, r: 128, g: 128, b: 128};
+    /*@MIN@*/
+    var min = {d: 0.123, r: 228, g: 228, b: 228};
+    /*@NAME@*/
+    var name = "Matrix";
+
+    var rows = data.length;
+    var cols = data[0].length;
+
+    var range = max.d - min.d;
+
+    var rw, rh;
+    var W, H;
+
+    if (cols > W) {
+        rw = 1;
+        W = cols;
+    }
+    else {
+        W = 1000;
+        rw = Math.min(Math.round(W / cols), 10);
+    }
+
+    if (rows > H) {
+        rh = 1;
+        H = rows;
+    }
+    else {
+        H = 1000;
+        rh = Math.min(Math.round(H / rows), 10);
+    }
+
+    d3.selectAll("body")
+        .append("p")
+        .text(name + " (" + rows + "x" + cols + ")")
+        .attr("class", "name");
+
+    d3.selectAll("body")
+        .append("p")
+        .attr("class", "name")
+        .text("Max: " + max.d)
+        .append("span")
+        .attr("class", "swatch")
+        .attr("style", "background-color: rgb(" + max.r + ", " + max.g + ", " + max.b + ")");
+
+    d3.selectAll("body")
+        .append("p")
+        .attr("class", "name")
+        .text("Min: " + min.d)
+        .append("span")
+        .attr("class", "swatch")
+        .attr("style", "background-color: rgb(" + min.r + ", " + min.g + ", " + min.b + ")");
+
+    var svg = d3.select("body").append("svg")
+        .attr("width", W)
+        .attr("height", H);
+
+    var y = 0;
+
+    for (var row = 0; row < rows; row++)
+        svg.selectAll("div")
+            .data(data[row])
+            .enter()
+            .append("rect")
+            .attr("x", function (d, i) {
+                return i * rw
+            })
+            .attr("y", rh * row)
+            .attr("fill", function (d) {
+                return "rgb(" + d.r + ", " + d.g + ", " + d.b + ")";
+            })
+            .attr("width", rw)
+            .attr("height", rh);
+</script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-vector-template.html
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-vector-template.html b/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-vector-template.html
new file mode 100644
index 0000000..7644481
--- /dev/null
+++ b/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-vector-template.html
@@ -0,0 +1,111 @@
+<!DOCTYPE html>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<meta charset="utf-8">
+<title>IgniteML</title>
+<style>
+    body {
+        margin: 0 15px;
+    }
+
+    p {
+        margin: 10px 0 !important;
+    }
+
+    .name {
+        font-size: 20px;
+        font-weight: 400;
+        font-family: monospace;
+    }
+
+    .swatch {
+        display: inline-block;
+        width: 25px;
+        height: 25px;
+        margin-left: 5px;
+        vertical-align: bottom;
+    }
+</style>
+<body>
+<img style="margin-top: 15px" width="100px" src="https://ignite.apache.org/images/logo3.png">
+<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.5.0/d3.min.js"></script>
+<script>
+    /*@DATA@*/
+    var data = [{d: 2.256, r: 128, g: 128, b: 128}, {d: 0.123, r: 228, g: 228, b: 228}];
+    /*@MAX@*/
+    var max = {d: 2.256, r: 128, g: 128, b: 128};
+    /*@MIN@*/
+    var min = {d: 0.123, r: 228, g: 228, b: 228};
+    /*@NAME@*/
+    var name = "Vector";
+
+    var W, H = 1000;
+
+    var range = max.d - min.d;
+
+    var rh = 20; // Constant.
+
+    var rw;
+
+    if (data.length > W) {
+        rw = 1;
+        W = data.length;
+    }
+    else {
+        W = 1000;
+        rw = Math.min(Math.round(W / data.length), 5);
+    }
+
+    d3.selectAll("body")
+        .append("p")
+        .text(name + " (size: " + data.length + ")")
+        .attr("class", "name");
+
+    d3.selectAll("body")
+        .append("p")
+        .attr("class", "name")
+        .text("Max: " + max.d)
+        .append("span")
+        .attr("class", "swatch")
+        .attr("style", "background-color: rgb(" + max.r + ", " + max.g + ", " + max.b + ")");
+
+    d3.selectAll("body")
+        .append("p")
+        .attr("class", "name")
+        .text("Min: " + min.d)
+        .append("span")
+        .attr("class", "swatch")
+        .attr("style", "background-color: rgb(" + min.r + ", " + min.g + ", " + min.b + ")");
+
+    var svg = d3.select("body").append("svg")
+        .attr("width", W)
+        .attr("height", H);
+
+    svg.selectAll("rect")
+        .data(data)
+        .enter()
+        .append("rect")
+        .attr("x", function (d, i) {
+            return i * rw
+        })
+        .attr("y", 10)
+        .attr("fill", function (d) {
+            return "rgb(" + d.r + ", " + d.g + ", " + d.b + ")";
+        })
+        .attr("width", rw)
+        .attr("height", rh);
+</script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/ExternalizeTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/ExternalizeTest.java b/modules/ml/src/test/java/org/apache/ignite/math/ExternalizeTest.java
deleted file mode 100644
index 218b7ff..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/ExternalizeTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Common test for externalization.
- */
-public abstract class ExternalizeTest<T extends Externalizable & Destroyable> {
-    /** */
-    protected void externalizeTest(T initObj) {
-        T objRestored = null;
-
-        try {
-            ByteArrayOutputStream byteArrOutputStream = new ByteArrayOutputStream();
-            ObjectOutputStream objOutputStream = new ObjectOutputStream(byteArrOutputStream);
-
-            objOutputStream.writeObject(initObj);
-
-            ByteArrayInputStream byteArrInputStream = new ByteArrayInputStream(byteArrOutputStream.toByteArray());
-            ObjectInputStream objInputStream = new ObjectInputStream(byteArrInputStream);
-
-            objRestored = (T)objInputStream.readObject();
-
-            assertTrue(MathTestConstants.VAL_NOT_EQUALS, initObj.equals(objRestored));
-            assertTrue(MathTestConstants.VAL_NOT_EQUALS, Integer.compare(initObj.hashCode(), objRestored.hashCode()) == 0);
-        }
-        catch (ClassNotFoundException | IOException e) {
-            fail(e + " [" + e.getMessage() + "]");
-        }
-        finally {
-            if (objRestored != null)
-                objRestored.destroy();
-        }
-    }
-
-    /** */
-    @Test
-    public abstract void externalizeTest();
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/MathImplDistributedTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/MathImplDistributedTestSuite.java b/modules/ml/src/test/java/org/apache/ignite/math/MathImplDistributedTestSuite.java
deleted file mode 100644
index 318ea95..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/MathImplDistributedTestSuite.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-import org.apache.ignite.math.impls.matrix.CacheMatrixTest;
-import org.apache.ignite.math.impls.matrix.SparseDistributedMatrixTest;
-import org.apache.ignite.math.impls.storage.matrix.SparseDistributedMatrixStorageTest;
-import org.apache.ignite.math.impls.vector.CacheVectorTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for all distributed tests located in org.apache.ignite.math.impls.* package.
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-    CacheVectorTest.class,
-    CacheMatrixTest.class,
-    SparseDistributedMatrixStorageTest.class,
-    SparseDistributedMatrixTest.class,
-})
-public class MathImplDistributedTestSuite {
-    // No-op.
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/MathImplLocalTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/MathImplLocalTestSuite.java b/modules/ml/src/test/java/org/apache/ignite/math/MathImplLocalTestSuite.java
deleted file mode 100644
index a652e7f..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/MathImplLocalTestSuite.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-import org.apache.ignite.math.decompositions.CholeskyDecompositionTest;
-import org.apache.ignite.math.decompositions.EigenDecompositionTest;
-import org.apache.ignite.math.decompositions.LUDecompositionTest;
-import org.apache.ignite.math.decompositions.QRDecompositionTest;
-import org.apache.ignite.math.decompositions.SingularValueDecompositionTest;
-import org.apache.ignite.math.impls.matrix.DenseLocalOffHeapMatrixConstructorTest;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrixConstructorTest;
-import org.apache.ignite.math.impls.matrix.DiagonalMatrixTest;
-import org.apache.ignite.math.impls.matrix.FunctionMatrixConstructorTest;
-import org.apache.ignite.math.impls.matrix.MatrixAttributeTest;
-import org.apache.ignite.math.impls.matrix.MatrixImplementationsTest;
-import org.apache.ignite.math.impls.matrix.MatrixViewConstructorTest;
-import org.apache.ignite.math.impls.matrix.PivotedMatrixViewConstructorTest;
-import org.apache.ignite.math.impls.matrix.RandomMatrixConstructorTest;
-import org.apache.ignite.math.impls.matrix.SparseLocalOnHeapMatrixConstructorTest;
-import org.apache.ignite.math.impls.matrix.TransposedMatrixViewTest;
-import org.apache.ignite.math.impls.storage.matrix.MatrixArrayStorageTest;
-import org.apache.ignite.math.impls.storage.matrix.MatrixOffHeapStorageTest;
-import org.apache.ignite.math.impls.storage.matrix.MatrixStorageImplementationTest;
-import org.apache.ignite.math.impls.storage.vector.RandomAccessSparseVectorStorageTest;
-import org.apache.ignite.math.impls.storage.vector.SparseLocalOffHeapVectorStorageTest;
-import org.apache.ignite.math.impls.storage.vector.VectorArrayStorageTest;
-import org.apache.ignite.math.impls.storage.vector.VectorOffheapStorageTest;
-import org.apache.ignite.math.impls.vector.AbstractVectorTest;
-import org.apache.ignite.math.impls.vector.ConstantVectorConstructorTest;
-import org.apache.ignite.math.impls.vector.DelegatingVectorConstructorTest;
-import org.apache.ignite.math.impls.vector.DenseLocalOffHeapVectorConstructorTest;
-import org.apache.ignite.math.impls.vector.DenseLocalOnHeapVectorConstructorTest;
-import org.apache.ignite.math.impls.vector.FunctionVectorConstructorTest;
-import org.apache.ignite.math.impls.vector.MatrixVectorViewTest;
-import org.apache.ignite.math.impls.vector.PivotedVectorViewConstructorTest;
-import org.apache.ignite.math.impls.vector.RandomVectorConstructorTest;
-import org.apache.ignite.math.impls.vector.SingleElementVectorConstructorTest;
-import org.apache.ignite.math.impls.vector.SingleElementVectorViewConstructorTest;
-import org.apache.ignite.math.impls.vector.SparseLocalVectorConstructorTest;
-import org.apache.ignite.math.impls.vector.VectorAttributesTest;
-import org.apache.ignite.math.impls.vector.VectorFoldMapTest;
-import org.apache.ignite.math.impls.vector.VectorImplementationsTest;
-import org.apache.ignite.math.impls.vector.VectorIterableTest;
-import org.apache.ignite.math.impls.vector.VectorNormTest;
-import org.apache.ignite.math.impls.vector.VectorToMatrixTest;
-import org.apache.ignite.math.impls.vector.VectorViewTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for all local tests located in org.apache.ignite.math.impls.* package.
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-    // Vector constructors tests.
-    DenseLocalOnHeapVectorConstructorTest.class,
-    DenseLocalOffHeapVectorConstructorTest.class,
-    SparseLocalVectorConstructorTest.class,
-    RandomVectorConstructorTest.class,
-    ConstantVectorConstructorTest.class,
-    FunctionVectorConstructorTest.class,
-    SingleElementVectorConstructorTest.class,
-    PivotedVectorViewConstructorTest.class,
-    SingleElementVectorViewConstructorTest.class,
-    DelegatingVectorConstructorTest.class,
-    // Various vectors tests.
-    AbstractVectorTest.class,
-    VectorImplementationsTest.class,
-    VectorViewTest.class,
-    MatrixVectorViewTest.class,
-    // Vector particular features tests.
-    VectorIterableTest.class,
-    VectorAttributesTest.class,
-    VectorToMatrixTest.class,
-    VectorNormTest.class,
-    VectorFoldMapTest.class,
-    // Vector storage tests
-    VectorArrayStorageTest.class,
-    VectorOffheapStorageTest.class,
-    RandomAccessSparseVectorStorageTest.class,
-    SparseLocalOffHeapVectorStorageTest.class,
-    // Matrix storage tests.
-    MatrixStorageImplementationTest.class,
-    MatrixOffHeapStorageTest.class,
-    MatrixArrayStorageTest.class,
-    // Matrix constructors tests.
-    DenseLocalOnHeapMatrixConstructorTest.class,
-    DenseLocalOffHeapMatrixConstructorTest.class,
-    RandomMatrixConstructorTest.class,
-    FunctionMatrixConstructorTest.class,
-    MatrixViewConstructorTest.class,
-    PivotedMatrixViewConstructorTest.class,
-    SparseLocalOnHeapMatrixConstructorTest.class,
-    // Matrix tests.
-    MatrixImplementationsTest.class,
-    DiagonalMatrixTest.class,
-    MatrixAttributeTest.class,
-    TransposedMatrixViewTest.class,
-    // Decomposes
-    LUDecompositionTest.class,
-    EigenDecompositionTest.class,
-    CholeskyDecompositionTest.class,
-    QRDecompositionTest.class,
-    SingularValueDecompositionTest.class
-})
-public class MathImplLocalTestSuite {
-    // No-op.
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/MathImplMainTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/MathImplMainTestSuite.java b/modules/ml/src/test/java/org/apache/ignite/math/MathImplMainTestSuite.java
deleted file mode 100644
index 44fa8e6..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/MathImplMainTestSuite.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for local and distributed tests
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-    MathImplLocalTestSuite.class,
-    MathImplDistributedTestSuite.class
-})
-public class MathImplMainTestSuite {
-    // No-op.
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/TracerTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/TracerTest.java b/modules/ml/src/test/java/org/apache/ignite/math/TracerTest.java
deleted file mode 100644
index 35d2f60..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/TracerTest.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math;
-
-import java.awt.Color;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.Optional;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector;
-import org.junit.Test;
-
-import static java.nio.file.Files.createTempFile;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests for {@link Tracer}.
- */
-public class TracerTest {
-    /** */ private static final String DEFAULT_FORMAT = "%.10f";
-    /** */ private static final double DEFAULT_DELTA = 0.000000001d;
-
-    /**
-     * Color mapper that maps [0, 1] range into three distinct RGB segments.
-     */
-    private static final Tracer.ColorMapper COLOR_MAPPER = new Tracer.ColorMapper() {
-        /** {@inheritDoc} */
-        @Override public Color apply(Double d) {
-            if (d <= 0.33)
-                return Color.RED;
-            else if (d <= 0.66)
-                return Color.GREEN;
-            else
-                return Color.BLUE;
-        }
-    };
-
-    /**
-     * @param size Vector size.
-     */
-    private Vector makeRandomVector(int size) {
-        DenseLocalOnHeapVector vec = new DenseLocalOnHeapVector(size);
-
-        vec.assign((idx) -> Math.random());
-
-        return vec;
-    }
-
-    /**
-     * @param rows Amount of rows in matrix.
-     * @param cols Amount of columns in matrix.
-     */
-    private Matrix makeRandomMatrix(int rows, int cols) {
-        DenseLocalOnHeapMatrix mtx = new DenseLocalOnHeapMatrix(rows, cols);
-
-        // Missing assign(f)?
-        mtx.map((d) -> Math.random());
-
-        return mtx;
-    }
-
-    /**
-     *
-     */
-    @Test
-    public void testAsciiVectorTracer() {
-        Vector vec = makeRandomVector(20);
-
-        Tracer.showAscii(vec);
-        Tracer.showAscii(vec, "%2f");
-        Tracer.showAscii(vec, "%.3g");
-    }
-
-    /**
-     *
-     */
-    @Test
-    public void testAsciiMatrixTracer() {
-        Matrix mtx = makeRandomMatrix(10, 10);
-
-        Tracer.showAscii(mtx);
-        Tracer.showAscii(mtx, "%2f");
-        Tracer.showAscii(mtx, "%.3g");
-    }
-
-    /**
-     *
-     */
-    @Test
-    public void testHtmlVectorTracer() throws IOException {
-        Vector vec1 = makeRandomVector(1000);
-
-        // Default color mapping.
-        Tracer.showHtml(vec1);
-
-        // Custom color mapping.
-        Tracer.showHtml(vec1, COLOR_MAPPER);
-
-        // Default color mapping with sorted vector.
-        Tracer.showHtml(vec1.sort());
-    }
-
-    /**
-     *
-     */
-    @Test
-    public void testHtmlMatrixTracer() throws IOException {
-        Matrix mtx1 = makeRandomMatrix(100, 100);
-
-        // Custom color mapping.
-        Tracer.showHtml(mtx1, COLOR_MAPPER);
-
-        Matrix mtx2 = new DenseLocalOnHeapMatrix(100, 100);
-
-        double MAX = (double)(mtx2.rowSize() * mtx2.columnSize());
-
-        mtx2.assign((x, y) -> (double)(x * y) / MAX);
-
-        Tracer.showHtml(mtx2);
-    }
-
-    /** */
-    @Test
-    public void testWriteVectorToCSVFile() throws IOException {
-        DenseLocalOnHeapVector vector = new DenseLocalOnHeapVector(MathTestConstants.STORAGE_SIZE);
-
-        for (int i = 0; i < vector.size(); i++)
-            vector.set(i, Math.random());
-
-        Path file = createTempFile("vector", ".csv");
-
-        Tracer.saveAsCsv(vector, DEFAULT_FORMAT, file.toString());
-
-        System.out.println("Vector exported: " + file.getFileName());
-
-        List<String> strings = Files.readAllLines(file);
-        Optional<String> reduce = strings.stream().reduce((s1, s2) -> s1 + s2);
-        String[] csvVals = reduce.get().split(",");
-
-        for (int i = 0; i < vector.size(); i++) {
-            Double csvVal = Double.valueOf(csvVals[i]);
-
-            assertEquals("Unexpected value.", csvVal, vector.get(i), DEFAULT_DELTA);
-        }
-
-        Files.deleteIfExists(file);
-    }
-
-    /** */
-    @Test
-    public void testWriteMatrixToCSVFile() throws IOException {
-        DenseLocalOnHeapMatrix matrix = new DenseLocalOnHeapMatrix(MathTestConstants.STORAGE_SIZE, MathTestConstants.STORAGE_SIZE);
-
-        for (int i = 0; i < matrix.rowSize(); i++)
-            for (int j = 0; j < matrix.columnSize(); j++)
-                matrix.set(i, j, Math.random());
-
-        Path file = createTempFile("matrix", ".csv");
-
-        Tracer.saveAsCsv(matrix, DEFAULT_FORMAT, file.toString());
-
-        System.out.println("Matrix exported: " + file.getFileName());
-
-        List<String> strings = Files.readAllLines(file);
-        Optional<String> reduce = strings.stream().reduce((s1, s2) -> s1 + s2);
-        String[] csvVals = reduce.get().split(",");
-
-        for (int i = 0; i < matrix.rowSize(); i++)
-            for (int j = 0; j < matrix.columnSize(); j++) {
-                Double csvVal = Double.valueOf(csvVals[i * matrix.rowSize() + j]);
-
-                assertEquals("Unexpected value.", csvVal, matrix.get(i, j), DEFAULT_DELTA);
-            }
-
-        Files.deleteIfExists(file);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/benchmark/MathBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/benchmark/MathBenchmark.java b/modules/ml/src/test/java/org/apache/ignite/math/benchmark/MathBenchmark.java
deleted file mode 100644
index 4c3718a..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/benchmark/MathBenchmark.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.benchmark;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-/** Refer {@link MathBenchmarkSelfTest} for usage examples. */
-class MathBenchmark {
-    /** */
-    private final boolean outputToConsole;
-
-    /** */
-    private final String benchmarkName;
-
-    /** */
-    private final int measurementTimes;
-
-    /** */
-    private final int warmUpTimes;
-
-    /** */
-    private final String tag;
-
-    /** */
-    private final String comments;
-
-    /** Constructor strictly for use within this class. */
-    private MathBenchmark(String benchmarkName, boolean outputToConsole, int measurementTimes, int warmUpTimes,
-        String tag, String comments) {
-        this.benchmarkName = benchmarkName;
-        this.outputToConsole = outputToConsole;
-        this.measurementTimes = measurementTimes;
-        this.warmUpTimes = warmUpTimes;
-        this.tag = tag;
-        this.comments = comments;
-        validate();
-    }
-
-    /**
-     * Benchmark with specified name and default parameters, in particular, default output file.
-     *
-     * @param benchmarkName name
-     */
-    MathBenchmark(String benchmarkName) {
-        this(benchmarkName, false, 100, 1, "", "");
-    }
-
-    /**
-     * Executes the code using config of this benchmark.
-     *
-     * @param code code to execute
-     * @throws Exception if something goes wrong
-     */
-    void execute(BenchmarkCode code) throws Exception {
-        System.out.println("Started benchmark [" + benchmarkName + "].");
-
-        for (int cnt = 0; cnt < warmUpTimes; cnt++)
-            code.call();
-
-        final long start = System.currentTimeMillis();
-
-        for (int cnt = 0; cnt < measurementTimes; cnt++)
-            code.call();
-
-        final long end = System.currentTimeMillis();
-
-        writeResults(formatResults(start, end));
-
-        System.out.println("Finished benchmark [" + benchmarkName + "].");
-    }
-
-    /**
-     * Set optional output mode for using stdout.
-     *
-     * @return configured benchmark
-     */
-    MathBenchmark outputToConsole() {
-        return new MathBenchmark(benchmarkName, true, measurementTimes, warmUpTimes, tag, comments);
-    }
-
-    /**
-     * Set optional measurement times.
-     *
-     * @param param times
-     * @return configured benchmark
-     */
-    MathBenchmark measurementTimes(int param) {
-        return new MathBenchmark(benchmarkName, outputToConsole, param, warmUpTimes, tag, comments);
-    }
-
-    /**
-     * Set optional warm-up times.
-     *
-     * @param param times
-     * @return configured benchmark
-     */
-    MathBenchmark warmUpTimes(int param) {
-        return new MathBenchmark(benchmarkName, outputToConsole, measurementTimes, param, tag, comments);
-    }
-
-    /**
-     * Set optional tag to help filtering specific kind of benchmark results.
-     *
-     * @param param name
-     * @return configured benchmark
-     */
-    MathBenchmark tag(String param) {
-        return new MathBenchmark(benchmarkName, outputToConsole, measurementTimes, warmUpTimes, param, comments);
-    }
-
-    /**
-     * Set optional comments.
-     *
-     * @param param name
-     * @return configured benchmark
-     */
-    MathBenchmark comments(String param) {
-        return new MathBenchmark(benchmarkName, outputToConsole, measurementTimes, warmUpTimes, tag, param);
-    }
-
-    /** */
-    private void writeResults(String results) throws Exception {
-        if (outputToConsole) {
-            System.out.println(results);
-
-            return;
-        }
-
-        new ResultsWriter().append(results);
-    }
-
-    /** */
-    private String formatResults(long start, long end) {
-        final String delim = ",";
-
-        assert !formatDouble(1000_000_001.1).contains(delim) : "Formatted results contain [" + delim + "].";
-
-        final String ts = formatTs(start);
-
-        assert !ts.contains(delim) : "Formatted timestamp contains [" + delim + "].";
-
-        return benchmarkName +
-            delim +
-            ts + // IMPL NOTE timestamp
-            delim +
-            formatDouble((double)(end - start) / measurementTimes) +
-            delim +
-            measurementTimes +
-            delim +
-            warmUpTimes +
-            delim +
-            tag +
-            delim +
-            comments;
-    }
-
-    /** */
-    private String formatDouble(double val) {
-        return String.format(Locale.US, "%f", val);
-    }
-
-    /** */
-    private String formatTs(long ts) {
-        final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
-
-        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
-
-        return sdf.format(new Date(ts));
-    }
-
-    /** */
-    private void validate() {
-        if (benchmarkName == null || benchmarkName.isEmpty())
-            throw new IllegalArgumentException("Invalid benchmark name: [" + benchmarkName + "].");
-
-        if (measurementTimes < 1)
-            throw new IllegalArgumentException("Invalid measurement times: [" + measurementTimes + "].");
-    }
-
-    /** */
-    interface BenchmarkCode {
-        // todo find out why Callable<Void> failed to work here
-
-        /** */
-        void call() throws Exception;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/benchmark/MathBenchmarkSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/benchmark/MathBenchmarkSelfTest.java b/modules/ml/src/test/java/org/apache/ignite/math/benchmark/MathBenchmarkSelfTest.java
deleted file mode 100644
index 7a86461..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/benchmark/MathBenchmarkSelfTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.benchmark;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/** */
-public class MathBenchmarkSelfTest {
-    /** */
-    @Test
-    @Ignore("Benchmark tests are intended only for manual execution")
-    public void demoTest() throws Exception {
-        for (int i = 0; i < 2; i++)
-            new MathBenchmark("demo test")
-                .outputToConsole() // IMPL NOTE this is to write output into console instead of a file
-                .tag(null) // IMPL NOTE try null for tag, expect it to be formatted reasonably
-                .comments(null) // IMPL NOTE try null for comments, expect it to be formatted reasonably
-                .execute(() -> {
-                    double seed = 1.1;
-
-                    for (int cnt = 0; cnt < 1000; cnt++) {
-                        seed = Math.pow(seed, 2);
-
-                        assertTrue(seed > 0);
-                    }
-                });
-    }
-
-    /** */
-    @Test
-    @Ignore("Benchmark tests are intended only for manual execution")
-    public void configTest() throws Exception {
-        new MathBenchmark("demo config test")
-            .outputToConsole()
-            .measurementTimes(2)
-            .warmUpTimes(0)
-            .tag("demo tag")
-            .comments("demo comments")
-            .execute(() -> System.out.println("config test"));
-    }
-
-    /** */
-    @Test(expected = IllegalArgumentException.class)
-    @Ignore("Benchmark tests are intended only for manual execution")
-    public void emptyNameTest() throws Exception {
-        new MathBenchmark("")
-            .outputToConsole()
-            .measurementTimes(1)
-            .warmUpTimes(1)
-            .tag("empty name test tag")
-            .comments("empty name test comments")
-            .execute(() -> System.out.println("empty name test"));
-    }
-
-    /** */
-    @Test(expected = IllegalArgumentException.class)
-    @Ignore("Benchmark tests are intended only for manual execution")
-    public void nullDropboxPathTest() throws Exception {
-        new ResultsWriter(null, "whatever", "whatever");
-    }
-
-    /** */
-    @Test(expected = IllegalArgumentException.class)
-    @Ignore("Benchmark tests are intended only for manual execution")
-    public void nullDropboxUrlTest() throws Exception {
-        new ResultsWriter("whatever", null, "whatever");
-    }
-
-    /** */
-    @Test(expected = IllegalArgumentException.class)
-    @Ignore("Benchmark tests are intended only for manual execution")
-    public void nullDropboxTokenTest() throws Exception {
-        new ResultsWriter("whatever", "whatever", null);
-    }
-
-    /** */
-    @Test(expected = IllegalArgumentException.class)
-    @Ignore("Benchmark tests are intended only for manual execution")
-    public void nullResultsTest() throws Exception {
-        new ResultsWriter("whatever", "whatever", "whatever").append(null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/benchmark/ResultsWriter.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/benchmark/ResultsWriter.java b/modules/ml/src/test/java/org/apache/ignite/math/benchmark/ResultsWriter.java
deleted file mode 100644
index aeec156..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/benchmark/ResultsWriter.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.benchmark;
-
-import com.dropbox.core.DbxException;
-import com.dropbox.core.DbxRequestConfig;
-import com.dropbox.core.v2.DbxClientV2;
-import com.dropbox.core.v2.files.WriteMode;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.StandardOpenOption;
-import java.util.UUID;
-
-/** */
-class ResultsWriter {
-    /** */
-    private static final String DROPBOX_PATH
-        = "/benchmarks/math.benchmark.results.csv";
-
-    /** */
-    private static final String DROPBOX_URL
-        = "https://www.dropbox.com/s/r7tcle31r7gaty8/math.benchmark.results.csv";
-
-    /** */
-    private static final String ACCESS_TOKEN
-        = "1MMmQjEyzGAAAAAAAAAAfDFrQ6oBPPi4NX-iU_VrgmXB2JDXqRHGa125cTkkEQ0V";
-
-    /** */
-    private final String dropboxPath;
-    /** */
-    private final String dropboxUrl;
-    /** */
-    private final String accessTok;
-
-    /** */
-    ResultsWriter(String dropboxPath, String dropboxUrl, String accessTok) {
-        this.dropboxPath = dropboxPath;
-        this.dropboxUrl = dropboxUrl;
-        this.accessTok = accessTok;
-
-        if (dropboxPath == null || dropboxUrl == null || accessTok == null)
-            throw new IllegalArgumentException("Neither of dropbox path, URL, access token can be null.");
-    }
-
-    /** **/
-    ResultsWriter() {
-        this(DROPBOX_PATH, DROPBOX_URL, ACCESS_TOKEN);
-    }
-
-    /** */
-    void append(String res) throws DbxException, IOException {
-        if (res == null)
-            throw new IllegalArgumentException("benchmark result is null");
-
-        if (dropboxPath == null) {
-            System.out.println(res);
-
-            return;
-        }
-
-        append(res, client());
-    }
-
-    /** */
-    private void append(String res, DbxClientV2 client) throws DbxException, IOException {
-        File tmp = createTmpFile();
-
-        try (FileOutputStream out = new FileOutputStream(tmp)) {
-            client.files().download(dropboxPath).download(out);
-        }
-
-        writeResults(res, tmp);
-
-        try (FileInputStream in = new FileInputStream(tmp)) {
-            client.files().uploadBuilder(dropboxPath).withMode(WriteMode.OVERWRITE).uploadAndFinish(in);
-        }
-
-        if (!tmp.delete())
-            System.out.println("Failed to delete " + tmp.getAbsolutePath());
-
-        System.out.println("Uploaded benchmark results to: " + dropboxUrl);
-    }
-
-    /** */
-    private void writeResults(String res, File tmp) throws IOException {
-        final String unixLineSeparator = "\n";
-
-        try (final PrintWriter writer = new PrintWriter(Files.newBufferedWriter(Paths.get(tmp.toURI()),
-            StandardOpenOption.APPEND, StandardOpenOption.CREATE))) {
-            writer.write(res + unixLineSeparator);
-        }
-    }
-
-    /** */
-    private File createTmpFile() throws IOException {
-        File tmp = File.createTempFile(UUID.randomUUID().toString(), ".csv");
-
-        tmp.deleteOnExit();
-
-        return tmp;
-    }
-
-    /** */
-    private DbxClientV2 client() {
-        return new DbxClientV2(DbxRequestConfig.newBuilder("dropbox/MathBenchmark").build(), accessTok);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/benchmark/VectorBenchmarkTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/benchmark/VectorBenchmarkTest.java b/modules/ml/src/test/java/org/apache/ignite/math/benchmark/VectorBenchmarkTest.java
deleted file mode 100644
index 1f7b204..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/benchmark/VectorBenchmarkTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.benchmark;
-
-import java.util.function.BiConsumer;
-import java.util.function.Function;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.vector.DenseLocalOffHeapVector;
-import org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
-/** */
-public class VectorBenchmarkTest {
-    // todo add benchmarks for other methods in Vector and for other types of Vector and Matrix
-
-    /** */
-    @Test
-    @Ignore("Benchmark tests are intended only for manual execution")
-    public void testDenseLocalOnHeapVector() throws Exception {
-        benchmark("DenseLocalOnHeapVector basic mix", DenseLocalOnHeapVector::new, this::basicMix);
-
-        benchmark("DenseLocalOnHeapVector fold map", DenseLocalOnHeapVector::new, this::foldMapMix);
-    }
-
-    /** */
-    @Test
-    @Ignore("Benchmark tests are intended only for manual execution")
-    public void testDenseLocalOffHeapVector() throws Exception {
-        benchmark("DenseLocalOffHeapVector basic mix", DenseLocalOffHeapVector::new, this::basicMix);
-
-        benchmark("DenseLocalOffHeapVector fold map", DenseLocalOffHeapVector::new, this::foldMapMix);
-    }
-
-    /** */
-    private void benchmark(String namePrefix, Function<Integer, Vector> constructor,
-        BiConsumer<Integer, Function<Integer, Vector>> consumer) throws Exception {
-        assertNotNull(namePrefix);
-
-        new MathBenchmark(namePrefix + " small sizes").execute(() -> {
-            for (int size : new int[] {2, 3, 4, 5, 6, 7})
-                consumer.accept(size, constructor);
-        });
-
-        new MathBenchmark(namePrefix + " sizes powers of 2").execute(() -> {
-            for (int power : new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14})
-                consumer.accept(1 << power, constructor);
-        });
-
-        new MathBenchmark(namePrefix + " large sizes").execute(() -> {
-            for (int power : new int[] {10, 12, 14, 16})
-                for (int delta : new int[] {-1, 0, 1})
-                    consumer.accept((1 << power) + delta, constructor);
-        });
-
-        new MathBenchmark(namePrefix + " extra large sizes")
-            .measurementTimes(10)
-            .execute(() -> { // IMPL NOTE trying below with power 22 almost killed my IDEA and laptop
-                for (int power : new int[] {17, 18, 19, 20, 21})
-                    for (int delta : new int[] {-1, 0}) // IMPL NOTE delta +1 is not intended for use here
-                        consumer.accept((1 << power) + delta, constructor);
-            });
-    }
-
-    /** */
-    private void basicMix(int size, Function<Integer, Vector> constructor) {
-        final Vector v1 = constructor.apply(size), v2 = constructor.apply(size);
-
-        for (int idx = 0; idx < size; idx++) {
-            v1.set(idx, idx);
-
-            v2.set(idx, size - idx);
-        }
-
-        assertNotNull(v1.sum());
-
-        assertNotNull(v1.copy());
-
-        assertFalse(v1.getLengthSquared() < 0);
-
-        assertNotNull(v1.normalize());
-
-        assertNotNull(v1.logNormalize());
-
-        assertFalse(v1.getDistanceSquared(v2) < 0);
-
-        assertNotNull(v1.divide(2));
-
-        assertNotNull(v1.minus(v2));
-
-        assertNotNull(v1.plus(v2));
-
-        assertNotNull(v1.dot(v2));
-
-        assertNotNull(v1.assign(v2));
-
-        assertNotNull(v1.assign(1)); // IMPL NOTE this would better be last test for it sets all values the same
-    }
-
-    /** */
-    private void foldMapMix(int size, Function<Integer, Vector> constructor) {
-        final Vector v1 = constructor.apply(size), v2 = constructor.apply(size);
-
-        for (int idx = 0; idx < size; idx++) {
-            v1.set(idx, idx);
-
-            v2.set(idx, size - idx);
-        }
-
-        assertNotNull(v1.map((val) -> (val + 1)));
-
-        assertNotNull(v1.map(v2, (one, other) -> one + other / 2.0));
-
-        assertNotNull(v1.map((val, val1) -> (val + val1), 2.0));
-
-        assertNotNull(v1.foldMap((sum, val) -> (val + sum), (val) -> val, 0.0));
-
-        assertNotNull(v1.foldMap(v2, (sum, val) -> (val + sum), (val1, val2) -> val1 + val2, 0.0));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/benchmark/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/benchmark/package-info.java b/modules/ml/src/test/java/org/apache/ignite/math/benchmark/package-info.java
deleted file mode 100644
index cbf5d36..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/benchmark/package-info.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.benchmark;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/decompositions/CholeskyDecompositionTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/decompositions/CholeskyDecompositionTest.java b/modules/ml/src/test/java/org/apache/ignite/math/decompositions/CholeskyDecompositionTest.java
deleted file mode 100644
index fa311e0..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/decompositions/CholeskyDecompositionTest.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.decompositions;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.CardinalityException;
-import org.apache.ignite.math.exceptions.NonPositiveDefiniteMatrixException;
-import org.apache.ignite.math.exceptions.NonSymmetricMatrixException;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.math.impls.matrix.PivotedMatrixView;
-import org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/** */
-public class CholeskyDecompositionTest {
-    /** */
-    @Test
-    public void basicTest() {
-        basicTest(new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d, 0.0d},
-            {-1.0d, 2.0d, -1.0d},
-            {0.0d, -1.0d, 2.0d}
-        }));
-    }
-
-    /**
-     * Test for {@link DecompositionSupport} features.
-     */
-    @Test
-    public void decompositionSupportTest() {
-        basicTest(new PivotedMatrixView(new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d, 0.0d},
-            {-1.0d, 2.0d, -1.0d},
-            {0.0d, -1.0d, 2.0d}
-        })));
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void nullMatrixTest() {
-        new CholeskyDecomposition(null);
-    }
-
-    /** */
-    @Test(expected = CardinalityException.class)
-    public void wrongMatrixSizeTest() {
-        new CholeskyDecomposition(new DenseLocalOnHeapMatrix(2, 3));
-    }
-
-    /** */
-    @Test(expected = NonSymmetricMatrixException.class)
-    public void nonSymmetricMatrixTest() {
-        new CholeskyDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d, 10.0d},
-            {-1.0d, 2.0d, -1.0d},
-            {-10.0d, -1.0d, 2.0d}
-        }));
-    }
-
-    /** */
-    @Test(expected = NonPositiveDefiniteMatrixException.class)
-    public void nonAbsPositiveMatrixTest() {
-        new CholeskyDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d, 0.0d},
-            {-1.0d, 0.0d, -1.0d},
-            {0.0d, -1.0d, 2.0d}
-        }));
-    }
-
-    /** */
-    @Test(expected = CardinalityException.class)
-    public void solveWrongVectorSizeTest() {
-        new CholeskyDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d, 0.0d},
-            {-1.0d, 2.0d, -1.0d},
-            {0.0d, -1.0d, 2.0d}
-        })).solve(new DenseLocalOnHeapVector(2));
-    }
-
-    /** */
-    @Test(expected = CardinalityException.class)
-    public void solveWrongMatrixSizeTest() {
-        new CholeskyDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d, 0.0d},
-            {-1.0d, 2.0d, -1.0d},
-            {0.0d, -1.0d, 2.0d}
-        })).solve(new DenseLocalOnHeapMatrix(2, 3));
-    }
-
-    /** */
-    private void basicTest(Matrix m) {
-        // This decomposition is useful when dealing with systems of linear equations of the form
-        // m x = b where m is a Hermitian matrix.
-        // For such systems Cholesky decomposition provides
-        // more effective method of solving compared to LU decomposition.
-        // Suppose we want to solve system
-        // m x = b for various bs. Then after we computed Cholesky decomposition, we can feed various bs
-        // as a matrix of the form
-        // (b1, b2, ..., bm)
-        // to the method Cholesky::solve which returns solutions in the form
-        // (sol1, sol2, ..., solm)
-        CholeskyDecomposition dec = new CholeskyDecomposition(m);
-        assertEquals("Unexpected value for decomposition determinant.",
-            4d, dec.getDeterminant(), 0d);
-
-        Matrix l = dec.getL();
-        Matrix lt = dec.getLT();
-
-        assertNotNull("Matrix l is expected to be not null.", l);
-        assertNotNull("Matrix lt is expected to be not null.", lt);
-
-        for (int row = 0; row < l.rowSize(); row++)
-            for (int col = 0; col < l.columnSize(); col++)
-                assertEquals("Unexpected value transposed matrix at (" + row + "," + col + ").",
-                    l.get(row, col), lt.get(col, row), 0d);
-
-        Matrix bs = new DenseLocalOnHeapMatrix(new double[][] {
-            {4.0, -6.0, 7.0},
-            {1.0, 1.0, 1.0}
-        }).transpose();
-        Matrix sol = dec.solve(bs);
-
-        assertNotNull("Solution matrix is expected to be not null.", sol);
-        assertEquals("Solution rows are not as expected.", bs.rowSize(), sol.rowSize());
-        assertEquals("Solution columns are not as expected.", bs.columnSize(), sol.columnSize());
-
-        for (int i = 0; i < sol.columnSize(); i++)
-            assertNotNull("Solution matrix column is expected to be not null at index " + i, sol.viewColumn(i));
-
-        Vector b = new DenseLocalOnHeapVector(new double[] {4.0, -6.0, 7.0});
-        Vector solVec = dec.solve(b);
-
-        for (int idx = 0; idx < b.size(); idx++)
-            assertEquals("Unexpected value solution vector at " + idx,
-                b.get(idx), solVec.get(idx), 0d);
-
-        dec.destroy();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/decompositions/EigenDecompositionTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/decompositions/EigenDecompositionTest.java b/modules/ml/src/test/java/org/apache/ignite/math/decompositions/EigenDecompositionTest.java
deleted file mode 100644
index e4e7b15..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/decompositions/EigenDecompositionTest.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.decompositions;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests for {@link EigenDecomposition}
- */
-public class EigenDecompositionTest {
-    /** */
-    private static final double EPSILON = 1e-11;
-
-    /** */
-    @Test
-    public void testMatrixWithRealEigenvalues() {
-        test(new double[][] {
-                {1.0d, 0.0d, 0.0d, 0.0d},
-                {0.0d, 1.0d, 0.0d, 0.0d},
-                {0.0d, 0.0d, 2.0d, 0.0d},
-                {1.0d, 1.0d, 0.0d, 2.0d}},
-            new double[] {1, 2, 2, 1});
-    }
-
-    /** */
-    @Test
-    public void testSymmetricMatrix() {
-        EigenDecomposition decomposition = new EigenDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
-            {1.0d, 0.0d, 0.0d, 1.0d},
-            {0.0d, 1.0d, 0.0d, 1.0d},
-            {0.0d, 0.0d, 2.0d, 0.0d},
-            {1.0d, 1.0d, 0.0d, 2.0d}}));
-
-        Matrix d = decomposition.getD();
-        Matrix v = decomposition.getV();
-
-        assertNotNull("Matrix d is expected to be not null.", d);
-        assertNotNull("Matrix v is expected to be not null.", v);
-
-        assertEquals("Unexpected rows in d matrix.", 4, d.rowSize());
-        assertEquals("Unexpected cols in d matrix.", 4, d.columnSize());
-
-        assertEquals("Unexpected rows in v matrix.", 4, v.rowSize());
-        assertEquals("Unexpected cols in v matrix.", 4, v.columnSize());
-
-        assertIsDiagonalNonZero(d);
-
-        decomposition.destroy();
-    }
-
-    /** */
-    @Test
-    public void testNonSquareMatrix() {
-        EigenDecomposition decomposition = new EigenDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
-            {1.0d, 0.0d, 0.0d},
-            {0.0d, 1.0d, 0.0d},
-            {0.0d, 0.0d, 2.0d},
-            {1.0d, 1.0d, 0.0d}}));
-        // todo find out why decomposition of 3X4 matrix throws row index exception
-
-        Matrix d = decomposition.getD();
-        Matrix v = decomposition.getV();
-
-        assertNotNull("Matrix d is expected to be not null.", d);
-        assertNotNull("Matrix v is expected to be not null.", v);
-
-        assertEquals("Unexpected rows in d matrix.", 4, d.rowSize());
-        assertEquals("Unexpected cols in d matrix.", 4, d.columnSize());
-
-        assertEquals("Unexpected rows in v matrix.", 4, v.rowSize());
-        assertEquals("Unexpected cols in v matrix.", 3, v.columnSize());
-
-        assertIsDiagonal(d, true);
-
-        decomposition.destroy();
-    }
-
-    /** */
-    private void test(double[][] mRaw, double[] expRealEigenValues) {
-        DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(mRaw);
-        EigenDecomposition decomposition = new EigenDecomposition(m);
-
-        Matrix d = decomposition.getD();
-        Matrix v = decomposition.getV();
-
-        assertIsDiagonalNonZero(d);
-
-        // check that d's diagonal consists of eigenvalues of m.
-        assertDiagonalConsistsOfEigenvalues(m, d, v);
-
-        // m = v d v^{-1} is equivalent to
-        // m v = v d
-        assertMatricesAreEqual(m.times(v), v.times(d));
-
-        assertEigenvalues(decomposition, expRealEigenValues);
-
-        decomposition.destroy();
-    }
-
-    /** */
-    private void assertEigenvalues(EigenDecomposition decomposition, double[] expRealEigenValues) {
-        Vector real = decomposition.getRealEigenValues();
-        Vector imag = decomposition.getImagEigenvalues();
-
-        assertEquals("Real values size differs from expected.", expRealEigenValues.length, real.size());
-        assertEquals("Imag values size differs from expected.", expRealEigenValues.length, imag.size());
-
-        for (int idx = 0; idx < expRealEigenValues.length; idx++) {
-            assertEquals("Real eigen value differs from expected at " + idx,
-                expRealEigenValues[idx], real.get(idx), 0d);
-
-            assertEquals("Imag eigen value differs from expected at " + idx,
-                0d, imag.get(idx), 0d);
-        }
-
-    }
-
-    /** */
-    private void assertDiagonalConsistsOfEigenvalues(DenseLocalOnHeapMatrix m, Matrix d, Matrix v) {
-        int n = m.columnSize();
-        for (int i = 0; i < n; i++) {
-            Vector eigenVector = v.viewColumn(i);
-            double eigenVal = d.getX(i, i);
-            assertVectorsAreEqual(m.times(eigenVector), eigenVector.times(eigenVal));
-        }
-
-    }
-
-    /** */
-    private void assertMatricesAreEqual(Matrix exp, Matrix actual) {
-        assertTrue("The row sizes of matrices are not equal", exp.rowSize() == actual.rowSize());
-        assertTrue("The col sizes of matrices are not equal", exp.columnSize() == actual.columnSize());
-
-        // Since matrix is square, we need only one dimension
-        int n = exp.columnSize();
-
-        for (int i = 0; i < n; i++)
-            for (int j = 0; j < n; j++)
-                assertEquals("Values should be equal", exp.getX(i, j), actual.getX(i, j), EPSILON);
-    }
-
-    /** */
-    private void assertVectorsAreEqual(Vector exp, Vector actual) {
-        assertTrue("Vectors sizes are not equal", exp.size() == actual.size());
-
-        // Since matrix is square, we need only one dimension
-        int n = exp.size();
-
-        for (int i = 0; i < n; i++)
-            assertEquals("Values should be equal", exp.getX(i), actual.getX(i), EPSILON);
-    }
-
-    /** */
-    private void assertIsDiagonalNonZero(Matrix m) {
-        assertIsDiagonal(m, false);
-    }
-
-    /** */
-    private void assertIsDiagonal(Matrix m, boolean zeroesAllowed) {
-        // Since matrix is square, we need only one dimension
-        int n = m.columnSize();
-
-        assertEquals("Diagonal matrix is not square", n, m.rowSize());
-
-        for (int i = 0; i < n; i++)
-            for (int j = 0; j < n; j++)
-                assertTrue("Matrix is not diagonal, violation at (" + i + "," + j + ")",
-                    ((i == j) && (zeroesAllowed || m.getX(i, j) != 0))
-                        || ((i != j) && m.getX(i, j) == 0));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/decompositions/LUDecompositionTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/decompositions/LUDecompositionTest.java b/modules/ml/src/test/java/org/apache/ignite/math/decompositions/LUDecompositionTest.java
deleted file mode 100644
index 0feb48f..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/decompositions/LUDecompositionTest.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.decompositions;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.CardinalityException;
-import org.apache.ignite.math.exceptions.SingularMatrixException;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.math.impls.matrix.PivotedMatrixView;
-import org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests for {@link LUDecomposition}.
- */
-public class LUDecompositionTest {
-    /** */
-    private Matrix testL;
-    /** */
-    private Matrix testU;
-    /** */
-    private Matrix testP;
-    /** */
-    private Matrix testMatrix;
-    /** */
-    private int[] rawPivot;
-
-    /** */
-    @Before
-    public void setUp() {
-        double[][] rawMatrix = new double[][] {
-            {2.0d, 1.0d, 1.0d, 0.0d},
-            {4.0d, 3.0d, 3.0d, 1.0d},
-            {8.0d, 7.0d, 9.0d, 5.0d},
-            {6.0d, 7.0d, 9.0d, 8.0d}};
-        double[][] rawL = {
-            {1.0d, 0.0d, 0.0d, 0.0d},
-            {3.0d / 4.0d, 1.0d, 0.0d, 0.0d},
-            {1.0d / 2.0d, -2.0d / 7.0d, 1.0d, 0.0d},
-            {1.0d / 4.0d, -3.0d / 7.0d, 1.0d / 3.0d, 1.0d}};
-        double[][] rawU = {
-            {8.0d, 7.0d, 9.0d, 5.0d},
-            {0.0d, 7.0d / 4.0d, 9.0d / 4.0d, 17.0d / 4.0d},
-            {0.0d, 0.0d, -6.0d / 7.0d, -2.0d / 7.0d},
-            {0.0d, 0.0d, 0.0d, 2.0d / 3.0d}};
-        double[][] rawP = new double[][] {
-            {0, 0, 1.0d, 0},
-            {0, 0, 0, 1.0d},
-            {0, 1.0d, 0, 0},
-            {1.0d, 0, 0, 0}};
-
-        rawPivot = new int[] {3, 4, 2, 1};
-
-        testMatrix = new DenseLocalOnHeapMatrix(rawMatrix);
-        testL = new DenseLocalOnHeapMatrix(rawL);
-        testU = new DenseLocalOnHeapMatrix(rawU);
-        testP = new DenseLocalOnHeapMatrix(rawP);
-    }
-
-    /** */
-    @Test
-    public void getL() throws Exception {
-        Matrix luDecompositionL = new LUDecomposition(testMatrix).getL();
-
-        assertEquals("Unexpected row size.", testL.rowSize(), luDecompositionL.rowSize());
-        assertEquals("Unexpected column size.", testL.columnSize(), luDecompositionL.columnSize());
-
-        for (int i = 0; i < testL.rowSize(); i++)
-            for (int j = 0; j < testL.columnSize(); j++)
-                assertEquals("Unexpected value at (" + i + "," + j + ").",
-                    testL.getX(i, j), luDecompositionL.getX(i, j), 0.0000001d);
-
-        luDecompositionL.destroy();
-    }
-
-    /** */
-    @Test
-    public void getU() throws Exception {
-        Matrix luDecompositionU = new LUDecomposition(testMatrix).getU();
-
-        assertEquals("Unexpected row size.", testU.rowSize(), luDecompositionU.rowSize());
-        assertEquals("Unexpected column size.", testU.columnSize(), luDecompositionU.columnSize());
-
-        for (int i = 0; i < testU.rowSize(); i++)
-            for (int j = 0; j < testU.columnSize(); j++)
-                assertEquals("Unexpected value at (" + i + "," + j + ").",
-                    testU.getX(i, j), luDecompositionU.getX(i, j), 0.0000001d);
-
-        luDecompositionU.destroy();
-    }
-
-    /** */
-    @Test
-    public void getP() throws Exception {
-        Matrix luDecompositionP = new LUDecomposition(testMatrix).getP();
-
-        assertEquals("Unexpected row size.", testP.rowSize(), luDecompositionP.rowSize());
-        assertEquals("Unexpected column size.", testP.columnSize(), luDecompositionP.columnSize());
-
-        for (int i = 0; i < testP.rowSize(); i++)
-            for (int j = 0; j < testP.columnSize(); j++)
-                assertEquals("Unexpected value at (" + i + "," + j + ").",
-                    testP.getX(i, j), luDecompositionP.getX(i, j), 0.0000001d);
-
-        luDecompositionP.destroy();
-    }
-
-    /** */
-    @Test
-    public void getPivot() throws Exception {
-        Vector pivot = new LUDecomposition(testMatrix).getPivot();
-
-        assertEquals("Unexpected pivot size.", rawPivot.length, pivot.size());
-
-        for (int i = 0; i < testU.rowSize(); i++)
-            assertEquals("Unexpected value at " + i, rawPivot[i], (int)pivot.get(i) + 1);
-    }
-
-    /**
-     * Test for {@link DecompositionSupport} features.
-     */
-    @Test
-    public void decompositionSupportTest() {
-        LUDecomposition dec = new LUDecomposition(new PivotedMatrixView(testMatrix));
-        Matrix luDecompositionL = dec.getL();
-
-        assertEquals("Unexpected L row size.", testL.rowSize(), luDecompositionL.rowSize());
-        assertEquals("Unexpected L column size.", testL.columnSize(), luDecompositionL.columnSize());
-
-        for (int i = 0; i < testL.rowSize(); i++)
-            for (int j = 0; j < testL.columnSize(); j++)
-                assertEquals("Unexpected L value at (" + i + "," + j + ").",
-                    testL.getX(i, j), luDecompositionL.getX(i, j), 0.0000001d);
-
-        Matrix luDecompositionU = dec.getU();
-
-        assertEquals("Unexpected U row size.", testU.rowSize(), luDecompositionU.rowSize());
-        assertEquals("Unexpected U column size.", testU.columnSize(), luDecompositionU.columnSize());
-
-        for (int i = 0; i < testU.rowSize(); i++)
-            for (int j = 0; j < testU.columnSize(); j++)
-                assertEquals("Unexpected U value at (" + i + "," + j + ").",
-                    testU.getX(i, j), luDecompositionU.getX(i, j), 0.0000001d);
-
-        Matrix luDecompositionP = dec.getP();
-
-        assertEquals("Unexpected P row size.", testP.rowSize(), luDecompositionP.rowSize());
-        assertEquals("Unexpected P column size.", testP.columnSize(), luDecompositionP.columnSize());
-
-        for (int i = 0; i < testP.rowSize(); i++)
-            for (int j = 0; j < testP.columnSize(); j++)
-                assertEquals("Unexpected P value at (" + i + "," + j + ").",
-                    testP.getX(i, j), luDecompositionP.getX(i, j), 0.0000001d);
-
-        dec.destroy();
-    }
-
-    /** */
-    @Test
-    public void singularDeterminant() throws Exception {
-        assertEquals("Unexpected determinant for singular matrix decomposition.",
-            0d, new LUDecomposition(new DenseLocalOnHeapMatrix(2, 2)).determinant(), 0d);
-    }
-
-    /** */
-    @Test(expected = CardinalityException.class)
-    public void solveVecWrongSize() throws Exception {
-        new LUDecomposition(testMatrix).solve(new DenseLocalOnHeapVector(testMatrix.rowSize() + 1));
-    }
-
-    /** */
-    @Test(expected = SingularMatrixException.class)
-    public void solveVecSingularMatrix() throws Exception {
-        new LUDecomposition(new DenseLocalOnHeapMatrix(testMatrix.rowSize(), testMatrix.rowSize()))
-            .solve(new DenseLocalOnHeapVector(testMatrix.rowSize()));
-    }
-
-    /** */
-    @Test
-    public void solveVec() throws Exception {
-        Vector sol = new LUDecomposition(new PivotedMatrixView(testMatrix))
-            .solve(new DenseLocalOnHeapVector(testMatrix.rowSize()));
-
-        assertEquals("Wrong solution vector size.", testMatrix.rowSize(), sol.size());
-
-        for (int i = 0; i < sol.size(); i++)
-            assertEquals("Unexpected value at index " + i, 0d, sol.getX(i), 0.0000001d);
-    }
-
-    /** */
-    @Test(expected = CardinalityException.class)
-    public void solveMtxWrongSize() throws Exception {
-        new LUDecomposition(testMatrix).solve(
-            new DenseLocalOnHeapMatrix(testMatrix.rowSize() + 1, testMatrix.rowSize()));
-    }
-
-    /** */
-    @Test(expected = SingularMatrixException.class)
-    public void solveMtxSingularMatrix() throws Exception {
-        new LUDecomposition(new DenseLocalOnHeapMatrix(testMatrix.rowSize(), testMatrix.rowSize()))
-            .solve(new DenseLocalOnHeapMatrix(testMatrix.rowSize(), testMatrix.rowSize()));
-    }
-
-    /** */
-    @Test
-    public void solveMtx() throws Exception {
-        Matrix sol = new LUDecomposition(new PivotedMatrixView(testMatrix))
-            .solve(new DenseLocalOnHeapMatrix(testMatrix.rowSize(), testMatrix.rowSize()));
-
-        assertEquals("Wrong solution matrix row size.", testMatrix.rowSize(), sol.rowSize());
-
-        assertEquals("Wrong solution matrix column size.", testMatrix.rowSize(), sol.columnSize());
-
-        for (int row = 0; row < sol.rowSize(); row++)
-            for (int col = 0; col < sol.columnSize(); col++)
-                assertEquals("Unexpected P value at (" + row + "," + col + ").",
-                    0d, sol.getX(row, col), 0.0000001d);
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void nullMatrixTest() {
-        new LUDecomposition(null);
-    }
-
-    /** */
-    @Test(expected = CardinalityException.class)
-    public void nonSquareMatrixTest() {
-        new LUDecomposition(new DenseLocalOnHeapMatrix(2, 3));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/decompositions/QRDecompositionTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/decompositions/QRDecompositionTest.java b/modules/ml/src/test/java/org/apache/ignite/math/decompositions/QRDecompositionTest.java
deleted file mode 100644
index 3bb92d1..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/decompositions/QRDecompositionTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.decompositions;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.math.impls.matrix.PivotedMatrixView;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/** */
-public class QRDecompositionTest {
-    /** */
-    @Test
-    public void basicTest() {
-        basicTest(new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d, 0.0d},
-            {-1.0d, 2.0d, -1.0d},
-            {0.0d, -1.0d, 2.0d}
-        }));
-    }
-
-    /**
-     * Test for {@link DecompositionSupport} features.
-     */
-    @Test
-    public void decompositionSupportTest() {
-        basicTest(new PivotedMatrixView(new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d, 0.0d},
-            {-1.0d, 2.0d, -1.0d},
-            {0.0d, -1.0d, 2.0d}
-        })));
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void nullMatrixTest() {
-        new QRDecomposition(null);
-    }
-
-    /** */
-    @Test(expected = IllegalArgumentException.class)
-    public void solveWrongMatrixSizeTest() {
-        new QRDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d, 0.0d},
-            {-1.0d, 2.0d, -1.0d},
-            {0.0d, -1.0d, 2.0d}
-        })).solve(new DenseLocalOnHeapMatrix(2, 3));
-    }
-
-    /** */
-    private void basicTest(Matrix m) {
-        QRDecomposition dec = new QRDecomposition(m);
-        assertTrue("Unexpected value for full rank in decomposition " + dec, dec.hasFullRank());
-
-        Matrix q = dec.getQ();
-        Matrix r = dec.getR();
-
-        assertNotNull("Matrix q is expected to be not null.", q);
-        assertNotNull("Matrix r is expected to be not null.", r);
-
-        Matrix qSafeCp = safeCopy(q);
-
-        Matrix expIdentity = qSafeCp.times(qSafeCp.transpose());
-
-        final double delta = 0.0001;
-
-        for (int row = 0; row < expIdentity.rowSize(); row++)
-            for (int col = 0; col < expIdentity.columnSize(); col++)
-                assertEquals("Unexpected identity matrix value at (" + row + "," + col + ").",
-                    row == col ? 1d : 0d, expIdentity.get(col, row), delta);
-
-        for (int row = 0; row < r.rowSize(); row++)
-            for (int col = 0; col < row - 1; col++)
-                assertEquals("Unexpected upper triangular matrix value at (" + row + "," + col + ").",
-                    0d, r.get(row, col), delta);
-
-        Matrix recomposed = qSafeCp.times(r);
-
-        for (int row = 0; row < m.rowSize(); row++)
-            for (int col = 0; col < m.columnSize(); col++)
-                assertEquals("Unexpected recomposed matrix value at (" + row + "," + col + ").",
-                    m.get(row, col), recomposed.get(row, col), delta);
-
-        Matrix sol = dec.solve(new DenseLocalOnHeapMatrix(3, 10));
-        assertEquals("Unexpected rows in solution matrix.", 3, sol.rowSize());
-        assertEquals("Unexpected cols in solution matrix.", 10, sol.columnSize());
-
-        for (int row = 0; row < sol.rowSize(); row++)
-            for (int col = 0; col < sol.columnSize(); col++)
-                assertEquals("Unexpected solution matrix value at (" + row + "," + col + ").",
-                    0d, sol.get(row, col), delta);
-
-        dec.destroy();
-
-        QRDecomposition dec1 = new QRDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d},
-            {-1.0d, 2.0d},
-            {0.0d, -1.0d}
-        }));
-
-        assertTrue("Unexpected value for full rank in decomposition " + dec1, dec1.hasFullRank());
-
-        dec1.destroy();
-
-        QRDecomposition dec2 = new QRDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d, 0.0d, 0.0d},
-            {-1.0d, 2.0d, -1.0d, 0.0d},
-            {0.0d, -1.0d, 2.0d, 0.0d}
-        }));
-
-        assertTrue("Unexpected value for full rank in decomposition " + dec2, dec2.hasFullRank());
-
-        dec2.destroy();
-    }
-
-    /** */
-    private Matrix safeCopy(Matrix orig) {
-        return new DenseLocalOnHeapMatrix(orig.rowSize(), orig.columnSize()).assign(orig);
-    }
-}


[47/65] [abbrv] ignite git commit: GridCachePartitionedTxSalvageSelfTest fix (remove unnecessary topology change wait) - Fixes #1853.

Posted by ag...@apache.org.
GridCachePartitionedTxSalvageSelfTest fix (remove unnecessary topology change wait) - Fixes #1853.

Signed-off-by: Alexey Goncharuk <al...@gmail.com>


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

Branch: refs/heads/ignite-5024
Commit: ca8ad03b8089ae3b2b466a727aeaa3c1080f8b50
Parents: dcd27a9
Author: Konstantin Dudkov <kd...@ya.ru>
Authored: Fri Apr 21 15:27:34 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Apr 21 15:27:34 2017 +0300

----------------------------------------------------------------------
 .../distributed/near/GridCachePartitionedTxSalvageSelfTest.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ca8ad03b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
index 3e56b00..9cc3988 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
@@ -234,7 +234,7 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
      * @throws Exception If failed.
      */
     private void stopNodeAndSleep(long timeout) throws Exception {
-        stopGrid(0);
+        stopGrid(getTestIgniteInstanceName(0), false, false);
 
         info("Stopped grid.");
 


[46/65] [abbrv] ignite git commit: IGNITE-4949 - Corrected JdbcPojoStore for keepBinary flag

Posted by ag...@apache.org.
IGNITE-4949 - Corrected JdbcPojoStore for keepBinary flag


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

Branch: refs/heads/ignite-5024
Commit: dcd27a92775eabf47884eba8482f516be01a54ce
Parents: 04e0822
Author: Dmitriy Govorukhin <dm...@gmail.com>
Authored: Fri Apr 21 15:01:26 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Apr 21 15:01:26 2017 +0300

----------------------------------------------------------------------
 .../store/jdbc/CacheAbstractJdbcStore.java      | 29 ++++++++++++--------
 .../cache/store/CacheOsStoreManager.java        |  3 ++
 .../store/GridCacheStoreManagerAdapter.java     | 11 ++++++--
 .../CacheJdbcPojoStoreAbstractSelfTest.java     | 19 +++++++++++--
 ...BinaryMarshallerStoreKeepBinarySelfTest.java | 28 +++++++++++++++++++
 ...lerStoreKeepBinaryWithSqlEscapeSelfTest.java | 28 +++++++++++++++++++
 .../store/jdbc/CacheJdbcPojoStoreTest.java      |  4 +--
 .../ignite/testsuites/IgniteCacheTestSuite.java |  4 +++
 8 files changed, 108 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dcd27a92/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
index 625d3cd..ba2a98d 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
@@ -48,7 +48,6 @@ import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.cache.store.CacheStore;
 import org.apache.ignite.cache.store.CacheStoreSession;
 import org.apache.ignite.cache.store.jdbc.dialect.BasicJdbcDialect;
@@ -58,6 +57,7 @@ import org.apache.ignite.cache.store.jdbc.dialect.JdbcDialect;
 import org.apache.ignite.cache.store.jdbc.dialect.MySQLDialect;
 import org.apache.ignite.cache.store.jdbc.dialect.OracleDialect;
 import org.apache.ignite.cache.store.jdbc.dialect.SQLServerDialect;
+import org.apache.ignite.internal.binary.BinaryEnumObjectImpl;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.C1;
@@ -1348,10 +1348,17 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
                             // No-op.
                     }
                 }
-                else if (field.getJavaFieldType().isEnum() && fieldVal instanceof Enum) {
-                    Enum val = (Enum)fieldVal;
+                else if (field.getJavaFieldType().isEnum()) {
+                    if (fieldVal instanceof Enum) {
+                        Enum val = (Enum)fieldVal;
 
-                    fieldVal = NUMERIC_TYPES.contains(field.getDatabaseFieldType()) ? val.ordinal() : val.name();
+                        fieldVal = NUMERIC_TYPES.contains(field.getDatabaseFieldType()) ? val.ordinal() : val.name();
+                    }
+                    else if (fieldVal instanceof BinaryEnumObjectImpl) {
+                        BinaryEnumObjectImpl val = (BinaryEnumObjectImpl)fieldVal;
+
+                        fieldVal = val.enumOrdinal();
+                    }
                 }
 
                 stmt.setObject(idx, fieldVal);
@@ -1403,14 +1410,14 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
      */
     protected int fillValueParameters(PreparedStatement stmt, int idx, EntryMapping em, Object val)
         throws CacheWriterException {
-        TypeKind valKind = em.valueKind();
-
-        // Object could be passed by cache in binary format in case of cache configured with setStoreKeepBinary(true).
-        if (valKind == TypeKind.POJO && val instanceof BinaryObject)
-            valKind = TypeKind.BINARY;
-
         for (JdbcTypeField field : em.uniqValFlds) {
-            Object fieldVal = extractParameter(em.cacheName, em.valueType(), valKind, field.getJavaFieldName(), val);
+            Object fieldVal = extractParameter(
+                em.cacheName,
+                em.valueType(),
+                em.valueKind(),
+                field.getJavaFieldName(),
+                val
+            );
 
             fillParameter(stmt, idx++, field, fieldVal);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/dcd27a92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
index 27771ff..2e23d04 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
@@ -77,6 +77,9 @@ public class CacheOsStoreManager extends GridCacheStoreManagerAdapter {
 
     /** {@inheritDoc} */
     @Override public boolean convertBinary() {
+        if (alwaysKeepBinary)
+            return false;
+
         return configuredConvertBinary() && !(cfgStore instanceof PlatformCacheStore);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/dcd27a92/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
index bfb0d8d..ae7a3f5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
@@ -33,10 +33,11 @@ import javax.cache.integration.CacheLoaderException;
 import javax.cache.integration.CacheWriterException;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.cache.store.CacheStore;
 import org.apache.ignite.cache.store.CacheStore;
 import org.apache.ignite.cache.store.CacheStoreSession;
 import org.apache.ignite.cache.store.CacheStoreSessionListener;
+import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
@@ -76,8 +77,6 @@ import org.apache.ignite.transactions.TransactionState;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import static org.apache.ignite.IgniteSystemProperties.IGNITE_LOCAL_STORE_KEEPS_PRIMARY_ONLY;
-
 /**
  * Store manager.
  */
@@ -113,6 +112,9 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
     /** */
     private boolean globalSesLsnrs;
 
+    /** Always keep binary. */
+    protected boolean alwaysKeepBinary;
+
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public void initialize(@Nullable CacheStore cfgStore, Map sesHolders) throws IgniteCheckedException {
@@ -148,6 +150,9 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
         sesHolder = sesHolder0;
 
         locStore = U.hasAnnotation(cfgStore, CacheLocalStore.class);
+
+        if (cfgStore instanceof CacheJdbcPojoStore)
+            alwaysKeepBinary = true;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/dcd27a92/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
index 645756c..8544f71 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
@@ -35,6 +35,7 @@ import org.apache.ignite.cache.store.jdbc.model.PersonKey;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.ConnectorConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -220,6 +221,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
         cc.setCacheMode(PARTITIONED);
         cc.setAtomicityMode(transactional ? TRANSACTIONAL : ATOMIC);
         cc.setWriteBehindEnabled(false);
+        cc.setStoreKeepBinary(storeKeepBinary());
 
         CacheJdbcPojoStoreFactory<Object, Object> storeFactory = new CacheJdbcPojoStoreFactory<>();
         storeFactory.setDialect(new H2Dialect());
@@ -237,6 +239,13 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
     }
 
     /**
+     * @return Flag indicate keep value in binary format or not.
+     */
+    protected boolean storeKeepBinary(){
+        return false;
+    }
+
+    /**
      * Fill in-memory database with sample data.
      *
      * @param conn Connection to database.
@@ -396,6 +405,8 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     private void checkPutRemove() throws Exception {
+        boolean binaryMarshaller = marshaller() instanceof BinaryMarshaller || marshaller() == null;
+
         IgniteCache<Object, Person> c1 = grid().cache(CACHE_NAME);
 
         Connection conn = getConnection();
@@ -428,7 +439,9 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
             assertEquals(-2, rs.getInt(2));
             assertEquals(testDate, rs.getDate(3));
             assertEquals("Person-to-test-put-insert", rs.getString(4));
-            assertEquals(testGender.toString(), rs.getString(5));
+
+            assertEquals(testGender.toString(),
+                binaryMarshaller ? Gender.values()[rs.getInt(5)].toString(): rs.getString(5));
 
             assertFalse("Unexpected more data in result set", rs.next());
 
@@ -447,7 +460,9 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
             assertEquals(-3, rs.getInt(2));
             assertEquals(testDate, rs.getDate(3));
             assertEquals("Person-to-test-put-update", rs.getString(4));
-            assertEquals(testGender.toString(), rs.getString(5));
+
+            assertEquals(testGender.toString(),
+                binaryMarshaller ? Gender.values()[rs.getInt(5)].toString(): rs.getString(5));
 
             assertFalse("Unexpected more data in result set", rs.next());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/dcd27a92/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinarySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinarySelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinarySelfTest.java
new file mode 100644
index 0000000..dfca864
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinarySelfTest.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.store.jdbc;
+
+/**
+ *
+ */
+public class CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinarySelfTest extends CacheJdbcPojoStoreBinaryMarshallerSelfTest {
+    /** {@inheritDoc} */
+    @Override protected boolean storeKeepBinary() {
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/dcd27a92/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinaryWithSqlEscapeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinaryWithSqlEscapeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinaryWithSqlEscapeSelfTest.java
new file mode 100644
index 0000000..c7e1f79
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinaryWithSqlEscapeSelfTest.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.store.jdbc;
+
+/**
+ *
+ */
+public class CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinaryWithSqlEscapeSelfTest extends CacheJdbcPojoStoreBinaryMarshallerWithSqlEscapeSelfTest {
+    /** {@inheritDoc} */
+    @Override protected boolean storeKeepBinary() {
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/dcd27a92/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java
index 1a76321..bb85cab 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java
@@ -44,6 +44,7 @@ import org.apache.ignite.internal.util.typedef.CI2;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiInClosure;
 import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.config.GridTestProperties;
 import org.apache.ignite.testframework.junits.cache.GridAbstractCacheStoreSelfTest;
 import org.h2.jdbcx.JdbcConnectionPool;
 
@@ -331,8 +332,7 @@ public class CacheJdbcPojoStoreTest extends GridAbstractCacheStoreSelfTest<Cache
                             && Person.class.getName().equals(valType))
                             prnComplexKeys.add(key);
                     }
-                }
-                else {
+                }else {
                     if (k instanceof OrganizationKey && v instanceof Organization)
                         orgKeys.add(k);
                     else if (k instanceof PersonKey && v instanceof Person)

http://git-wip-us.apache.org/repos/asf/ignite/blob/dcd27a92/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index d338bf8..d544810 100755
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -24,6 +24,8 @@ import org.apache.ignite.cache.store.GridCacheBalancingStoreSelfTest;
 import org.apache.ignite.cache.store.GridCacheLoadOnlyStoreAdapterSelfTest;
 import org.apache.ignite.cache.store.StoreResourceInjectionSelfTest;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreBinaryMarshallerSelfTest;
+import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinarySelfTest;
+import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinaryWithSqlEscapeSelfTest;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreBinaryMarshallerWithSqlEscapeSelfTest;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreMultitreadedSelfTest;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreOptimizedMarshallerSelfTest;
@@ -228,7 +230,9 @@ public class IgniteCacheTestSuite extends TestSuite {
         suite.addTestSuite(CacheJdbcPojoStoreOptimizedMarshallerSelfTest.class);
         suite.addTestSuite(CacheJdbcPojoStoreOptimizedMarshallerWithSqlEscapeSelfTest.class);
         suite.addTestSuite(CacheJdbcPojoStoreBinaryMarshallerSelfTest.class);
+        suite.addTestSuite(CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinarySelfTest.class);
         suite.addTestSuite(CacheJdbcPojoStoreBinaryMarshallerWithSqlEscapeSelfTest.class);
+        suite.addTestSuite(CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinaryWithSqlEscapeSelfTest.class);
         suite.addTestSuite(CacheJdbcPojoStoreMultitreadedSelfTest.class);
         suite.addTestSuite(GridCacheBalancingStoreSelfTest.class);
         suite.addTestSuite(GridCacheAffinityApiSelfTest.class);


[13/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/package-info.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/package-info.java
new file mode 100644
index 0000000..e0a760c
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Contains specific implementations for matrix storage models.
+ */
+package org.apache.ignite.ml.math.impls.storage.matrix;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ArrayVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ArrayVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ArrayVectorStorage.java
new file mode 100644
index 0000000..dc23611
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ArrayVectorStorage.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Arrays;
+import org.apache.ignite.ml.math.VectorStorage;
+
+/**
+ * Array based {@link VectorStorage} implementation.
+ */
+public class ArrayVectorStorage implements VectorStorage {
+    /** Backing data array. */
+    private double[] data;
+
+    /**
+     * IMPL NOTE required by {@link Externalizable}.
+     */
+    public ArrayVectorStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param size Vector size.
+     */
+    public ArrayVectorStorage(int size) {
+        assert size > 0;
+
+        data = new double[size];
+    }
+
+    /**
+     * @param data Backing data array.
+     */
+    public ArrayVectorStorage(double[] data) {
+        assert data != null;
+
+        this.data = data;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return data == null ? 0 : data.length;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int i) {
+        return data[i];
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int i, double v) {
+        data[i] = v;
+    }
+
+    /** {@inheritDoc}} */
+    @Override public boolean isArrayBased() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double[] data() {
+        return data;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(data);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        data = (double[])in.readObject();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + Arrays.hashCode(data);
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+
+        if (obj == null || getClass() != obj.getClass())
+            return false;
+
+        ArrayVectorStorage that = (ArrayVectorStorage)obj;
+
+        return Arrays.equals(data, (that.data));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
new file mode 100644
index 0000000..7aa317c
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.ml.math.ValueMapper;
+import org.apache.ignite.ml.math.VectorKeyMapper;
+import org.apache.ignite.ml.math.VectorStorage;
+
+/**
+ * Vector storage based on existing cache and index and value mapping functions.
+ */
+public class CacheVectorStorage<K, V> implements VectorStorage {
+    /** Storage size. */
+    private int size;
+    /** Key mapper. */
+    private VectorKeyMapper<K> keyMapper;
+    /** Value mapper. */
+    private ValueMapper<V> valMapper;
+    /** Underlying ignite cache. */
+    private IgniteCache<K, V> cache;
+
+    /**
+     *
+     */
+    public CacheVectorStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param size
+     * @param cache
+     * @param keyMapper
+     * @param valMapper
+     */
+    public CacheVectorStorage(int size, IgniteCache<K, V> cache, VectorKeyMapper<K> keyMapper,
+        ValueMapper<V> valMapper) {
+        assert size > 0;
+        assert cache != null;
+        assert keyMapper != null;
+        assert valMapper != null;
+
+        this.size = size;
+        this.cache = cache;
+        this.keyMapper = keyMapper;
+        this.valMapper = valMapper;
+    }
+
+    /**
+     *
+     *
+     */
+    public IgniteCache<K, V> cache() {
+        return cache;
+    }
+
+    /**
+     *
+     *
+     */
+    public VectorKeyMapper<K> keyMapper() {
+        return keyMapper;
+    }
+
+    /**
+     *
+     *
+     */
+    public ValueMapper<V> valueMapper() {
+        return valMapper;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int i) {
+        return valMapper.toDouble(cache.get(keyMapper.apply(i)));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int i, double v) {
+        cache.put(keyMapper.apply(i), valMapper.fromDouble(v));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(size);
+        out.writeObject(keyMapper);
+        out.writeObject(valMapper);
+        out.writeUTF(cache.getName());
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        size = in.readInt();
+        keyMapper = (VectorKeyMapper<K>)in.readObject();
+        valMapper = (ValueMapper<V>)in.readObject();
+        cache = Ignition.localIgnite().getOrCreateCache(in.readUTF());
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + size();
+        res = res * 37 + keyMapper.hashCode();
+        res = res * 37 + valMapper.hashCode();
+        res = res * 37 + cache.hashCode();
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+
+        if (obj == null || getClass() != obj.getClass())
+            return false;
+
+        CacheVectorStorage that = (CacheVectorStorage)obj;
+
+        return size == that.size
+            && (keyMapper != null ? keyMapper.getClass().equals(that.keyMapper.getClass()) : that.keyMapper == null)
+            && (valMapper != null ? valMapper.getClass().equals(that.valMapper.getClass()) : that.valMapper == null)
+            && (cache != null ? cache.equals(that.cache) : that.cache == null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
new file mode 100644
index 0000000..31469ea
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+
+/**
+ * Constant read-only vector storage.
+ */
+public class ConstantVectorStorage implements VectorStorage {
+    /** */ private int size;
+    /** */ private double val;
+
+    /**
+     *
+     */
+    public ConstantVectorStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param size Vector size.
+     * @param val Value to set for vector elements.
+     */
+    public ConstantVectorStorage(int size, double val) {
+        assert size > 0;
+
+        this.size = size;
+        this.val = val;
+    }
+
+    /**
+     *
+     *
+     */
+    public double constant() {
+        return val;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int i) {
+        return val;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int i, double v) {
+        throw new UnsupportedOperationException("Can't set value into constant vector.");
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(size);
+        out.writeDouble(val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        size = in.readInt();
+        val = in.readDouble();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + size;
+        res = res * 37 + Double.hashCode(val);
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        ConstantVectorStorage that = (ConstantVectorStorage)o;
+
+        return size == that.size && val == that.val;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
new file mode 100644
index 0000000..c431bdb
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.ml.math.VectorStorage;
+
+/**
+ * {@link VectorStorage} implementation that delegates to parent matrix.
+ */
+public class DelegateVectorStorage implements VectorStorage {
+    /** Parent vector storage. */
+    private VectorStorage sto;
+
+    /** Offset in the parent vector. */
+    private int off;
+
+    /** Size of the vector. */
+    private int len;
+
+    /**
+     *
+     */
+    public DelegateVectorStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param sto Vector storage to delegate to.
+     * @param off Offset in the parent vector.
+     * @param len Size of the vector.
+     */
+    public DelegateVectorStorage(VectorStorage sto, int off, int len) {
+        assert sto != null;
+        assert off >= 0;
+        assert len > 0;
+
+        this.sto = sto;
+        this.off = off;
+        this.len = len;
+    }
+
+    /** */
+    public VectorStorage delegate() {
+        return sto;
+    }
+
+    /** */
+    public int offset() {
+        return off;
+    }
+
+    /** */
+    public int length() {
+        return len;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return len;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int i) {
+        return sto.get(off + i);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int i, double v) {
+        sto.set(off + i, v);
+    }
+
+    /** {@inheritDoc} */
+    @Override public double[] data() {
+        return sto.data();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return sto.isSequentialAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return sto.isDense();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return sto.isRandomAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return sto.isDistributed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return sto.isArrayBased();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(sto);
+        out.writeInt(off);
+        out.writeInt(len);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        sto = (VectorStorage)in.readObject();
+        off = in.readInt();
+        len = in.readInt();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        DelegateVectorStorage that = (DelegateVectorStorage)o;
+
+        return len == that.len && off == that.off && (sto != null ? sto.equals(that.sto) : that.sto == null);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + off;
+        res = res * 37 + len;
+        res = res * 37 + sto.hashCode();
+
+        return res;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DenseLocalOffHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DenseLocalOffHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DenseLocalOffHeapVectorStorage.java
new file mode 100644
index 0000000..a9965cc
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DenseLocalOffHeapVectorStorage.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.ml.math.VectorStorage;
+
+/**
+ * Local, dense off-heap vector storage.
+ */
+public class DenseLocalOffHeapVectorStorage implements VectorStorage {
+    /** Vector size. */
+    private int size;
+
+    /** */
+    private transient long ptr;
+    //TODO: temp solution.
+    /** */
+    private int ptrInitHash;
+
+    /**
+     *
+     */
+    public DenseLocalOffHeapVectorStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param size Vector size.
+     */
+    public DenseLocalOffHeapVectorStorage(int size) {
+        assert size > 0;
+
+        this.size = size;
+
+        allocateMemory(size);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int i) {
+        return GridUnsafe.getDouble(pointerOffset(i));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int i, double v) {
+        GridUnsafe.putDouble(pointerOffset(i), v);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double[] data() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(size);
+        out.writeInt(ptrInitHash);
+
+        for (int i = 0; i < size; i++)
+            out.writeDouble(get(i));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        size = in.readInt();
+
+        allocateMemory(size);
+
+        ptrInitHash = in.readInt();
+
+        for (int i = 0; i < size; i++)
+            set(i, in.readDouble());
+    }
+
+    /** {@inheritDoc} */
+    @Override public void destroy() {
+        GridUnsafe.freeMemory(ptr);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + size;
+        res = res * 37 + ptrInitHash;
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        DenseLocalOffHeapVectorStorage that = (DenseLocalOffHeapVectorStorage)o;
+
+        return size == that.size && isMemoryEquals(that);
+    }
+
+    /** */
+    private boolean isMemoryEquals(DenseLocalOffHeapVectorStorage otherStorage) {
+        return IntStream.range(0, size).parallel().noneMatch(idx -> Double.compare(get(idx), otherStorage.get(idx)) != 0);
+    }
+
+    /**
+     * Pointer offset for specific index.
+     *
+     * @param i Offset index.
+     */
+    private long pointerOffset(int i) {
+        return ptr + i * Double.BYTES;
+    }
+
+    /** */
+    private void allocateMemory(int size) {
+        ptr = GridUnsafe.allocateMemory(size * Double.BYTES);
+
+        ptrInitHash = Long.hashCode(ptr);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
new file mode 100644
index 0000000..0f13bb6
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.IgniteFunction;
+import org.apache.ignite.ml.math.functions.IntDoubleToVoidFunction;
+
+/**
+ * Read-only or read-write function-based vector storage.
+ */
+public class FunctionVectorStorage implements VectorStorage {
+    /** */ private IgniteFunction<Integer, Double> getFunc;
+    /** */ private IntDoubleToVoidFunction setFunc;
+    /** */ private int size;
+
+    /**
+     *
+     */
+    public FunctionVectorStorage() {
+        // No-op.
+    }
+
+    /**
+     * Creates read-only or read-write storage.
+     *
+     * @param size Cardinality of this vector storage.
+     * @param getFunc Get function.
+     * @param setFunc Optional set function ({@code null} for read-only storage).
+     */
+    public FunctionVectorStorage(int size, IgniteFunction<Integer, Double> getFunc, IntDoubleToVoidFunction setFunc) {
+        assert size > 0;
+        assert getFunc != null; // At least get function is required.
+
+        this.size = size;
+        this.getFunc = getFunc;
+        this.setFunc = setFunc;
+    }
+
+    /**
+     *
+     *
+     */
+    public IgniteFunction<Integer, Double> getFunction() {
+        return getFunc;
+    }
+
+    /**
+     *
+     *
+     */
+    public IntDoubleToVoidFunction setFunction() {
+        return setFunc;
+    }
+
+    /**
+     * Creates read-only storage.
+     *
+     * @param size Cardinality of this vector storage.
+     * @param getFunc Get function.
+     */
+    public FunctionVectorStorage(int size, IgniteFunction<Integer, Double> getFunc) {
+        this(size, getFunc, null);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int i) {
+        return getFunc.apply(i);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int i, double v) {
+        if (setFunc != null)
+            setFunc.accept(i, v);
+        else
+            throw new UnsupportedOperationException("Cannot set into read-only vector.");
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(setFunc);
+        out.writeObject(getFunc);
+        out.writeInt(size);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        setFunc = (IntDoubleToVoidFunction)in.readObject();
+        getFunc = (IgniteFunction<Integer, Double>)in.readObject();
+        size = in.readInt();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
new file mode 100644
index 0000000..a7d7e26
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.exceptions.IndexException;
+
+/**
+ * Row, column or diagonal vector-based view of the matrix
+ */
+public class MatrixVectorStorage implements VectorStorage {
+    /** */ private Matrix parent;
+
+    /** */ private int row;
+    /** */ private int col;
+
+    /** */ private int rowStride;
+    /** */  private int colStride;
+
+    /** */ private int size;
+
+    /**
+     *
+     */
+    public MatrixVectorStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param parent
+     * @param row
+     * @param col
+     * @param rowStride
+     * @param colStride
+     */
+    public MatrixVectorStorage(Matrix parent, int row, int col, int rowStride, int colStride) {
+        assert parent != null;
+        assert rowStride >= 0;
+        assert colStride >= 0;
+        assert rowStride > 0 || colStride > 0;
+
+        if (row < 0 || row >= parent.rowSize())
+            throw new IndexException(row);
+        if (col < 0 || col >= parent.columnSize())
+            throw new IndexException(col);
+
+        this.parent = parent;
+
+        this.row = row;
+        this.col = col;
+
+        this.rowStride = rowStride;
+        this.colStride = colStride;
+
+        this.size = getSize();
+    }
+
+    /**
+     *
+     *
+     */
+    int row() {
+        return row;
+    }
+
+    /**
+     *
+     *
+     */
+    int column() {
+        return col;
+    }
+
+    /**
+     *
+     *
+     */
+    int rowStride() {
+        return rowStride;
+    }
+
+    /**
+     *
+     *
+     */
+    int columnStride() {
+        return colStride;
+    }
+
+    /**
+     *
+     *
+     */
+    private int getSize() {
+        if (rowStride != 0 && colStride != 0) {
+            int n1 = (parent.rowSize() - row) / rowStride;
+            int n2 = (parent.columnSize() - col) / colStride;
+
+            return Math.min(n1, n2);
+        }
+        else if (rowStride > 0)
+            return (parent.rowSize() - row) / rowStride;
+        else
+            return (parent.columnSize() - col) / colStride;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int i) {
+        return parent.get(row + i * rowStride, col + i * colStride);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int i, double v) {
+        parent.set(row + i * rowStride, col + i * colStride, v);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return parent.isSequentialAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return parent.isDense();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return parent.isRandomAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return parent.isDistributed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(parent);
+        out.writeInt(row);
+        out.writeInt(col);
+        out.writeInt(rowStride);
+        out.writeInt(colStride);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        parent = (Matrix)in.readObject();
+        row = in.readInt();
+        col = in.readInt();
+        rowStride = in.readInt();
+        colStride = in.readInt();
+
+        size = getSize();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
new file mode 100644
index 0000000..a524838
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Arrays;
+import org.apache.ignite.ml.math.VectorStorage;
+
+/**
+ * Pivoted (index mapped) view over another vector storage implementation.
+ */
+public class PivotedVectorStorage implements VectorStorage {
+    /** */ private VectorStorage sto;
+
+    /** */ private int[] pivot;
+    /** */ private int[] unpivot;
+
+    /**
+     * @param pivot Pivot array.
+     */
+    private static int[] reverse(int[] pivot) {
+        int[] res = new int[pivot.length];
+
+        for (int i = 0; i < pivot.length; i++)
+            res[pivot[i]] = i;
+
+        return res;
+    }
+
+    /**
+     *
+     *
+     */
+    public int[] pivot() {
+        return pivot;
+    }
+
+    /**
+     *
+     *
+     */
+    public int[] unpivot() {
+        return unpivot;
+    }
+
+    /**
+     * @param sto Backing vector storage.
+     * @param pivot Mapping from external index to internal.
+     * @param unpivot Mapping from internal index to external.
+     */
+    public PivotedVectorStorage(VectorStorage sto, int[] pivot, int[] unpivot) {
+        assert sto != null;
+        assert pivot != null;
+        assert unpivot != null;
+
+        this.sto = sto;
+        this.pivot = pivot;
+        this.unpivot = unpivot;
+    }
+
+    /**
+     * @param sto Backing vector storage.
+     * @param pivot Mapping from external index to internal.
+     */
+    public PivotedVectorStorage(VectorStorage sto, int[] pivot) {
+        this(sto, pivot, reverse(pivot));
+    }
+
+    /**
+     *
+     */
+    public PivotedVectorStorage() {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return sto.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int i) {
+        return sto.get(pivot[i]);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int i, double v) {
+        sto.set(pivot[i], v);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(sto);
+        out.writeObject(pivot);
+        out.writeObject(unpivot);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        sto = (VectorStorage)in.readObject();
+        pivot = (int[])in.readObject();
+        unpivot = (int[])in.readObject();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return sto.isSequentialAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return sto.isDense();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return sto.isRandomAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return sto.isDistributed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return sto.isArrayBased();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double[] data() {
+        return isArrayBased() ? sto.data() : null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        PivotedVectorStorage that = (PivotedVectorStorage)o;
+
+        return (sto != null ? sto.equals(that.sto) : that.sto == null) && Arrays.equals(pivot, that.pivot)
+            && Arrays.equals(unpivot, that.unpivot);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = sto != null ? sto.hashCode() : 0;
+
+        res = 31 * res + Arrays.hashCode(pivot);
+        res = 31 * res + Arrays.hashCode(unpivot);
+
+        return res;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/RandomVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/RandomVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/RandomVectorStorage.java
new file mode 100644
index 0000000..be1ad91
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/RandomVectorStorage.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.nio.ByteBuffer;
+import java.util.Random;
+import org.apache.ignite.ml.math.MurmurHash;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+
+/**
+ * {@link VectorStorage} implementation with random values in the vector elements.
+ */
+public class RandomVectorStorage implements VectorStorage {
+    /** */
+    private static final long SCALE = 1L << 32;
+    /** */
+    private static final int PRIME = 104047;
+
+    /** Random generation seed. */
+    private int seed;
+
+    /** Vector size. */
+    private int size;
+
+    /** Whether fast hash is used, in {@link #get(int)}. */
+    private boolean fastHash;
+
+    /** */
+    public RandomVectorStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param size Size of the storage.
+     * @param fastHash Whether or not to use fast hashing or Murmur hashing.
+     */
+    public RandomVectorStorage(int size, boolean fastHash) {
+        assert size > 0;
+
+        this.size = size;
+        this.fastHash = fastHash;
+
+        seed = new Random().nextInt();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int i) {
+        if (!fastHash) {
+            ByteBuffer buf = ByteBuffer.allocate(4);
+
+            buf.putInt(i);
+            buf.flip();
+
+            return (MurmurHash.hash64A(buf, seed) & (SCALE - 1)) / (double)SCALE;
+        }
+        else
+            // This isn't a fantastic random number generator, but it is just fine for random projections.
+            return (((i * PRIME) & 8) * 0.25) - 1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int i, double v) {
+        throw new UnsupportedOperationException("Random vector storage is a read-only storage.");
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(size);
+        out.writeInt(seed);
+        out.writeBoolean(fastHash);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        size = in.readInt();
+        seed = in.readInt();
+        fastHash = in.readBoolean();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + Boolean.hashCode(fastHash);
+        res = res * 37 + seed;
+        res = res * 37 + size;
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        RandomVectorStorage that = (RandomVectorStorage)o;
+
+        return size == that.size && seed == that.seed && fastHash == that.fastHash;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
new file mode 100644
index 0000000..d472e3a
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+
+/**
+ * Single value view storage over another vector.
+ */
+public class SingleElementVectorDelegateStorage implements VectorStorage {
+    /** */ private int idx;
+    /** */ private Vector vec;
+
+    /**
+     *
+     */
+    public SingleElementVectorDelegateStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param vec Parent vector.
+     * @param idx Element index.
+     */
+    public SingleElementVectorDelegateStorage(Vector vec, int idx) {
+        assert vec != null;
+        assert idx >= 0;
+
+        this.vec = vec;
+        this.idx = idx;
+    }
+
+    /**
+     *
+     *
+     */
+    public int index() {
+        return idx;
+    }
+
+    /**
+     *
+     *
+     */
+    public Vector delegate() {
+        return vec;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return vec.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int i) {
+        return i == idx ? vec.get(i) : 0.0;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int i, double v) {
+        if (i == idx)
+            vec.set(i, v);
+        else
+            throw new UnsupportedOperationException("Can't set element outside of index: " + idx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(vec);
+        out.writeInt(idx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        vec = (Vector)in.readObject();
+        idx = in.readInt();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        SingleElementVectorDelegateStorage that = (SingleElementVectorDelegateStorage)o;
+
+        return idx == that.idx && (vec != null ? vec.equals(that.vec) : that.vec == null);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = idx;
+
+        res = 31 * res + (vec != null ? vec.hashCode() : 0);
+
+        return res;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
new file mode 100644
index 0000000..854b732
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+
+/**
+ * Vector storage holding a single non-zero value at some index.
+ */
+public class SingleElementVectorStorage implements VectorStorage {
+    /** */ private int idx;
+    /** */ private double val;
+    /** */ private int size;
+
+    /**
+     *
+     */
+    public SingleElementVectorStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param size Parent vector size.
+     * @param idx Element index in the parent vector.
+     * @param val Value of the element.
+     */
+    public SingleElementVectorStorage(int size, int idx, double val) {
+        assert size > 0;
+        assert idx >= 0;
+
+        this.size = size;
+        this.idx = idx;
+        this.val = val;
+    }
+
+    /**
+     *
+     * @return Index of the element in the parent vector.
+     */
+    public int index() {
+        return idx;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int i) {
+        return i == idx ? val : 0.0;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int i, double v) {
+        if (i == idx)
+            val = v;
+        else
+            throw new UnsupportedOperationException("Can't set element outside of index: " + idx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(size);
+        out.writeInt(idx);
+        out.writeDouble(val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        size = in.readInt();
+        idx = in.readInt();
+        val = in.readDouble();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        SingleElementVectorStorage that = (SingleElementVectorStorage)o;
+
+        return idx == that.idx && Double.compare(that.val, val) == 0 && size == that.size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = idx;
+        long temp = Double.doubleToLongBits(val);
+
+        res = 31 * res + (int)(temp ^ (temp >>> 32));
+        res = 31 * res + size;
+
+        return res;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
new file mode 100644
index 0000000..7b3da78
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.nio.ByteBuffer;
+import org.apache.ignite.internal.util.offheap.GridOffHeapMap;
+import org.apache.ignite.internal.util.offheap.GridOffHeapMapFactory;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.vector.SparseLocalOffHeapVector;
+
+/**
+ * {@link VectorStorage} implementation for {@link SparseLocalOffHeapVector}.
+ */
+public class SparseLocalOffHeapVectorStorage implements VectorStorage {
+    /** Assume 10% density. */
+    private static final int INIT_DENSITY = 10;
+    /** Storage capacity. */
+    private int size;
+    /** Local off heap map. */
+    private GridOffHeapMap gridOffHeapMap;
+
+    /** */
+    public SparseLocalOffHeapVectorStorage() {
+        //No-op.
+    }
+
+    /** */
+    public SparseLocalOffHeapVectorStorage(int cap) {
+        assert cap > 0;
+
+        gridOffHeapMap = GridOffHeapMapFactory.unsafeMap(cap / INIT_DENSITY);
+        size = cap;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int i) {
+        byte[] bytes = gridOffHeapMap.get(hash(i), intToByteArray(i));
+        return bytes == null ? 0 : ByteBuffer.wrap(bytes).getDouble();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int i, double v) {
+        if (v != 0.0)
+            gridOffHeapMap.put(hash(i), intToByteArray(i), doubleToByteArray(v));
+        else if (gridOffHeapMap.contains(hash(i), intToByteArray(i)))
+            gridOffHeapMap.remove(hash(i), intToByteArray(i));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        throw new UnsupportedOperationException(); // TODO: add externalization support.
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void destroy() {
+        gridOffHeapMap.destruct();
+    }
+
+    /** */
+    private int hash(int h) {
+        // Apply base step of MurmurHash; see http://code.google.com/p/smhasher/
+        // Despite two multiplies, this is often faster than others
+        // with comparable bit-spread properties.
+        h ^= h >>> 16;
+        h *= 0x85ebca6b;
+        h ^= h >>> 13;
+        h *= 0xc2b2ae35;
+
+        return (h >>> 16) ^ h;
+    }
+
+    /** */
+    private byte[] intToByteArray(int val) {
+        return new byte[] {
+            (byte)(val >>> 24),
+            (byte)(val >>> 16),
+            (byte)(val >>> 8),
+            (byte)val};
+    }
+
+    /** */
+    private byte[] doubleToByteArray(double val) {
+        long l = Double.doubleToRawLongBits(val);
+        return new byte[] {
+            (byte)((l >> 56) & 0xff),
+            (byte)((l >> 48) & 0xff),
+            (byte)((l >> 40) & 0xff),
+            (byte)((l >> 32) & 0xff),
+            (byte)((l >> 24) & 0xff),
+            (byte)((l >> 16) & 0xff),
+            (byte)((l >> 8) & 0xff),
+            (byte)((l) & 0xff),
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
new file mode 100644
index 0000000..75318d6
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
+import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Map;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.VectorStorage;
+
+/**
+ * Sparse, local, on-heap vector storage.
+ */
+public class SparseLocalOnHeapVectorStorage implements VectorStorage, StorageConstants {
+    /** */ private int size;
+    /** */ private int acsMode;
+
+    /** Actual map storage. */
+    private Map<Integer, Double> sto;
+
+    /**
+     *
+     */
+    public SparseLocalOnHeapVectorStorage() {
+        // No-op.
+    }
+
+    /**
+     * @param size Vector size.
+     * @param acsMode Access mode.
+     */
+    public SparseLocalOnHeapVectorStorage(int size, int acsMode) {
+        assert size > 0;
+        assertAccessMode(acsMode);
+
+        this.size = size;
+        this.acsMode = acsMode;
+
+        if (acsMode == SEQUENTIAL_ACCESS_MODE)
+            sto = new Int2DoubleRBTreeMap();
+        else
+            sto = new Int2DoubleOpenHashMap();
+    }
+
+    /**
+     *
+     *
+     */
+    public int getAccessMode() {
+        return acsMode;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int i) {
+        return sto.getOrDefault(i, 0.0);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void set(int i, double v) {
+        if (v != 0.0)
+            sto.put(i, v);
+        else if (sto.containsKey(i))
+            sto.remove(i);
+
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(size);
+        out.writeInt(acsMode);
+        out.writeObject(sto);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings({"unchecked"})
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        size = in.readInt();
+        acsMode = in.readInt();
+        sto = (Map<Integer, Double>)in.readObject();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return acsMode == SEQUENTIAL_ACCESS_MODE;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        SparseLocalOnHeapVectorStorage that = (SparseLocalOnHeapVectorStorage)o;
+
+        return size == that.size && acsMode == that.acsMode && (sto != null ? sto.equals(that.sto) : that.sto == null);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = size;
+
+        res = 31 * res + acsMode;
+        res = 31 * res + (sto != null ? sto.hashCode() : 0);
+
+        return res;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/package-info.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/package-info.java
new file mode 100644
index 0000000..a9825b3
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Contains specific implementations for vector storage models.
+ */
+package org.apache.ignite.ml.math.impls.storage.vector;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractReadOnlyVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractReadOnlyVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractReadOnlyVector.java
new file mode 100644
index 0000000..e48542b
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractReadOnlyVector.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.functions.IgniteBiFunction;
+import org.apache.ignite.ml.math.functions.IgniteDoubleFunction;
+import org.apache.ignite.ml.math.impls.matrix.FunctionMatrix;
+
+/**
+ * This class provides a helper implementation of the read-only implementation of {@link Vector}
+ * interface to minimize the effort required to implement it.
+ * Subclasses may override some of the implemented methods if a more
+ * specific or optimized implementation is desirable.
+ */
+public abstract class AbstractReadOnlyVector extends AbstractVector {
+    /** */
+    public AbstractReadOnlyVector() {
+        // No-op.
+    }
+
+    /**
+     * @param sto Storage.
+     */
+    public AbstractReadOnlyVector(VectorStorage sto) {
+        super(true, sto);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix cross(Vector vec) {
+        return new FunctionMatrix(size(), vec.size(),
+            (row, col) -> vec.get(col) * get(row));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix toMatrix(boolean rowLike) {
+        return new FunctionMatrix(rowLike ? 1 : size(), rowLike ? size() : 1,
+            (row, col) -> rowLike ? get(col) : get(row));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix toMatrixPlusOne(boolean rowLike, double zeroVal) {
+        return new FunctionMatrix(rowLike ? 1 : size() + 1, rowLike ? size() + 1 : 1, (row, col) -> {
+            if (row == 0 && col == 0)
+                return zeroVal;
+
+            return rowLike ? get(col - 1) : get(row - 1);
+        });
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector copy() {
+        return this; // This exploits read-only feature of this type vector.
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector logNormalize() {
+        return logNormalize(2.0, Math.sqrt(getLengthSquared()));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector logNormalize(double power) {
+        return logNormalize(power, kNorm(power));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector map(IgniteDoubleFunction<Double> fun) {
+        return new FunctionVector(size(), (i) -> fun.apply(get(i)));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector map(Vector vec, IgniteBiFunction<Double, Double, Double> fun) {
+        checkCardinality(vec);
+
+        return new FunctionVector(size(), (i) -> fun.apply(get(i), vec.get(i)));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector map(IgniteBiFunction<Double, Double, Double> fun, double y) {
+        return new FunctionVector(size(), (i) -> fun.apply(get(i), y));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector divide(double x) {
+        if (x == 1.0)
+            return this;
+
+        return new FunctionVector(size(), (i) -> get(i) / x);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector times(double x) {
+        return x == 0 ? new ConstantVector(size(), 0) : new FunctionVector(size(), (i) -> get(i) * x);
+    }
+
+    /**
+     * @param power Power.
+     * @param normLen Normalized length.
+     * @return logNormalized value.
+     */
+    private Vector logNormalize(double power, double normLen) {
+        assert !(Double.isInfinite(power) || power <= 1.0);
+
+        double denominator = normLen * Math.log(power);
+
+        return new FunctionVector(size(), (idx) -> Math.log1p(get(idx)) / denominator);
+    }
+}


[04/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixImplementationsTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixImplementationsTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixImplementationsTest.java
new file mode 100644
index 0000000..c827037
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixImplementationsTest.java
@@ -0,0 +1,1113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import java.util.function.Supplier;
+import org.apache.ignite.ml.math.ExternalizeTest;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.CardinalityException;
+import org.apache.ignite.ml.math.exceptions.ColumnIndexException;
+import org.apache.ignite.ml.math.exceptions.IndexException;
+import org.apache.ignite.ml.math.exceptions.RowIndexException;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOffHeapVector;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.apache.ignite.ml.math.impls.vector.RandomVector;
+import org.apache.ignite.ml.math.impls.vector.SparseLocalVector;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Tests for {@link Matrix} implementations.
+ */
+public class MatrixImplementationsTest extends ExternalizeTest<Matrix> {
+    /** */
+    private static final double DEFAULT_DELTA = 0.000000001d;
+
+    /** */
+    private void consumeSampleMatrix(BiConsumer<Matrix, String> consumer) {
+        new MatrixImplementationFixtures().consumeSampleMatrix(consumer);
+    }
+
+    /** */
+    @Test
+    public void externalizeTest() {
+        consumeSampleMatrix((m, desc) -> externalizeTest(m));
+    }
+
+    /** */
+    @Test
+    public void testLike() {
+        consumeSampleMatrix((m, desc) -> {
+            Class<? extends Matrix> cls = likeMatrixType(m);
+
+            if (cls != null) {
+                Matrix like = m.like(m.rowSize(), m.columnSize());
+
+                assertEquals("Wrong \"like\" matrix for " + desc + "; Unexpected rows.", like.rowSize(), m.rowSize());
+                assertEquals("Wrong \"like\" matrix for " + desc + "; Unexpected columns.", like.columnSize(), m.columnSize());
+
+                assertEquals("Wrong \"like\" matrix for " + desc
+                        + "; Unexpected class: " + like.getClass().toString(),
+                    cls,
+                    like.getClass());
+
+                return;
+            }
+
+            boolean expECaught = false;
+
+            try {
+                m.like(1, 1);
+            }
+            catch (UnsupportedOperationException uoe) {
+                expECaught = true;
+            }
+
+            assertTrue("Expected exception was not caught for " + desc, expECaught);
+        });
+    }
+
+    /** */
+    @Test
+    public void testCopy() {
+        consumeSampleMatrix((m, desc) -> {
+            Matrix cp = m.copy();
+            assertTrue("Incorrect copy for empty matrix " + desc, cp.equals(m));
+
+            if (!readOnly(m))
+                fillMatrix(m);
+
+            cp = m.copy();
+
+            assertTrue("Incorrect copy for matrix " + desc, cp.equals(m));
+        });
+    }
+
+    /** */
+    @Test
+    public void testHaveLikeVector() throws InstantiationException, IllegalAccessException {
+        for (Class<? extends Matrix> key : likeVectorTypesMap().keySet()) {
+            Class<? extends Vector> val = likeVectorTypesMap().get(key);
+
+            if (val == null && !ignore(key))
+                System.out.println("Missing test for implementation of likeMatrix for " + key.getSimpleName());
+        }
+    }
+
+    /** */
+    @Test
+    public void testLikeVector() {
+        consumeSampleMatrix((m, desc) -> {
+            if (likeVectorTypesMap().containsKey(m.getClass())) {
+                Vector likeVector = m.likeVector(m.columnSize());
+
+                assertNotNull(likeVector);
+                assertEquals("Unexpected value for " + desc, likeVector.size(), m.columnSize());
+
+                return;
+            }
+
+            boolean expECaught = false;
+
+            try {
+                m.likeVector(1);
+            }
+            catch (UnsupportedOperationException uoe) {
+                expECaught = true;
+            }
+
+            assertTrue("Expected exception was not caught for " + desc, expECaught);
+        });
+    }
+
+    /** */
+    @Test
+    public void testAssignSingleElement() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            final double assignVal = Math.random();
+
+            m.assign(assignVal);
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
+                        assignVal, m.get(i, j), 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testAssignArray() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            double[][] data = new double[m.rowSize()][m.columnSize()];
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    data[i][j] = Math.random();
+
+            m.assign(data);
+
+            for (int i = 0; i < m.rowSize(); i++) {
+                for (int j = 0; j < m.columnSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
+                        data[i][j], m.get(i, j), 0d);
+            }
+        });
+    }
+
+    /** */
+    @Test
+    public void testAssignFunction() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            m.assign((i, j) -> (double)(i * m.columnSize() + j));
+
+            for (int i = 0; i < m.rowSize(); i++) {
+                for (int j = 0; j < m.columnSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
+                        (double)(i * m.columnSize() + j), m.get(i, j), 0d);
+            }
+        });
+    }
+
+    /** */
+    @Test
+    public void testPlus() {
+        consumeSampleMatrix((m, desc) -> {
+            if (readOnly(m))
+                return;
+
+            double[][] data = fillAndReturn(m);
+
+            double plusVal = Math.random();
+
+            Matrix plus = m.plus(plusVal);
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
+                        data[i][j] + plusVal, plus.get(i, j), 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testPlusMatrix() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            double[][] data = fillAndReturn(m);
+
+            Matrix plus = m.plus(m);
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
+                        data[i][j] * 2.0, plus.get(i, j), 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testMinusMatrix() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            fillMatrix(m);
+
+            Matrix minus = m.minus(m);
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
+                        0.0, minus.get(i, j), 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testTimes() {
+        consumeSampleMatrix((m, desc) -> {
+            if (readOnly(m))
+                return;
+
+            double[][] data = fillAndReturn(m);
+
+            double timeVal = Math.random();
+            Matrix times = m.times(timeVal);
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
+                        data[i][j] * timeVal, times.get(i, j), 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testTimesVector() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            double[][] data = fillAndReturn(m);
+
+            double[] arr = fillArray(m.columnSize());
+
+            Vector times = m.times(new DenseLocalOnHeapVector(arr));
+
+            assertEquals("Unexpected vector size for " + desc, times.size(), m.rowSize());
+
+            for (int i = 0; i < m.rowSize(); i++) {
+                double exp = 0.0;
+
+                for (int j = 0; j < m.columnSize(); j++)
+                    exp += arr[j] * data[i][j];
+
+                assertEquals("Unexpected value for " + desc + " at " + i,
+                    times.get(i), exp, 0d);
+            }
+
+            testInvalidCardinality(() -> m.times(new DenseLocalOnHeapVector(m.columnSize() + 1)), desc);
+        });
+    }
+
+    /** */
+    @Test
+    public void testTimesMatrix() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            double[][] data = fillAndReturn(m);
+
+            double[] arr = fillArray(m.columnSize());
+
+            Matrix mult = new DenseLocalOnHeapMatrix(m.columnSize(), 1);
+
+            mult.setColumn(0, arr);
+
+            Matrix times = m.times(mult);
+
+            assertEquals("Unexpected rows for " + desc, times.rowSize(), m.rowSize());
+
+            assertEquals("Unexpected cols for " + desc, times.columnSize(), 1);
+
+            for (int i = 0; i < m.rowSize(); i++) {
+                double exp = 0.0;
+
+                for (int j = 0; j < m.columnSize(); j++)
+                    exp += arr[j] * data[i][j];
+
+                assertEquals("Unexpected value for " + desc + " at " + i,
+                    exp, times.get(i, 0), 0d);
+            }
+
+            testInvalidCardinality(() -> m.times(new DenseLocalOnHeapMatrix(m.columnSize() + 1, 1)), desc);
+        });
+    }
+
+    /** */
+    @Test
+    public void testDivide() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            double[][] data = fillAndReturn(m);
+
+            double divVal = Math.random();
+
+            Matrix divide = m.divide(divVal);
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
+                        data[i][j] / divVal, divide.get(i, j), 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testTranspose() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            fillMatrix(m);
+
+            Matrix transpose = m.transpose();
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
+                        m.get(i, j), transpose.get(j, i), 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testDeterminant() {
+        consumeSampleMatrix((m, desc) -> {
+            if (m.rowSize() != m.columnSize())
+                return;
+
+            if (ignore(m.getClass()))
+                return;
+
+            double[][] doubles = fillIntAndReturn(m);
+
+            if (m.rowSize() == 1) {
+                assertEquals("Unexpected value " + desc, m.determinant(), doubles[0][0], 0d);
+
+                return;
+            }
+
+            if (m.rowSize() == 2) {
+                double det = doubles[0][0] * doubles[1][1] - doubles[0][1] * doubles[1][0];
+                assertEquals("Unexpected value " + desc, m.determinant(), det, 0d);
+
+                return;
+            }
+
+            if (m.rowSize() > 512)
+                return; // IMPL NOTE if row size >= 30000 it takes unacceptably long for normal test run.
+
+            Matrix diagMtx = m.like(m.rowSize(), m.columnSize());
+
+            diagMtx.assign(0);
+            for (int i = 0; i < m.rowSize(); i++)
+                diagMtx.set(i, i, m.get(i, i));
+
+            double det = 1;
+
+            for (int i = 0; i < diagMtx.rowSize(); i++)
+                det *= diagMtx.get(i, i);
+
+            try {
+                assertEquals("Unexpected value " + desc, det, diagMtx.determinant(), DEFAULT_DELTA);
+            }
+            catch (Exception e) {
+                System.out.println(desc);
+                throw e;
+            }
+        });
+    }
+
+    /** */
+    @Test
+    public void testInverse() {
+        consumeSampleMatrix((m, desc) -> {
+            if (m.rowSize() != m.columnSize())
+                return;
+
+            if (ignore(m.getClass()))
+                return;
+
+            if (m.rowSize() > 256)
+                return; // IMPL NOTE this is for quicker test run.
+
+            fillNonSingularMatrix(m);
+
+            assertTrue("Unexpected zero determinant " + desc, Math.abs(m.determinant()) > 0d);
+
+            Matrix inverse = m.inverse();
+
+            Matrix mult = m.times(inverse);
+
+            final double delta = 0.001d;
+
+            assertEquals("Unexpected determinant " + desc, 1d, mult.determinant(), delta);
+
+            assertEquals("Unexpected top left value " + desc, 1d, mult.get(0, 0), delta);
+
+            if (m.rowSize() == 1)
+                return;
+
+            assertEquals("Unexpected center value " + desc,
+                1d, mult.get(m.rowSize() / 2, m.rowSize() / 2), delta);
+
+            assertEquals("Unexpected bottom right value " + desc,
+                1d, mult.get(m.rowSize() - 1, m.rowSize() - 1), delta);
+
+            assertEquals("Unexpected top right value " + desc,
+                0d, mult.get(0, m.rowSize() - 1), delta);
+
+            assertEquals("Unexpected bottom left value " + desc,
+                0d, mult.get(m.rowSize() - 1, 0), delta);
+        });
+    }
+
+    /** */
+    @Test
+    public void testMap() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            fillMatrix(m);
+
+            m.map(x -> 10d);
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
+                        10d, m.get(i, j), 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testMapMatrix() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            double[][] doubles = fillAndReturn(m);
+
+            testMapMatrixWrongCardinality(m, desc);
+
+            Matrix cp = m.copy();
+
+            m.map(cp, (m1, m2) -> m1 + m2);
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
+                        m.get(i, j), doubles[i][j] * 2, 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testViewRow() {
+        consumeSampleMatrix((m, desc) -> {
+            if (!readOnly(m))
+                fillMatrix(m);
+
+            for (int i = 0; i < m.rowSize(); i++) {
+                Vector vector = m.viewRow(i);
+                assert vector != null;
+
+                for (int j = 0; j < m.columnSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
+                        m.get(i, j), vector.get(j), 0d);
+            }
+        });
+    }
+
+    /** */
+    @Test
+    public void testViewCol() {
+        consumeSampleMatrix((m, desc) -> {
+            if (!readOnly(m))
+                fillMatrix(m);
+
+            for (int i = 0; i < m.columnSize(); i++) {
+                Vector vector = m.viewColumn(i);
+                assert vector != null;
+
+                for (int j = 0; j < m.rowSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
+                        m.get(j, i), vector.get(j), 0d);
+            }
+        });
+    }
+
+    /** */
+    @Test
+    public void testFoldRow() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            fillMatrix(m);
+
+            Vector foldRows = m.foldRows(Vector::sum);
+
+            for (int i = 0; i < m.rowSize(); i++) {
+                Double locSum = 0d;
+
+                for (int j = 0; j < m.columnSize(); j++)
+                    locSum += m.get(i, j);
+
+                assertEquals("Unexpected value for " + desc + " at " + i,
+                    foldRows.get(i), locSum, 0d);
+            }
+        });
+    }
+
+    /** */
+    @Test
+    public void testFoldCol() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            fillMatrix(m);
+
+            Vector foldCols = m.foldColumns(Vector::sum);
+
+            for (int j = 0; j < m.columnSize(); j++) {
+                Double locSum = 0d;
+
+                for (int i = 0; i < m.rowSize(); i++)
+                    locSum += m.get(i, j);
+
+                assertEquals("Unexpected value for " + desc + " at " + j,
+                    foldCols.get(j), locSum, 0d);
+            }
+        });
+    }
+
+    /** */
+    @Test
+    public void testSum() {
+        consumeSampleMatrix((m, desc) -> {
+            double[][] data = fillAndReturn(m);
+
+            double sum = m.sum();
+
+            double rawSum = 0;
+            for (double[] anArr : data)
+                for (int j = 0; j < data[0].length; j++)
+                    rawSum += anArr[j];
+
+            assertEquals("Unexpected value for " + desc,
+                rawSum, sum, 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testMax() {
+        consumeSampleMatrix((m, desc) -> {
+            double[][] doubles = fillAndReturn(m);
+            double max = Double.NEGATIVE_INFINITY;
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    max = max < doubles[i][j] ? doubles[i][j] : max;
+
+            assertEquals("Unexpected value for " + desc, m.maxValue(), max, 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testMin() {
+        consumeSampleMatrix((m, desc) -> {
+            double[][] doubles = fillAndReturn(m);
+            double min = Double.MAX_VALUE;
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    min = min > doubles[i][j] ? doubles[i][j] : min;
+
+            assertEquals("Unexpected value for " + desc, m.minValue(), min, 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testGetElement() {
+        consumeSampleMatrix((m, desc) -> {
+            if (!(readOnly(m)))
+                fillMatrix(m);
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++) {
+                    final Matrix.Element e = m.getElement(i, j);
+
+                    final String details = desc + " at [" + i + "," + j + "]";
+
+                    assertEquals("Unexpected element row " + details, i, e.row());
+                    assertEquals("Unexpected element col " + details, j, e.column());
+
+                    final double val = m.get(i, j);
+
+                    assertEquals("Unexpected value for " + details, val, e.get(), 0d);
+
+                    boolean expECaught = false;
+
+                    final double newVal = val * 2.0;
+
+                    try {
+                        e.set(newVal);
+                    }
+                    catch (UnsupportedOperationException uoe) {
+                        if (!(readOnly(m)))
+                            throw uoe;
+
+                        expECaught = true;
+                    }
+
+                    if (readOnly(m)) {
+                        if (!expECaught)
+                            fail("Expected exception was not caught for " + details);
+
+                        continue;
+                    }
+
+                    assertEquals("Unexpected value set for " + details, newVal, m.get(i, j), 0d);
+                }
+        });
+    }
+
+    /** */
+    @Test
+    public void testGetX() {
+        consumeSampleMatrix((m, desc) -> {
+            if (!(readOnly(m)))
+                fillMatrix(m);
+
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    assertEquals("Unexpected value for " + desc + " at [" + i + "," + j + "]",
+                        m.get(i, j), m.getX(i, j), 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testGetMetaStorage() {
+        consumeSampleMatrix((m, desc) -> assertNotNull("Null meta storage in " + desc, m.getMetaStorage()));
+    }
+
+    /** */
+    @Test
+    public void testGuid() {
+        consumeSampleMatrix((m, desc) -> assertNotNull("Null guid in " + desc, m.guid()));
+    }
+
+    /** */
+    @Test
+    public void testSwapRows() {
+        consumeSampleMatrix((m, desc) -> {
+            if (readOnly(m))
+                return;
+
+            double[][] doubles = fillAndReturn(m);
+
+            final int swap_i = m.rowSize() == 1 ? 0 : 1;
+            final int swap_j = 0;
+
+            Matrix swap = m.swapRows(swap_i, swap_j);
+
+            for (int col = 0; col < m.columnSize(); col++) {
+                assertEquals("Unexpected value for " + desc + " at col " + col + ", swap_i " + swap_i,
+                    swap.get(swap_i, col), doubles[swap_j][col], 0d);
+
+                assertEquals("Unexpected value for " + desc + " at col " + col + ", swap_j " + swap_j,
+                    swap.get(swap_j, col), doubles[swap_i][col], 0d);
+            }
+
+            testInvalidRowIndex(() -> m.swapRows(-1, 0), desc + " negative first swap index");
+            testInvalidRowIndex(() -> m.swapRows(0, -1), desc + " negative second swap index");
+            testInvalidRowIndex(() -> m.swapRows(m.rowSize(), 0), desc + " too large first swap index");
+            testInvalidRowIndex(() -> m.swapRows(0, m.rowSize()), desc + " too large second swap index");
+        });
+    }
+
+    /** */
+    @Test
+    public void testSwapColumns() {
+        consumeSampleMatrix((m, desc) -> {
+            if (readOnly(m))
+                return;
+
+            double[][] doubles = fillAndReturn(m);
+
+            final int swap_i = m.columnSize() == 1 ? 0 : 1;
+            final int swap_j = 0;
+
+            Matrix swap = m.swapColumns(swap_i, swap_j);
+
+            for (int row = 0; row < m.rowSize(); row++) {
+                assertEquals("Unexpected value for " + desc + " at row " + row + ", swap_i " + swap_i,
+                    swap.get(row, swap_i), doubles[row][swap_j], 0d);
+
+                assertEquals("Unexpected value for " + desc + " at row " + row + ", swap_j " + swap_j,
+                    swap.get(row, swap_j), doubles[row][swap_i], 0d);
+            }
+
+            testInvalidColIndex(() -> m.swapColumns(-1, 0), desc + " negative first swap index");
+            testInvalidColIndex(() -> m.swapColumns(0, -1), desc + " negative second swap index");
+            testInvalidColIndex(() -> m.swapColumns(m.columnSize(), 0), desc + " too large first swap index");
+            testInvalidColIndex(() -> m.swapColumns(0, m.columnSize()), desc + " too large second swap index");
+        });
+    }
+
+    /** */
+    @Test
+    public void testSetRow() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            fillMatrix(m);
+
+            int rowIdx = m.rowSize() / 2;
+
+            double[] newValues = fillArray(m.columnSize());
+
+            m.setRow(rowIdx, newValues);
+
+            for (int col = 0; col < m.columnSize(); col++)
+                assertEquals("Unexpected value for " + desc + " at " + col,
+                    newValues[col], m.get(rowIdx, col), 0d);
+
+            testInvalidCardinality(() -> m.setRow(rowIdx, new double[m.columnSize() + 1]), desc);
+        });
+    }
+
+    /** */
+    @Test
+    public void testSetColumn() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            fillMatrix(m);
+
+            int colIdx = m.columnSize() / 2;
+
+            double[] newValues = fillArray(m.rowSize());
+
+            m.setColumn(colIdx, newValues);
+
+            for (int row = 0; row < m.rowSize(); row++)
+                assertEquals("Unexpected value for " + desc + " at " + row,
+                    newValues[row], m.get(row, colIdx), 0d);
+
+            testInvalidCardinality(() -> m.setColumn(colIdx, new double[m.rowSize() + 1]), desc);
+        });
+    }
+
+    /** */
+    @Test
+    public void testViewPart() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            fillMatrix(m);
+
+            int rowOff = m.rowSize() < 3 ? 0 : 1;
+            int rows = m.rowSize() < 3 ? 1 : m.rowSize() - 2;
+            int colOff = m.columnSize() < 3 ? 0 : 1;
+            int cols = m.columnSize() < 3 ? 1 : m.columnSize() - 2;
+
+            Matrix view1 = m.viewPart(rowOff, rows, colOff, cols);
+            Matrix view2 = m.viewPart(new int[] {rowOff, colOff}, new int[] {rows, cols});
+
+            String details = desc + " view [" + rowOff + ", " + rows + ", " + colOff + ", " + cols + "]";
+
+            for (int i = 0; i < rows; i++)
+                for (int j = 0; j < cols; j++) {
+                    assertEquals("Unexpected view1 value for " + details + " at (" + i + "," + j + ")",
+                        m.get(i + rowOff, j + colOff), view1.get(i, j), 0d);
+
+                    assertEquals("Unexpected view2 value for " + details + " at (" + i + "," + j + ")",
+                        m.get(i + rowOff, j + colOff), view2.get(i, j), 0d);
+                }
+        });
+    }
+
+    /** */
+    @Test
+    public void testDensity() {
+        consumeSampleMatrix((m, desc) -> {
+            if (!readOnly(m))
+                fillMatrix(m);
+
+            assertTrue("Unexpected density with threshold 0 for " + desc, m.density(0.0));
+
+            assertFalse("Unexpected density with threshold 1 for " + desc, m.density(1.0));
+        });
+    }
+
+    /** */
+    @Test
+    public void testMaxAbsRowSumNorm() {
+        consumeSampleMatrix((m, desc) -> {
+            if (!readOnly(m))
+                fillMatrix(m);
+
+            assertEquals("Unexpected value for " + desc,
+                maxAbsRowSumNorm(m), m.maxAbsRowSumNorm(), 0d);
+        });
+    }
+
+    /** */
+    @Test
+    public void testAssignRow() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            fillMatrix(m);
+
+            int rowIdx = m.rowSize() / 2;
+
+            double[] newValues = fillArray(m.columnSize());
+
+            m.assignRow(rowIdx, new DenseLocalOnHeapVector(newValues));
+
+            for (int col = 0; col < m.columnSize(); col++)
+                assertEquals("Unexpected value for " + desc + " at " + col,
+                    newValues[col], m.get(rowIdx, col), 0d);
+
+            testInvalidCardinality(() -> m.assignRow(rowIdx, new DenseLocalOnHeapVector(m.columnSize() + 1)), desc);
+        });
+    }
+
+    /** */
+    @Test
+    public void testAssignColumn() {
+        consumeSampleMatrix((m, desc) -> {
+            if (ignore(m.getClass()))
+                return;
+
+            fillMatrix(m);
+
+            int colIdx = m.columnSize() / 2;
+
+            double[] newValues = fillArray(m.rowSize());
+
+            m.assignColumn(colIdx, new DenseLocalOnHeapVector(newValues));
+
+            for (int row = 0; row < m.rowSize(); row++)
+                assertEquals("Unexpected value for " + desc + " at " + row,
+                    newValues[row], m.get(row, colIdx), 0d);
+        });
+    }
+
+    /** */
+    private double[] fillArray(int len) {
+        double[] newValues = new double[len];
+
+        for (int i = 0; i < newValues.length; i++)
+            newValues[i] = newValues.length - i;
+        return newValues;
+    }
+
+    /** */
+    private double maxAbsRowSumNorm(Matrix m) {
+        double max = 0.0;
+
+        for (int x = 0; x < m.rowSize(); x++) {
+            double sum = 0;
+
+            for (int y = 0; y < m.columnSize(); y++)
+                sum += Math.abs(m.getX(x, y));
+
+            if (sum > max)
+                max = sum;
+        }
+
+        return max;
+    }
+
+    /** */
+    private void testInvalidRowIndex(Supplier<Matrix> supplier, String desc) {
+        try {
+            supplier.get();
+        }
+        catch (RowIndexException | IndexException ie) {
+            return;
+        }
+
+        fail("Expected exception was not caught for " + desc);
+    }
+
+    /** */
+    private void testInvalidColIndex(Supplier<Matrix> supplier, String desc) {
+        try {
+            supplier.get();
+        }
+        catch (ColumnIndexException | IndexException ie) {
+            return;
+        }
+
+        fail("Expected exception was not caught for " + desc);
+    }
+
+    /** */
+    private void testMapMatrixWrongCardinality(Matrix m, String desc) {
+        for (int rowDelta : new int[] {-1, 0, 1})
+            for (int colDelta : new int[] {-1, 0, 1}) {
+                if (rowDelta == 0 && colDelta == 0)
+                    continue;
+
+                int rowNew = m.rowSize() + rowDelta;
+                int colNew = m.columnSize() + colDelta;
+
+                if (rowNew < 1 || colNew < 1)
+                    continue;
+
+                testInvalidCardinality(() -> m.map(new DenseLocalOnHeapMatrix(rowNew, colNew), (m1, m2) -> m1 + m2),
+                    desc + " wrong cardinality when mapping to size " + rowNew + "x" + colNew);
+            }
+    }
+
+    /** */
+    private void testInvalidCardinality(Supplier<Object> supplier, String desc) {
+        try {
+            supplier.get();
+        }
+        catch (CardinalityException ce) {
+            return;
+        }
+
+        fail("Expected exception was not caught for " + desc);
+    }
+
+    /** */
+    private boolean readOnly(Matrix m) {
+        return m instanceof RandomMatrix;
+    }
+
+    /** */
+    private double[][] fillIntAndReturn(Matrix m) {
+        double[][] data = new double[m.rowSize()][m.columnSize()];
+
+        if (readOnly(m)) {
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    data[i][j] = m.get(i, j);
+
+        }
+        else {
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    data[i][j] = i * m.rowSize() + j + 1;
+
+            m.assign(data);
+        }
+        return data;
+    }
+
+    /** */
+    private double[][] fillAndReturn(Matrix m) {
+        double[][] data = new double[m.rowSize()][m.columnSize()];
+
+        if (readOnly(m)) {
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    data[i][j] = m.get(i, j);
+
+        }
+        else {
+            for (int i = 0; i < m.rowSize(); i++)
+                for (int j = 0; j < m.columnSize(); j++)
+                    data[i][j] = -0.5d + Math.random();
+
+            m.assign(data);
+        }
+        return data;
+    }
+
+    /** */
+    private void fillNonSingularMatrix(Matrix m) {
+        for (int i = 0; i < m.rowSize(); i++) {
+            m.set(i, i, 10);
+
+            for (int j = 0; j < m.columnSize(); j++)
+                if (j != i)
+                    m.set(i, j, 0.01d);
+        }
+    }
+
+    /** */
+    private void fillMatrix(Matrix m) {
+        for (int i = 0; i < m.rowSize(); i++)
+            for (int j = 0; j < m.columnSize(); j++)
+                m.set(i, j, Math.random());
+    }
+
+    /** Ignore test for given matrix type. */
+    private boolean ignore(Class<? extends Matrix> clazz) {
+        List<Class<? extends Matrix>> ignoredClasses = Arrays.asList(RandomMatrix.class, PivotedMatrixView.class,
+            MatrixView.class, FunctionMatrix.class, TransposedMatrixView.class);
+
+        for (Class<? extends Matrix> ignoredClass : ignoredClasses)
+            if (ignoredClass.isAssignableFrom(clazz))
+                return true;
+
+        return false;
+    }
+
+    /** */
+    private Class<? extends Matrix> likeMatrixType(Matrix m) {
+        for (Class<? extends Matrix> clazz : likeTypesMap().keySet())
+            if (clazz.isAssignableFrom(m.getClass()))
+                return likeTypesMap().get(clazz);
+
+        return null;
+    }
+
+    /** */
+    private static Map<Class<? extends Matrix>, Class<? extends Vector>> likeVectorTypesMap() {
+        return new LinkedHashMap<Class<? extends Matrix>, Class<? extends Vector>>() {{
+            put(DenseLocalOnHeapMatrix.class, DenseLocalOnHeapVector.class);
+            put(DenseLocalOffHeapMatrix.class, DenseLocalOffHeapVector.class);
+            put(RandomMatrix.class, RandomVector.class);
+            put(SparseLocalOnHeapMatrix.class, SparseLocalVector.class);
+            put(DenseLocalOnHeapMatrix.class, DenseLocalOnHeapVector.class);
+            put(DiagonalMatrix.class, DenseLocalOnHeapVector.class); // IMPL NOTE per fixture
+            // IMPL NOTE check for presence of all implementations here will be done in testHaveLikeMatrix via Fixture
+        }};
+    }
+
+    /** */
+    private static Map<Class<? extends Matrix>, Class<? extends Matrix>> likeTypesMap() {
+        return new LinkedHashMap<Class<? extends Matrix>, Class<? extends Matrix>>() {{
+            put(DenseLocalOnHeapMatrix.class, DenseLocalOnHeapMatrix.class);
+            put(DenseLocalOffHeapMatrix.class, DenseLocalOffHeapMatrix.class);
+            put(RandomMatrix.class, RandomMatrix.class);
+            put(SparseLocalOnHeapMatrix.class, SparseLocalOnHeapMatrix.class);
+            put(DenseLocalOnHeapMatrix.class, DenseLocalOnHeapMatrix.class);
+            put(DiagonalMatrix.class, DenseLocalOnHeapMatrix.class); // IMPL NOTE per fixture
+            put(FunctionMatrix.class, FunctionMatrix.class);
+            // IMPL NOTE check for presence of all implementations here will be done in testHaveLikeMatrix via Fixture
+        }};
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
new file mode 100644
index 0000000..bc628c9
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.ml.math.MatrixKeyMapper;
+
+/** */
+public class MatrixKeyMapperForTests implements MatrixKeyMapper<Integer> {
+    /** */ private int rows;
+    /** */ private int cols;
+
+    /** */
+    public MatrixKeyMapperForTests() {
+        // No-op.
+    }
+
+    /** */
+    public MatrixKeyMapperForTests(int rows, int cols) {
+        this.rows = rows;
+        this.cols = cols;
+    }
+
+    /** */
+    @Override public Integer apply(int x, int y) {
+        return x * cols + y;
+    }
+
+    /** */
+    @Override public boolean isValid(Integer integer) {
+        return (rows * cols) > integer;
+    }
+
+    /** */
+    @Override public int hashCode() {
+        int hash = 1;
+
+        hash += hash * 31 + rows;
+        hash += hash * 31 + cols;
+
+        return hash;
+    }
+
+    /** */
+    @Override public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+
+        if (obj == null || getClass() != obj.getClass())
+            return false;
+
+        MatrixKeyMapperForTests that = (MatrixKeyMapperForTests)obj;
+
+        return rows == that.rows && cols == that.cols;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixViewConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixViewConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixViewConstructorTest.java
new file mode 100644
index 0000000..82564cb
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixViewConstructorTest.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.storage.matrix.MatrixDelegateStorage;
+import org.junit.Test;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+/** */
+public class MatrixViewConstructorTest {
+    /** */
+    @Test
+    public void invalidArgsTest() {
+        Matrix m = new DenseLocalOnHeapMatrix(1, 1);
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new MatrixView((Matrix)null, 0, 0, 1, 1),
+            "Null parent matrix.");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new MatrixView(m, -1, 0, 1, 1),
+            "Invalid row offset.");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new MatrixView(m, 0, -1, 1, 1),
+            "Invalid col offset.");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new MatrixView(m, 0, 0, 0, 1),
+            "Invalid rows.");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new MatrixView(m, 0, 0, 1, 0),
+            "Invalid cols.");
+    }
+
+    /** */
+    @Test
+    public void basicTest() {
+        for (Matrix m : new Matrix[] {
+            new DenseLocalOnHeapMatrix(3, 3),
+            new DenseLocalOnHeapMatrix(3, 4), new DenseLocalOnHeapMatrix(4, 3)})
+            for (int rowOff : new int[] {0, 1})
+                for (int colOff : new int[] {0, 1})
+                    for (int rows : new int[] {1, 2})
+                        for (int cols : new int[] {1, 2})
+                            basicTest(m, rowOff, colOff, rows, cols);
+    }
+
+    /** */
+    private void basicTest(Matrix parent, int rowOff, int colOff, int rows, int cols) {
+        for (int row = 0; row < parent.rowSize(); row++)
+            for (int col = 0; col < parent.columnSize(); col++)
+                parent.set(row, col, row * parent.columnSize() + col + 1);
+
+        Matrix view = new MatrixView(parent, rowOff, colOff, rows, cols);
+
+        assertEquals("Rows in view.", rows, view.rowSize());
+        assertEquals("Cols in view.", cols, view.columnSize());
+
+        for (int row = 0; row < rows; row++)
+            for (int col = 0; col < cols; col++)
+                assertEquals("Unexpected value at " + row + "x" + col,
+                    parent.get(row + rowOff, col + colOff), view.get(row, col), 0d);
+
+        for (int row = 0; row < rows; row++)
+            for (int col = 0; col < cols; col++)
+                view.set(row, col, 0d);
+
+        for (int row = 0; row < rows; row++)
+            for (int col = 0; col < cols; col++)
+                assertEquals("Unexpected value set at " + row + "x" + col,
+                    0d, parent.get(row + rowOff, col + colOff), 0d);
+    }
+
+    /** */
+    @Test
+    public void attributeTest() {
+        for (Matrix m : new Matrix[] {
+            new DenseLocalOnHeapMatrix(3, 3),
+            new DenseLocalOnHeapMatrix(3, 4), new DenseLocalOnHeapMatrix(4, 3)}) {
+            MatrixView matrixView = new MatrixView(m, 0, 0, m.rowSize(), m.columnSize());
+
+            MatrixDelegateStorage delegateStorage = (MatrixDelegateStorage)matrixView.getStorage();
+
+            assertEquals(m.rowSize(), matrixView.rowSize());
+            assertEquals(m.columnSize(), matrixView.columnSize());
+
+            assertEquals(m.rowSize(), (delegateStorage).rowsLength());
+            assertEquals(m.columnSize(), (delegateStorage).columnsLength());
+
+            assertEquals(m.isSequentialAccess(), delegateStorage.isSequentialAccess());
+            assertEquals(m.isRandomAccess(), delegateStorage.isRandomAccess());
+            assertEquals(m.isDistributed(), delegateStorage.isDistributed());
+            assertEquals(m.isDense(), delegateStorage.isDense());
+            assertEquals(m.isArrayBased(), delegateStorage.isArrayBased());
+
+            assertArrayEquals(m.getStorage().data(), delegateStorage.data());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixViewConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixViewConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixViewConstructorTest.java
new file mode 100644
index 0000000..87bf3ad
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixViewConstructorTest.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import java.util.Arrays;
+import org.apache.ignite.ml.math.Matrix;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class PivotedMatrixViewConstructorTest {
+    /** */
+    @Test
+    public void invalidArgsTest() {
+        Matrix m = new DenseLocalOnHeapMatrix(1, 1);
+
+        int[] pivot = new int[] {0};
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new PivotedMatrixView(null),
+            "Null parent matrix.");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new PivotedMatrixView(null, pivot),
+            "Null parent matrix, with pivot.");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new PivotedMatrixView(m, null),
+            "Null pivot.");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new PivotedMatrixView(m, null, pivot),
+            "Null row pivot.");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new PivotedMatrixView(m, pivot, null),
+            "Null col pivot.");
+    }
+
+    /** */
+    @Test
+    public void basicTest() {
+        Matrix m = new DenseLocalOnHeapMatrix(2, 2);
+
+        int[] pivot = new int[] {0, 1};
+
+        PivotedMatrixView view = new PivotedMatrixView(m, pivot);
+
+        assertEquals("Rows in view.", m.rowSize(), view.rowSize());
+        assertEquals("Cols in view.", m.columnSize(), view.columnSize());
+
+        assertTrue("Row pivot array in view.", Arrays.equals(pivot, view.rowPivot()));
+        assertTrue("Col pivot array in view.", Arrays.equals(pivot, view.columnPivot()));
+
+        Assert.assertEquals("Base matrix in view.", m, view.getBaseMatrix());
+
+        assertEquals("Row pivot value in view.", 0, view.rowPivot(0));
+        assertEquals("Col pivot value in view.", 0, view.columnPivot(0));
+
+        assertEquals("Row unpivot value in view.", 0, view.rowUnpivot(0));
+        assertEquals("Col unpivot value in view.", 0, view.columnUnpivot(0));
+
+        Matrix swap = view.swap(1, 1);
+
+        for (int row = 0; row < view.rowSize(); row++)
+            for (int col = 0; col < view.columnSize(); col++)
+                assertEquals("Unexpected swap value set at (" + row + "," + col + ").",
+                    view.get(row, col), swap.get(row, col), 0d);
+
+        //noinspection EqualsWithItself
+        assertTrue("View is expected to be equal to self.", view.equals(view));
+        //noinspection ObjectEqualsNull
+        assertFalse("View is expected to be not equal to null.", view.equals(null));
+    }
+
+    /** */
+    @Test
+    public void pivotTest() {
+        int[] pivot = new int[] {2, 1, 0, 3};
+
+        for (Matrix m : new Matrix[] {
+            new DenseLocalOnHeapMatrix(3, 3),
+            new DenseLocalOnHeapMatrix(3, 4), new DenseLocalOnHeapMatrix(4, 3)})
+            pivotTest(m, pivot);
+    }
+
+    /** */
+    private void pivotTest(Matrix parent, int[] pivot) {
+        for (int row = 0; row < parent.rowSize(); row++)
+            for (int col = 0; col < parent.columnSize(); col++)
+                parent.set(row, col, row * parent.columnSize() + col + 1);
+
+        Matrix view = new PivotedMatrixView(parent, pivot);
+
+        int rows = parent.rowSize();
+        int cols = parent.columnSize();
+
+        assertEquals("Rows in view.", rows, view.rowSize());
+        assertEquals("Cols in view.", cols, view.columnSize());
+
+        for (int row = 0; row < rows; row++)
+            for (int col = 0; col < cols; col++)
+                assertEquals("Unexpected value at " + row + "x" + col,
+                    parent.get(pivot[row], pivot[col]), view.get(row, col), 0d);
+
+        int min = rows < cols ? rows : cols;
+
+        for (int idx = 0; idx < min; idx++)
+            view.set(idx, idx, 0d);
+
+        for (int idx = 0; idx < min; idx++)
+            assertEquals("Unexpected value set at " + idx,
+                0d, parent.get(pivot[idx], pivot[idx]), 0d);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/RandomMatrixConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/RandomMatrixConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/RandomMatrixConstructorTest.java
new file mode 100644
index 0000000..558e4d8
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/RandomMatrixConstructorTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class RandomMatrixConstructorTest {
+    /** */
+    @Test
+    public void invalidArgsTest() {
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new RandomMatrix(0, 1), "invalid row parameter");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new RandomMatrix(1, 0), "invalid col parameter");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new RandomMatrix(0, 1, true), "invalid row parameter, fastHash true");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new RandomMatrix(1, 0, true), "invalid col parameter, fastHash true");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new RandomMatrix(0, 1, false), "invalid row parameter, fastHash false");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new RandomMatrix(1, 0, false), "invalid col parameter, fastHash false");
+    }
+
+    /** */
+    @Test
+    public void basicTest() {
+        assertEquals("Expected number of rows, int parameters.", 1,
+            new RandomMatrix(1, 2).rowSize());
+
+        assertEquals("Expected number of cols, int parameters.", 1,
+            new RandomMatrix(2, 1).columnSize());
+
+        assertEquals("Expected number of rows, int parameters, fastHash true.", 1,
+            new RandomMatrix(1, 2, true).rowSize());
+
+        assertEquals("Expected number of cols, int parameters, fastHash true.", 1,
+            new RandomMatrix(2, 1, true).columnSize());
+
+        assertEquals("Expected number of rows, int parameters, fastHash false.", 1,
+            new RandomMatrix(1, 2, false).rowSize());
+
+        assertEquals("Expected number of cols, int parameters, fastHash false.", 1,
+            new RandomMatrix(2, 1, false).columnSize());
+
+        RandomMatrix m = new RandomMatrix(1, 1);
+        //noinspection EqualsWithItself
+        assertTrue("Matrix is expected to be equal to self.", m.equals(m));
+        //noinspection ObjectEqualsNull
+        assertFalse("Matrix is expected to be not equal to null.", m.equals(null));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrixTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrixTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrixTest.java
new file mode 100644
index 0000000..8985806
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrixTest.java
@@ -0,0 +1,265 @@
+// @java.file.header
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.common.GridCommonTest;
+
+import static org.apache.ignite.ml.math.impls.MathTestConstants.UNEXPECTED_VAL;
+
+/**
+ * Tests for {@link SparseDistributedMatrix}.
+ */
+@GridCommonTest(group = "Distributed Models")
+public class SparseDistributedMatrixTest extends GridCommonAbstractTest {
+    /** Number of nodes in grid */
+    private static final int NODE_COUNT = 3;
+    /** Cache name. */
+    private static final String CACHE_NAME = "test-cache";
+    /** Precision. */
+    private static final double PRECISION = 0.0;
+    /** Grid instance. */
+    private Ignite ignite;
+    /** Matrix rows */
+    private final int rows = MathTestConstants.STORAGE_SIZE;
+    /** Matrix cols */
+    private final int cols = MathTestConstants.STORAGE_SIZE;
+    /** Matrix for tests */
+    private SparseDistributedMatrix cacheMatrix;
+
+    /**
+     * Default constructor.
+     */
+    public SparseDistributedMatrixTest() {
+        super(false);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        for (int i = 1; i <= NODE_COUNT; i++)
+            startGrid(i);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override protected void beforeTest() throws Exception {
+        ignite = grid(NODE_COUNT);
+
+        ignite.configuration().setPeerClassLoadingEnabled(true);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        ignite.destroyCache(CACHE_NAME);
+
+        if (cacheMatrix != null) {
+            cacheMatrix.destroy();
+            cacheMatrix = null;
+        }
+    }
+
+    /** */
+    public void testGetSet() throws Exception {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+        for (int i = 0; i < rows; i++) {
+            for (int j = 0; j < cols; j++) {
+                double v = Math.random();
+                cacheMatrix.set(i, j, v);
+
+                assert Double.compare(v, cacheMatrix.get(i, j)) == 0;
+            }
+        }
+    }
+
+    /** */
+    public void testExternalize() throws IOException, ClassNotFoundException {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+        cacheMatrix.set(1, 1, 1.0);
+
+        ByteArrayOutputStream byteArrOutputStream = new ByteArrayOutputStream();
+        ObjectOutputStream objOutputStream = new ObjectOutputStream(byteArrOutputStream);
+
+        objOutputStream.writeObject(cacheMatrix);
+
+        ByteArrayInputStream byteArrInputStream = new ByteArrayInputStream(byteArrOutputStream.toByteArray());
+        ObjectInputStream objInputStream = new ObjectInputStream(byteArrInputStream);
+
+        SparseDistributedMatrix objRestored = (SparseDistributedMatrix)objInputStream.readObject();
+
+        assertTrue(MathTestConstants.VAL_NOT_EQUALS, cacheMatrix.equals(objRestored));
+        assertEquals(MathTestConstants.VAL_NOT_EQUALS, objRestored.get(1, 1), 1.0, 0.0);
+    }
+
+    /** Test simple math. */
+    public void testMath() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+        initMtx(cacheMatrix);
+
+        cacheMatrix.assign(2.0);
+        for (int i = 0; i < cacheMatrix.rowSize(); i++)
+            for (int j = 0; j < cacheMatrix.columnSize(); j++)
+                assertEquals(UNEXPECTED_VAL, 2.0, cacheMatrix.get(i, j), PRECISION);
+
+        cacheMatrix.plus(3.0);
+        for (int i = 0; i < cacheMatrix.rowSize(); i++)
+            for (int j = 0; j < cacheMatrix.columnSize(); j++)
+                assertEquals(UNEXPECTED_VAL, 5.0, cacheMatrix.get(i, j), PRECISION);
+
+        cacheMatrix.times(2.0);
+        for (int i = 0; i < cacheMatrix.rowSize(); i++)
+            for (int j = 0; j < cacheMatrix.columnSize(); j++)
+                assertEquals(UNEXPECTED_VAL, 10.0, cacheMatrix.get(i, j), PRECISION);
+
+        cacheMatrix.divide(10.0);
+        for (int i = 0; i < cacheMatrix.rowSize(); i++)
+            for (int j = 0; j < cacheMatrix.columnSize(); j++)
+                assertEquals(UNEXPECTED_VAL, 1.0, cacheMatrix.get(i, j), PRECISION);
+
+        assertEquals(UNEXPECTED_VAL, cacheMatrix.rowSize() * cacheMatrix.columnSize(), cacheMatrix.sum(), PRECISION);
+    }
+
+    /** */
+    public void testMinMax() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+        for (int i = 0; i < cacheMatrix.rowSize(); i++)
+            for (int j = 0; j < cacheMatrix.columnSize(); j++)
+                cacheMatrix.set(i, j, i * cols + j + 1);
+
+        assertEquals(UNEXPECTED_VAL, 1.0, cacheMatrix.minValue(), PRECISION);
+        assertEquals(UNEXPECTED_VAL, rows * cols, cacheMatrix.maxValue(), PRECISION);
+
+        for (int i = 0; i < cacheMatrix.rowSize(); i++)
+            for (int j = 0; j < cacheMatrix.columnSize(); j++)
+                cacheMatrix.set(i, j, -1.0 * (i * cols + j + 1));
+
+        assertEquals(UNEXPECTED_VAL, -rows * cols, cacheMatrix.minValue(), PRECISION);
+        assertEquals(UNEXPECTED_VAL, -1.0, cacheMatrix.maxValue(), PRECISION);
+
+        for (int i = 0; i < cacheMatrix.rowSize(); i++)
+            for (int j = 0; j < cacheMatrix.columnSize(); j++)
+                cacheMatrix.set(i, j, i * cols + j);
+
+        assertEquals(UNEXPECTED_VAL, 1.0, cacheMatrix.minValue(), PRECISION);
+        assertEquals(UNEXPECTED_VAL, rows * cols - 1.0, cacheMatrix.maxValue(), PRECISION);
+    }
+
+    /** */
+    public void testMap() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+        initMtx(cacheMatrix);
+
+        cacheMatrix.map(i -> 100.0);
+        for (int i = 0; i < cacheMatrix.rowSize(); i++)
+            for (int j = 0; j < cacheMatrix.columnSize(); j++)
+                assertEquals(UNEXPECTED_VAL, 100.0, cacheMatrix.get(i, j), PRECISION);
+    }
+
+    /** */
+    public void testCopy() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+        try {
+            cacheMatrix.copy();
+            fail("UnsupportedOperationException expected.");
+        }
+        catch (UnsupportedOperationException e) {
+            return;
+        }
+        fail("UnsupportedOperationException expected.");
+    }
+
+    /** */
+    public void testLike() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+        try {
+            cacheMatrix.like(1, 1);
+            fail("UnsupportedOperationException expected.");
+        }
+        catch (UnsupportedOperationException e) {
+            return;
+        }
+        fail("UnsupportedOperationException expected.");
+    }
+
+    /** */
+    public void testLikeVector() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+        try {
+            cacheMatrix.likeVector(1);
+            fail("UnsupportedOperationException expected.");
+        }
+        catch (UnsupportedOperationException e) {
+            return;
+        }
+        fail("UnsupportedOperationException expected.");
+    }
+
+    /** */
+    private void initMtx(Matrix m) {
+        for (int i = 0; i < m.rowSize(); i++)
+            for (int j = 0; j < m.columnSize(); j++)
+                m.set(i, j, 1.0);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/SparseLocalOnHeapMatrixConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/SparseLocalOnHeapMatrixConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/SparseLocalOnHeapMatrixConstructorTest.java
new file mode 100644
index 0000000..bc05eb7
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/SparseLocalOnHeapMatrixConstructorTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class SparseLocalOnHeapMatrixConstructorTest {
+    /** */
+    @Test
+    public void invalidArgsTest() {
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new SparseLocalOnHeapMatrix(0, 1),
+            "invalid row parameter");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new SparseLocalOnHeapMatrix(1, 0),
+            "invalid col parameter");
+    }
+
+    /** */
+    @Test
+    public void basicTest() {
+        assertEquals("Expected number of rows.", 1,
+            new SparseLocalOnHeapMatrix(1, 2).rowSize());
+
+        assertEquals("Expected number of cols, int parameters.", 1,
+            new SparseLocalOnHeapMatrix(2, 1).columnSize());
+
+        SparseLocalOnHeapMatrix m = new SparseLocalOnHeapMatrix(1, 1);
+        //noinspection EqualsWithItself
+        assertTrue("Matrix is expected to be equal to self.", m.equals(m));
+        //noinspection ObjectEqualsNull
+        assertFalse("Matrix is expected to be not equal to null.", m.equals(null));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/TransposedMatrixViewTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/TransposedMatrixViewTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/TransposedMatrixViewTest.java
new file mode 100644
index 0000000..22ec7cc
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/TransposedMatrixViewTest.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.ml.math.ExternalizeTest;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests for {@link TransposedMatrixView}.
+ */
+public class TransposedMatrixViewTest extends ExternalizeTest<TransposedMatrixView> {
+    /** */
+    private static final String UNEXPECTED_VALUE = "Unexpected value";
+    /** */
+    private TransposedMatrixView testMatrix;
+    /** */
+    private DenseLocalOnHeapMatrix parent;
+
+    /** */
+    @Before
+    public void setup() {
+        parent = new DenseLocalOnHeapMatrix(MathTestConstants.STORAGE_SIZE, MathTestConstants.STORAGE_SIZE);
+        fillMatrix(parent);
+        testMatrix = new TransposedMatrixView(parent);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void externalizeTest() {
+        externalizeTest(testMatrix);
+    }
+
+    /** */
+    @Test
+    public void testView() {
+        assertEquals(UNEXPECTED_VALUE, parent.rowSize(), testMatrix.columnSize());
+        assertEquals(UNEXPECTED_VALUE, parent.columnSize(), testMatrix.rowSize());
+
+        for (int i = 0; i < parent.rowSize(); i++)
+            for (int j = 0; j < parent.columnSize(); j++)
+                assertEquals(UNEXPECTED_VALUE, parent.get(i, j), testMatrix.get(j, i), 0d);
+    }
+
+    /** */
+    @Test
+    public void testNullParams() {
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new TransposedMatrixView(null), "Null Matrix parameter");
+    }
+
+    /** */
+    @Test(expected = UnsupportedOperationException.class)
+    public void testLike() {
+        testMatrix.like(0, 0);
+    }
+
+    /** */
+    @Test(expected = UnsupportedOperationException.class)
+    public void testLikeVector() {
+        testMatrix.likeVector(0);
+    }
+
+    /** */
+    private void fillMatrix(DenseLocalOnHeapMatrix mtx) {
+        for (int i = 0; i < mtx.rowSize(); i++)
+            for (int j = 0; j < mtx.columnSize(); j++)
+                mtx.setX(i, j, i * mtx.rowSize() + j);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixArrayStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixArrayStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixArrayStorageTest.java
new file mode 100644
index 0000000..569ed57
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixArrayStorageTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Unit tests for {@link ArrayMatrixStorage}.
+ */
+public class MatrixArrayStorageTest extends MatrixBaseStorageTest<ArrayMatrixStorage> {
+    /** {@inheritDoc} */
+    @Override public void setUp() {
+        storage = new ArrayMatrixStorage(MathTestConstants.STORAGE_SIZE, MathTestConstants.STORAGE_SIZE);
+    }
+
+    /** */
+    @Test
+    public void isSequentialAccess() throws Exception {
+        assertFalse(MathTestConstants.UNEXPECTED_VAL, storage.isSequentialAccess());
+    }
+
+    /** */
+    @Test
+    public void isDense() throws Exception {
+        assertTrue(MathTestConstants.UNEXPECTED_VAL, storage.isDense());
+    }
+
+    /** */
+    @Test
+    public void isArrayBased() throws Exception {
+        assertTrue(MathTestConstants.UNEXPECTED_VAL, storage.isArrayBased());
+    }
+
+    /** */
+    @Test
+    public void data() throws Exception {
+        double[][] data = storage.data();
+        assertNotNull(MathTestConstants.NULL_VAL, data);
+        assertTrue(MathTestConstants.UNEXPECTED_VAL, data.length == MathTestConstants.STORAGE_SIZE);
+        assertTrue(MathTestConstants.UNEXPECTED_VAL, data[0].length == MathTestConstants.STORAGE_SIZE);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixBaseStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixBaseStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixBaseStorageTest.java
new file mode 100644
index 0000000..94e87c2
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixBaseStorageTest.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import org.apache.ignite.ml.math.ExternalizeTest;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Abstract class with base tests for each matrix storage.
+ */
+public abstract class MatrixBaseStorageTest<T extends MatrixStorage> extends ExternalizeTest<T> {
+    /** */
+    protected T storage;
+
+    /** */
+    @Before
+    public abstract void setUp();
+
+    /** */
+    @After
+    public void tearDown() throws Exception {
+        storage.destroy();
+    }
+
+    /** */
+    @Test
+    public void getSet() throws Exception {
+        int rows = MathTestConstants.STORAGE_SIZE;
+        int cols = MathTestConstants.STORAGE_SIZE;
+
+        for (int i = 0; i < rows; i++) {
+            for (int j = 0; j < cols; j++) {
+                double data = Math.random();
+
+                storage.set(i, j, data);
+
+                Assert.assertEquals(MathTestConstants.VAL_NOT_EQUALS, storage.get(i, j), data, MathTestConstants.NIL_DELTA);
+            }
+        }
+    }
+
+    /** */
+    @Test
+    public void columnSize() throws Exception {
+        assertEquals(MathTestConstants.VAL_NOT_EQUALS, storage.columnSize(), MathTestConstants.STORAGE_SIZE);
+    }
+
+    /** */
+    @Test
+    public void rowSize() throws Exception {
+        assertEquals(MathTestConstants.VAL_NOT_EQUALS, storage.rowSize(), MathTestConstants.STORAGE_SIZE);
+    }
+
+    /** */
+    @Override public void externalizeTest() {
+        fillMatrix();
+        super.externalizeTest(storage);
+    }
+
+    /** */
+    protected void fillMatrix() {
+        for (int i = 0; i < storage.rowSize(); i++) {
+            for (int j = 0; j < storage.columnSize(); j++)
+                storage.set(i, j, Math.random());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixOffHeapStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixOffHeapStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixOffHeapStorageTest.java
new file mode 100644
index 0000000..52d57fd
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixOffHeapStorageTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNull;
+
+/**
+ * Unit tests for {@link DenseOffHeapMatrixStorage}.
+ */
+public class MatrixOffHeapStorageTest extends MatrixBaseStorageTest<DenseOffHeapMatrixStorage> {
+    /** {@inheritDoc} */
+    @Override public void setUp() {
+        storage = new DenseOffHeapMatrixStorage(MathTestConstants.STORAGE_SIZE, MathTestConstants.STORAGE_SIZE);
+    }
+
+    /** */
+    @Test
+    public void data() throws Exception {
+        assertNull(MathTestConstants.UNEXPECTED_VAL, storage.data());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
new file mode 100644
index 0000000..03473cf
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.function.BiConsumer;
+import java.util.function.Supplier;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ *
+ */
+class MatrixStorageFixtures {
+    /** */
+    private static final List<Supplier<Iterable<MatrixStorage>>> suppliers = Collections.singletonList(
+        (Supplier<Iterable<MatrixStorage>>) SparseLocalMatrixStorageFixture::new
+    );
+
+    /** */
+    void consumeSampleStorages(BiConsumer<Integer, Integer> paramsConsumer,
+        BiConsumer<MatrixStorage, String> consumer) {
+        for (Supplier<Iterable<MatrixStorage>> fixtureSupplier : suppliers) {
+            final Iterable<MatrixStorage> fixture = fixtureSupplier.get();
+
+            for (MatrixStorage matrixStorage : fixture) {
+                if (paramsConsumer != null)
+                    paramsConsumer.accept(matrixStorage.rowSize(), matrixStorage.columnSize());
+
+                consumer.accept(matrixStorage, fixture.toString());
+            }
+        }
+    }
+
+    /** */
+    private static class SparseLocalMatrixStorageFixture implements Iterable<MatrixStorage> {
+        /** */
+        private final Integer[] rows = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 512, 1024, null};
+        /** */
+        private final Integer[] cols = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1024, 512, null};
+        /** */
+        private final Integer[] randomAccess = new Integer[] {StorageConstants.SEQUENTIAL_ACCESS_MODE, StorageConstants.RANDOM_ACCESS_MODE, null};
+        /** */
+        private final Integer[] rowStorage = new Integer[] {StorageConstants.ROW_STORAGE_MODE, StorageConstants.COLUMN_STORAGE_MODE, null};
+        /** */
+        private int sizeIdx = 0;
+        /** */
+        private int acsModeIdx = 0;
+        /** */
+        private int stoModeIdx = 0;
+
+        /** {@inheritDoc} */
+        @NotNull
+        @Override public Iterator<MatrixStorage> iterator() {
+            return new Iterator<MatrixStorage>() {
+                /** {@inheritDoc} */
+                @Override public boolean hasNext() {
+                    return hasNextCol(sizeIdx) && hasNextRow(sizeIdx)
+                        && hasNextAcsMode(acsModeIdx) && hasNextStoMode(stoModeIdx);
+                }
+
+                /** {@inheritDoc} */
+                @Override public MatrixStorage next() {
+                    if (!hasNext())
+                        throw new NoSuchElementException(SparseLocalMatrixStorageFixture.this.toString());
+
+                    MatrixStorage storage = new SparseLocalOnHeapMatrixStorage(
+                        rows[sizeIdx], cols[sizeIdx], randomAccess[acsModeIdx], rowStorage[stoModeIdx]);
+
+                    nextIdx();
+
+                    return storage;
+                }
+
+                private void nextIdx() {
+                    if (hasNextStoMode(stoModeIdx + 1)) {
+                        stoModeIdx++;
+
+                        return;
+                    }
+
+                    stoModeIdx = 0;
+
+                    if (hasNextAcsMode(acsModeIdx + 1)) {
+                        acsModeIdx++;
+
+                        return;
+                    }
+
+                    acsModeIdx = 0;
+                    sizeIdx++;
+                }
+            };
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return "SparseLocalMatrixStorageFixture{ " + "rows=" + rows[sizeIdx] + ", cols=" + cols[sizeIdx] +
+                ", access mode=" + randomAccess[acsModeIdx] + ", storage mode=" + rowStorage[stoModeIdx] + "}";
+        }
+
+        /** */ private boolean hasNextRow(int idx) {
+            return rows[idx] != null;
+        }
+
+        /** */ private boolean hasNextCol(int idx) {
+            return cols[idx] != null;
+        }
+
+        /** */ private boolean hasNextAcsMode(int idx) {
+            return randomAccess[idx] != null;
+        }
+
+        /** */ private boolean hasNextStoMode(int idx) {
+            return rowStorage[idx] != null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageImplementationTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageImplementationTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageImplementationTest.java
new file mode 100644
index 0000000..72daeca
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageImplementationTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.BiConsumer;
+import org.apache.ignite.ml.math.ExternalizeTest;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Unit tests for {@link MatrixStorage} implementations.
+ *
+ * TODO: add attribute tests.
+ */
+public class MatrixStorageImplementationTest extends ExternalizeTest<MatrixStorage> {
+    /**
+     * The columnSize() and the rowSize() test.
+     */
+    @Test
+    public void sizeTest() {
+        final AtomicReference<Integer> expRowSize = new AtomicReference<>(0);
+        final AtomicReference<Integer> expColSize = new AtomicReference<>(0);
+
+        consumeSampleStorages((x, y) -> {
+                expRowSize.set(x);
+                expColSize.set(y);
+            },
+            (ms, desc) -> assertTrue("Expected size for " + desc, expColSize.get().equals(ms.columnSize()) && expRowSize.get().equals(ms.rowSize())));
+    }
+
+    /** */
+    @Test
+    public void getSetTest() {
+        consumeSampleStorages(null, (ms, desc) -> {
+            for (int i = 0; i < ms.rowSize(); i++) {
+                for (int j = 0; j < ms.columnSize(); j++) {
+                    double random = Math.random();
+                    ms.set(i, j, random);
+                    assertTrue("Unexpected value for " + desc + " x:" + i + ", y:" + j, Double.compare(random, ms.get(i, j)) == 0);
+                }
+            }
+        });
+    }
+
+    /** */
+    @Override public void externalizeTest() {
+        consumeSampleStorages(null, (ms, desc) -> externalizeTest(ms));
+    }
+
+    /** */
+    private void consumeSampleStorages(BiConsumer<Integer, Integer> paramsConsumer,
+        BiConsumer<MatrixStorage, String> consumer) {
+        new MatrixStorageFixtures().consumeSampleStorages(paramsConsumer, consumer);
+    }
+}


[62/65] [abbrv] ignite git commit: ignite-2.0 - minor fixes

Posted by ag...@apache.org.
ignite-2.0 - minor fixes


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

Branch: refs/heads/ignite-5024
Commit: 8a1ded1cf55b9aaf1f60d2657ec3ebf1e14fa8bc
Parents: f299671
Author: Sergi Vladykin <se...@gmail.com>
Authored: Mon Apr 24 10:43:03 2017 +0300
Committer: Sergi Vladykin <se...@gmail.com>
Committed: Mon Apr 24 10:43:03 2017 +0300

----------------------------------------------------------------------
 .../query/h2/opt/GridH2SpatialIndex.java        | 24 +++++++++++++++-----
 .../query/h2/sql/GridQueryParsingTest.java      |  2 +-
 2 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8a1ded1c/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java b/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
index c8f3f68..9389290 100644
--- a/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
+++ b/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.query.h2.opt;
 import com.vividsolutions.jts.geom.Envelope;
 import com.vividsolutions.jts.geom.Geometry;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -29,13 +28,14 @@ import java.util.Map;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import org.apache.ignite.*;
-import org.apache.ignite.internal.processors.query.h2.*;
-import org.apache.ignite.internal.util.*;
-import org.apache.ignite.internal.util.lang.*;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.processors.query.h2.H2Cursor;
+import org.apache.ignite.internal.util.GridCursorIteratorWrapper;
+import org.apache.ignite.internal.util.IgniteTree;
+import org.apache.ignite.internal.util.lang.GridCursor;
 import org.h2.engine.Session;
 import org.h2.index.Cursor;
+import org.h2.index.IndexLookupBatch;
 import org.h2.index.IndexType;
 import org.h2.index.SingleRowCursor;
 import org.h2.index.SpatialIndex;
@@ -132,6 +132,18 @@ public class GridH2SpatialIndex extends GridH2IndexBase implements SpatialIndex
         ctx = tbl.rowDescriptor().context();
     }
 
+    /** {@inheritDoc} */
+    @Override public IndexLookupBatch createLookupBatch(TableFilter[] filters, int filter) {
+        if (getTable().isPartitioned()) {
+            assert filter > 0; // Lookup batch will not be created for the first table filter.
+
+            throw DbException.throwInternalError(
+                "Table with a spatial index must be the first in the query: " + getTable());
+        }
+
+        return null; // Support must be explicitly added.
+    }
+
     /**
      * Check closed.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/8a1ded1c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
index 2085c9f..9782f28 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
@@ -506,7 +506,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
 
         // Schemas for index and table must match
         assertParseThrows("create index if not exists sch2.idx on sch1.Person (name)",
-            DbException.class, "Schema name must match [90080-194]");
+            DbException.class, "Schema name must match [90080-195]");
 
         assertParseThrows("create hash index if not exists idx on Person (name)",
             IgniteSQLException.class, "Only SPATIAL modifier is supported for CREATE INDEX");


[20/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/RandomMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/RandomMatrix.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/RandomMatrix.java
deleted file mode 100644
index 2c3dcb2..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/RandomMatrix.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.storage.matrix.RandomMatrixStorage;
-import org.apache.ignite.math.impls.vector.RandomVector;
-
-/**
- * Implementation of {@link Matrix} with random values in the elements.
- */
-public class RandomMatrix extends AbstractMatrix {
-    /** Whether fast hash is used, see {@link RandomMatrixStorage}. */
-    private boolean fastHash;
-
-    /**
-     * @param rows Amount of rows in the matrix.
-     * @param cols Amount of columns in the matrix.
-     * @param fastHash Whether fast hash is used.
-     */
-    private MatrixStorage mkStorage(int rows, int cols, boolean fastHash) {
-        this.fastHash = fastHash;
-
-        return new RandomMatrixStorage(rows, cols, fastHash);
-    }
-
-    /**
-     * @param rows Amount of rows in the matrix.
-     * @param cols Amount of columns in the matrix.
-     * @param fastHash Whether fast hash is used.
-     */
-    public RandomMatrix(int rows, int cols, boolean fastHash) {
-        setStorage(mkStorage(rows, cols, fastHash));
-    }
-
-    /**
-     * @param rows Amount of rows in the matrix.
-     * @param cols Amount of columns in the matrix.
-     */
-    public RandomMatrix(int rows, int cols) {
-        this(rows, cols, true);
-    }
-
-    /** */
-    public RandomMatrix() {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix copy() {
-        return new RandomMatrix(rowSize(), columnSize(), fastHash);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix like(int rows, int cols) {
-        return new RandomMatrix(rows, cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector likeVector(int crd) {
-        return new RandomVector(crd);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        super.writeExternal(out);
-
-        out.writeBoolean(fastHash);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        super.readExternal(in);
-
-        fastHash = in.readBoolean();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/SparseDistributedMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/SparseDistributedMatrix.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/SparseDistributedMatrix.java
deleted file mode 100644
index 5c40d70..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/SparseDistributedMatrix.java
+++ /dev/null
@@ -1,155 +0,0 @@
-// @java.file.header
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.StorageConstants;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.IgniteDoubleFunction;
-import org.apache.ignite.math.functions.IgniteFunction;
-import org.apache.ignite.math.impls.CacheUtils;
-import org.apache.ignite.math.impls.storage.matrix.SparseDistributedMatrixStorage;
-
-/**
- * Sparse distributed matrix implementation based on data grid.
- *
- * Unlike {@link CacheMatrix} that is based on existing cache, this implementation creates distributed
- * cache internally and doesn't rely on pre-existing cache.
- *
- * You also need to call {@link #destroy()} to remove the underlying cache when you no longer need this
- * matrix.
- *
- * <b>Currently fold supports only commutative operations.<b/>
- */
-public class SparseDistributedMatrix extends AbstractMatrix implements StorageConstants {
-    /**
-     *
-     */
-    public SparseDistributedMatrix() {
-        // No-op.
-    }
-
-    /**
-     * @param rows
-     * @param cols
-     * @param stoMode
-     * @param acsMode
-     */
-    public SparseDistributedMatrix(int rows, int cols, int stoMode, int acsMode) {
-        assert rows > 0;
-        assert cols > 0;
-        assertAccessMode(acsMode);
-        assertStorageMode(stoMode);
-
-        setStorage(new SparseDistributedMatrixStorage(rows, cols, stoMode, acsMode));
-    }
-
-    /**
-     *
-     *
-     */
-    private SparseDistributedMatrixStorage storage() {
-        return (SparseDistributedMatrixStorage)getStorage();
-    }
-
-    /**
-     * Return the same matrix with updates values (broken contract).
-     *
-     * @param d
-     */
-    @Override public Matrix divide(double d) {
-        return mapOverValues((Double v) -> v / d);
-    }
-
-    /**
-     * Return the same matrix with updates values (broken contract).
-     *
-     * @param x
-     */
-    @Override public Matrix plus(double x) {
-        return mapOverValues((Double v) -> v + x);
-    }
-
-    /**
-     * Return the same matrix with updates values (broken contract).
-     *
-     * @param x
-     */
-    @Override public Matrix times(double x) {
-        return mapOverValues((Double v) -> v * x);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix assign(double val) {
-        return mapOverValues((Double v) -> val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix map(IgniteDoubleFunction<Double> fun) {
-        return mapOverValues(fun::apply);
-    }
-
-    /**
-     * @param mapper
-     */
-    private Matrix mapOverValues(IgniteFunction<Double, Double> mapper) {
-        CacheUtils.sparseMap(storage().cache().getName(), mapper);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double sum() {
-        return CacheUtils.sparseSum(storage().cache().getName());
-    }
-
-    /** {@inheritDoc} */
-    @Override public double maxValue() {
-        return CacheUtils.sparseMax(storage().cache().getName());
-    }
-
-    /** {@inheritDoc} */
-    @Override public double minValue() {
-        return CacheUtils.sparseMin(storage().cache().getName());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix copy() {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix like(int rows, int cols) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector likeVector(int crd) {
-        throw new UnsupportedOperationException();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/SparseLocalOnHeapMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/SparseLocalOnHeapMatrix.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/SparseLocalOnHeapMatrix.java
deleted file mode 100644
index cb08939..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/SparseLocalOnHeapMatrix.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.StorageConstants;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.storage.matrix.SparseLocalOnHeapMatrixStorage;
-import org.apache.ignite.math.impls.vector.SparseLocalVector;
-
-/**
- * Sparse local onheap matrix with {@link SparseLocalVector} as rows.
- */
-public class SparseLocalOnHeapMatrix extends AbstractMatrix implements StorageConstants {
-    /**
-     *
-     */
-    public SparseLocalOnHeapMatrix() {
-        // No-op.
-    }
-
-    /**
-     * Construct new {@link SparseLocalOnHeapMatrix}.
-     *
-     * By default storage sets in row optimized mode and in random access mode.
-     */
-    public SparseLocalOnHeapMatrix(int rows, int cols) {
-        setStorage(mkStorage(rows, cols));
-    }
-
-    /**
-     * Create new {@link SparseLocalOnHeapMatrixStorage}.
-     */
-    private MatrixStorage mkStorage(int rows, int cols) {
-        return new SparseLocalOnHeapMatrixStorage(rows, cols, StorageConstants.RANDOM_ACCESS_MODE, StorageConstants.ROW_STORAGE_MODE);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix like(int rows, int cols) {
-        return new SparseLocalOnHeapMatrix(rows, cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector likeVector(int crd) {
-        return new SparseLocalVector(crd, StorageConstants.RANDOM_ACCESS_MODE);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix copy() {
-        Matrix cp = like(rowSize(), columnSize());
-
-        cp.assign(this);
-
-        return cp;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/TransposedMatrixView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/TransposedMatrixView.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/TransposedMatrixView.java
deleted file mode 100644
index 9da909b..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/TransposedMatrixView.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.storage.matrix.MatrixDelegateStorage;
-
-/**
- * Implements transposed view of the parent {@link Matrix}.
- */
-public class TransposedMatrixView extends AbstractMatrix {
-    /** */
-    public TransposedMatrixView() {
-        //No-op.
-    }
-
-    /**
-     * @param mtx Parent matrix.
-     */
-    public TransposedMatrixView(Matrix mtx) {
-        this(mtx == null ? null : mtx.getStorage());
-    }
-
-    /** */
-    private TransposedMatrixView(MatrixStorage sto) {
-        super(new MatrixDelegateStorage(sto, 0, 0,
-            sto == null ? 0 : sto.rowSize(), sto == null ? 0 : sto.columnSize()));
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void storageSet(int row, int col, double v) {
-        super.storageSet(col, row, v);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected double storageGet(int row, int col) {
-        return super.storageGet(col, row);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int rowSize() {
-        return getStorage().columnSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int columnSize() {
-        return getStorage().rowSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix copy() {
-        MatrixDelegateStorage sto = (MatrixDelegateStorage)getStorage();
-
-        return new TransposedMatrixView(sto.delegate());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix like(int rows, int cols) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector likeVector(int crd) {
-        throw new UnsupportedOperationException();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/package-info.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/package-info.java
deleted file mode 100644
index 75d7532..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Contains several matrix implementations.
- */
-package org.apache.ignite.math.impls.matrix;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/package-info.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/package-info.java
deleted file mode 100644
index f1b2e36..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Contains specific implementations for core algebra.
- */
-package org.apache.ignite.math.impls;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/ArrayMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/ArrayMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/ArrayMatrixStorage.java
deleted file mode 100644
index eb65b1d..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/ArrayMatrixStorage.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Arrays;
-import org.apache.ignite.math.MatrixStorage;
-
-/**
- * Array based {@link MatrixStorage} implementation.
- */
-public class ArrayMatrixStorage implements MatrixStorage {
-    /** Backing data array. */
-    private double[][] data;
-    /** Amount of rows in the matrix. */
-    private int rows;
-    /** Amount of columns in the matrix. */
-    private int cols;
-
-    /**
-     *
-     */
-    public ArrayMatrixStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param rows Amount of rows in the matrix.
-     * @param cols Amount of columns in the matrix.
-     */
-    public ArrayMatrixStorage(int rows, int cols) {
-        assert rows > 0;
-        assert cols > 0;
-
-        this.data = new double[rows][cols];
-        this.rows = rows;
-        this.cols = cols;
-    }
-
-    /**
-     * @param data Backing data array.
-     */
-    public ArrayMatrixStorage(double[][] data) {
-        assert data != null;
-        assert data[0] != null;
-
-        this.data = data;
-        this.rows = data.length;
-        this.cols = data[0].length;
-
-        assert rows > 0;
-        assert cols > 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int x, int y) {
-        return data[x][y];
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int x, int y, double v) {
-        data[x][y] = v;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int columnSize() {
-        return cols;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int rowSize() {
-        return rows;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double[][] data() {
-        return data;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(rows);
-        out.writeInt(cols);
-
-        out.writeObject(data);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        rows = in.readInt();
-        cols = in.readInt();
-
-        data = (double[][])in.readObject();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res += res * 37 + rows;
-        res += res * 37 + cols;
-        res += res * 37 + Arrays.deepHashCode(data);
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        ArrayMatrixStorage that = (ArrayMatrixStorage)o;
-
-        return Arrays.deepEquals(data, that.data);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/CacheMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/CacheMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/CacheMatrixStorage.java
deleted file mode 100644
index 7aefa2c..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/CacheMatrixStorage.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.math.MatrixKeyMapper;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.ValueMapper;
-
-/**
- * Matrix storage based on arbitrary cache and key and value mapping functions.
- */
-public class CacheMatrixStorage<K, V> implements MatrixStorage {
-    /** */ private int rows;
-    /** */  private int cols;
-    /** */ private IgniteCache<K, V> cache;
-    /** */ private MatrixKeyMapper<K> keyMapper;
-    /** */ private ValueMapper<V> valMapper;
-
-    /**
-     *
-     */
-    public CacheMatrixStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param rows
-     * @param cols
-     * @param cache
-     * @param keyMapper
-     * @param valMapper
-     */
-    public CacheMatrixStorage(int rows, int cols, IgniteCache<K, V> cache, MatrixKeyMapper<K> keyMapper,
-        ValueMapper<V> valMapper) {
-        assert rows > 0;
-        assert cols > 0;
-        assert cache != null;
-        assert keyMapper != null;
-        assert valMapper != null;
-
-        this.rows = rows;
-        this.cols = cols;
-        this.cache = cache;
-        this.keyMapper = keyMapper;
-        this.valMapper = valMapper;
-    }
-
-    /**
-     * @return Ignite cache.
-     */
-    public IgniteCache<K, V> cache() {
-        return cache;
-    }
-
-    /**
-     * @return Key mapper.
-     */
-    public MatrixKeyMapper<K> keyMapper() {
-        return keyMapper;
-    }
-
-    /**
-     * @return Value mapper.
-     */
-    public ValueMapper<V> valueMapper() {
-        return valMapper;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int x, int y) {
-        return valMapper.toDouble(cache.get(keyMapper.apply(x, y)));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int x, int y, double v) {
-        cache.put(keyMapper.apply(x, y), valMapper.fromDouble(v));
-    }
-
-    /** {@inheritDoc} */
-    @Override public int columnSize() {
-        return cols;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int rowSize() {
-        return rows;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(rows);
-        out.writeInt(cols);
-        out.writeUTF(cache.getName());
-        out.writeObject(keyMapper);
-        out.writeObject(valMapper);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings({"unchecked"})
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        rows = in.readInt();
-        cols = in.readInt();
-        cache = Ignition.localIgnite().getOrCreateCache(in.readUTF());
-        keyMapper = (MatrixKeyMapper<K>)in.readObject();
-        valMapper = (ValueMapper<V>)in.readObject();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + rows;
-        res = res * 37 + cols;
-        res = res * 37 + cache.hashCode();
-        res = res * 37 + keyMapper.hashCode();
-        res = res * 37 + valMapper.hashCode();
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        CacheMatrixStorage that = (CacheMatrixStorage)o;
-
-        return (cache != null ? cache.equals(that.cache) : that.cache == null) &&
-            (keyMapper != null ? keyMapper.equals(that.keyMapper) : that.keyMapper == null) &&
-            (valMapper != null ? valMapper.equals(that.valMapper) : that.valMapper == null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
deleted file mode 100644
index 6695bc2..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.math.MatrixStorage;
-
-/**
- * Local, dense off-heap matrix storage.
- */
-public class DenseOffHeapMatrixStorage implements MatrixStorage {
-    /** */ private int rows;
-    /** */ private int cols;
-    /** */ private transient long ptr;
-    //TODO: temp solution.
-    /** */ private int ptrInitHash;
-
-    /** */
-    public DenseOffHeapMatrixStorage() {
-        // No-op.
-    }
-
-    /** */
-    public DenseOffHeapMatrixStorage(int rows, int cols) {
-        assert rows > 0;
-        assert cols > 0;
-
-        this.rows = rows;
-        this.cols = cols;
-
-        allocateMemory(rows, cols);
-    }
-
-    /** */
-    public DenseOffHeapMatrixStorage(double[][] data) {
-        assert data != null;
-        assert data[0] != null;
-
-        this.rows = data.length;
-        this.cols = data[0].length;
-
-        assert rows > 0;
-        assert cols > 0;
-
-        allocateMemory(rows, cols);
-
-        for (int i = 0; i < rows; i++)
-            for (int j = 0; j < cols; j++)
-                set(i, j, data[i][j]);
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int x, int y) {
-        return GridUnsafe.getDouble(pointerOffset(x, y));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int x, int y, double v) {
-        GridUnsafe.putDouble(pointerOffset(x, y), v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int columnSize() {
-        return cols;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int rowSize() {
-        return rows;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double[][] data() {
-        return null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(rows);
-        out.writeInt(cols);
-        out.writeInt(ptrInitHash);
-
-        for (int i = 0; i < rows; i++)
-            for (int j = 0; j < cols; j++)
-                out.writeDouble(get(i, j));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        rows = in.readInt();
-        cols = in.readInt();
-
-        allocateMemory(rows, cols);
-
-        ptrInitHash = in.readInt();
-
-        for (int i = 0; i < rows; i++)
-            for (int j = 0; j < cols; j++)
-                set(i, j, in.readDouble());
-    }
-
-    /** {@inheritDoc} */
-    @Override public void destroy() {
-        GridUnsafe.freeMemory(ptr);
-    }
-
-    /** {@inheritDoc} */
-    private long pointerOffset(int x, int y) {
-        return ptr + x * cols * Double.BYTES + y * Double.BYTES;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object obj) {
-        return obj != null &&
-            getClass().equals(obj.getClass()) &&
-            (rows == ((DenseOffHeapMatrixStorage)obj).rows) &&
-            (cols == ((DenseOffHeapMatrixStorage)obj).cols) &&
-            (rows == 0 || cols == 0 || ptr == ((DenseOffHeapMatrixStorage)obj).ptr || isMemoryEquals((DenseOffHeapMatrixStorage)obj));
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + rows;
-        res = res * 37 + cols;
-        res = res * 37 + ptrInitHash;
-
-        return res;
-    }
-
-    /** */
-    private boolean isMemoryEquals(DenseOffHeapMatrixStorage otherStorage) {
-        boolean res = true;
-
-        for (int i = 0; i < otherStorage.rows; i++) {
-            for (int j = 0; j < otherStorage.cols; j++) {
-                if (Double.compare(get(i, j), otherStorage.get(i, j)) != 0) {
-                    res = false;
-                    break;
-                }
-            }
-        }
-
-        return res;
-    }
-
-    /** */
-    private void allocateMemory(int rows, int cols) {
-        ptr = GridUnsafe.allocateMemory(rows * cols * Double.BYTES);
-
-        ptrInitHash = Long.hashCode(ptr);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/DiagonalMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/DiagonalMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/DiagonalMatrixStorage.java
deleted file mode 100644
index 099db38..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/DiagonalMatrixStorage.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-
-/**
- * {@link MatrixStorage} implementation for diagonal Matrix view.
- */
-public class DiagonalMatrixStorage implements MatrixStorage {
-    /** Backing vector for matrix diagonal. */
-    private Vector diagonal;
-
-    /**
-     *
-     */
-    public DiagonalMatrixStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param diagonal Backing {@link Vector} for matrix diagonal.
-     */
-    public DiagonalMatrixStorage(Vector diagonal) {
-        assert diagonal != null;
-
-        this.diagonal = diagonal;
-    }
-
-    /**
-     *
-     */
-    public Vector diagonal() {
-        return diagonal;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int x, int y) {
-        return x == y ? diagonal.get(x) : 0.0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int x, int y, double v) {
-        if (x == y)
-            diagonal.set(x, v);
-        else
-            throw new UnsupportedOperationException("Can't set off-diagonal element.");
-    }
-
-    /** {@inheritDoc} */
-    @Override public int columnSize() {
-        return diagonal.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int rowSize() {
-        return diagonal.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(diagonal);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        diagonal = (Vector)in.readObject();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return diagonal.isSequentialAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return diagonal.isDense();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return diagonal.isRandomAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return diagonal.isDistributed();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + diagonal.hashCode();
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        DiagonalMatrixStorage that = (DiagonalMatrixStorage)o;
-
-        return diagonal.equals(that.diagonal);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/FunctionMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/FunctionMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/FunctionMatrixStorage.java
deleted file mode 100644
index 6b0c6b4..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/FunctionMatrixStorage.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.IntIntDoubleToVoidFunction;
-import org.apache.ignite.math.functions.IntIntToDoubleFunction;
-
-/**
- * Read-only or read-write function-based matrix storage.
- */
-public class FunctionMatrixStorage implements MatrixStorage {
-    /** */ private int rows;
-    /** */ private int cols;
-
-    /** */ private IntIntToDoubleFunction getFunc;
-    /** */ private IntIntDoubleToVoidFunction setFunc;
-
-    /**
-     *
-     */
-    public FunctionMatrixStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param rows Amount of rows in the matrix.
-     * @param cols Amount of columns in the matrix.
-     * @param getFunc Function that returns value corresponding to given row and column index.
-     * @param setFunc Set function. If {@code null} - this will be a read-only matrix.
-     */
-    public FunctionMatrixStorage(int rows, int cols, IntIntToDoubleFunction getFunc,
-        IntIntDoubleToVoidFunction setFunc) {
-        assert rows > 0;
-        assert cols > 0;
-        assert getFunc != null;
-
-        this.rows = rows;
-        this.cols = cols;
-        this.getFunc = getFunc;
-        this.setFunc = setFunc;
-    }
-
-    /**
-     * @param rows Amount of rows in the matrix.
-     * @param cols Amount of columns in the matrix.
-     * @param getFunc Function that returns value corresponding to given row and column index.
-     */
-    public FunctionMatrixStorage(int rows, int cols, IntIntToDoubleFunction getFunc) {
-        this(rows, cols, getFunc, null);
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int x, int y) {
-        return getFunc.apply(x, y);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int x, int y, double v) {
-        if (setFunc != null)
-            setFunc.apply(x, y, v);
-        else
-            throw new UnsupportedOperationException("Cannot set into read-only matrix.");
-    }
-
-    /**
-     *
-     */
-    public IntIntToDoubleFunction getFunction() {
-        return getFunc;
-    }
-
-    /**
-     *
-     */
-    public IntIntDoubleToVoidFunction setFunction() {
-        return setFunc;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int columnSize() {
-        return cols;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int rowSize() {
-        return rows;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(setFunc);
-        out.writeObject(getFunc);
-        out.writeInt(rows);
-        out.writeInt(cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        setFunc = (IntIntDoubleToVoidFunction)in.readObject();
-        getFunc = (IntIntToDoubleFunction)in.readObject();
-        rows = in.readInt();
-        cols = in.readInt();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        FunctionMatrixStorage that = (FunctionMatrixStorage)o;
-
-        return rows == that.rows && cols == that.cols
-            && (getFunc != null ? getFunc.equals(that.getFunc) : that.getFunc == null)
-            && (setFunc != null ? setFunc.equals(that.setFunc) : that.setFunc == null);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = rows;
-
-        res = 31 * res + cols;
-        res = 31 * res + (getFunc != null ? getFunc.hashCode() : 0);
-        res = 31 * res + (setFunc != null ? setFunc.hashCode() : 0);
-
-        return res;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/MatrixDelegateStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/MatrixDelegateStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/MatrixDelegateStorage.java
deleted file mode 100644
index 2e1fc12..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/MatrixDelegateStorage.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.math.MatrixStorage;
-
-/**
- * {@link MatrixStorage} implementation that delegates to parent matrix.
- */
-public class MatrixDelegateStorage implements MatrixStorage {
-    /** Parent matrix storage. */
-    private MatrixStorage sto;
-
-    /** Row offset in the parent matrix. */
-    private int rowOff;
-    /** Column offset in the parent matrix. */
-    private int colOff;
-
-    /** Amount of rows in the matrix. */
-    private int rows;
-    /** Amount of columns in the matrix. */
-    private int cols;
-
-    /**
-     *
-     */
-    public MatrixDelegateStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param sto Backing parent storage.
-     * @param rowOff Row offset to parent matrix.
-     * @param colOff Column offset to parent matrix.
-     * @param rows Amount of rows in the view.
-     * @param cols Amount of columns in the view.
-     */
-    public MatrixDelegateStorage(MatrixStorage sto, int rowOff, int colOff, int rows, int cols) {
-        assert sto != null;
-        assert rowOff >= 0;
-        assert colOff >= 0;
-        assert rows > 0;
-        assert cols > 0;
-
-        this.sto = sto;
-
-        this.rowOff = rowOff;
-        this.colOff = colOff;
-
-        this.rows = rows;
-        this.cols = cols;
-    }
-
-    /**
-     *
-     */
-    public MatrixStorage delegate() {
-        return sto;
-    }
-
-    /**
-     *
-     */
-    public int rowOffset() {
-        return rowOff;
-    }
-
-    /**
-     *
-     */
-    public int columnOffset() {
-        return colOff;
-    }
-
-    /**
-     *
-     */
-    public int rowsLength() {
-        return rows;
-    }
-
-    /**
-     *
-     */
-    public int columnsLength() {
-        return cols;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int x, int y) {
-        return sto.get(rowOff + x, colOff + y);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int x, int y, double v) {
-        sto.set(rowOff + x, colOff + y, v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int columnSize() {
-        return cols;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int rowSize() {
-        return rows;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return sto.isArrayBased() && rowOff == 0 && colOff == 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return sto.isSequentialAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return sto.isDense();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return sto.isRandomAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return sto.isDistributed();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double[][] data() {
-        return sto.data();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(sto);
-
-        out.writeInt(rowOff);
-        out.writeInt(colOff);
-
-        out.writeInt(rows);
-        out.writeInt(cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        sto = (MatrixStorage)in.readObject();
-
-        rowOff = in.readInt();
-        colOff = in.readInt();
-
-        rows = in.readInt();
-        cols = in.readInt();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + rows;
-        res = res * 37 + cols;
-        res = res * 37 + rowOff;
-        res = res * 37 + colOff;
-        res = res * 37 + sto.hashCode();
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        MatrixDelegateStorage that = (MatrixDelegateStorage)o;
-
-        return rows == that.rows && cols == that.cols && rowOff == that.rowOff && colOff == that.colOff &&
-            (sto != null ? sto.equals(that.sto) : that.sto == null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/PivotedMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/PivotedMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/PivotedMatrixStorage.java
deleted file mode 100644
index 32c8624..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/PivotedMatrixStorage.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Arrays;
-import org.apache.ignite.math.MatrixStorage;
-
-/**
- * Pivoted (index mapped) view over another matrix storage implementation.
- */
-public class PivotedMatrixStorage implements MatrixStorage {
-    /** Matrix storage. */
-    private MatrixStorage sto;
-
-    /** */
-    private int[] rowPivot;
-    /** */
-    private int[] colPivot;
-    /** */
-    private int[] rowUnpivot;
-    /** */
-    private int[] colUnpivot;
-
-    /**
-     *
-     */
-    public PivotedMatrixStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param sto Matrix storage.
-     * @param rowPivot Pivot array for rows.
-     * @param colPivot Pivot array for columns.
-     */
-    public PivotedMatrixStorage(MatrixStorage sto, int[] rowPivot, int[] colPivot) {
-        assert sto != null;
-        assert rowPivot != null;
-        assert colPivot != null;
-
-        this.sto = sto;
-        this.rowPivot = rowPivot;
-        this.colPivot = colPivot;
-
-        rowUnpivot = invert(rowPivot);
-        colUnpivot = invert(colPivot);
-    }
-
-    /**
-     *
-     */
-    public int[] rowPivot() {
-        return rowPivot;
-    }
-
-    /**
-     *
-     */
-    public int[] columnPivot() {
-        return colPivot;
-    }
-
-    /**
-     *
-     */
-    public int[] rowUnpivot() {
-        return rowUnpivot;
-    }
-
-    /**
-     *
-     */
-    public int[] columnUnpivot() {
-        return colUnpivot;
-    }
-
-    /**
-     * @param sto Matrix storage.
-     * @param pivot Pivot array.
-     */
-    public PivotedMatrixStorage(MatrixStorage sto, int[] pivot) {
-        this(sto, pivot, pivot == null ? null : java.util.Arrays.copyOf(pivot, pivot.length));
-    }
-
-    /**
-     * @param sto Matrix storage.
-     */
-    public PivotedMatrixStorage(MatrixStorage sto) {
-        this(sto, sto == null ? null : identityPivot(sto.rowSize()), sto == null ? null : identityPivot(sto.columnSize()));
-    }
-
-    /**
-     * @param i First row index to swap.
-     * @param j Second row index to swap.
-     */
-    public void swapRows(int i, int j) {
-        if (i != j) {
-            int tmp = rowPivot[i];
-
-            rowPivot[i] = rowPivot[j];
-            rowPivot[j] = tmp;
-
-            rowUnpivot[rowPivot[i]] = i;
-            rowUnpivot[rowPivot[j]] = j;
-        }
-    }
-
-    /**
-     * @param i First column index to swap.
-     * @param j Second column index to swap.
-     */
-    public void swapColumns(int i, int j) {
-        if (i != j) {
-            int tmp = colPivot[i];
-
-            colPivot[i] = colPivot[j];
-            colPivot[j] = tmp;
-
-            colUnpivot[colPivot[i]] = i;
-            colUnpivot[colPivot[j]] = j;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int x, int y) {
-        return sto.get(rowPivot[x], colPivot[y]);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int x, int y, double v) {
-        sto.set(rowPivot[x], colPivot[y], v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int columnSize() {
-        return sto.columnSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int rowSize() {
-        return sto.rowSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(sto);
-        out.writeObject(rowPivot);
-        out.writeObject(colPivot);
-        out.writeObject(rowUnpivot);
-        out.writeObject(colUnpivot);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        sto = (MatrixStorage)in.readObject();
-        rowPivot = (int[])in.readObject();
-        colPivot = (int[])in.readObject();
-        rowUnpivot = (int[])in.readObject();
-        colUnpivot = (int[])in.readObject();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return sto.isSequentialAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return sto.isDense();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return sto.isRandomAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return sto.isDistributed();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + sto.hashCode();
-        res = res * 37 + Arrays.hashCode(rowPivot);
-        res = res * 37 + Arrays.hashCode(rowUnpivot);
-        res = res * 37 + Arrays.hashCode(colPivot);
-        res = res * 37 + Arrays.hashCode(colUnpivot);
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-
-        if (obj == null || getClass() != obj.getClass())
-            return false;
-
-        PivotedMatrixStorage that = (PivotedMatrixStorage)obj;
-
-        return Arrays.equals(rowPivot, that.rowPivot) && Arrays.equals(rowUnpivot, that.rowUnpivot)
-            && Arrays.equals(colPivot, that.colPivot) && Arrays.equals(colUnpivot, that.colUnpivot)
-            && (sto != null ? sto.equals(that.sto) : that.sto == null);
-    }
-
-    /**
-     * @param n Pivot array length.
-     */
-    private static int[] identityPivot(int n) {
-        int[] pivot = new int[n];
-
-        for (int i = 0; i < n; i++)
-            pivot[i] = i;
-
-        return pivot;
-    }
-
-    /**
-     * @param pivot Pivot array to be inverted.
-     */
-    private static int[] invert(int[] pivot) {
-        int[] x = new int[pivot.length];
-
-        for (int i = 0; i < pivot.length; i++)
-            x[pivot[i]] = i;
-
-        return x;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/RandomMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/RandomMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/RandomMatrixStorage.java
deleted file mode 100644
index 8283201..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/RandomMatrixStorage.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.nio.ByteBuffer;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.MurmurHash;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-
-/**
- * {@link MatrixStorage} implementation with random values in the matrix elements.
- */
-public class RandomMatrixStorage implements MatrixStorage {
-    /** */
-    private static final int PRIME1 = 104047;
-    /** */
-    private static final int PRIME2 = 101377;
-    /** */
-    private static final int PRIME3 = 64661;
-    /** */
-    private static final long SCALE = 1L << 32;
-
-    /** Random generation seed. */
-    private int seed;
-
-    /** Amount of rows in the matrix. */
-    private int rows;
-    /** Amount of columns in the matrix. */
-    private int cols;
-
-    /** Whether fast hash is used, in {@link #get(int, int)}. */
-    private boolean fastHash;
-
-    /**
-     * For externalization.
-     */
-    public RandomMatrixStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param rows Amount of rows in the matrix.
-     * @param cols Amount of columns in the matrix.
-     * @param fastHash Whether fast hash is used.
-     */
-    public RandomMatrixStorage(int rows, int cols, boolean fastHash) {
-        assert rows > 0;
-        assert cols > 0;
-
-        this.rows = rows;
-        this.cols = cols;
-        this.fastHash = fastHash;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int x, int y) {
-        if (!fastHash) {
-            ByteBuffer buf = ByteBuffer.allocate(8);
-
-            buf.putInt(x);
-            buf.putInt(y);
-            buf.flip();
-
-            return (MurmurHash.hash64A(buf, seed) & (SCALE - 1)) / (double)SCALE;
-        }
-        else
-            // This isn't a fantastic random number generator, but it is just fine for random projections.
-            return ((((x * PRIME1) + y * PRIME2 + x * y * PRIME3) & 8) * 0.25) - 1;
-    }
-
-    /**
-     *
-     */
-    public boolean isFastHash() {
-        return fastHash;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int x, int y, double v) {
-        throw new UnsupportedOperationException("Random matrix storage is a read-only storage.");
-    }
-
-    /** {@inheritDoc} */
-    @Override public int columnSize() {
-        return cols;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int rowSize() {
-        return rows;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(rows);
-        out.writeInt(cols);
-        out.writeInt(seed);
-        out.writeBoolean(fastHash);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        rows = in.readInt();
-        cols = in.readInt();
-        seed = in.readInt();
-        fastHash = in.readBoolean();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + Boolean.hashCode(fastHash);
-        res = res * 37 + seed;
-        res = res * 37 + cols;
-        res = res * 37 + rows;
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        RandomMatrixStorage that = (RandomMatrixStorage)o;
-
-        return rows == that.rows && cols == that.cols && seed == that.seed && fastHash == that.fastHash;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/SparseDistributedMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/SparseDistributedMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/SparseDistributedMatrixStorage.java
deleted file mode 100644
index 82807c5..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/SparseDistributedMatrixStorage.java
+++ /dev/null
@@ -1,281 +0,0 @@
-// @java.file.header
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
-import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Map;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.lang.IgniteUuid;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.StorageConstants;
-import org.apache.ignite.math.impls.CacheUtils;
-
-/**
- * {@link MatrixStorage} implementation for {@link org.apache.ignite.math.impls.matrix.SparseDistributedMatrix}.
- */
-public class SparseDistributedMatrixStorage extends CacheUtils implements MatrixStorage, StorageConstants {
-    /** Amount of rows in the matrix. */
-    private int rows;
-    /** Amount of columns in the matrix. */
-    private int cols;
-
-    /** Row or column based storage mode. */
-    private int stoMode;
-    /** Random or sequential access mode. */
-    private int acsMode;
-
-    /** Actual distributed storage. */
-    private IgniteCache<
-        Integer /* Row or column index. */,
-        Map<Integer, Double> /* Map-based row or column. */
-        > cache = null;
-
-    /**
-     *
-     */
-    public SparseDistributedMatrixStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param rows Amount of rows in the matrix.
-     * @param cols Amount of columns in the matrix.
-     * @param stoMode Row or column based storage mode.
-     * @param acsMode Random or sequential access mode.
-     */
-    public SparseDistributedMatrixStorage(int rows, int cols, int stoMode, int acsMode) {
-        assert rows > 0;
-        assert cols > 0;
-        assertAccessMode(acsMode);
-        assertStorageMode(stoMode);
-
-        this.rows = rows;
-        this.cols = cols;
-        this.stoMode = stoMode;
-        this.acsMode = acsMode;
-
-        cache = newCache();
-    }
-
-    /**
-     *
-     *
-     */
-    private IgniteCache<Integer, Map<Integer, Double>> newCache() {
-        CacheConfiguration<Integer, Map<Integer, Double>> cfg = new CacheConfiguration<>();
-
-        // Assume 10% density.
-        cfg.setStartSize(Math.max(1024, (rows * cols) / 10));
-
-        // Write to primary.
-        cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
-
-        // Atomic transactions only.
-        cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
-
-        // No eviction.
-        cfg.setEvictionPolicy(null);
-
-        // No copying of values.
-        cfg.setCopyOnRead(false);
-
-        // Cache is partitioned.
-        cfg.setCacheMode(CacheMode.PARTITIONED);
-
-        // Random cache name.
-        cfg.setName(new IgniteUuid().shortString());
-
-        return Ignition.localIgnite().getOrCreateCache(cfg);
-    }
-
-    /**
-     *
-     *
-     */
-    public IgniteCache<Integer, Map<Integer, Double>> cache() {
-        return cache;
-    }
-
-    /**
-     *
-     *
-     */
-    public int accessMode() {
-        return acsMode;
-    }
-
-    /**
-     *
-     *
-     */
-    public int storageMode() {
-        return stoMode;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int x, int y) {
-        if (stoMode == ROW_STORAGE_MODE)
-            return matrixGet(cache.getName(), x, y);
-        else
-            return matrixGet(cache.getName(), y, x);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int x, int y, double v) {
-        if (stoMode == ROW_STORAGE_MODE)
-            matrixSet(cache.getName(), x, y, v);
-        else
-            matrixSet(cache.getName(), y, x, v);
-    }
-
-    /**
-     * Distributed matrix get.
-     *
-     * @param cacheName Matrix's cache.
-     * @param a Row or column index.
-     * @param b Row or column index.
-     * @return Matrix value at (a, b) index.
-     */
-    private double matrixGet(String cacheName, int a, int b) {
-        // Remote get from the primary node (where given row or column is stored locally).
-        return ignite().compute(groupForKey(cacheName, a)).call(() -> {
-            IgniteCache<Integer, Map<Integer, Double>> cache = Ignition.localIgnite().getOrCreateCache(cacheName);
-
-            // Local get.
-            Map<Integer, Double> map = cache.localPeek(a, CachePeekMode.PRIMARY);
-
-            return (map == null || !map.containsKey(b)) ? 0.0 : map.get(b);
-        });
-    }
-
-    /**
-     * Distributed matrix set.
-     *
-     * @param cacheName Matrix's cache.
-     * @param a Row or column index.
-     * @param b Row or column index.
-     * @param v New value to set.
-     */
-    private void matrixSet(String cacheName, int a, int b, double v) {
-        // Remote set on the primary node (where given row or column is stored locally).
-        ignite().compute(groupForKey(cacheName, a)).run(() -> {
-            IgniteCache<Integer, Map<Integer, Double>> cache = Ignition.localIgnite().getOrCreateCache(cacheName);
-
-            // Local get.
-            Map<Integer, Double> map = cache.localPeek(a, CachePeekMode.PRIMARY);
-
-            if (map == null)
-                map = acsMode == SEQUENTIAL_ACCESS_MODE ? new Int2DoubleRBTreeMap() : new Int2DoubleOpenHashMap();
-
-            if (v != 0.0)
-                map.put(b, v);
-            else if (map.containsKey(b))
-                map.remove(b);
-
-            // Local put.
-            cache.put(a, map);
-        });
-    }
-
-    /** {@inheritDoc} */
-    @Override public int columnSize() {
-        return cols;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int rowSize() {
-        return rows;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(rows);
-        out.writeInt(cols);
-        out.writeInt(acsMode);
-        out.writeInt(stoMode);
-        out.writeUTF(cache.getName());
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        rows = in.readInt();
-        cols = in.readInt();
-        acsMode = in.readInt();
-        stoMode = in.readInt();
-        cache = ignite().getOrCreateCache(in.readUTF());
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return acsMode == SEQUENTIAL_ACCESS_MODE;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return acsMode == RANDOM_ACCESS_MODE;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** Destroy underlying cache. */
-    @Override public void destroy() {
-        cache.destroy();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + cols;
-        res = res * 37 + rows;
-        res = res * 37 + acsMode;
-        res = res * 37 + stoMode;
-        res = res * 37 + cache.hashCode();
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-
-        if (obj == null || getClass() != obj.getClass())
-            return false;
-
-        SparseDistributedMatrixStorage that = (SparseDistributedMatrixStorage)obj;
-
-        return rows == that.rows && cols == that.cols && acsMode == that.acsMode && stoMode == that.stoMode
-            && (cache != null ? cache.equals(that.cache) : that.cache == null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
deleted file mode 100644
index e72da70..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
-import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.StorageConstants;
-
-/**
- * Storage for sparse, local, on-heap matrix.
- */
-public class SparseLocalOnHeapMatrixStorage implements MatrixStorage, StorageConstants {
-    /** Default zero value. */
-    private static final double DEFAULT_VALUE = 0.0;
-
-    /** */ private int rows;
-    /** */ private int cols;
-
-    /** */ private int acsMode;
-    /** */ private int stoMode;
-
-    /** Actual map storage. */
-    private Map<Integer, Map<Integer, Double>> sto;
-
-    /** */
-    public SparseLocalOnHeapMatrixStorage() {
-        // No-op.
-    }
-
-    /** */
-    public SparseLocalOnHeapMatrixStorage(int rows, int cols, int acsMode, int stoMode) {
-        assert rows > 0;
-        assert cols > 0;
-        assertAccessMode(acsMode);
-        assertStorageMode(stoMode);
-
-        this.rows = rows;
-        this.cols = cols;
-        this.acsMode = acsMode;
-        this.stoMode = stoMode;
-
-        sto = new HashMap<>();
-    }
-
-    /**
-     *
-     *
-     */
-    public int getStorageMode() {
-        return stoMode;
-    }
-
-    /**
-     *
-     *
-     */
-    public int getAccessMode() {
-        return acsMode;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int x, int y) {
-        if (stoMode == ROW_STORAGE_MODE) {
-            Map<Integer, Double> row = sto.get(x);
-
-            if (row != null) {
-                Double val = row.get(y);
-
-                if (val != null)
-                    return val;
-            }
-
-            return DEFAULT_VALUE;
-        }
-        else {
-            Map<Integer, Double> col = sto.get(y);
-
-            if (col != null) {
-                Double val = col.get(x);
-
-                if (val != null)
-                    return val;
-            }
-
-            return DEFAULT_VALUE;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int x, int y, double v) {
-        // Ignore default values (currently 0.0).
-        if (v != DEFAULT_VALUE) {
-            if (stoMode == ROW_STORAGE_MODE) {
-                Map<Integer, Double> row = sto.computeIfAbsent(x, k ->
-                    acsMode == SEQUENTIAL_ACCESS_MODE ? new Int2DoubleRBTreeMap() : new Int2DoubleOpenHashMap());
-
-                row.put(y, v);
-            }
-            else {
-                Map<Integer, Double> col = sto.computeIfAbsent(y, k ->
-                    acsMode == SEQUENTIAL_ACCESS_MODE ? new Int2DoubleRBTreeMap() : new Int2DoubleOpenHashMap());
-
-                col.put(x, v);
-            }
-        }
-        else {
-            if (stoMode == ROW_STORAGE_MODE) {
-                if (sto.containsKey(x)) {
-                    Map<Integer, Double> row = sto.get(x);
-
-                    if (row.containsKey(y))
-                        row.remove(y);
-                }
-
-            }
-            else {
-                if (sto.containsKey(y)) {
-                    Map<Integer, Double> col = sto.get(y);
-
-                    if (col.containsKey(x))
-                        col.remove(x);
-                }
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public int columnSize() {
-        return cols;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int rowSize() {
-        return rows;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(rows);
-        out.writeInt(cols);
-        out.writeInt(acsMode);
-        out.writeInt(stoMode);
-        out.writeObject(sto);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings({"unchecked"})
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        rows = in.readInt();
-        cols = in.readInt();
-        acsMode = in.readInt();
-        stoMode = in.readInt();
-        sto = (Map<Integer, Map<Integer, Double>>)in.readObject();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return acsMode == SEQUENTIAL_ACCESS_MODE;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return acsMode == RANDOM_ACCESS_MODE;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + rows;
-        res = res * 37 + cols;
-        res = res * 37 + sto.hashCode();
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        SparseLocalOnHeapMatrixStorage that = (SparseLocalOnHeapMatrixStorage)o;
-
-        return rows == that.rows && cols == that.cols && acsMode == that.acsMode && stoMode == that.stoMode
-            && (sto != null ? sto.equals(that.sto) : that.sto == null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/package-info.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/package-info.java
deleted file mode 100644
index aba47db..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/matrix/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Contains specific implementations for matrix storage models.
- */
-package org.apache.ignite.math.impls.storage.matrix;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/ArrayVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/ArrayVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/ArrayVectorStorage.java
deleted file mode 100644
index ef59c62..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/ArrayVectorStorage.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Arrays;
-import org.apache.ignite.math.VectorStorage;
-
-/**
- * Array based {@link VectorStorage} implementation.
- */
-public class ArrayVectorStorage implements VectorStorage {
-    /** Backing data array. */
-    private double[] data;
-
-    /**
-     * IMPL NOTE required by {@link Externalizable}.
-     */
-    public ArrayVectorStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param size Vector size.
-     */
-    public ArrayVectorStorage(int size) {
-        assert size > 0;
-
-        data = new double[size];
-    }
-
-    /**
-     * @param data Backing data array.
-     */
-    public ArrayVectorStorage(double[] data) {
-        assert data != null;
-
-        this.data = data;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return data == null ? 0 : data.length;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int i) {
-        return data[i];
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int i, double v) {
-        data[i] = v;
-    }
-
-    /** {@inheritDoc}} */
-    @Override public boolean isArrayBased() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double[] data() {
-        return data;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(data);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        data = (double[])in.readObject();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + Arrays.hashCode(data);
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-
-        if (obj == null || getClass() != obj.getClass())
-            return false;
-
-        ArrayVectorStorage that = (ArrayVectorStorage)obj;
-
-        return Arrays.equals(data, (that.data));
-    }
-}


[08/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/SparseDistributedMatrixStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/SparseDistributedMatrixStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/SparseDistributedMatrixStorageTest.java
deleted file mode 100644
index 66fe9b4..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/SparseDistributedMatrixStorageTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.math.StorageConstants;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.apache.ignite.testframework.junits.common.GridCommonTest;
-
-/**
- * Tests for {@link SparseDistributedMatrixStorage}.
- */
-@GridCommonTest(group = "Distributed Models")
-public class SparseDistributedMatrixStorageTest extends GridCommonAbstractTest {
-    /** Number of nodes in grid */
-    private static final int NODE_COUNT = 3;
-    /** Cache name. */
-    private static final String CACHE_NAME = "test-cache";
-    /** */
-    private static final String UNEXPECTED_ATTRIBUTE_VALUE = "Unexpected attribute value.";
-    /** Grid instance. */
-    private Ignite ignite;
-
-    /**
-     * Default constructor.
-     */
-    public SparseDistributedMatrixStorageTest() {
-        super(false);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        for (int i = 1; i <= NODE_COUNT; i++)
-            startGrid(i);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        stopAllGrids();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override protected void beforeTest() throws Exception {
-        ignite = grid(NODE_COUNT);
-
-        ignite.configuration().setPeerClassLoadingEnabled(true);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        ignite.destroyCache(CACHE_NAME);
-    }
-
-    /** */
-    public void testCacheCreation() throws Exception {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        final int rows = MathTestConstants.STORAGE_SIZE;
-        final int cols = MathTestConstants.STORAGE_SIZE;
-
-        SparseDistributedMatrixStorage storage = new SparseDistributedMatrixStorage(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
-        assertNotNull("SparseDistributedMatrixStorage cache is null.", storage.cache());
-    }
-
-    /** */
-    public void testSetGet() throws Exception {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        final int rows = MathTestConstants.STORAGE_SIZE;
-        final int cols = MathTestConstants.STORAGE_SIZE;
-
-        SparseDistributedMatrixStorage storage = new SparseDistributedMatrixStorage(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
-        for (int i = 0; i < rows; i++) {
-            for (int j = 0; j < cols; j++) {
-                double v = Math.random();
-                storage.set(i, j, v);
-
-                assert Double.compare(v, storage.get(i, j)) == 0;
-                assert Double.compare(v, storage.get(i, j)) == 0;
-            }
-        }
-    }
-
-    /** */
-    public void testAttributes() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        final int rows = MathTestConstants.STORAGE_SIZE;
-        final int cols = MathTestConstants.STORAGE_SIZE;
-
-        SparseDistributedMatrixStorage storage = new SparseDistributedMatrixStorage(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
-        assertEquals(UNEXPECTED_ATTRIBUTE_VALUE, storage.rowSize(), rows);
-        assertEquals(UNEXPECTED_ATTRIBUTE_VALUE, storage.columnSize(), cols);
-
-        assertFalse(UNEXPECTED_ATTRIBUTE_VALUE, storage.isArrayBased());
-        assertFalse(UNEXPECTED_ATTRIBUTE_VALUE, storage.isDense());
-        assertTrue(UNEXPECTED_ATTRIBUTE_VALUE, storage.isDistributed());
-
-        assertEquals(UNEXPECTED_ATTRIBUTE_VALUE, storage.isRandomAccess(), !storage.isSequentialAccess());
-        assertTrue(UNEXPECTED_ATTRIBUTE_VALUE, storage.isRandomAccess());
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/RandomAccessSparseVectorStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/RandomAccessSparseVectorStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/RandomAccessSparseVectorStorageTest.java
deleted file mode 100644
index 8a223fc..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/RandomAccessSparseVectorStorageTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import org.apache.ignite.math.StorageConstants;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-
-/**
- * Unit tests for {@link SparseLocalOnHeapVectorStorage}.
- */
-public class RandomAccessSparseVectorStorageTest extends VectorBaseStorageTest<SparseLocalOnHeapVectorStorage> {
-    /** */
-    @Override public void setUp() {
-        storage = new SparseLocalOnHeapVectorStorage(MathTestConstants.STORAGE_SIZE, StorageConstants.RANDOM_ACCESS_MODE);
-    }
-
-    /** */
-    @Test
-    public void data() throws Exception {
-        assertNull(MathTestConstants.NULL_VAL, storage.data());
-    }
-
-    /** */
-    @Test
-    public void isSequentialAccess() throws Exception {
-        assertFalse(MathTestConstants.UNEXPECTED_VAL, storage.isSequentialAccess());
-    }
-
-    /** */
-    @Test
-    public void isDense() throws Exception {
-        assertFalse(MathTestConstants.UNEXPECTED_VAL, storage.isDense());
-    }
-
-    /** */
-    @Test
-    public void isArrayBased() throws Exception {
-        assertFalse(MathTestConstants.UNEXPECTED_VAL, storage.isArrayBased());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
deleted file mode 100644
index a7751d8..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import org.apache.ignite.math.ExternalizeTest;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.apache.ignite.math.impls.MathTestConstants.STORAGE_SIZE;
-import static org.apache.ignite.math.impls.MathTestConstants.UNEXPECTED_VAL;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests for {@link SparseLocalOffHeapVectorStorage}.
- */
-public class SparseLocalOffHeapVectorStorageTest extends ExternalizeTest<SparseLocalOffHeapVectorStorage> {
-    /** */ private SparseLocalOffHeapVectorStorage testVectorStorage;
-
-    /** */
-    @Before
-    public void setup() {
-        testVectorStorage = new SparseLocalOffHeapVectorStorage(STORAGE_SIZE);
-    }
-
-    /** */
-    @After
-    public void teardown() {
-        testVectorStorage.destroy();
-        testVectorStorage = null;
-    }
-
-    /** */
-    @Test
-    public void testBasic() {
-        for (int i = 0; i < STORAGE_SIZE; i++) {
-            double testVal = Math.random();
-            testVectorStorage.set(i, testVal);
-            assertEquals(UNEXPECTED_VAL, testVal, testVectorStorage.get(i), 0d);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Test(expected = UnsupportedOperationException.class)
-    @Override public void externalizeTest() {
-        super.externalizeTest(new SparseLocalOffHeapVectorStorage(STORAGE_SIZE));
-    }
-
-    /** */
-    @Test
-    public void testAttributes() {
-        SparseLocalOffHeapVectorStorage testVectorStorage = new SparseLocalOffHeapVectorStorage(STORAGE_SIZE);
-
-        assertTrue(UNEXPECTED_VAL, testVectorStorage.isRandomAccess());
-        assertFalse(UNEXPECTED_VAL, testVectorStorage.isSequentialAccess());
-        assertFalse(UNEXPECTED_VAL, testVectorStorage.isDense());
-        assertFalse(UNEXPECTED_VAL, testVectorStorage.isArrayBased());
-        assertFalse(UNEXPECTED_VAL, testVectorStorage.isDistributed());
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/VectorArrayStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/VectorArrayStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/VectorArrayStorageTest.java
deleted file mode 100644
index 2afc97b..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/VectorArrayStorageTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import java.util.Arrays;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Unit test for {@link ArrayVectorStorage}.
- */
-public class VectorArrayStorageTest extends VectorBaseStorageTest<ArrayVectorStorage> {
-    /** */
-    @Override public void setUp() {
-        storage = new ArrayVectorStorage(MathTestConstants.STORAGE_SIZE);
-    }
-
-    /** */
-    @Test
-    public void isArrayBased() throws Exception {
-        assertTrue(MathTestConstants.WRONG_ATTRIBUTE_VAL, storage.isArrayBased());
-
-        assertTrue(MathTestConstants.WRONG_ATTRIBUTE_VAL, new ArrayVectorStorage().isArrayBased());
-    }
-
-    /** */
-    @Test
-    public void data() throws Exception {
-        assertNotNull(MathTestConstants.NULL_DATA_STORAGE, storage.data());
-
-        assertEquals(MathTestConstants.WRONG_DATA_SIZE, storage.data().length, MathTestConstants.STORAGE_SIZE);
-
-        assertTrue(MathTestConstants.UNEXPECTED_DATA_VAL, Arrays.equals(storage.data(), new double[MathTestConstants.STORAGE_SIZE]));
-
-        assertNull(MathTestConstants.UNEXPECTED_DATA_VAL, new ArrayVectorStorage().data());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/VectorBaseStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/VectorBaseStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/VectorBaseStorageTest.java
deleted file mode 100644
index 988f8c3..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/VectorBaseStorageTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import org.apache.ignite.math.ExternalizeTest;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Abstract class with base tests for each vector storage.
- */
-public abstract class VectorBaseStorageTest<T extends VectorStorage> extends ExternalizeTest<T> {
-    /** */
-    protected T storage;
-
-    /** */
-    @Before
-    public abstract void setUp();
-
-    /** */
-    @After
-    public void tearDown() throws Exception {
-        storage.destroy();
-    }
-
-    /** */
-    @Test
-    public void getSet() throws Exception {
-        for (int i = 0; i < MathTestConstants.STORAGE_SIZE; i++) {
-            double random = Math.random();
-
-            storage.set(i, random);
-
-            assertEquals(MathTestConstants.WRONG_DATA_ELEMENT, storage.get(i), random, MathTestConstants.NIL_DELTA);
-        }
-    }
-
-    /** */
-    @Test
-    public void size() {
-        assertTrue(MathTestConstants.UNEXPECTED_VAL, storage.size() == MathTestConstants.STORAGE_SIZE);
-    }
-
-    /** */
-    @Override public void externalizeTest() {
-        super.externalizeTest(storage);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/VectorOffheapStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/VectorOffheapStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/VectorOffheapStorageTest.java
deleted file mode 100644
index 2645926..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/vector/VectorOffheapStorageTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Unit tests for {@link DenseLocalOffHeapVectorStorage}.
- */
-public class VectorOffheapStorageTest extends VectorBaseStorageTest<DenseLocalOffHeapVectorStorage> {
-    /** */
-    @Before
-    public void setUp() {
-        storage = new DenseLocalOffHeapVectorStorage(MathTestConstants.STORAGE_SIZE);
-    }
-
-    /** */
-    @Test
-    public void isArrayBased() throws Exception {
-        assertFalse(MathTestConstants.UNEXPECTED_VAL, storage.isArrayBased());
-    }
-
-    /** */
-    @Test
-    public void data() throws Exception {
-        assertNull(MathTestConstants.NULL_VAL, storage.data());
-    }
-
-    /** */
-    @Test
-    public void isSequentialAccess() throws Exception {
-        assertTrue(MathTestConstants.UNEXPECTED_VAL, storage.isSequentialAccess());
-    }
-
-    /** */
-    @Test
-    public void isDense() throws Exception {
-        assertTrue(MathTestConstants.UNEXPECTED_VAL, storage.isDense());
-    }
-
-    /** */
-    @Test
-    public void equalsTest() {
-        //noinspection EqualsWithItself
-        assertTrue(MathTestConstants.VAL_NOT_EQUALS, storage.equals(storage));
-
-        //noinspection EqualsBetweenInconvertibleTypes
-        assertFalse(MathTestConstants.VALUES_SHOULD_BE_NOT_EQUALS,
-            storage.equals(new ArrayVectorStorage(MathTestConstants.STORAGE_SIZE)));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/AbstractVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/AbstractVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/AbstractVectorTest.java
deleted file mode 100644
index c7927a5..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/AbstractVectorTest.java
+++ /dev/null
@@ -1,543 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.Arrays;
-import java.util.stream.StreamSupport;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.exceptions.IndexException;
-import org.apache.ignite.math.functions.Functions;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.apache.ignite.math.impls.storage.vector.ArrayVectorStorage;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Unit test for {@link AbstractVector}.
- */
-public class AbstractVectorTest {
-    /** */
-    private AbstractVector testVector;
-
-    /** */
-    @Before
-    public void setUp() {
-        testVector = getAbstractVector();
-    }
-
-    /** */
-    @Test
-    public void setStorage() {
-        testVector.setStorage(createStorage());
-
-        assertTrue(testVector.size() == MathTestConstants.STORAGE_SIZE);
-    }
-
-    /** */
-    @Test
-    public void size() {
-        testVector.setStorage(createStorage());
-        assertTrue(testVector.size() == MathTestConstants.STORAGE_SIZE);
-
-        testVector.setStorage(new ArrayVectorStorage(MathTestConstants.STORAGE_SIZE + MathTestConstants.STORAGE_SIZE));
-        assertTrue(testVector.size() == MathTestConstants.STORAGE_SIZE + MathTestConstants.STORAGE_SIZE);
-
-        testVector = getAbstractVector(createStorage());
-        assertTrue(testVector.size() == MathTestConstants.STORAGE_SIZE);
-    }
-
-    /** */
-    @Test
-    public void getPositive() {
-        testVector = getAbstractVector(createStorage());
-
-        for (int i = 0; i < MathTestConstants.STORAGE_SIZE; i++)
-            assertNotNull(MathTestConstants.NULL_VALUES, testVector.get(i));
-
-    }
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void getNegative0() {
-        testVector.get(0);
-    }
-
-    /** */
-    @Test(expected = IndexException.class)
-    public void getNegative1() {
-        testVector.setStorage(createStorage());
-
-        testVector.get(-1);
-    }
-
-    /** */
-    @Test(expected = IndexException.class)
-    public void getNegative2() {
-        testVector.setStorage(createStorage());
-
-        testVector.get(testVector.size() + 1);
-    }
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void getXNegative0() {
-        testVector.getX(0);
-    }
-
-    /** */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void getXNegative1() {
-        testVector.setStorage(createStorage());
-
-        testVector.getX(-1);
-    }
-
-    /** */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void getXNegative2() {
-        testVector.setStorage(createStorage());
-
-        testVector.getX(MathTestConstants.STORAGE_SIZE + 1);
-    }
-
-    /** */
-    @Test
-    public void set() {
-        double[] data = initVector();
-
-        for (int i = 0; i < MathTestConstants.STORAGE_SIZE; i++)
-            testVector.set(i, Math.exp(data[i]));
-
-        for (int i = 0; i < MathTestConstants.STORAGE_SIZE; i++)
-            assertEquals(MathTestConstants.VAL_NOT_EQUALS, testVector.get(i), Math.exp(data[i]), MathTestConstants.NIL_DELTA);
-    }
-
-    /** */
-    @Test(expected = IndexException.class)
-    public void setNegative0() {
-        testVector.set(-1, -1);
-    }
-
-    /** */
-    @Test(expected = IndexException.class)
-    public void setNegative1() {
-        initVector();
-
-        testVector.set(-1, -1);
-    }
-
-    /** */
-    @Test(expected = IndexException.class)
-    public void setNegative2() {
-        initVector();
-
-        testVector.set(MathTestConstants.STORAGE_SIZE + 1, -1);
-    }
-
-    /** */
-    @Test(expected = IndexOutOfBoundsException.class)
-    public void setXNegative0() {
-        initVector();
-
-        testVector.setX(-1, -1);
-    }
-
-    /** */
-    @Test(expected = IndexOutOfBoundsException.class)
-    public void setXNegative1() {
-        initVector();
-
-        testVector.setX(MathTestConstants.STORAGE_SIZE + 1, -1);
-    }
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void setXNegative2() {
-        testVector.setX(-1, -1);
-    }
-
-    /** */
-    @Test
-    public void isZero() {
-        assertTrue(MathTestConstants.UNEXPECTED_VAL, testVector.isZero(0d));
-
-        assertFalse(MathTestConstants.UNEXPECTED_VAL, testVector.isZero(1d));
-    }
-
-    /** */
-    @Test
-    public void guid() {
-        assertNotNull(MathTestConstants.NULL_GUID, testVector.guid());
-
-        assertEquals(MathTestConstants.UNEXPECTED_GUID_VAL, testVector.guid(), testVector.guid());
-
-        assertFalse(MathTestConstants.EMPTY_GUID, testVector.guid().toString().isEmpty());
-
-        testVector = getAbstractVector(createStorage());
-
-        assertNotNull(MathTestConstants.NULL_GUID, testVector.guid());
-
-        assertEquals(MathTestConstants.UNEXPECTED_GUID_VAL, testVector.guid(), testVector.guid());
-
-        assertFalse(MathTestConstants.EMPTY_GUID, testVector.guid().toString().isEmpty());
-    }
-
-    /** */
-    @Test
-    public void equalsTest() {
-        VectorStorage storage = createStorage();
-
-        AbstractVector testVector1 = getAbstractVector();
-
-        testVector1.setStorage(storage);
-
-        AbstractVector testVector2 = getAbstractVector();
-
-        assertEquals(MathTestConstants.VAL_NOT_EQUALS, testVector, testVector);
-
-        testVector2.setStorage(storage);
-
-        assertTrue(MathTestConstants.VAL_NOT_EQUALS, testVector1.equals(testVector2));
-
-        assertFalse(MathTestConstants.VALUES_SHOULD_BE_NOT_EQUALS, testVector1.equals(testVector));
-    }
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void all() {
-        assertNotNull(MathTestConstants.NULL_VAL, testVector.all());
-
-        assertNotNull(MathTestConstants.NULL_VAL, getAbstractVector(createStorage()).all());
-
-        getAbstractVector().all().iterator().next();
-    }
-
-    /** */
-    @Test
-    public void nonZeroElements() {
-        VectorStorage storage = createStorage();
-
-        double[] data = storage.data();
-
-        testVector = getAbstractVector(storage);
-
-        assertEquals(MathTestConstants.VAL_NOT_EQUALS, testVector.nonZeroElements(), Arrays.stream(data).filter(x -> x != 0d).count());
-
-        addNilValues(data);
-
-        assertEquals(MathTestConstants.VAL_NOT_EQUALS, testVector.nonZeroElements(), Arrays.stream(data).filter(x -> x != 0d).count());
-    }
-
-    /** */
-    @Test
-    public void foldMapWithSecondVector() {
-        double[] data0 = initVector();
-
-        VectorStorage storage1 = createStorage();
-
-        double[] data1 = storage1.data().clone();
-
-        AbstractVector testVector1 = getAbstractVector(storage1);
-
-        String testVal = "";
-
-        for (int i = 0; i < data0.length; i++)
-            testVal += data0[i] + data1[i];
-
-        assertEquals(MathTestConstants.VAL_NOT_EQUALS, testVector.foldMap(testVector1, (string, xi) -> string.concat(xi.toString()), Functions.PLUS, ""), testVal);
-    }
-
-    /** */
-    @Test
-    public void nonZeroes() {
-        assertNotNull(MathTestConstants.NULL_VAL, testVector.nonZeroes());
-
-        double[] data = initVector();
-
-        assertNotNull(MathTestConstants.NULL_VAL, testVector.nonZeroes());
-
-        Assert.assertEquals(MathTestConstants.VAL_NOT_EQUALS, StreamSupport.stream(testVector.nonZeroes().spliterator(), false).count(), Arrays.stream(data).filter(x -> x != 0d).count());
-
-        addNilValues(data);
-
-        Assert.assertEquals(MathTestConstants.VAL_NOT_EQUALS, StreamSupport.stream(testVector.nonZeroes().spliterator(), false).count(), Arrays.stream(data).filter(x -> x != 0d).count());
-    }
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void nonZeroesEmpty() {
-        testVector.nonZeroes().iterator().next();
-    }
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void assign() {
-        testVector.assign(MathTestConstants.TEST_VAL);
-    }
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void assignArr() {
-        testVector.assign(new double[1]);
-    }
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void assignArrEmpty() {
-        testVector.assign(new double[0]);
-    }
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void dotNegative() {
-        testVector.dot(getAbstractVector(createEmptyStorage()));
-    }
-
-    /** */
-    @Test
-    public void dotSelf() {
-        double[] data = initVector();
-
-        assertEquals(MathTestConstants.VAL_NOT_EQUALS, testVector.dotSelf(), Arrays.stream(data).reduce(0, (x, y) -> x + y * y), MathTestConstants.NIL_DELTA);
-    }
-
-    /** */
-    @Test
-    public void getStorage() {
-        assertNotNull(MathTestConstants.NULL_VAL, getAbstractVector(createEmptyStorage()));
-        assertNotNull(MathTestConstants.NULL_VAL, getAbstractVector(createStorage()));
-        testVector.setStorage(createStorage());
-        assertNotNull(MathTestConstants.NULL_VAL, testVector.getStorage());
-    }
-
-    /** */
-    @Test
-    public void getElement() {
-        double[] data = initVector();
-
-        for (int i = 0; i < data.length; i++) {
-            assertNotNull(MathTestConstants.NULL_VAL, testVector.getElement(i));
-
-            assertEquals(MathTestConstants.UNEXPECTED_VAL, testVector.getElement(i).get(), data[i], MathTestConstants.NIL_DELTA);
-
-            testVector.getElement(i).set(++data[i]);
-
-            assertEquals(MathTestConstants.UNEXPECTED_VAL, testVector.getElement(i).get(), data[i], MathTestConstants.NIL_DELTA);
-        }
-    }
-
-    /**
-     * Create {@link AbstractVector} with storage for tests.
-     *
-     * @param storage {@link VectorStorage}
-     * @return AbstractVector.
-     */
-    private AbstractVector getAbstractVector(VectorStorage storage) {
-        return new AbstractVector(storage) { // TODO: find out how to fix warning about missing constructor
-            /** */
-            @Override public boolean isDense() {
-                return false;
-            }
-
-            /** */
-            @Override public boolean isSequentialAccess() {
-                return false;
-            }
-
-            /** */
-            @Override public Matrix likeMatrix(int rows, int cols) {
-                return null;
-            }
-
-            /** */
-            @Override public Vector copy() {
-                return getAbstractVector(this.getStorage());
-            }
-
-            /** */
-            @Override public Vector like(int crd) {
-                return null;
-            }
-
-            /** */
-            @Override public Vector normalize() {
-                return null;
-            }
-
-            /** */
-            @Override public Vector normalize(double power) {
-                return null;
-            }
-
-            /** */
-            @Override public Vector logNormalize() {
-                return null;
-            }
-
-            /** */
-            @Override public Vector logNormalize(double power) {
-                return null;
-            }
-
-            /** */
-            @Override public Vector viewPart(int off, int len) {
-                return null;
-            }
-
-            /** {@inheritDoc} */
-            @Override public boolean isRandomAccess() {
-                return true;
-            }
-
-            /** {@inheritDoc} */
-            @Override public boolean isDistributed() {
-                return false;
-            }
-        };
-    }
-
-    /**
-     * Create empty {@link AbstractVector} for tests.
-     *
-     * @return AbstractVector.
-     */
-    private AbstractVector getAbstractVector() {
-        return new AbstractVector() { // TODO: find out how to fix warning about missing constructor
-            /** */
-            @Override public boolean isDense() {
-                return false;
-            }
-
-            /** */
-            @Override public Matrix likeMatrix(int rows, int cols) {
-                return null;
-            }
-
-            /** */
-            @Override public boolean isSequentialAccess() {
-                return false;
-            }
-
-            /** */
-            @Override public Vector copy() {
-                return getAbstractVector(this.getStorage());
-            }
-
-            /** */
-            @Override public Vector like(int crd) {
-                return null;
-            }
-
-            /** */
-            @Override public Vector normalize() {
-                return null;
-            }
-
-            /** */
-            @Override public Vector normalize(double power) {
-                return null;
-            }
-
-            /** */
-            @Override public Vector logNormalize() {
-                return null;
-            }
-
-            /** */
-            @Override public Vector logNormalize(double power) {
-                return null;
-            }
-
-            /** */
-            @Override public Vector viewPart(int off, int len) {
-                return null;
-            }
-
-            /** {@inheritDoc} */
-            @Override public boolean isRandomAccess() {
-                return true;
-            }
-
-            /** {@inheritDoc} */
-            @Override public boolean isDistributed() {
-                return false;
-            }
-        };
-    }
-
-    /**
-     * Create {@link VectorStorage} for tests.
-     *
-     * @return VectorStorage
-     */
-    private VectorStorage createEmptyStorage() {
-        return new ArrayVectorStorage(MathTestConstants.STORAGE_SIZE);
-    }
-
-    /**
-     * Create filled {@link VectorStorage} for tests.
-     *
-     * @return VectorStorage.
-     */
-    private VectorStorage createStorage() {
-        ArrayVectorStorage storage = new ArrayVectorStorage(MathTestConstants.STORAGE_SIZE);
-
-        for (int i = 0; i < MathTestConstants.STORAGE_SIZE; i++)
-            storage.set(i, Math.random());
-
-        return storage;
-    }
-
-    /**
-     * Init vector and return initialized values.
-     *
-     * @return Initial values.
-     */
-    private double[] initVector() {
-        VectorStorage storage = createStorage();
-        double[] data = storage.data().clone();
-
-        testVector = getAbstractVector(storage);
-        return data;
-    }
-
-    /**
-     * Add some zeroes to vector elements.
-     */
-    private void addNilValues() {
-        testVector.set(10, 0);
-        testVector.set(50, 0);
-    }
-
-    /**
-     * Add some zeroes to vector elements. Also set zeroes to the same elements in reference array data
-     */
-    private void addNilValues(double[] testRef) {
-        addNilValues();
-        testRef[10] = 0;
-        testRef[50] = 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/CacheVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/CacheVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/CacheVectorTest.java
deleted file mode 100644
index f276820..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/CacheVectorTest.java
+++ /dev/null
@@ -1,417 +0,0 @@
-package org.apache.ignite.math.impls.vector;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.stream.IntStream;
-import junit.framework.TestCase;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.math.IdentityValueMapper;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.VectorKeyMapper;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.Functions;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.apache.ignite.testframework.junits.common.GridCommonTest;
-
-/**
- * Tests for {@link CacheVector}.
- */
-@GridCommonTest(group = "Distributed Models")
-public class CacheVectorTest extends GridCommonAbstractTest {
-    /** Number of nodes in grid */
-    private static final int NODE_COUNT = 3;
-    /** Cache name. */
-    private static final String CACHE_NAME = "test-cache";
-    /** Cache size. */
-    private static final int size = MathTestConstants.STORAGE_SIZE;
-    /** Grid instance. */
-    private Ignite ignite;
-    /** Default key mapper. */
-    private VectorKeyMapper<Integer> keyMapper = new TestKeyMapper();
-
-    /**
-     * Default constructor.
-     */
-    public CacheVectorTest() {
-        super(false);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        for (int i = 1; i <= NODE_COUNT; i++)
-            startGrid(i);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        stopAllGrids();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        ignite = grid(NODE_COUNT);
-
-        ignite.configuration().setPeerClassLoadingEnabled(true);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        ignite.destroyCache(CACHE_NAME);
-    }
-
-    /** */
-    public void testGetSet() throws Exception {
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        for (int i = 0; i < size; i++) {
-            double random = Math.random();
-            cacheVector.set(i, random);
-            assertEquals("Unexpected value.", random, cacheVector.get(i), 0d);
-        }
-    }
-
-    /** */
-    public void testMap() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        initVector(cacheVector);
-
-        cacheVector.map(value -> 110d);
-
-        for (int i = 0; i < size; i++)
-            assertEquals("Unexpected value.", cacheVector.get(i), 110d, 0d);
-    }
-
-    /** */
-    public void testMapBiFunc() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        initVector(cacheVector);
-
-        cacheVector.map(Functions.PLUS, 1d);
-
-        for (int i = 0; i < size; i++)
-            assertEquals("Unexpected value.", cacheVector.get(i), 1d, 0d);
-    }
-
-    /** */
-    public void testSum() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        initVector(cacheVector);
-
-        assertEquals("Unexpected value.", cacheVector.sum(), 0d, 0d);
-
-        cacheVector.assign(1d);
-
-        assertEquals("Unexpected value.", cacheVector.sum(), size, 0d);
-    }
-
-    /** */
-    public void testSumNegative() {
-        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.
-        }
-    }
-
-    /** */
-    public void testAssign() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        initVector(cacheVector);
-
-        cacheVector.assign(1d);
-
-        for (int i = 0; i < size; i++)
-            assertEquals("Unexpected value.", cacheVector.get(i), 1d, 0d);
-    }
-
-    /** */
-    public void testAssignRange() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        cacheVector.assign(IntStream.range(0, size).asDoubleStream().toArray());
-
-        for (int i = 0; i < size; i++)
-            assertEquals("Unexpected value.", cacheVector.get(i), i, 0d);
-    }
-
-    /** */
-    public void testAssignVector() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        Vector testVec = new DenseLocalOnHeapVector(IntStream.range(0, size).asDoubleStream().toArray());
-
-        cacheVector.assign(testVec);
-
-        for (int i = 0; i < size; i++)
-            assertEquals("Unexpected value.", cacheVector.get(i), testVec.get(i), 0d);
-    }
-
-    /** */
-    public void testAssignFunc() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        cacheVector.assign(idx -> idx);
-
-        for (int i = 0; i < size; i++)
-            assertEquals("Unexpected value.", cacheVector.get(i), i, 0d);
-    }
-
-    /** */
-    public void testPlus() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        initVector(cacheVector);
-
-        cacheVector.plus(1d);
-
-        for (int i = 0; i < size; i++)
-            assertEquals("Unexpected value.", cacheVector.get(i), 1d, 0d);
-    }
-
-    /** */
-    public void testPlusVec() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        Vector testVec = new DenseLocalOnHeapVector(IntStream.range(0, size).asDoubleStream().toArray());
-
-        try {
-            cacheVector.plus(testVec);
-            TestCase.fail();
-        }
-        catch (UnsupportedOperationException ignored) {
-
-        }
-    }
-
-    /** */
-    public void testDivide() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        final int size = MathTestConstants.STORAGE_SIZE;
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        initVector(cacheVector);
-        cacheVector.assign(1d);
-
-        cacheVector.divide(2d);
-
-        for (int i = 0; i < size; i++)
-            assertEquals("Unexpected value.", cacheVector.get(i), 1d / 2d, 0d);
-    }
-
-    /** */
-    public void testTimes() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        final int size = MathTestConstants.STORAGE_SIZE;
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        initVector(cacheVector);
-        cacheVector.assign(1d);
-
-        cacheVector.times(2d);
-
-        for (int i = 0; i < size; i++)
-            assertEquals("Unexpected value.", cacheVector.get(i), 2d, 0d);
-    }
-
-    /** */
-    public void testTimesVector() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        cacheVector.assign(1d);
-        Vector testVec = new DenseLocalOnHeapVector(IntStream.range(0, size).asDoubleStream().toArray());
-
-        try {
-            cacheVector.times(testVec);
-            TestCase.fail();
-        }
-        catch (UnsupportedOperationException ignored) {
-
-        }
-
-    }
-
-    /** */
-    public void testMin() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        Vector testVec = new DenseLocalOnHeapVector(IntStream.range(0, size).asDoubleStream().toArray());
-
-        cacheVector.assign(testVec);
-
-        assertEquals("Unexpected value.", cacheVector.minValue(), 0d, 0d);
-    }
-
-    /** */
-    public void testMax() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        Vector testVec = new DenseLocalOnHeapVector(IntStream.range(0, size).asDoubleStream().toArray());
-
-        cacheVector.assign(testVec);
-
-        assertEquals("Unexpected value.", cacheVector.maxValue(), testVec.get(size - 1), 0d);
-    }
-
-    /** */
-    public void testLike() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        try {
-            cacheVector.like(size);
-            TestCase.fail("Unsupported case");
-        }
-        catch (UnsupportedOperationException ignored) {
-
-        }
-    }
-
-    /** */
-    public void testLikeMatrix() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        try {
-            cacheVector.likeMatrix(size, size);
-            TestCase.fail("Unsupported case");
-        }
-        catch (UnsupportedOperationException ignored) {
-
-        }
-    }
-
-    /** */
-    public void testCopy() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        try {
-            cacheVector.copy();
-            TestCase.fail("Unsupported case");
-        }
-        catch (UnsupportedOperationException ignored) {
-
-        }
-    }
-
-    /** */
-    public void testExternalize() throws IOException, ClassNotFoundException {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        IdentityValueMapper valMapper = new IdentityValueMapper();
-        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
-
-        cacheVector.set(1, 1.0);
-
-        ByteArrayOutputStream byteArrOutputStream = new ByteArrayOutputStream();
-        ObjectOutputStream objOutputStream = new ObjectOutputStream(byteArrOutputStream);
-
-        objOutputStream.writeObject(cacheVector);
-
-        ByteArrayInputStream byteArrInputStream = new ByteArrayInputStream(byteArrOutputStream.toByteArray());
-        ObjectInputStream objInputStream = new ObjectInputStream(byteArrInputStream);
-
-        CacheVector objRestored = (CacheVector)objInputStream.readObject();
-
-        assertTrue(MathTestConstants.VAL_NOT_EQUALS, cacheVector.equals(objRestored));
-        assertEquals(MathTestConstants.VAL_NOT_EQUALS, objRestored.get(1), 1.0, 0.0);
-    }
-
-    /** */
-    private void initVector(CacheVector cacheVector) {
-        for (int i = 0; i < cacheVector.size(); i++)
-            cacheVector.set(i, 0d);
-    }
-
-    /** */
-    private IgniteCache<Integer, Double> getCache() {
-        assert ignite != null;
-
-        CacheConfiguration cfg = new CacheConfiguration();
-        cfg.setName(CACHE_NAME);
-
-        IgniteCache<Integer, Double> cache = ignite.getOrCreateCache(CACHE_NAME);
-
-        assert cache != null;
-        return cache;
-    }
-
-    /** */ private static class TestKeyMapper implements VectorKeyMapper<Integer> {
-        /** {@inheritDoc} */
-        @Override public Integer apply(int i) {
-            return i;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean isValid(Integer i) {
-            return i < size;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/ConstantVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/ConstantVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/ConstantVectorConstructorTest.java
deleted file mode 100644
index 2ed42bc..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/ConstantVectorConstructorTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/** */
-public class ConstantVectorConstructorTest {
-    /** */
-    private static final int IMPOSSIBLE_SIZE = -1;
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void negativeSizeTest() {
-        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
-            new ConstantVector(-1, 1).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void zeroSizeTest() {
-        assertEquals("Zero size.", IMPOSSIBLE_SIZE,
-            new ConstantVector(0, 1).size());
-    }
-
-    /** */
-    @Test
-    public void primitiveTest() {
-        assertEquals("1 size.", 1,
-            new ConstantVector(1, 1).size());
-
-        assertEquals("2 size.", 2,
-            new ConstantVector(2, 1).size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/DelegatingVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/DelegatingVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/DelegatingVectorConstructorTest.java
deleted file mode 100644
index 82e4e0b..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/DelegatingVectorConstructorTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import org.apache.ignite.math.Vector;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/** */
-public class DelegatingVectorConstructorTest {
-    /** */
-    private static final int IMPOSSIBLE_SIZE = -1;
-
-    /** */
-    @Test
-    public void basicTest() {
-        final Vector parent = new DenseLocalOnHeapVector(new double[] {0, 1});
-
-        final Vector delegate = new DelegatingVector(parent);
-
-        final int size = parent.size();
-
-        assertEquals("Delegate size differs from expected.", size, delegate.size());
-
-        for (int idx = 0; idx < size; idx++)
-            assertDelegate(parent, delegate, idx);
-    }
-
-    /** */
-    private void assertDelegate(Vector parent, Vector delegate, int idx) {
-        assertValue(parent, delegate, idx);
-
-        parent.set(idx, parent.get(idx) + 1);
-
-        assertValue(parent, delegate, idx);
-
-        delegate.set(idx, delegate.get(idx) + 2);
-
-        assertValue(parent, delegate, idx);
-    }
-
-    /** */
-    private void assertValue(Vector parent, Vector delegate, int idx) {
-        assertEquals("Unexpected value at index " + idx, parent.get(idx), delegate.get(idx), 0d);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/DenseLocalOffHeapVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/DenseLocalOffHeapVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/DenseLocalOffHeapVectorConstructorTest.java
deleted file mode 100644
index d62f35f..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/DenseLocalOffHeapVectorConstructorTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/** */
-public class DenseLocalOffHeapVectorConstructorTest {
-    /** */
-    private static final int IMPOSSIBLE_SIZE = -1;
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void negativeSizeTest() {
-        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
-            new DenseLocalOffHeapVector(-1).size());
-    }
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void nullArrayTest() {
-        assertEquals("Null array.", IMPOSSIBLE_SIZE,
-            new DenseLocalOffHeapVector(null).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void zeroSizeTest() {
-        assertEquals("0 size.", IMPOSSIBLE_SIZE,
-            new DenseLocalOffHeapVector(new double[0]).size());
-    }
-
-    /** */
-    @Test
-    public void primitiveTest() {
-        assertEquals("1 size.", 1,
-            new DenseLocalOffHeapVector(new double[1]).size());
-
-        assertEquals("2 size.", 2,
-            new DenseLocalOffHeapVector(new double[2]).size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/DenseLocalOnHeapVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/DenseLocalOnHeapVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/DenseLocalOnHeapVectorConstructorTest.java
deleted file mode 100644
index c10778e..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/DenseLocalOnHeapVectorConstructorTest.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/** */
-public class DenseLocalOnHeapVectorConstructorTest {
-    /** */
-    private static final int IMPOSSIBLE_SIZE = -1;
-
-    /** */
-    @Test(expected = org.apache.ignite.math.exceptions.UnsupportedOperationException.class)
-    public void mapInvalidArgsTest() {
-        assertEquals("Expect exception due to invalid args.", IMPOSSIBLE_SIZE,
-            new DenseLocalOnHeapVector(new HashMap<String, Object>() {{
-                put("invalid", 99);
-            }}).size());
-    }
-
-    /** */
-    @Test(expected = UnsupportedOperationException.class)
-    public void mapMissingArgsTest() {
-        final Map<String, Object> test = new HashMap<String, Object>() {{
-            put("arr", new double[0]);
-            put("shallowCopyMissing", "whatever");
-        }};
-
-        assertEquals("Expect exception due to missing args.", IMPOSSIBLE_SIZE,
-            new DenseLocalOnHeapVector(test).size());
-    }
-
-    /** */
-    @Test(expected = ClassCastException.class)
-    public void mapInvalidArrTypeTest() {
-        final Map<String, Object> test = new HashMap<String, Object>() {{
-            put("size", "whatever");
-        }};
-
-        assertEquals("Expect exception due to invalid arr type.", IMPOSSIBLE_SIZE,
-            new DenseLocalOnHeapVector(test).size());
-    }
-
-    /** */
-    @Test(expected = UnsupportedOperationException.class)
-    public void mapInvalidCopyTypeTest() {
-        final Map<String, Object> test = new HashMap<String, Object>() {{
-            put("arr", new double[0]);
-            put("shallowCopy", 0);
-        }};
-
-        assertEquals("Expect exception due to invalid copy type.", IMPOSSIBLE_SIZE,
-            new DenseLocalOnHeapVector(test).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void mapNullTest() {
-        //noinspection ConstantConditions
-        assertEquals("Null map args.", IMPOSSIBLE_SIZE,
-            new DenseLocalOnHeapVector((Map<String, Object>)null).size());
-    }
-
-    /** */
-    @Test
-    public void mapTest() {
-        assertEquals("Size from args.", 99,
-            new DenseLocalOnHeapVector(new HashMap<String, Object>() {{
-                put("size", 99);
-            }}).size());
-
-        final double[] test = new double[99];
-
-        assertEquals("Size from array in args.", test.length,
-            new DenseLocalOnHeapVector(new HashMap<String, Object>() {{
-                put("arr", test);
-                put("copy", false);
-            }}).size());
-
-        assertEquals("Size from array in args, shallow copy.", test.length,
-            new DenseLocalOnHeapVector(new HashMap<String, Object>() {{
-                put("arr", test);
-                put("copy", true);
-            }}).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void negativeSizeTest() {
-        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
-            new DenseLocalOnHeapVector(-1).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void nullCopyTest() {
-        assertEquals("Null array to non-shallow copy.", IMPOSSIBLE_SIZE,
-            new DenseLocalOnHeapVector(null, false).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void nullDefaultCopyTest() {
-        assertEquals("Null array default copy.", IMPOSSIBLE_SIZE,
-            new DenseLocalOnHeapVector((double[])null).size());
-    }
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void defaultConstructorTest() {
-        assertEquals("Default constructor.", IMPOSSIBLE_SIZE,
-            new DenseLocalOnHeapVector().size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void nullArrShallowCopyTest() {
-        assertEquals("Null array shallow copy.", IMPOSSIBLE_SIZE,
-            new DenseLocalOnHeapVector(null, true).size());
-    }
-
-    /** */
-    @Test
-    public void primitiveTest() {
-        assertEquals("0 size shallow copy.", 0,
-            new DenseLocalOnHeapVector(new double[0], true).size());
-
-        assertEquals("0 size.", 0,
-            new DenseLocalOnHeapVector(new double[0], false).size());
-
-        assertEquals("1 size shallow copy.", 1,
-            new DenseLocalOnHeapVector(new double[1], true).size());
-
-        assertEquals("1 size.", 1,
-            new DenseLocalOnHeapVector(new double[1], false).size());
-
-        assertEquals("0 size default copy.", 0,
-            new DenseLocalOnHeapVector(new double[0]).size());
-
-        assertEquals("1 size default copy.", 1,
-            new DenseLocalOnHeapVector(new double[1]).size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/FunctionVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/FunctionVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/FunctionVectorConstructorTest.java
deleted file mode 100644
index 57c96d1..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/FunctionVectorConstructorTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.function.IntToDoubleFunction;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.IgniteFunction;
-import org.apache.ignite.math.functions.IntDoubleToVoidFunction;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/** */
-public class FunctionVectorConstructorTest {
-    /** */
-    private static final int IMPOSSIBLE_SIZE = -1;
-
-    /** */
-    @Test(expected = org.apache.ignite.math.exceptions.UnsupportedOperationException.class)
-    public void mapInvalidArgsTest() {
-        assertEquals("Expect exception due to invalid args.", IMPOSSIBLE_SIZE,
-            new FunctionVector(new HashMap<String, Object>() {{
-                put("invalid", 99);
-            }}).size());
-    }
-
-    /** */
-    @Test(expected = UnsupportedOperationException.class)
-    public void mapMissingArgsTest() {
-        final Map<String, Object> test = new HashMap<String, Object>() {{
-            put("size", 1);
-            put("paramMissing", "whatever");
-        }};
-
-        assertEquals("Expect exception due to missing args.",
-            -1, new FunctionVector(test).size());
-    }
-
-    /** */
-    @Test(expected = ClassCastException.class)
-    public void mapInvalidParamTypeTest() {
-        final Map<String, Object> test = new HashMap<String, Object>() {{
-            put("size", "whatever");
-
-            put("getFunc", (IntToDoubleFunction)i -> i);
-        }};
-
-        assertEquals("Expect exception due to invalid param type.", IMPOSSIBLE_SIZE,
-            new FunctionVector(test).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void mapNullTest() {
-        //noinspection ConstantConditions
-        assertEquals("Null map args.", IMPOSSIBLE_SIZE,
-            new FunctionVector(null).size());
-    }
-
-    /** */
-    @Test
-    public void mapTest() {
-        assertEquals("Size from args.", 99,
-            new FunctionVector(new HashMap<String, Object>() {{
-                put("size", 99);
-
-                put("getFunc", (IgniteFunction<Integer, Double>)i -> (double)i);
-            }}).size());
-
-        assertEquals("Size from args with setFunc.", 99,
-            new FunctionVector(new HashMap<String, Object>() {{
-                put("size", 99);
-
-                put("getFunc", (IgniteFunction<Integer, Double>)i -> (double)i);
-
-                put("setFunc", (IntDoubleToVoidFunction)(integer, aDouble) -> {
-                });
-            }}).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void negativeSizeTest() {
-        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
-            new FunctionVector(-1, (i) -> (double)i).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void zeroSizeTest() {
-        assertEquals("0 size.", IMPOSSIBLE_SIZE,
-            new FunctionVector(0, (i) -> (double)i).size());
-    }
-
-    /** */
-    @Test
-    public void primitiveTest() {
-        assertEquals("1 size.", 1,
-            new FunctionVector(1, (i) -> (double)i).size());
-
-        assertEquals("2 size.", 2,
-            new FunctionVector(2, (i) -> (double)i).size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/MatrixVectorViewTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/MatrixVectorViewTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/MatrixVectorViewTest.java
deleted file mode 100644
index b7e390e..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/MatrixVectorViewTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-package org.apache.ignite.math.impls.vector;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.IndexException;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests for {@link MatrixVectorView}.
- */
-public class MatrixVectorViewTest {
-    /** */
-    private static final String UNEXPECTED_VALUE = "Unexpected value";
-    /** */
-    private static final int SMALL_SIZE = 3;
-    /** */
-    private static final int IMPOSSIBLE_SIZE = -1;
-
-    /** */
-    private Matrix parent;
-
-    /** */
-    @Before
-    public void setup() {
-        parent = newMatrix(SMALL_SIZE, SMALL_SIZE);
-    }
-
-    /** */
-    @Test
-    public void testDiagonal() {
-        Vector vector = parent.viewDiagonal();
-
-        for (int i = 0; i < SMALL_SIZE; i++)
-            assertView(i, i, vector, i);
-    }
-
-    /** */
-    @Test
-    public void testRow() {
-        for (int i = 0; i < SMALL_SIZE; i++) {
-            Vector viewRow = parent.viewRow(i);
-
-            for (int j = 0; j < SMALL_SIZE; j++)
-                assertView(i, j, viewRow, j);
-        }
-    }
-
-    /** */
-    @Test
-    public void testCols() {
-        for (int i = 0; i < SMALL_SIZE; i++) {
-            Vector viewCol = parent.viewColumn(i);
-
-            for (int j = 0; j < SMALL_SIZE; j++)
-                assertView(j, i, viewCol, j);
-        }
-    }
-
-    /** */
-    @Test
-    public void basicTest() {
-        for (int rowSize : new int[] {1, 2, 3, 4})
-            for (int colSize : new int[] {1, 2, 3, 4})
-                for (int row = 0; row < rowSize; row++)
-                    for (int col = 0; col < colSize; col++)
-                        for (int rowStride = 0; rowStride < rowSize; rowStride++)
-                            for (int colStride = 0; colStride < colSize; colStride++)
-                                if (rowStride != 0 || colStride != 0)
-                                    assertMatrixVectorView(newMatrix(rowSize, colSize), row, col, rowStride, colStride);
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void parentNullTest() {
-        //noinspection ConstantConditions
-        assertEquals(IMPOSSIBLE_SIZE,
-            new MatrixVectorView(null, 1, 1, 1, 1).size());
-    }
-
-    /** */
-    @Test(expected = IndexException.class)
-    public void rowNegativeTest() {
-        //noinspection ConstantConditions
-        assertEquals(IMPOSSIBLE_SIZE,
-            new MatrixVectorView(parent, -1, 1, 1, 1).size());
-    }
-
-    /** */
-    @Test(expected = IndexException.class)
-    public void colNegativeTest() {
-        //noinspection ConstantConditions
-        assertEquals(IMPOSSIBLE_SIZE,
-            new MatrixVectorView(parent, 1, -1, 1, 1).size());
-    }
-
-    /** */
-    @Test(expected = IndexException.class)
-    public void rowTooLargeTest() {
-        //noinspection ConstantConditions
-        assertEquals(IMPOSSIBLE_SIZE,
-            new MatrixVectorView(parent, parent.rowSize() + 1, 1, 1, 1).size());
-    }
-
-    /** */
-    @Test(expected = IndexException.class)
-    public void colTooLargeTest() {
-        //noinspection ConstantConditions
-        assertEquals(IMPOSSIBLE_SIZE,
-            new MatrixVectorView(parent, 1, parent.columnSize() + 1, 1, 1).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void rowStrideNegativeTest() {
-        //noinspection ConstantConditions
-        assertEquals(IMPOSSIBLE_SIZE,
-            new MatrixVectorView(parent, 1, 1, -1, 1).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void colStrideNegativeTest() {
-        //noinspection ConstantConditions
-        assertEquals(IMPOSSIBLE_SIZE,
-            new MatrixVectorView(parent, 1, 1, 1, -1).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void rowStrideTooLargeTest() {
-        //noinspection ConstantConditions
-        assertEquals(IMPOSSIBLE_SIZE,
-            new MatrixVectorView(parent, 1, 1, parent.rowSize() + 1, 1).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void colStrideTooLargeTest() {
-        //noinspection ConstantConditions
-        assertEquals(IMPOSSIBLE_SIZE,
-            new MatrixVectorView(parent, 1, 1, 1, parent.columnSize() + 1).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void bothStridesZeroTest() {
-        //noinspection ConstantConditions
-        assertEquals(IMPOSSIBLE_SIZE,
-            new MatrixVectorView(parent, 1, 1, 0, 0).size());
-    }
-
-    /** */
-    private void assertMatrixVectorView(Matrix parent, int row, int col, int rowStride, int colStride) {
-        MatrixVectorView view = new MatrixVectorView(parent, row, col, rowStride, colStride);
-
-        String desc = "parent [" + parent.rowSize() + "x" + parent.columnSize() + "], view ["
-            + row + "x" + col + "], strides [" + rowStride + ", " + colStride + "]";
-
-        final int size = view.size();
-
-        final int sizeByRows = rowStride == 0 ? IMPOSSIBLE_SIZE : (parent.rowSize() - row) / rowStride;
-        final int sizeByCols = colStride == 0 ? IMPOSSIBLE_SIZE : (parent.columnSize() - col) / colStride;
-
-        assertTrue("Size " + size + " differs from expected for " + desc,
-            size == sizeByRows || size == sizeByCols);
-
-        for (int idx = 0; idx < size; idx++) {
-            final int rowIdx = row + idx * rowStride;
-            final int colIdx = col + idx * colStride;
-
-            assertEquals(UNEXPECTED_VALUE + " at view index " + idx + desc,
-                parent.get(rowIdx, colIdx), view.get(idx), 0d);
-        }
-    }
-
-    /** */
-    private Matrix newMatrix(int rowSize, int colSize) {
-        Matrix res = new DenseLocalOnHeapMatrix(rowSize, colSize);
-
-        for (int i = 0; i < res.rowSize(); i++)
-            for (int j = 0; j < res.columnSize(); j++)
-                res.set(i, j, i * res.rowSize() + j);
-
-        return res;
-    }
-
-    /** */
-    private void assertView(int row, int col, Vector view, int viewIdx) {
-        assertValue(row, col, view, viewIdx);
-
-        parent.set(row, col, parent.get(row, col) + 1);
-
-        assertValue(row, col, view, viewIdx);
-
-        view.set(viewIdx, view.get(viewIdx) + 2);
-
-        assertValue(row, col, view, viewIdx);
-    }
-
-    /** */
-    private void assertValue(int row, int col, Vector view, int viewIdx) {
-        assertEquals(UNEXPECTED_VALUE + " at row " + row + " col " + col, parent.get(row, col), view.get(viewIdx), 0d);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/PivotedVectorViewConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/PivotedVectorViewConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/PivotedVectorViewConstructorTest.java
deleted file mode 100644
index 91650dc..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/PivotedVectorViewConstructorTest.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.CardinalityException;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-/** */
-public class PivotedVectorViewConstructorTest {
-    /** */
-    private static final int IMPOSSIBLE_SIZE = -1;
-
-    /** */
-    private static final SampleParams sampleParams = new SampleParams();
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void nullVecParamTest() {
-        assertEquals("Expect exception due to null vector param.", IMPOSSIBLE_SIZE,
-            new PivotedVectorView(null, sampleParams.pivot).size());
-    }
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void nullVecParam2Test() {
-        assertEquals("Expect exception due to null vector param, with unpivot.", IMPOSSIBLE_SIZE,
-            new PivotedVectorView(null, sampleParams.pivot, sampleParams.unpivot).size());
-    }
-
-    /** */
-    @Test(expected = NullPointerException.class)
-    public void nullPivotParamTest() {
-        assertEquals("Expect exception due to null pivot param.", IMPOSSIBLE_SIZE,
-            new PivotedVectorView(sampleParams.vec, null).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void nullPivotParam2Test() {
-        assertEquals("Expect exception due to null pivot param, with unpivot.", IMPOSSIBLE_SIZE,
-            new PivotedVectorView(sampleParams.vec, null, sampleParams.unpivot).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void nullUnpivotParam2Test() {
-        assertEquals("Expect exception due to null unpivot param.", IMPOSSIBLE_SIZE,
-            new PivotedVectorView(sampleParams.vec, sampleParams.pivot, null).size());
-    }
-
-    /** */
-    @Test(expected = CardinalityException.class)
-    public void emptyPivotTest() {
-        assertEquals("Expect exception due to empty pivot param.", IMPOSSIBLE_SIZE,
-            new PivotedVectorView(sampleParams.vec, new int[] {}).size());
-    }
-
-    /** */
-    @Test(expected = CardinalityException.class)
-    public void emptyPivot2Test() {
-        assertEquals("Expect exception due to empty pivot param, with unpivot.", IMPOSSIBLE_SIZE,
-            new PivotedVectorView(sampleParams.vec, new int[] {}, sampleParams.unpivot).size());
-    }
-
-    /** */
-    @Test(expected = CardinalityException.class)
-    public void wrongPivotTest() {
-        assertEquals("Expect exception due to wrong pivot param.", IMPOSSIBLE_SIZE,
-            new PivotedVectorView(sampleParams.vec, new int[] {0}).size());
-    }
-
-    /** */
-    @Test(expected = CardinalityException.class)
-    public void wrongPivot2Test() {
-        assertEquals("Expect exception due to wrong pivot param, with unpivot.", IMPOSSIBLE_SIZE,
-            new PivotedVectorView(sampleParams.vec, new int[] {0}, sampleParams.unpivot).size());
-    }
-
-    /** */
-    @Test(expected = CardinalityException.class)
-    public void emptyUnpivotTest() {
-        assertEquals("Expect exception due to empty unpivot param.", IMPOSSIBLE_SIZE,
-            new PivotedVectorView(sampleParams.vec, sampleParams.pivot, new int[] {}).size());
-    }
-
-    /** */
-    @Test(expected = CardinalityException.class)
-    public void wrongUnpivotTest() {
-        assertEquals("Expect exception due to wrong unpivot param, with unpivot.", IMPOSSIBLE_SIZE,
-            new PivotedVectorView(sampleParams.vec, sampleParams.pivot, new int[] {0}).size());
-    }
-
-    /** */
-    @Test
-    public void basicPivotTest() {
-        final PivotedVectorView pvv = new PivotedVectorView(sampleParams.vec, sampleParams.pivot);
-
-        final int size = sampleParams.vec.size();
-
-        assertEquals("View size differs from expected.", size, pvv.size());
-
-        assertSame("Base vector differs from expected.", sampleParams.vec, pvv.getBaseVector());
-
-        for (int idx = 0; idx < size; idx++) {
-            assertEquals("Sample pivot and unpivot differ from expected",
-                idx, sampleParams.unpivot[sampleParams.pivot[idx]]);
-
-            assertEquals("Pivot differs from expected at index " + idx,
-                sampleParams.pivot[idx], pvv.pivot(idx));
-
-            assertEquals("Default unpivot differs from expected at index " + idx,
-                sampleParams.unpivot[idx], pvv.unpivot(idx));
-
-            final Metric metric = new Metric(sampleParams.vec.get(idx), pvv.get(pvv.pivot(idx)));
-
-            assertTrue("Not close enough at index " + idx + ", " + metric, metric.closeEnough());
-        }
-
-        for (int idx = 0; idx < size; idx++) {
-            sampleParams.vec.set(idx, sampleParams.vec.get(idx) + idx + 1);
-
-            final Metric metric = new Metric(sampleParams.vec.get(idx), pvv.get(pvv.pivot(idx)));
-
-            assertTrue("Modified value not close enough at index " + idx + ", " + metric, metric.closeEnough());
-        }
-    }
-
-    /** */
-    @Test
-    public void basicUnpivotTest() {
-        final PivotedVectorView pvv = new PivotedVectorView(sampleParams.vec, sampleParams.pivot, sampleParams.unpivot);
-
-        final int size = sampleParams.vec.size();
-
-        assertEquals("View size differs from expected.", size, pvv.size());
-
-        for (int idx = 0; idx < size; idx++) {
-            assertEquals("Unpivot differs from expected at index " + idx,
-                sampleParams.unpivot[idx], pvv.unpivot(idx));
-
-            final Metric metric = new Metric(sampleParams.vec.get(idx), pvv.get(pvv.unpivot(idx)));
-
-            assertTrue("Not close enough at index " + idx + ", " + metric, metric.closeEnough());
-        }
-    }
-
-    /** */
-    private static class SampleParams {
-        /** */
-        final double[] data = new double[] {0, 1};
-        /** */
-        final Vector vec = new DenseLocalOnHeapVector(data);
-        /** */
-        final int[] pivot = new int[] {1, 0};
-        /** */
-        final int[] unpivot = new int[] {1, 0};
-    }
-
-    /** */
-    private static class Metric { // todo consider if softer tolerance (like say 0.1 or 0.01) would make sense here
-        /** */
-        private final double exp;
-
-        /** */
-        private final double obtained;
-
-        /** **/
-        Metric(double exp, double obtained) {
-            this.exp = exp;
-            this.obtained = obtained;
-        }
-
-        /** */
-        boolean closeEnough() {
-            return new Double(exp).equals(obtained) || closeEnoughToZero();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return "Metric{" + "expected=" + exp +
-                ", obtained=" + obtained +
-                '}';
-        }
-
-        /** */
-        private boolean closeEnoughToZero() {
-            return (new Double(exp).equals(0.0) && new Double(obtained).equals(-0.0))
-                || (new Double(exp).equals(-0.0) && new Double(obtained).equals(0.0));
-        }
-    }
-}


[52/65] [abbrv] ignite git commit: Added test.

Posted by ag...@apache.org.
Added test.


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

Branch: refs/heads/ignite-5024
Commit: a900dc685a24b21ac155796ecb027c60608b88f5
Parents: ca8ad03
Author: sboikov <sb...@gridgain.com>
Authored: Fri Apr 21 17:30:23 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Apr 21 17:30:23 2017 +0300

----------------------------------------------------------------------
 .../internal/TestRecordingCommunicationSpi.java |  29 ++-
 .../cache/IgniteOnePhaseCommitInvokeTest.java   |  10 +-
 .../CacheLateAffinityAssignmentTest.java        |  31 ++-
 ...heClientMultiNodeUpdateTopologyLockTest.java | 193 +++++++++++++++++++
 .../IgniteCacheReadFromBackupTest.java          |  15 +-
 .../IgniteTxCachePrimarySyncTest.java           |  17 +-
 .../dht/IgniteCacheTxRecoveryRollbackTest.java  |  17 +-
 .../atomic/IgniteCacheAtomicProtocolTest.java   | 183 ++----------------
 .../ignite/testframework/GridTestNode.java      |   7 +
 .../junits/common/GridCommonAbstractTest.java   |  76 +++++++-
 10 files changed, 353 insertions(+), 225 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a900dc68/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java b/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
index aa0cc09..98d2553 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
@@ -32,7 +32,6 @@ import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgniteInClosure;
-import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.spi.IgniteSpiException;
 import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
@@ -59,7 +58,7 @@ public class TestRecordingCommunicationSpi extends TcpCommunicationSpi {
     private Map<Class<?>, Set<String>> blockCls = new HashMap<>();
 
     /** */
-    private IgnitePredicate<GridIoMessage> blockP;
+    private IgniteBiPredicate<ClusterNode, Message> blockP;
 
     /**
      * @param node Node.
@@ -75,16 +74,18 @@ public class TestRecordingCommunicationSpi extends TcpCommunicationSpi {
         if (msg instanceof GridIoMessage) {
             GridIoMessage ioMsg = (GridIoMessage)msg;
 
-            Object msg0 = ioMsg.message();
+            Message msg0 = ioMsg.message();
 
             synchronized (this) {
-                if ((recordClasses != null && recordClasses.contains(msg0.getClass())) ||
-                    (recordP != null && recordP.apply(node, msg)))
+                boolean record = (recordClasses != null && recordClasses.contains(msg0.getClass())) ||
+                    (recordP != null && recordP.apply(node, msg0));
+
+                if (record)
                     recordedMsgs.add(msg0);
 
                 boolean block = false;
 
-                if (blockP != null && blockP.apply(ioMsg))
+                if (blockP != null && blockP.apply(node, msg0))
                     block = true;
                 else {
                     Set<String> blockNodes = blockCls.get(msg0.getClass());
@@ -106,6 +107,8 @@ public class TestRecordingCommunicationSpi extends TcpCommunicationSpi {
 
                     return;
                 }
+                else if (record)
+                    notifyAll();
             }
         }
 
@@ -166,7 +169,7 @@ public class TestRecordingCommunicationSpi extends TcpCommunicationSpi {
      * @param nodeName Node name.
      * @throws InterruptedException If interrupted.
      */
-    public void waitForMessage(Class<?> cls, String nodeName) throws InterruptedException {
+    public void waitForBlocked(Class<?> cls, String nodeName) throws InterruptedException {
         synchronized (this) {
             while (!hasMessage(cls, nodeName))
                 wait();
@@ -174,6 +177,16 @@ public class TestRecordingCommunicationSpi extends TcpCommunicationSpi {
     }
 
     /**
+     * @throws InterruptedException If interrupted.
+     */
+    public void waitForRecorded() throws InterruptedException {
+        synchronized (this) {
+            while (recordedMsgs.isEmpty())
+                wait();
+        }
+    }
+
+    /**
      * @param cls Message class.
      * @param nodeName Node name.
      * @return {@code True} if has blocked message.
@@ -191,7 +204,7 @@ public class TestRecordingCommunicationSpi extends TcpCommunicationSpi {
     /**
      * @param blockP Message block predicate.
      */
-    public void blockMessages(IgnitePredicate<GridIoMessage> blockP) {
+    public void blockMessages(IgniteBiPredicate<ClusterNode, Message> blockP) {
         synchronized (this) {
             this.blockP = blockP;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a900dc68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java
index 601c067..a5cb3f2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java
@@ -21,17 +21,17 @@ import java.util.concurrent.Callable;
 import javax.cache.processor.MutableEntry;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.TestRecordingCommunicationSpi;
-import org.apache.ignite.internal.managers.communication.GridIoMessage;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareResponse;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
@@ -127,10 +127,8 @@ public class IgniteOnePhaseCommitInvokeTest extends GridCommonAbstractTest {
 
         final Ignite clientNode = startGrid(1);
 
-        TestRecordingCommunicationSpi.spi(srv0).blockMessages(new IgnitePredicate<GridIoMessage>() {
-            @Override public boolean apply(GridIoMessage msg0) {
-                Message msg = msg0.message();
-
+        TestRecordingCommunicationSpi.spi(srv0).blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+            @Override public boolean apply(ClusterNode node, Message msg) {
                 return msg instanceof GridDhtPartitionSupplyMessage &&
                     ((GridDhtPartitionSupplyMessage)msg).cacheId() == CU.cacheId(CACHE_NAME);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a900dc68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
index a74117c..c68c8d0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
@@ -75,6 +75,7 @@ import org.apache.ignite.internal.util.typedef.PA;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.plugin.extensions.communication.Message;
@@ -1082,12 +1083,10 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest {
             TestRecordingCommunicationSpi spi =
                     (TestRecordingCommunicationSpi)ignite(i).configuration().getCommunicationSpi();
 
-            spi.blockMessages(new IgnitePredicate<GridIoMessage>() {
-                @Override public boolean apply(GridIoMessage msg) {
-                    Message msg0 = msg.message();
-
-                    return msg0.getClass().equals(GridDhtPartitionsSingleMessage.class) ||
-                        msg0.getClass().equals(GridDhtPartitionsFullMessage.class);
+            spi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+                @Override public boolean apply(ClusterNode node, Message msg) {
+                    return msg.getClass().equals(GridDhtPartitionsSingleMessage.class) ||
+                        msg.getClass().equals(GridDhtPartitionsFullMessage.class);
                 }
             });
         }
@@ -1710,14 +1709,12 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest {
             @Override public TestRecordingCommunicationSpi apply(String s) {
                 TestRecordingCommunicationSpi spi = new TestRecordingCommunicationSpi();
 
-                spi.blockMessages(new IgnitePredicate<GridIoMessage>() {
-                    @Override public boolean apply(GridIoMessage msg) {
-                        Message msg0 = msg.message();
-
-                        if (msg0 instanceof GridDhtForceKeysRequest || msg0 instanceof GridDhtForceKeysResponse) {
+                spi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+                    @Override public boolean apply(ClusterNode node, Message msg) {
+                        if (msg instanceof GridDhtForceKeysRequest || msg instanceof GridDhtForceKeysResponse) {
                             fail.set(true);
 
-                            U.dumpStack(log, "Unexpected message: " + msg0);
+                            U.dumpStack(log, "Unexpected message: " + msg);
                         }
 
                         return false;
@@ -2011,14 +2008,12 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest {
      * @param cacheName Cache name.
      */
     private void blockSupplySend(TestRecordingCommunicationSpi spi, final String cacheName) {
-        spi.blockMessages(new IgnitePredicate<GridIoMessage>() {
-            @Override public boolean apply(GridIoMessage ioMsg) {
-                if (!ioMsg.message().getClass().equals(GridDhtPartitionSupplyMessage.class))
+        spi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+            @Override public boolean apply(ClusterNode node, Message msg) {
+                if (!msg.getClass().equals(GridDhtPartitionSupplyMessage.class))
                     return false;
 
-                GridDhtPartitionSupplyMessage msg = (GridDhtPartitionSupplyMessage)ioMsg.message();
-
-                return msg.cacheId() == CU.cacheId(cacheName);
+                return ((GridDhtPartitionSupplyMessage)msg).cacheId() == CU.cacheId(cacheName);
             }
         });
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a900dc68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java
new file mode 100644
index 0000000..4adf5f4
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed;
+
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.TestRecordingCommunicationSpi;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
+/**
+ *
+ */
+public class IgniteCacheClientMultiNodeUpdateTopologyLockTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final String TEST_CACHE = "testCache";
+
+    /** */
+    private boolean client;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setConsistentId(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+        TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
+
+        cfg.setCommunicationSpi(commSpi);
+
+        cfg.setClientMode(client);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticTx() throws Exception {
+        startGrids(3);
+
+        client = true;
+
+        Ignite clientNode = startGrid(3);
+
+        client = false;
+
+        IgniteCache<Integer, Integer> cache = clientNode.createCache(cacheConfiguration(0, FULL_SYNC));
+
+        awaitPartitionMapExchange();
+
+        Integer key1 = movingKeysAfterJoin(ignite(1), TEST_CACHE, 1).get(0);
+        Integer key2 = movingKeysAfterJoin(ignite(2), TEST_CACHE, 1).get(0);
+
+        log.info("Start tx [key1=" + key1 + ", key2=" + key2 + ']');
+
+        IgniteInternalFuture<?> startFut;
+
+        TestRecordingCommunicationSpi spi2 = TestRecordingCommunicationSpi.spi(ignite(2));
+
+        TestRecordingCommunicationSpi clientSpi = TestRecordingCommunicationSpi.spi(clientNode);
+
+        final UUID node0Id = ignite(0).cluster().localNode().id();
+        final UUID node2Id = ignite(2).cluster().localNode().id();
+
+        spi2.record(new IgniteBiPredicate<ClusterNode, Message>() {
+            @Override public boolean apply(ClusterNode node, Message msg) {
+                if (!node0Id.equals(node.id()))
+                    return false;
+
+                return (msg instanceof GridDhtPartitionsSingleMessage) &&
+                    ((GridDhtPartitionsSingleMessage)msg).exchangeId() != null;
+            }
+        });
+
+        clientSpi.record(new IgniteBiPredicate<ClusterNode, Message>() {
+            @Override public boolean apply(ClusterNode node, Message msg) {
+                if (!node2Id.equals(node.id()))
+                    return false;
+
+                if (msg instanceof GridNearTxFinishRequest) {
+                    log.info("Delay message [msg=" + msg + ']');
+
+                    try {
+                        Thread.sleep(5000);
+                    }
+                    catch (InterruptedException e) {
+                        e.printStackTrace();
+                    }
+
+                    log.info("Send delayed message [msg=" + msg + ']');
+                }
+
+                return false;
+            }
+        });
+
+        try (Transaction tx = clientNode.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+            cache.put(key1, 1);
+
+            startFut = GridTestUtils.runAsync(new Callable<Object>() {
+                @Override public Object call() throws Exception {
+                    startGrid(4);
+
+                    return null;
+                }
+            }, "start-thread");
+
+            spi2.waitForRecorded();
+
+            U.sleep(5);
+
+            cache.put(key2, 2);
+
+            log.info("Commit tx");
+
+            tx.commit();
+        }
+
+        assertEquals((Integer)1, cache.get(key1));
+        assertEquals((Integer)2, cache.get(key2));
+
+        startFut.get();
+
+        assertEquals((Integer)1, cache.get(key1));
+        assertEquals((Integer)2, cache.get(key2));
+
+        awaitPartitionMapExchange();
+
+        assertEquals((Integer)1, cache.get(key1));
+        assertEquals((Integer)2, cache.get(key2));
+    }
+
+    /**
+     * @param backups Number of backups.
+     * @param writeSync Cache write synchronization mode.
+     * @return Cache configuration.
+     */
+    private CacheConfiguration<Integer, Integer> cacheConfiguration(int backups,
+        CacheWriteSynchronizationMode writeSync) {
+        CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>();
+
+        ccfg.setName(TEST_CACHE);
+        ccfg.setAtomicityMode(TRANSACTIONAL);
+        ccfg.setWriteSynchronizationMode(writeSync);
+        ccfg.setBackups(backups);
+        ccfg.setRebalanceMode(ASYNC);
+
+        return ccfg;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a900dc68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java
index 29c2af6..42de613 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java
@@ -33,16 +33,17 @@ import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.store.CacheStore;
 import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.internal.TestRecordingCommunicationSpi;
-import org.apache.ignite.internal.managers.communication.GridIoMessage;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest;
 import org.apache.ignite.internal.util.typedef.internal.CU;
-import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -195,14 +196,12 @@ public class IgniteCacheReadFromBackupTest extends GridCommonAbstractTest {
                     TestRecordingCommunicationSpi spi =
                         (TestRecordingCommunicationSpi)ignite.configuration().getCommunicationSpi();
 
-                    spi.blockMessages(new IgnitePredicate<GridIoMessage>() {
-                        @Override public boolean apply(GridIoMessage ioMsg) {
-                            if (!ioMsg.message().getClass().equals(GridDhtPartitionSupplyMessage.class))
+                    spi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+                        @Override public boolean apply(ClusterNode node, Message msg) {
+                            if (!msg.getClass().equals(GridDhtPartitionSupplyMessage.class))
                                 return false;
 
-                            GridDhtPartitionSupplyMessage msg = (GridDhtPartitionSupplyMessage)ioMsg.message();
-
-                            return msg.cacheId() == CU.cacheId(ccfg.getName());
+                            return ((GridDhtPartitionSupplyMessage)msg).cacheId() == CU.cacheId(ccfg.getName());
                         }
                     });
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a900dc68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java
index 8a1d4a7..91e6cf6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java
@@ -29,7 +29,6 @@ import javax.cache.integration.CacheLoaderException;
 import javax.cache.integration.CacheWriterException;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteTransactions;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cache.affinity.Affinity;
@@ -41,7 +40,6 @@ import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.TestRecordingCommunicationSpi;
-import org.apache.ignite.internal.managers.communication.GridIoMessage;
 import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest;
@@ -50,10 +48,11 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPr
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse;
 import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
 import org.apache.ignite.internal.util.lang.GridAbsPredicate;
-import org.apache.ignite.internal.util.lang.IgnitePredicateX;
 import org.apache.ignite.internal.util.typedef.G;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiInClosure;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -213,9 +212,9 @@ public class IgniteTxCachePrimarySyncTest extends GridCommonAbstractTest {
 
         commSpi0.record(GridDhtTxFinishRequest.class);
 
-        commSpi0.blockMessages(new IgnitePredicateX<GridIoMessage>() {
-            @Override public boolean applyx(GridIoMessage e) throws IgniteCheckedException {
-                return e.message() instanceof GridDhtTxFinishRequest;
+        commSpi0.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+            @Override public boolean apply(ClusterNode node, Message msg) {
+                return msg instanceof GridDhtTxFinishRequest;
             }
         });
 
@@ -466,9 +465,9 @@ public class IgniteTxCachePrimarySyncTest extends GridCommonAbstractTest {
 
         commSpi0.record(GridDhtTxFinishRequest.class);
 
-        commSpi0.blockMessages(new IgnitePredicateX<GridIoMessage>() {
-            @Override public boolean applyx(GridIoMessage e) throws IgniteCheckedException {
-                return e.message() instanceof GridDhtTxFinishRequest;
+        commSpi0.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+            @Override public boolean apply(ClusterNode node, Message msg) {
+                return msg instanceof GridDhtTxFinishRequest;
             }
         });
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a900dc68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheTxRecoveryRollbackTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheTxRecoveryRollbackTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheTxRecoveryRollbackTest.java
index cfe9029..7e7d341 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheTxRecoveryRollbackTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheTxRecoveryRollbackTest.java
@@ -32,13 +32,13 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.store.CacheStore;
 import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.TestRecordingCommunicationSpi;
-import org.apache.ignite.internal.managers.communication.GridIoMessage;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
@@ -46,7 +46,8 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.G;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.resources.LoggerResource;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
@@ -189,7 +190,7 @@ public class IgniteCacheTxRecoveryRollbackTest extends GridCommonAbstractTest {
 
         assertFalse(fut.isDone());
 
-        testSpi(client2).waitForMessage(GridNearTxFinishRequest.class, srv0.name());
+        testSpi(client2).waitForBlocked(GridNearTxFinishRequest.class, srv0.name());
 
         stopGrid(client2.name());
 
@@ -264,9 +265,9 @@ public class IgniteCacheTxRecoveryRollbackTest extends GridCommonAbstractTest {
 
         testSpi(client2).blockMessages(GridNearTxFinishRequest.class, srv0.name());
 
-        testSpi(srv0).blockMessages(new IgnitePredicate<GridIoMessage>() {
-            @Override public boolean apply(GridIoMessage msg) {
-                return msg.message() instanceof GridDhtTxFinishRequest;
+        testSpi(srv0).blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+            @Override public boolean apply(ClusterNode node, Message msg) {
+                return msg instanceof GridDhtTxFinishRequest;
             }
         });
 
@@ -292,7 +293,7 @@ public class IgniteCacheTxRecoveryRollbackTest extends GridCommonAbstractTest {
 
         assertFalse(fut.isDone());
 
-        testSpi(client2).waitForMessage(GridNearTxFinishRequest.class, srv0.name());
+        testSpi(client2).waitForBlocked(GridNearTxFinishRequest.class, srv0.name());
 
         stopGrid(client2.name());
         stopGrid(srv0.name());
@@ -397,7 +398,7 @@ public class IgniteCacheTxRecoveryRollbackTest extends GridCommonAbstractTest {
 
         assertFalse(fut.isDone());
 
-        testSpi(srv0).waitForMessage(GridNearTxPrepareResponse.class, client.name());
+        testSpi(srv0).waitForBlocked(GridNearTxPrepareResponse.class, client.name());
 
         stopGrid(client.name());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a900dc68/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
index 5a6b1c8..591858a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
@@ -17,14 +17,11 @@
 
 package org.apache.ignite.internal.processors.cache.distributed.dht.atomic;
 
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 import javax.cache.processor.MutableEntry;
 import org.apache.ignite.Ignite;
@@ -32,18 +29,11 @@ import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cache.affinity.Affinity;
-import org.apache.ignite.cache.affinity.AffinityFunction;
-import org.apache.ignite.cache.affinity.AffinityFunctionContext;
-import org.apache.ignite.cluster.ClusterMetrics;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.TestRecordingCommunicationSpi;
-import org.apache.ignite.internal.managers.communication.GridIoMessage;
-import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
-import org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheMessage;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
 import org.apache.ignite.internal.util.lang.GridAbsPredicate;
@@ -51,15 +41,14 @@ import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.G;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.lang.IgniteProductVersion;
+import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
 import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC;
@@ -112,12 +101,10 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
      */
     private void blockRebalance() {
         for (Ignite node : G.allGrids()) {
-            testSpi(node).blockMessages(new IgnitePredicate<GridIoMessage>() {
-                @Override public boolean apply(GridIoMessage msg) {
-                    Object msg0 = msg.message();
-
-                    return (msg0 instanceof GridDhtPartitionSupplyMessage)
-                        && ((GridCacheMessage)msg0).cacheId() == CU.cacheId(TEST_CACHE);
+            testSpi(node).blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+                @Override public boolean apply(ClusterNode node, Message msg) {
+                    return (msg instanceof GridDhtPartitionSupplyMessage)
+                        && ((GridCacheMessage)msg).cacheId() == CU.cacheId(TEST_CACHE);
                 }
             });
         }
@@ -368,7 +355,7 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
 
         final IgniteCache<Integer, Integer> nearCache = clientNode.createCache(cacheConfiguration(1, FULL_ASYNC));
 
-        List<Integer> keys = getKeysMoved(srv0, TEST_CACHE, putAll ? 3 : 1);
+        List<Integer> keys = movingKeysAfterJoin(srv0, TEST_CACHE, putAll ? 10 : 1);
 
         testSpi(clientNode).blockMessages(GridNearAtomicSingleUpdateRequest.class, srv0.name());
         testSpi(clientNode).blockMessages(GridNearAtomicFullUpdateRequest.class, srv0.name());
@@ -663,9 +650,9 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
 
         IgniteCache<Integer, Integer> nearCache = client.cache(TEST_CACHE);
 
-        testSpi(ignite(0)).blockMessages(new IgnitePredicate<GridIoMessage>() {
-            @Override public boolean apply(GridIoMessage msg) {
-                return msg.message() instanceof GridDhtAtomicAbstractUpdateRequest;
+        testSpi(ignite(0)).blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+            @Override public boolean apply(ClusterNode node, Message msg) {
+                return msg instanceof GridDhtAtomicAbstractUpdateRequest;
             }
         });
 
@@ -719,16 +706,16 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
         IgniteCache<Integer, Integer> nearCache = client.cache(TEST_CACHE);
 
         if (fail0) {
-            testSpi(ignite(0)).blockMessages(new IgnitePredicate<GridIoMessage>() {
-                @Override public boolean apply(GridIoMessage msg) {
-                    return msg.message() instanceof GridDhtAtomicAbstractUpdateRequest;
+            testSpi(ignite(0)).blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+                @Override public boolean apply(ClusterNode node, Message msg) {
+                    return msg instanceof GridDhtAtomicAbstractUpdateRequest;
                 }
             });
         }
         if (fail1) {
-            testSpi(ignite(2)).blockMessages(new IgnitePredicate<GridIoMessage>() {
-                @Override public boolean apply(GridIoMessage msg) {
-                    return msg.message() instanceof GridDhtAtomicAbstractUpdateRequest;
+            testSpi(ignite(2)).blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+                @Override public boolean apply(ClusterNode node, Message msg) {
+                    return msg instanceof GridDhtAtomicAbstractUpdateRequest;
                 }
             });
         }
@@ -825,68 +812,6 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
     }
 
     /**
-     * Return list of keys that are primary for given node on given topology,
-     * but will not be primary after add one new node.
-     *
-     * @param ign Ignite.
-     * @param cacheName Cache name.
-     * @param size Number of keys.
-     * @return List of keys.
-     */
-    private List<Integer> getKeysMoved(Ignite ign, String cacheName, int size) {
-        GridCacheContext<Object, Object> cctx = ((IgniteKernal)ign).context().cache().internalCache(cacheName).context();
-
-        ArrayList<ClusterNode> nodes = new ArrayList<>(ign.cluster().nodes());
-
-        AffinityFunction func = cctx.config().getAffinity();
-
-        AffinityFunctionContext ctx = new GridAffinityFunctionContextImpl(
-            nodes,
-            null,
-            null,
-            new AffinityTopologyVersion(1, 0),
-            cctx.config().getBackups());
-
-        List<List<ClusterNode>> calcAff = func.assignPartitions(ctx);
-
-        String name = getTestIgniteInstanceName(nodes.size());
-
-        nodes.add(new FakeNode(name));
-
-        ctx = new GridAffinityFunctionContextImpl(
-            nodes,
-            null,
-            null,
-            new AffinityTopologyVersion(1, 0),
-            cctx.config().getBackups());
-
-        List<List<ClusterNode>> calcAff2 = func.assignPartitions(ctx);
-
-        Set<Integer> movedParts = new HashSet<>();
-
-        UUID localId = ign.cluster().localNode().id();
-
-        for (int i = 0; i < calcAff.size(); i++) {
-            if (calcAff.get(i).get(0).id().equals(localId) && !calcAff2.get(i).get(0).id().equals(localId))
-                movedParts.add(i);
-        }
-
-        List<Integer> keys = new ArrayList<>();
-
-        for (int i = 0; i < 10000; i++) {
-            int keyPart = func.partition(ign.affinity(cacheName).affinityKey(i));
-
-            if (movedParts.contains(keyPart))
-                keys.add(i);
-
-            if (keys.size() == size)
-                break;
-        }
-
-        return keys;
-    }
-
-    /**
      *
      */
     public static class SetValueEntryProcessor implements CacheEntryProcessor<Integer, Integer, Object> {
@@ -908,80 +833,4 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
             return null;
         }
     }
-
-    /**
-     *
-     */
-    public static class FakeNode implements ClusterNode {
-        /** */
-        private final String consistendId;
-        /** */
-        private final UUID uuid;
-
-        /** */
-        public FakeNode(String consistendId) {
-            this.consistendId = consistendId;
-            uuid = UUID.randomUUID();
-        }
-
-        /** {@inheritDoc} */
-        @Override public UUID id() {
-            return uuid;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object consistentId() {
-            return consistendId;
-        }
-
-        /** {@inheritDoc} */
-        @Nullable @Override public <T> T attribute(String name) {
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public ClusterMetrics metrics() {
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Map<String, Object> attributes() {
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Collection<String> addresses() {
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Collection<String> hostNames() {
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public long order() {
-            return 0;
-        }
-
-        /** {@inheritDoc} */
-        @Override public IgniteProductVersion version() {
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean isLocal() {
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean isDaemon() {
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean isClient() {
-            return false;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a900dc68/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
index d331387..cefb774 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
@@ -103,6 +103,13 @@ public class GridTestNode extends GridMetadataAwareAdapter implements ClusterNod
         return id;
     }
 
+    /**
+     * @param consistentId Consistent ID.
+     */
+    public void consistentId(Object consistentId) {
+        this.consistentId = consistentId;
+    }
+
     /** {@inheritDoc} */
     @Override public Object consistentId() {
         return consistentId;

http://git-wip-us.apache.org/repos/asf/ignite/blob/a900dc68/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index c76c83e..e6b30e0 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -46,10 +46,10 @@ import org.apache.ignite.IgniteEvents;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteMessaging;
 import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.cache.affinity.AffinityFunction;
+import org.apache.ignite.cache.affinity.AffinityFunctionContext;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.cluster.ClusterGroup;
 import org.apache.ignite.cluster.ClusterNode;
@@ -64,7 +64,9 @@ import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheExplicitLockSpan;
 import org.apache.ignite.internal.processors.cache.GridCacheFuture;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
@@ -91,6 +93,7 @@ import org.apache.ignite.internal.util.typedef.internal.LT;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.testframework.GridTestNode;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.GridAbstractTest;
 import org.apache.ignite.transactions.Transaction;
@@ -1117,6 +1120,77 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
     }
 
     /**
+     * Return list of keys that are primary for given node on current topology,
+     * but primary node will change after new node will be added.
+     *
+     * @param ign Ignite.
+     * @param cacheName Cache name.
+     * @param size Number of keys.
+     * @return List of keys.
+     */
+    protected final List<Integer> movingKeysAfterJoin(Ignite ign, String cacheName, int size) {
+        assertEquals("Expected consistentId is set to node name", ign.name(), ign.cluster().localNode().consistentId());
+
+        GridCacheContext<Object, Object> cctx = ((IgniteKernal)ign).context().cache().internalCache(cacheName).context();
+
+        ArrayList<ClusterNode> nodes = new ArrayList<>(ign.cluster().nodes());
+
+        AffinityFunction func = cctx.config().getAffinity();
+
+        AffinityFunctionContext ctx = new GridAffinityFunctionContextImpl(
+            nodes,
+            null,
+            null,
+            AffinityTopologyVersion.NONE,
+            cctx.config().getBackups());
+
+        List<List<ClusterNode>> calcAff = func.assignPartitions(ctx);
+
+        GridTestNode fakeNode = new GridTestNode(UUID.randomUUID(), null);
+
+        fakeNode.consistentId(getTestIgniteInstanceName(nodes.size()));
+
+        nodes.add(fakeNode);
+
+        ctx = new GridAffinityFunctionContextImpl(
+            nodes,
+            null,
+            null,
+            AffinityTopologyVersion.NONE,
+            cctx.config().getBackups());
+
+        List<List<ClusterNode>> calcAff2 = func.assignPartitions(ctx);
+
+        Set<Integer> movedParts = new HashSet<>();
+
+        UUID locId = ign.cluster().localNode().id();
+
+        for (int i = 0; i < calcAff.size(); i++) {
+            if (calcAff.get(i).get(0).id().equals(locId) && !calcAff2.get(i).get(0).id().equals(locId))
+                movedParts.add(i);
+        }
+
+        List<Integer> keys = new ArrayList<>();
+
+        Affinity<Integer> aff = ign.affinity(cacheName);
+
+        for (int i = 0; i < 10_000; i++) {
+            int keyPart = aff.partition(i);
+
+            if (movedParts.contains(keyPart)) {
+                keys.add(i);
+
+                if (keys.size() == size)
+                    break;
+            }
+        }
+
+        assertEquals("Failed to find moving keys [movedPats=" + movedParts + ", keys=" + keys + ']', size, keys.size());
+
+        return keys;
+    }
+
+    /**
      * @param cache Cache.
      * @return Collection of keys for which given cache is primary.
      * @throws IgniteCheckedException If failed.


[07/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/RandomVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/RandomVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/RandomVectorConstructorTest.java
deleted file mode 100644
index 6d4e4f1..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/RandomVectorConstructorTest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/** */
-public class RandomVectorConstructorTest {
-    /** */
-    private static final int IMPOSSIBLE_SIZE = -1;
-
-    /** */
-    @Test(expected = org.apache.ignite.math.exceptions.UnsupportedOperationException.class)
-    public void mapInvalidArgsTest() {
-        assertEquals("Expect exception due to invalid args.", IMPOSSIBLE_SIZE,
-            new RandomVector(new HashMap<String, Object>() {{
-                put("invalid", 99);
-            }}).size());
-    }
-
-    /** */
-    @Test(expected = UnsupportedOperationException.class)
-    public void mapMissingArgsTest() {
-        final Map<String, Object> test = new HashMap<String, Object>() {{
-            put("paramMissing", "whatever");
-        }};
-
-        assertEquals("Expect exception due to missing args.",
-            -1, new RandomVector(test).size());
-    }
-
-    /** */
-    @Test(expected = ClassCastException.class)
-    public void mapInvalidParamTypeTest() {
-        final Map<String, Object> test = new HashMap<String, Object>() {{
-            put("size", "whatever");
-            put("fastHash", true);
-        }};
-
-        assertEquals("Expect exception due to invalid param type.", IMPOSSIBLE_SIZE,
-            new RandomVector(test).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void mapNullTest() {
-        //noinspection ConstantConditions
-        assertEquals("Null map args.", IMPOSSIBLE_SIZE,
-            new RandomVector(null).size());
-    }
-
-    /** */
-    @Test
-    public void mapTest() {
-        assertEquals("Size from args.", 99,
-            new RandomVector(new HashMap<String, Object>() {{
-                put("size", 99);
-            }}).size());
-
-        final int test = 99;
-
-        assertEquals("Size from args with fastHash false.", test,
-            new RandomVector(new HashMap<String, Object>() {{
-                put("size", test);
-                put("fastHash", false);
-            }}).size());
-
-        assertEquals("Size from args with fastHash true.", test,
-            new RandomVector(new HashMap<String, Object>() {{
-                put("size", test);
-                put("fastHash", true);
-            }}).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void negativeSizeTest() {
-        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
-            new RandomVector(-1).size());
-    }
-
-    /** */
-    @Test
-    public void basicTest() {
-        final int basicSize = 3;
-
-        Vector v1 = new RandomVector(basicSize);
-
-        //noinspection EqualsWithItself
-        assertTrue("Expect vector to be equal to self", v1.equals(v1));
-
-        //noinspection ObjectEqualsNull
-        assertFalse("Expect vector to be not equal to null", v1.equals(null));
-
-        assertEquals("Size differs from expected", basicSize, v1.size());
-
-        verifyValues(v1);
-
-        Vector v2 = new RandomVector(basicSize, true);
-
-        assertEquals("Size differs from expected", basicSize, v2.size());
-
-        verifyValues(v2);
-
-        Vector v3 = new RandomVector(basicSize, false);
-
-        assertEquals("Size differs from expected", basicSize, v3.size());
-
-        verifyValues(v3);
-    }
-
-    /** */
-    private void verifyValues(Vector v) {
-        for (Vector.Element e : v.all()) {
-            double val = e.get();
-
-            assertTrue("Value too small: " + val + " at index " + e.index(), -1d <= val);
-
-            assertTrue("Value too large: " + val + " at index " + e.index(), val <= 1d);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/SingleElementVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/SingleElementVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/SingleElementVectorConstructorTest.java
deleted file mode 100644
index 69e22e0..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/SingleElementVectorConstructorTest.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/** */
-public class SingleElementVectorConstructorTest {
-    /** */
-    private static final int IMPOSSIBLE_SIZE = -1;
-
-    /** */
-    @Test(expected = UnsupportedOperationException.class)
-    public void mapInvalidArgsTest() {
-        assertEquals("Expect exception due to invalid args.", IMPOSSIBLE_SIZE,
-            new SingleElementVector(new HashMap<String, Object>() {{
-                put("invalid", 99);
-            }}).size());
-    }
-
-    /** */
-    @Test(expected = UnsupportedOperationException.class)
-    public void mapMissingArgsTest() {
-        final Map<String, Object> test = new HashMap<String, Object>() {{
-            put("size", 1);
-
-            put("paramMissing", "whatever");
-        }};
-
-        assertEquals("Expect exception due to missing args.",
-            -1, new SingleElementVector(test).size());
-    }
-
-    /** */
-    @Test(expected = ClassCastException.class)
-    public void mapInvalidParamTypeTest() {
-        final Map<String, Object> test = new HashMap<String, Object>() {{
-            put("size", "whatever");
-
-            put("index", 0);
-            put("value", 1.0);
-        }};
-
-        assertEquals("Expect exception due to invalid param type.", IMPOSSIBLE_SIZE,
-            new SingleElementVector(test).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void mapNullTest() {
-        //noinspection ConstantConditions
-        assertEquals("Null map args.", IMPOSSIBLE_SIZE,
-            new SingleElementVector(null).size());
-    }
-
-    /** */
-    @Test
-    public void mapTest() {
-        assertEquals("Size from array in args.", 99,
-            new SingleElementVector(new HashMap<String, Object>() {{
-                put("size", 99);
-                put("index", 0);
-                put("value", 1.0);
-            }}).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void negativeSizeTest() {
-        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
-            new SingleElementVector(-1, 0, 1.0).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void zeroSizeTest() {
-        assertEquals("Zero size.", IMPOSSIBLE_SIZE,
-            new SingleElementVector(0, 0, 1.0).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void wrongIndexTest() {
-        //noinspection ConstantConditions
-        assertEquals("Wrong index.", IMPOSSIBLE_SIZE,
-            new SingleElementVector(1, 2, 1.0).size());
-    }
-
-    /** */
-    @Test
-    public void basicTest() {
-        final int[] sizes = new int[] {1, 4, 8};
-
-        for (int size : sizes)
-            for (int idx = 0; idx < size; idx++)
-                basicTest(size, idx);
-    }
-
-    /** */
-    private void basicTest(int size, int idx) {
-        final Double expVal = (double)(size - idx);
-
-        Vector v = new SingleElementVector(size, idx, expVal);
-
-        assertTrue("Expect value " + expVal + " at index " + idx + " for size " + size,
-            expVal.equals(v.get(idx)));
-
-        final double delta = 1.0;
-
-        v.set(idx, expVal - delta);
-
-        assertTrue("Expect value " + expVal + " at index " + idx + " for size " + size,
-            expVal.equals(v.get(idx) + delta));
-
-        final Double zero = 0.0;
-
-        for (int i = 0; i < size; i++) {
-            if (i == idx)
-                continue;
-
-            assertTrue("Expect zero at index " + i + " for size " + size,
-                zero.equals(v.get(i)));
-
-            boolean eCaught = false;
-
-            try {
-                v.set(i, 1.0);
-            }
-            catch (UnsupportedOperationException uoe) {
-                eCaught = true;
-            }
-
-            assertTrue("Expect " + java.lang.UnsupportedOperationException.class.getSimpleName()
-                + " at index " + i + " for size " + size, eCaught);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/SingleElementVectorViewConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/SingleElementVectorViewConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/SingleElementVectorViewConstructorTest.java
deleted file mode 100644
index 957f3b7..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/SingleElementVectorViewConstructorTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/** */
-public class SingleElementVectorViewConstructorTest {
-    /** */
-    private static final int IMPOSSIBLE_SIZE = -1;
-
-    /** */
-    private static final SampleHelper helper = new SampleHelper();
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void nullVecParamTest() {
-        assertEquals("Expect exception due to null vector param.", IMPOSSIBLE_SIZE,
-            new SingleElementVectorView(null, helper.idx).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void negativeIdxParamTest() {
-        assertEquals("Expect exception due to negative index param.", IMPOSSIBLE_SIZE,
-            new SingleElementVectorView(helper.vec, -1).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void tooLargeIdxParamTest() {
-        assertEquals("Expect exception due to too large index param.", IMPOSSIBLE_SIZE,
-            new SingleElementVectorView(helper.vec, helper.vec.size()).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void emptyVecParamTest() {
-        assertEquals("Expect exception due to empty vector param.", IMPOSSIBLE_SIZE,
-            new SingleElementVectorView(helper.vecEmpty, 0).size());
-    }
-
-    /** */
-    @Test
-    public void basicTest() {
-        final int[] sizes = new int[] {1, 4, 8};
-
-        for (int size : sizes)
-            for (int idx = 0; idx < size; idx++)
-                basicTest(size, idx);
-    }
-
-    /** */
-    private void basicTest(int size, int idx) {
-        final Double expVal = (double)(size - idx);
-
-        Vector orig = helper.newSample(size, idx, expVal);
-
-        SingleElementVectorView svv = new SingleElementVectorView(orig, idx);
-
-        assertEquals("Size differs from expected", size, svv.size());
-
-        assertTrue("Expect value " + expVal + " at index " + idx + " for size " + size,
-            expVal.equals(svv.get(idx)));
-
-        final double delta = 1.0;
-
-        svv.set(idx, expVal - delta);
-
-        assertTrue("Expect value " + expVal + " at index " + idx + " for size " + size,
-            expVal.equals(orig.get(idx) + delta));
-
-        final Double zero = 0.0;
-
-        for (int i = 0; i < size; i++) {
-            if (i == idx)
-                continue;
-
-            assertTrue("Expect zero at index " + i + " for size " + size,
-                zero.equals(svv.get(i)));
-
-            boolean eCaught = false;
-
-            try {
-                svv.set(i, 1.0);
-            }
-            catch (UnsupportedOperationException uoe) {
-                eCaught = true;
-            }
-
-            assertTrue("Expect " + UnsupportedOperationException.class.getSimpleName()
-                + " at index " + i + " for size " + size, eCaught);
-        }
-    }
-
-    /** */
-    private static class SampleHelper {
-        /** */
-        final double[] data = new double[] {0, 1};
-        /** */
-        final Vector vec = new DenseLocalOnHeapVector(data);
-        /** */
-        final Vector vecEmpty = new DenseLocalOnHeapVector(new double[] {});
-        /** */
-        final int idx = 0;
-
-        /** */
-        Vector newSample(int size, int idx, double expVal) {
-            final Vector v = new DenseLocalOnHeapVector(size);
-
-            for (int i = 0; i < size; i++)
-                v.set(i, i == idx ? expVal : i);
-
-            return v;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/SparseLocalVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/SparseLocalVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/SparseLocalVectorConstructorTest.java
deleted file mode 100644
index 2be4a10..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/SparseLocalVectorConstructorTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import org.apache.ignite.math.StorageConstants;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/** */
-public class SparseLocalVectorConstructorTest {
-    /** */
-    private static final int IMPOSSIBLE_SIZE = -1;
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void negativeSizeTest() {
-        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
-            new SparseLocalVector(-1, 1).size());
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void zeroSizeTest() {
-        assertEquals("0 size.", IMPOSSIBLE_SIZE,
-            new SparseLocalVector(0, 1).size());
-    }
-
-    /** */
-    @Test
-    public void primitiveTest() {
-        assertEquals("1 size, random access.", 1,
-            new SparseLocalVector(1, StorageConstants.RANDOM_ACCESS_MODE).size());
-
-        assertEquals("1 size, sequential access.", 1,
-            new SparseLocalVector(1, StorageConstants.SEQUENTIAL_ACCESS_MODE).size());
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorAttributesTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorAttributesTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorAttributesTest.java
deleted file mode 100644
index 992018a..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorAttributesTest.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.function.Function;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.matrix.DenseLocalOffHeapMatrix;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/** */
-public class VectorAttributesTest {
-    /** */
-    private final List<AttrCfg> attrCfgs = Arrays.asList(
-        new AttrCfg("isDense", Vector::isDense,
-            DenseLocalOnHeapVector.class, DenseLocalOffHeapVector.class, RandomVector.class, ConstantVector.class,
-            SingleElementVector.class),
-        new AttrCfg("isArrayBased", Vector::isArrayBased,
-            DenseLocalOnHeapVector.class),
-        new AttrCfg("isSequentialAccess", Vector::isSequentialAccess,
-            DenseLocalOnHeapVector.class, DenseLocalOffHeapVector.class, SparseLocalVectorSequentialAccess.class,
-            RandomVector.class, ConstantVector.class, SingleElementVector.class),
-        new AttrCfg("guidNotNull", v -> v.guid() == null), // IMPL NOTE this is somewhat artificial
-        new AttrCfg("isRandomAccess", Vector::isRandomAccess,
-            DenseLocalOnHeapVector.class, DenseLocalOffHeapVector.class, RandomVector.class, ConstantVector.class,
-            SingleElementVector.class, SparseLocalVectorSequentialAccess.class, SparseLocalVectorRandomAccess.class),
-        new AttrCfg("isDistributed", Vector::isDistributed));
-
-    /** */
-    private final List<Specification> specFixture = Arrays.asList(
-        new Specification(new DenseLocalOnHeapVector(1)),
-        new Specification(new DenseLocalOffHeapVector(1)),
-        new Specification(new DelegatingVector(new DenseLocalOnHeapVector(1)),
-            DenseLocalOnHeapVector.class, "isDense", "isArrayBased", "isSequentialAccess",
-            "isRandomAccess", "isDistributed"),
-        new Specification(new DelegatingVector(new DenseLocalOffHeapVector(1)),
-            DenseLocalOffHeapVector.class, "isDense", "isArrayBased", "isSequentialAccess",
-            "isRandomAccess", "isDistributed"),
-        new Specification(new SparseLocalVectorSequentialAccess(1)),
-        new Specification(new SparseLocalVectorRandomAccess(1)),
-        new Specification(new RandomVector(1)),
-        new Specification(new ConstantVector(1, 1.0)),
-        new Specification(new FunctionVector(1, idx -> (double)idx)),
-        new Specification(new SingleElementVector(1, 0, 1.0)),
-        new Specification(new PivotedVectorView(new DenseLocalOnHeapVector(1), new int[] {0}),
-            DenseLocalOnHeapVector.class, "isDense", "isArrayBased", "isSequentialAccess",
-            "isRandomAccess", "isDistributed"),
-        new Specification(new PivotedVectorView(new DenseLocalOffHeapVector(1), new int[] {0}),
-            DenseLocalOffHeapVector.class, "isDense", "isArrayBased", "isSequentialAccess",
-            "isRandomAccess", "isDistributed"),
-        new Specification(new SingleElementVectorView(new DenseLocalOnHeapVector(1), 0),
-            DenseLocalOnHeapVector.class, "isDense", "isSequentialAccess",
-            "isRandomAccess", "isDistributed"),
-        new Specification(new SingleElementVectorView(new DenseLocalOffHeapVector(1), 0),
-            DenseLocalOffHeapVector.class, "isDense", "isSequentialAccess",
-            "isRandomAccess", "isDistributed"),
-        new Specification(new MatrixVectorView(new DenseLocalOnHeapMatrix(1, 1), 0, 0, 1, 1),
-            DenseLocalOnHeapVector.class, "isDense",
-            "isRandomAccess", "isDistributed"), // todo find out why "isSequentialAccess" fails here
-        new Specification(new MatrixVectorView(new DenseLocalOffHeapMatrix(1, 1), 0, 0, 1, 1),
-            DenseLocalOffHeapVector.class, "isDense",
-            "isRandomAccess", "isDistributed"));
-
-    /** */
-    @Test
-    public void isDenseTest() {
-        assertAttribute("isDense");
-    }
-
-    /** */
-    @Test
-    public void isArrayBasedTest() {
-        assertAttribute("isArrayBased");
-    }
-
-    /** */
-    @Test
-    public void isSequentialAccessTest() {
-        assertAttribute("isSequentialAccess");
-    }
-
-    /** */
-    @Test
-    public void guidTest() {
-        assertAttribute("guidNotNull");
-    }
-
-    /** */
-    @Test
-    public void isRandomAccessTest() {
-        assertAttribute("isRandomAccess");
-    }
-
-    /** */
-    @Test
-    public void isDistributedTest() {
-        assertAttribute("isDistributed");
-    }
-
-    /** */
-    private void assertAttribute(String name) {
-        final AttrCfg attr = attrCfg(name);
-
-        for (Specification spec : specFixture)
-            spec.verify(attr);
-    }
-
-    /** */
-    private AttrCfg attrCfg(String name) {
-        for (AttrCfg attr : attrCfgs)
-            if (attr.name.equals(name))
-                return attr;
-
-        throw new IllegalArgumentException("Undefined attribute " + name);
-    }
-
-    /** See http://en.wikipedia.org/wiki/Specification_pattern */
-    private static class Specification {
-        /** */
-        private final Vector v;
-        /** */
-        private final Class<? extends Vector> underlyingType;
-        /** */
-        private final List<String> attrsFromUnderlying;
-        /** */
-        final String desc;
-
-        /** */
-        Specification(Vector v, Class<? extends Vector> underlyingType, String... attrsFromUnderlying) {
-            this.v = v;
-            this.underlyingType = underlyingType;
-            this.attrsFromUnderlying = Arrays.asList(attrsFromUnderlying);
-            final Class<? extends Vector> clazz = v.getClass();
-            desc = clazz.getSimpleName() + (clazz.equals(underlyingType)
-                ? "" : " (underlying type " + underlyingType.getSimpleName() + ")");
-        }
-
-        /** */
-        Specification(Vector v) {
-            this(v, v.getClass());
-        }
-
-        /** */
-        void verify(AttrCfg attr) {
-            final boolean obtained = attr.obtain.apply(v);
-
-            final Class<? extends Vector> typeToCheck
-                = attrsFromUnderlying.contains(attr.name) ? underlyingType : v.getClass();
-
-            final boolean exp = attr.trueInTypes.contains(typeToCheck);
-
-            assertEquals("Unexpected " + attr.name + " value for " + desc, exp, obtained);
-        }
-    }
-
-    /** */
-    private static class AttrCfg {
-        /** */
-        final String name;
-        /** */
-        final Function<Vector, Boolean> obtain;
-        /** */
-        final List<Class> trueInTypes;
-
-        /** */
-        AttrCfg(String name, Function<Vector, Boolean> obtain, Class... trueInTypes) {
-            this.name = name;
-            this.obtain = obtain;
-            this.trueInTypes = Arrays.asList(trueInTypes);
-        }
-    }
-
-    /** */
-    private static class SparseLocalVectorSequentialAccess extends SparseLocalVector {
-        /** */
-        public SparseLocalVectorSequentialAccess() {
-            // No-op.
-        }
-
-        /** */
-        SparseLocalVectorSequentialAccess(int size) {
-            super(size, SEQUENTIAL_ACCESS_MODE);
-        }
-    }
-
-    /** */
-    private static class SparseLocalVectorRandomAccess extends SparseLocalVector {
-        /** */
-        public SparseLocalVectorRandomAccess() {
-            // No-op.
-        }
-
-        /** */
-        SparseLocalVectorRandomAccess(int size) {
-            super(size, RANDOM_ACCESS_MODE);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorFoldMapTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorFoldMapTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorFoldMapTest.java
deleted file mode 100644
index 67eb8ba..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorFoldMapTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.Arrays;
-import java.util.function.BiConsumer;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.functions.Functions;
-import org.junit.Test;
-
-import static java.util.function.DoubleUnaryOperator.identity;
-import static org.junit.Assert.assertTrue;
-
-/** See also: {@link AbstractVectorTest} and {@link VectorToMatrixTest}. */
-public class VectorFoldMapTest {
-    /** */
-    @Test
-    public void mapVectorTest() {
-        operationVectorTest((operand1, operand2) -> operand1 + operand2, (Vector v1, Vector v2) -> v1.map(v2, Functions.PLUS));
-    }
-
-    /** */
-    @Test
-    public void mapDoubleFunctionTest() {
-        consumeSampleVectors((v, desc) -> operatorTest(v, desc,
-            (vec) -> vec.map(Functions.INV), (val) -> 1.0 / val));
-    }
-
-    /** */
-    @Test
-    public void mapBiFunctionTest() {
-        consumeSampleVectors((v, desc) -> operatorTest(v, desc,
-            (vec) -> vec.map(Functions.PLUS, 1.0), (val) -> 1.0 + val));
-    }
-
-    /** */
-    @Test
-    public void foldMapTest() {
-        toDoubleTest(
-            ref -> Arrays.stream(ref).map(identity()).sum(),
-            (v) -> v.foldMap(Functions.PLUS, Functions.IDENTITY, 0.0));
-    }
-
-    /** */
-    @Test
-    public void foldMapVectorTest() {
-        toDoubleTest(
-            ref -> 2.0 * Arrays.stream(ref).sum(),
-            (v) -> v.foldMap(v, Functions.PLUS, Functions.PLUS, 0.0));
-
-    }
-
-    /** */
-    private void operatorTest(Vector v, String desc, Function<Vector, Vector> op, Function<Double, Double> refOp) {
-        final int size = v.size();
-        final double[] ref = new double[size];
-
-        VectorImplementationsTest.ElementsChecker checker = new VectorImplementationsTest.ElementsChecker(v, ref, desc);
-
-        Vector actual = op.apply(v);
-
-        for (int idx = 0; idx < size; idx++)
-            ref[idx] = refOp.apply(ref[idx]);
-
-        checker.assertCloseEnough(actual, ref);
-    }
-
-    /** */
-    private void toDoubleTest(Function<double[], Double> calcRef, Function<Vector, Double> calcVec) {
-        consumeSampleVectors((v, desc) -> {
-            final int size = v.size();
-            final double[] ref = new double[size];
-
-            new VectorImplementationsTest.ElementsChecker(v, ref, desc); // IMPL NOTE this initialises vector and reference array
-
-            final VectorImplementationsTest.Metric metric = new VectorImplementationsTest.Metric(calcRef.apply(ref), calcVec.apply(v));
-
-            assertTrue("Not close enough at " + desc
-                + ", " + metric, metric.closeEnough());
-        });
-    }
-
-    /** */
-    private void operationVectorTest(BiFunction<Double, Double, Double> operation,
-        BiFunction<Vector, Vector, Vector> vecOperation) {
-        consumeSampleVectors((v, desc) -> {
-            // TODO find out if more elaborate testing scenario is needed or it's okay as is.
-            final int size = v.size();
-            final double[] ref = new double[size];
-
-            final VectorImplementationsTest.ElementsChecker checker = new VectorImplementationsTest.ElementsChecker(v, ref, desc);
-            final Vector operand = v.copy();
-
-            for (int idx = 0; idx < size; idx++)
-                ref[idx] = operation.apply(ref[idx], ref[idx]);
-
-            checker.assertCloseEnough(vecOperation.apply(v, operand), ref);
-        });
-    }
-
-    /** */
-    private void consumeSampleVectors(BiConsumer<Vector, String> consumer) {
-        new VectorImplementationsFixtures().consumeSampleVectors(null, consumer);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorImplementationsFixtures.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorImplementationsFixtures.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorImplementationsFixtures.java
deleted file mode 100644
index 5a46218..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorImplementationsFixtures.java
+++ /dev/null
@@ -1,655 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.BiConsumer;
-import java.util.function.BiFunction;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.function.Supplier;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.StorageConstants;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.math.impls.storage.vector.FunctionVectorStorage;
-import org.jetbrains.annotations.NotNull;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/** */
-class VectorImplementationsFixtures {
-    /** */
-    private static final List<Supplier<Iterable<Vector>>> suppliers = Arrays.asList(
-        (Supplier<Iterable<Vector>>)DenseLocalOnHeapVectorFixture::new,
-        (Supplier<Iterable<Vector>>)DenseLocalOffHeapVectorFixture::new,
-        (Supplier<Iterable<Vector>>)SparseLocalVectorFixture::new,
-        (Supplier<Iterable<Vector>>)RandomVectorFixture::new,
-        (Supplier<Iterable<Vector>>)ConstantVectorFixture::new,
-        (Supplier<Iterable<Vector>>)DelegatingVectorFixture::new,
-        (Supplier<Iterable<Vector>>)FunctionVectorFixture::new,
-        (Supplier<Iterable<Vector>>)SingleElementVectorFixture::new,
-        (Supplier<Iterable<Vector>>)PivotedVectorViewFixture::new,
-        (Supplier<Iterable<Vector>>)SingleElementVectorViewFixture::new,
-        (Supplier<Iterable<Vector>>)MatrixVectorViewFixture::new,
-        (Supplier<Iterable<Vector>>)SparseLocalOffHeapVectorFixture::new
-    );
-
-    /** */
-    void consumeSampleVectors(Consumer<Integer> paramsConsumer, BiConsumer<Vector, String> consumer) {
-        for (Supplier<Iterable<Vector>> fixtureSupplier : VectorImplementationsFixtures.suppliers) {
-            final Iterable<Vector> fixture = fixtureSupplier.get();
-
-            for (Vector v : fixture) {
-                if (paramsConsumer != null)
-                    paramsConsumer.accept(v.size());
-
-                consumer.accept(v, fixture.toString());
-            }
-        }
-    }
-
-    /** */
-    void selfTest() {
-        new VectorSizesExtraIterator<>("VectorSizesExtraIterator test",
-            (size, shallowCp) -> new DenseLocalOnHeapVector(new double[size], shallowCp),
-            null, "shallow copy", new Boolean[] {false, true, null}).selfTest();
-
-        new VectorSizesIterator("VectorSizesIterator test", DenseLocalOffHeapVector::new, null).selfTest();
-    }
-
-    /** */
-    private static class DenseLocalOnHeapVectorFixture extends VectorSizesExtraFixture<Boolean> {
-        /** */
-        DenseLocalOnHeapVectorFixture() {
-            super("DenseLocalOnHeapVector",
-                (size, shallowCp) -> new DenseLocalOnHeapVector(new double[size], shallowCp),
-                "shallow copy", new Boolean[] {false, true, null});
-        }
-    }
-
-    /** */
-    private static class DenseLocalOffHeapVectorFixture extends VectorSizesFixture {
-        /** */
-        DenseLocalOffHeapVectorFixture() {
-            super("DenseLocalOffHeapVector", DenseLocalOffHeapVector::new);
-        }
-    }
-
-    /** */
-    private static class SparseLocalVectorFixture extends VectorSizesExtraFixture<Integer> {
-        /** */
-        SparseLocalVectorFixture() {
-            super("SparseLocalVector", SparseLocalVector::new, "access mode",
-                new Integer[] {StorageConstants.SEQUENTIAL_ACCESS_MODE, StorageConstants.RANDOM_ACCESS_MODE, null});
-        }
-    }
-
-    /** */
-    private static class RandomVectorFixture extends VectorSizesFixture {
-        /** */
-        RandomVectorFixture() {
-            super("RandomVector", RandomVector::new);
-        }
-    }
-
-    /** */
-    private static class ConstantVectorFixture extends VectorSizesExtraFixture<Double> {
-        /** */
-        ConstantVectorFixture() {
-            super("ConstantVector", ConstantVector::new,
-                "value", new Double[] {-1.0, 0.0, 0.5, 1.0, 2.0, null});
-        }
-    }
-
-    /** */
-    private static class FunctionVectorFixture extends VectorSizesExtraFixture<Double> {
-        /** */
-        FunctionVectorFixture() {
-            super("FunctionVector",
-                (size, scale) -> new FunctionVectorForTest(new double[size], scale),
-                "scale", new Double[] {0.5, 1.0, 2.0, null});
-        }
-    }
-
-    /** */
-    private static class SingleElementVectorFixture implements Iterable<Vector> {
-        /** */
-        private final Supplier<TwoParamsIterator<Integer, Double>> iter;
-
-        /** */
-        private final AtomicReference<String> ctxDescrHolder = new AtomicReference<>("Iterator not started.");
-
-        /** */
-        SingleElementVectorFixture() {
-            iter = () -> new TwoParamsIterator<Integer, Double>("SingleElementVector",
-                null, ctxDescrHolder::set,
-                "size", new Integer[] {1, null},
-                "value", new Double[] {-1.0, 0.0, 0.5, 1.0, 2.0, null}) {
-
-                /** {@inheritDoc} */
-                @Override BiFunction<Integer, Double, Vector> ctor() {
-                    return (size, value) -> new SingleElementVector(size, 0, value);
-                }
-            };
-        }
-
-        /** {@inheritDoc} */
-        @NotNull
-        @Override public Iterator<Vector> iterator() {
-            return iter.get();//(
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
-            return ctxDescrHolder.get();
-        }
-    }
-
-    /** */
-    private static class PivotedVectorViewFixture extends VectorSizesFixture {
-        /** */
-        PivotedVectorViewFixture() {
-            super("PivotedVectorView", PivotedVectorViewFixture::pivotedVectorView);
-        }
-
-        /** */
-        private static PivotedVectorView pivotedVectorView(int size) {
-            final DenseLocalOnHeapVector vec = new DenseLocalOnHeapVector(size);
-
-            final int[] pivot = new int[size];
-
-            for (int idx = 0; idx < size; idx++)
-                pivot[idx] = size - 1 - idx;
-
-            PivotedVectorView tmp = new PivotedVectorView(vec, pivot);
-
-            final int[] unpivot = new int[size];
-
-            for (int idx = 0; idx < size; idx++)
-                unpivot[idx] = tmp.unpivot(idx);
-
-            final int[] idxRecovery = new int[size];
-
-            for (int idx = 0; idx < size; idx++)
-                idxRecovery[idx] = idx;
-
-            return new PivotedVectorView(new PivotedVectorView(tmp, unpivot), idxRecovery);
-        }
-    }
-
-    /** */
-    private static class SingleElementVectorViewFixture implements Iterable<Vector> {
-        /** */
-        private final Supplier<TwoParamsIterator<Integer, Double>> iter;
-
-        /** */
-        private final AtomicReference<String> ctxDescrHolder = new AtomicReference<>("Iterator not started.");
-
-        /** */
-        SingleElementVectorViewFixture() {
-            iter = () -> new TwoParamsIterator<Integer, Double>("SingleElementVectorView",
-                null, ctxDescrHolder::set,
-                "size", new Integer[] {1, null},
-                "value", new Double[] {-1.0, 0.0, 0.5, 1.0, 2.0, null}) {
-
-                /** {@inheritDoc} */
-                @Override BiFunction<Integer, Double, Vector> ctor() {
-                    return (size, value) -> new SingleElementVectorView(new SingleElementVector(size, 0, value), 0);
-                }
-            };
-        }
-
-        /** {@inheritDoc} */
-        @NotNull
-        @Override public Iterator<Vector> iterator() {
-            return iter.get();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
-            return ctxDescrHolder.get();
-        }
-    }
-
-    /** */
-    private static class MatrixVectorViewFixture extends VectorSizesExtraFixture<Integer> {
-        /** */
-        MatrixVectorViewFixture() {
-            super("MatrixVectorView",
-                MatrixVectorViewFixture::newView,
-                "stride kind", new Integer[] {0, 1, 2, null});
-        }
-
-        /** */
-        private static Vector newView(int size, int strideKind) {
-            final Matrix parent = new DenseLocalOnHeapMatrix(size, size);
-
-            return new MatrixVectorView(parent, 0, 0, strideKind != 1 ? 1 : 0, strideKind != 0 ? 1 : 0);
-        }
-    }
-
-    /** */
-    private static class VectorSizesExtraFixture<T> implements Iterable<Vector> {
-        /** */
-        private final Supplier<VectorSizesExtraIterator<T>> iter;
-
-        /** */
-        private final AtomicReference<String> ctxDescrHolder = new AtomicReference<>("Iterator not started.");
-
-        /** */
-        VectorSizesExtraFixture(String vectorKind, BiFunction<Integer, T, Vector> ctor, String extraParamName,
-            T[] extras) {
-            iter = () -> new VectorSizesExtraIterator<>(vectorKind, ctor, ctxDescrHolder::set, extraParamName, extras);
-        }
-
-        /** {@inheritDoc} */
-        @NotNull
-        @Override public Iterator<Vector> iterator() {
-            return iter.get();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
-            return ctxDescrHolder.get();
-        }
-    }
-
-    /** */
-    private static abstract class VectorSizesFixture implements Iterable<Vector> {
-        /** */
-        private final Supplier<VectorSizesIterator> iter;
-
-        /** */
-        private final AtomicReference<String> ctxDescrHolder = new AtomicReference<>("Iterator not started.");
-
-        /** */
-        VectorSizesFixture(String vectorKind, Function<Integer, Vector> ctor) {
-            iter = () -> new VectorSizesIterator(vectorKind, ctor, ctxDescrHolder::set);
-        }
-
-        /** {@inheritDoc} */
-        @NotNull
-        @Override public Iterator<Vector> iterator() {
-            return iter.get();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
-            return ctxDescrHolder.get();
-        }
-    }
-
-    /** */
-    private static class VectorSizesExtraIterator<T> extends VectorSizesIterator {
-        /** */
-        private final T[] extras;
-        /** */
-        private int extraIdx = 0;
-        /** */
-        private final BiFunction<Integer, T, Vector> ctor;
-        /** */
-        private final String extraParamName;
-
-        /**
-         * @param vectorKind Descriptive name to use for context logging.
-         * @param ctor Constructor for objects to iterate over.
-         * @param ctxDescrConsumer Context logging consumer.
-         * @param extraParamName Name of extra parameter to iterate over.
-         * @param extras Array of extra parameter values to iterate over.
-         */
-        VectorSizesExtraIterator(String vectorKind, BiFunction<Integer, T, Vector> ctor,
-            Consumer<String> ctxDescrConsumer, String extraParamName, T[] extras) {
-            super(vectorKind, null, ctxDescrConsumer);
-
-            this.ctor = ctor;
-            this.extraParamName = extraParamName;
-            this.extras = extras;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean hasNext() {
-            return super.hasNext() && hasNextExtra(extraIdx);
-        }
-
-        /** {@inheritDoc} */
-        @Override void nextIdx() {
-            assert extras[extraIdx] != null
-                : "Index(es) out of bound at " + VectorSizesExtraIterator.this;
-
-            if (hasNextExtra(extraIdx + 1)) {
-                extraIdx++;
-
-                return;
-            }
-
-            extraIdx = 0;
-
-            super.nextIdx();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
-            return "{" + super.toString() +
-                ", " + extraParamName + "=" + extras[extraIdx] +
-                '}';
-        }
-
-        /** {@inheritDoc} */
-        @Override BiFunction<Integer, Integer, Vector> ctor() {
-            return (size, delta) -> ctor.apply(size + delta, extras[extraIdx]);
-        }
-
-        /** */
-        void selfTest() {
-            final Set<Integer> extraIdxs = new HashSet<>();
-
-            int cnt = 0;
-
-            while (hasNext()) {
-                assertNotNull("Expect not null vector at " + this, next());
-
-                if (extras[extraIdx] != null)
-                    extraIdxs.add(extraIdx);
-
-                cnt++;
-            }
-
-            assertEquals("Extra param tested", extraIdxs.size(), extras.length - 1);
-
-            assertEquals("Combinations tested mismatch.",
-                7 * 3 * (extras.length - 1), cnt);
-        }
-
-        /** */
-        private boolean hasNextExtra(int idx) {
-            return extras[idx] != null;
-        }
-    }
-
-    /** */
-    private static class VectorSizesIterator extends TwoParamsIterator<Integer, Integer> {
-        /** */
-        private final Function<Integer, Vector> ctor;
-
-        /** */
-        VectorSizesIterator(String vectorKind, Function<Integer, Vector> ctor, Consumer<String> ctxDescrConsumer) {
-            super(vectorKind, null, ctxDescrConsumer,
-                "size", new Integer[] {2, 4, 8, 16, 32, 64, 128, null},
-                "size delta", new Integer[] {-1, 0, 1, null});
-
-            this.ctor = ctor;
-        }
-
-        /** {@inheritDoc} */
-        @Override BiFunction<Integer, Integer, Vector> ctor() {
-            return (size, delta) -> ctor.apply(size + delta);
-        }
-    }
-
-    /** */
-    private static class TwoParamsIterator<T, U> implements Iterator<Vector> {
-        /** */
-        private final T params1[];
-
-        /** */
-        private final U params2[];
-
-        /** */
-        private final String vectorKind;
-
-        /** */
-        private final String param1Name;
-
-        /** */
-        private final String param2Name;
-
-        /** */
-        private final BiFunction<T, U, Vector> ctor;
-
-        /** */
-        private final Consumer<String> ctxDescrConsumer;
-
-        /** */
-        private int param1Idx = 0;
-
-        /** */
-        private int param2Idx = 0;
-
-        /** */
-        TwoParamsIterator(String vectorKind, BiFunction<T, U, Vector> ctor,
-            Consumer<String> ctxDescrConsumer, String param1Name, T[] params1, String param2Name, U[] params2) {
-            this.param1Name = param1Name;
-            this.params1 = params1;
-
-            this.param2Name = param2Name;
-            this.params2 = params2;
-
-            this.vectorKind = vectorKind;
-
-            this.ctor = ctor;
-
-            this.ctxDescrConsumer = ctxDescrConsumer;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean hasNext() {
-            return hasNextParam1(param1Idx) && hasNextParam2(param2Idx);
-        }
-
-        /** {@inheritDoc} */
-        @Override public Vector next() {
-            if (!hasNext())
-                throw new NoSuchElementException(TwoParamsIterator.this.toString());
-
-            if (ctxDescrConsumer != null)
-                ctxDescrConsumer.accept(toString());
-
-            Vector res = ctor().apply(params1[param1Idx], params2[param2Idx]);
-
-            nextIdx();
-
-            return res;
-        }
-
-        /** */
-        void selfTest() {
-            final Set<Integer> sizeIdxs = new HashSet<>(), deltaIdxs = new HashSet<>();
-
-            int cnt = 0;
-
-            while (hasNext()) {
-                assertNotNull("Expect not null vector at " + this, next());
-
-                if (params1[param1Idx] != null)
-                    sizeIdxs.add(param1Idx);
-
-                if (params2[param2Idx] != null)
-                    deltaIdxs.add(param2Idx);
-
-                cnt++;
-            }
-
-            assertEquals("Sizes tested mismatch.", sizeIdxs.size(), params1.length - 1);
-
-            assertEquals("Deltas tested", deltaIdxs.size(), params2.length - 1);
-
-            assertEquals("Combinations tested mismatch.",
-                (params1.length - 1) * (params2.length - 1), cnt);
-        }
-
-        /** IMPL NOTE override in subclasses if needed */
-        void nextIdx() {
-            assert params1[param1Idx] != null && params2[param2Idx] != null
-                : "Index(es) out of bound at " + TwoParamsIterator.this;
-
-            if (hasNextParam2(param2Idx + 1)) {
-                param2Idx++;
-
-                return;
-            }
-
-            param2Idx = 0;
-
-            param1Idx++;
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
-            return vectorKind + "{" + param1Name + "=" + params1[param1Idx] +
-                ", " + param2Name + "=" + params2[param2Idx] +
-                '}';
-        }
-
-        /** IMPL NOTE override in subclasses if needed */
-        BiFunction<T, U, Vector> ctor() {
-            return ctor;
-        }
-
-        /** */
-        private boolean hasNextParam1(int idx) {
-            return params1[idx] != null;
-        }
-
-        /** */
-        private boolean hasNextParam2(int idx) {
-            return params2[idx] != null;
-        }
-    }
-
-    /** Delegating vector with dense local onheap vector */
-    private static class DelegatingVectorFixture implements Iterable<Vector> {
-
-        /** */
-        private final Supplier<VectorSizesExtraIterator<Boolean>> iter;
-
-        /** */
-        private final AtomicReference<String> ctxDescrHolder = new AtomicReference<>("Iterator not started.");
-
-        /** */
-        DelegatingVectorFixture() {
-            iter = () -> new VectorSizesExtraIterator<>("DelegatingVector with DenseLocalOnHeapVector",
-                (size, shallowCp) -> new DelegatingVector(new DenseLocalOnHeapVector(new double[size], shallowCp)),
-                ctxDescrHolder::set, "shallow copy", new Boolean[] {false, true, null});
-        }
-
-        /** {@inheritDoc} */
-        @NotNull
-        @Override public Iterator<Vector> iterator() {
-            return iter.get();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
-            return ctxDescrHolder.get();
-        }
-    }
-
-    /** Subclass tweaked for serialization */
-    private static class FunctionVectorForTest extends FunctionVector {
-        /** */
-        double[] arr;
-
-        /** */
-        double scale;
-
-        /** */
-        public FunctionVectorForTest() {
-            // No-op.
-        }
-
-        /** */
-        FunctionVectorForTest(double[] arr, double scale) {
-            super(arr.length, idx -> arr[idx] * scale, (idx, value) -> arr[idx] = value / scale);
-
-            this.arr = arr;
-
-            this.scale = scale;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws IOException {
-            super.writeExternal(out);
-
-            out.writeObject(arr);
-
-            out.writeDouble(scale);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-            super.readExternal(in);
-
-            arr = (double[])in.readObject();
-
-            scale = in.readDouble();
-
-            setStorage(new FunctionVectorStorage(arr.length, idx -> arr[idx] * scale, (idx, value) -> arr[idx] = value / scale));
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            int res = 1;
-
-            res = res * 37 + Double.hashCode(scale);
-            res = res * 37 + Integer.hashCode(getStorage().size());
-
-            return res;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object o) {
-            if (this == o)
-                return true;
-
-            if (o == null || getClass() != o.getClass())
-                return false;
-
-            FunctionVectorForTest that = (FunctionVectorForTest)o;
-
-            return new Double(scale).equals(that.scale)
-                && (arr != null ? Arrays.equals(arr, that.arr) : that.arr == null);
-        }
-    }
-
-    /** */
-    private static class SparseLocalOffHeapVectorFixture extends VectorSizesFixture {
-
-        /** */
-        SparseLocalOffHeapVectorFixture() {
-            super("SparseLocalOffHeapVector", SparseLocalOffHeapVector::new);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorImplementationsTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorImplementationsTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorImplementationsTest.java
deleted file mode 100644
index 0e61513..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorImplementationsTest.java
+++ /dev/null
@@ -1,860 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.Arrays;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.BiConsumer;
-import java.util.function.BiFunction;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.math.ExternalizeTest;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.CardinalityException;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/** See also: {@link AbstractVectorTest} and {@link VectorToMatrixTest}. */
-public class VectorImplementationsTest { // todo split this to smaller cohesive test classes
-    /** */
-    @Test
-    public void vectorImplementationsFixturesTest() {
-        new VectorImplementationsFixtures().selfTest();
-    }
-
-    /** */
-    @Test
-    public void setGetTest() {
-        consumeSampleVectors((v, desc) -> mutateAtIdxTest(v, desc, (vec, idx, val) -> {
-            vec.set(idx, val);
-
-            return val;
-        }));
-    }
-
-    /** */
-    @Test
-    public void setXTest() {
-        consumeSampleVectors((v, desc) -> mutateAtIdxTest(v, desc, (vec, idx, val) -> {
-            vec.setX(idx, val);
-
-            return val;
-        }));
-    }
-
-    /** */
-    @Test
-    public void incrementTest() {
-        consumeSampleVectors((v, desc) -> mutateAtIdxTest(v, desc, (vec, idx, val) -> {
-            double old = vec.get(idx);
-
-            vec.increment(idx, val);
-
-            return old + val;
-        }));
-    }
-
-    /** */
-    @Test
-    public void incrementXTest() {
-        consumeSampleVectors((v, desc) -> mutateAtIdxTest(v, desc, (vec, idx, val) -> {
-            double old = vec.getX(idx);
-
-            vec.incrementX(idx, val);
-
-            return old + val;
-        }));
-    }
-
-    /** */
-    @Test
-    public void operateXOutOfBoundsTest() {
-        consumeSampleVectors((v, desc) -> {
-            if (v instanceof DenseLocalOffHeapVector || v instanceof SparseLocalVector || v instanceof SparseLocalOffHeapVector)
-                return; // todo find out if it's OK to skip by instances here
-
-            boolean expECaught = false;
-
-            try {
-                v.getX(-1);
-            }
-            catch (ArrayIndexOutOfBoundsException | IgniteException e) {
-                expECaught = true;
-            }
-
-            if (!getXOutOfBoundsOK(v))
-                assertTrue("Expect exception at negative index getX in " + desc, expECaught);
-
-            expECaught = false;
-
-            try {
-                v.setX(-1, 0);
-            }
-            catch (ArrayIndexOutOfBoundsException | IgniteException e) {
-                expECaught = true;
-            }
-
-            assertTrue("Expect exception at negative index setX in " + desc, expECaught);
-
-            expECaught = false;
-
-            try {
-                v.incrementX(-1, 1);
-            }
-            catch (ArrayIndexOutOfBoundsException | IgniteException e) {
-                expECaught = true;
-            }
-
-            assertTrue("Expect exception at negative index incrementX in " + desc, expECaught);
-
-            expECaught = false;
-
-            try {
-                v.getX(v.size());
-            }
-            catch (ArrayIndexOutOfBoundsException | IgniteException e) {
-                expECaught = true;
-            }
-
-            if (!getXOutOfBoundsOK(v))
-                assertTrue("Expect exception at too large index getX in " + desc, expECaught);
-
-            expECaught = false;
-
-            try {
-                v.setX(v.size(), 1);
-            }
-            catch (ArrayIndexOutOfBoundsException | IgniteException e) {
-                expECaught = true;
-            }
-
-            assertTrue("Expect exception at too large index setX in " + desc, expECaught);
-
-            expECaught = false;
-
-            try {
-                v.incrementX(v.size(), 1);
-            }
-            catch (ArrayIndexOutOfBoundsException | IgniteException e) {
-                expECaught = true;
-            }
-
-            assertTrue("Expect exception at too large index incrementX in " + desc, expECaught);
-        });
-    }
-
-    /** */
-    @Test
-    public void sizeTest() {
-        final AtomicReference<Integer> expSize = new AtomicReference<>(0);
-
-        consumeSampleVectors(
-            expSize::set,
-            (v, desc) -> assertEquals("Expected size for " + desc,
-                (int)expSize.get(), v.size())
-        );
-    }
-
-    /** */
-    @Test
-    public void getElementTest() {
-        consumeSampleVectors((v, desc) -> new ElementsChecker(v, desc).assertCloseEnough(v));
-    }
-
-    /** */
-    @Test
-    public void copyTest() {
-        consumeSampleVectors((v, desc) -> new ElementsChecker(v, desc).assertCloseEnough(v.copy()));
-    }
-
-    /** */
-    @Test
-    public void divideTest() {
-        operationTest((val, operand) -> val / operand, Vector::divide);
-    }
-
-    /** */
-    @Test
-    public void likeTest() {
-        for (int card : new int[] {1, 2, 4, 8, 16, 32, 64, 128})
-            consumeSampleVectors((v, desc) -> {
-                Class<? extends Vector> expType = expLikeType(v);
-
-                if (expType == null) {
-                    try {
-                        v.like(card);
-                    }
-                    catch (UnsupportedOperationException uoe) {
-                        return;
-                    }
-
-                    fail("Expected exception wasn't caught for " + desc);
-
-                    return;
-                }
-
-                Vector vLike = v.like(card);
-
-                assertNotNull("Expect non-null like vector for " + expType.getSimpleName() + " in " + desc, vLike);
-                assertEquals("Expect size equal to cardinality at " + desc, card, vLike.size());
-
-                Class<? extends Vector> actualType = vLike.getClass();
-
-                assertTrue("Actual vector type " + actualType.getSimpleName()
-                        + " should be assignable from expected type " + expType.getSimpleName() + " in " + desc,
-                    actualType.isAssignableFrom(expType));
-            });
-    }
-
-    /** */
-    @Test
-    public void minusTest() {
-        operationVectorTest((operand1, operand2) -> operand1 - operand2, Vector::minus);
-    }
-
-    /** */
-    @Test
-    public void plusVectorTest() {
-        operationVectorTest((operand1, operand2) -> operand1 + operand2, Vector::plus);
-    }
-
-    /** */
-    @Test
-    public void plusDoubleTest() {
-        operationTest((val, operand) -> val + operand, Vector::plus);
-    }
-
-    /** */
-    @Test
-    public void timesVectorTest() {
-        operationVectorTest((operand1, operand2) -> operand1 * operand2, Vector::times);
-    }
-
-    /** */
-    @Test
-    public void timesDoubleTest() {
-        operationTest((val, operand) -> val * operand, Vector::times);
-    }
-
-    /** */
-    @Test
-    public void viewPartTest() {
-        consumeSampleVectors((v, desc) -> {
-            final int size = v.size();
-            final double[] ref = new double[size];
-            final int delta = size > 32 ? 3 : 1; // IMPL NOTE this is for faster test execution
-
-            final ElementsChecker checker = new ElementsChecker(v, ref, desc);
-
-            for (int off = 0; off < size; off += delta)
-                for (int len = 1; len < size - off; len += delta)
-                    checker.assertCloseEnough(v.viewPart(off, len), Arrays.copyOfRange(ref, off, off + len));
-        });
-    }
-
-    /** */
-    @Test
-    public void sumTest() {
-        toDoubleTest(
-            ref -> Arrays.stream(ref).sum(),
-            Vector::sum);
-    }
-
-    /** */
-    @Test
-    public void minValueTest() {
-        toDoubleTest(
-            ref -> Arrays.stream(ref).min().getAsDouble(),
-            Vector::minValue);
-    }
-
-    /** */
-    @Test
-    public void maxValueTest() {
-        toDoubleTest(
-            ref -> Arrays.stream(ref).max().getAsDouble(),
-            Vector::maxValue);
-    }
-
-    /** */
-    @Test
-    public void sortTest() {
-        consumeSampleVectors((v, desc) -> {
-            if (readOnly(v) || !v.isArrayBased()) {
-                boolean expECaught = false;
-
-                try {
-                    v.sort();
-                }
-                catch (UnsupportedOperationException uoe) {
-                    expECaught = true;
-                }
-
-                assertTrue("Expected exception was not caught for sort in " + desc, expECaught);
-
-                return;
-            }
-
-            final int size = v.size();
-            final double[] ref = new double[size];
-
-            new ElementsChecker(v, ref, desc).assertCloseEnough(v.sort(), Arrays.stream(ref).sorted().toArray());
-        });
-    }
-
-    /** */
-    @Test
-    public void metaAttributesTest() {
-        consumeSampleVectors((v, desc) -> {
-            assertNotNull("Null meta storage in " + desc, v.getMetaStorage());
-
-            final String key = "test key";
-            final String val = "test value";
-            final String details = "key [" + key + "] for " + desc;
-
-            v.setAttribute(key, val);
-            assertTrue("Expect to have meta attribute for " + details, v.hasAttribute(key));
-            assertEquals("Unexpected meta attribute value for " + details, val, v.getAttribute(key));
-
-            v.removeAttribute(key);
-            assertFalse("Expect not to have meta attribute for " + details, v.hasAttribute(key));
-            assertNull("Unexpected meta attribute value for " + details, v.getAttribute(key));
-        });
-    }
-
-    /** */
-    @Test
-    public void assignDoubleTest() {
-        consumeSampleVectors((v, desc) -> {
-            if (readOnly(v))
-                return;
-
-            for (double val : new double[] {0, -1, 0, 1}) {
-                v.assign(val);
-
-                for (int idx = 0; idx < v.size(); idx++) {
-                    final Metric metric = new Metric(val, v.get(idx));
-
-                    assertTrue("Not close enough at index " + idx + ", val " + val + ", " + metric
-                        + ", " + desc, metric.closeEnough());
-                }
-            }
-        });
-    }
-
-    /** */
-    @Test
-    public void assignDoubleArrTest() {
-        consumeSampleVectors((v, desc) -> {
-            if (readOnly(v))
-                return;
-
-            final int size = v.size();
-            final double[] ref = new double[size];
-
-            final ElementsChecker checker = new ElementsChecker(v, ref, desc);
-
-            for (int idx = 0; idx < size; idx++)
-                ref[idx] = -ref[idx];
-
-            v.assign(ref);
-
-            checker.assertCloseEnough(v, ref);
-
-            assignDoubleArrWrongCardinality(v, desc);
-        });
-    }
-
-    /** */
-    @Test
-    public void assignVectorTest() {
-        consumeSampleVectors((v, desc) -> {
-            if (readOnly(v))
-                return;
-
-            final int size = v.size();
-            final double[] ref = new double[size];
-
-            final ElementsChecker checker = new ElementsChecker(v, ref, desc);
-
-            for (int idx = 0; idx < size; idx++)
-                ref[idx] = -ref[idx];
-
-            v.assign(new DenseLocalOnHeapVector(ref));
-
-            checker.assertCloseEnough(v, ref);
-
-            assignVectorWrongCardinality(v, desc);
-        });
-    }
-
-    /** */
-    @Test
-    public void assignFunctionTest() {
-        consumeSampleVectors((v, desc) -> {
-            if (readOnly(v))
-                return;
-
-            final int size = v.size();
-            final double[] ref = new double[size];
-
-            final ElementsChecker checker = new ElementsChecker(v, ref, desc);
-
-            for (int idx = 0; idx < size; idx++)
-                ref[idx] = -ref[idx];
-
-            v.assign((idx) -> ref[idx]);
-
-            checker.assertCloseEnough(v, ref);
-        });
-    }
-
-    /** */
-    @Test
-    public void minElementTest() {
-        consumeSampleVectors((v, desc) -> {
-            final ElementsChecker checker = new ElementsChecker(v, desc);
-
-            final Vector.Element minE = v.minElement();
-
-            final int minEIdx = minE.index();
-
-            assertTrue("Unexpected index from minElement " + minEIdx + ", " + desc,
-                minEIdx >= 0 && minEIdx < v.size());
-
-            final Metric metric = new Metric(minE.get(), v.minValue());
-
-            assertTrue("Not close enough minElement at index " + minEIdx + ", " + metric
-                + ", " + desc, metric.closeEnough());
-
-            checker.assertNewMinElement(v);
-        });
-    }
-
-    /** */
-    @Test
-    public void maxElementTest() {
-        consumeSampleVectors((v, desc) -> {
-            final ElementsChecker checker = new ElementsChecker(v, desc);
-
-            final Vector.Element maxE = v.maxElement();
-
-            final int minEIdx = maxE.index();
-
-            assertTrue("Unexpected index from minElement " + minEIdx + ", " + desc,
-                minEIdx >= 0 && minEIdx < v.size());
-
-            final Metric metric = new Metric(maxE.get(), v.maxValue());
-
-            assertTrue("Not close enough maxElement at index " + minEIdx + ", " + metric
-                + ", " + desc, metric.closeEnough());
-
-            checker.assertNewMaxElement(v);
-        });
-    }
-
-    /** */
-    @Test
-    public void externalizeTest() {
-        (new ExternalizeTest<Vector>() {
-            /** {@inheritDoc} */
-            @Override public void externalizeTest() {
-                consumeSampleVectors((v, desc) -> {
-                    if (v instanceof SparseLocalOffHeapVector)
-                        return; //TODO: wait till SparseLocalOffHeapVector externalization support.
-
-                    externalizeTest(v);
-                });
-            }
-        }).externalizeTest();
-    }
-
-    /** */
-    @Test
-    public void hashCodeTest() {
-        consumeSampleVectors((v, desc) -> assertTrue("Zero hash code for " + desc, v.hashCode() != 0));
-    }
-
-    /** */
-    private boolean getXOutOfBoundsOK(Vector v) {
-        // todo find out if this is indeed OK
-        return v instanceof RandomVector || v instanceof ConstantVector
-            || v instanceof SingleElementVector || v instanceof SingleElementVectorView;
-    }
-
-    /** */
-    private void mutateAtIdxTest(Vector v, String desc, MutateAtIdx operation) {
-        if (readOnly(v)) {
-            if (v.size() < 1)
-                return;
-
-            boolean expECaught = false;
-
-            try {
-                operation.apply(v, 0, 1);
-            }
-            catch (UnsupportedOperationException uoe) {
-                expECaught = true;
-            }
-
-            assertTrue("Expect exception at attempt to mutate element in " + desc, expECaught);
-
-            return;
-        }
-
-        for (double val : new double[] {0, -1, 0, 1})
-            for (int idx = 0; idx < v.size(); idx++) {
-                double exp = operation.apply(v, idx, val);
-
-                final Metric metric = new Metric(exp, v.get(idx));
-
-                assertTrue("Not close enough at index " + idx + ", val " + val + ", " + metric
-                    + ", " + desc, metric.closeEnough());
-            }
-    }
-
-    /** */
-    private Class<? extends Vector> expLikeType(Vector v) {
-        Class<? extends Vector> clazz = v.getClass();
-
-        if (clazz.isAssignableFrom(PivotedVectorView.class) || clazz.isAssignableFrom(SingleElementVectorView.class))
-            return null;
-
-        if (clazz.isAssignableFrom(MatrixVectorView.class) || clazz.isAssignableFrom(DelegatingVector.class))
-            return DenseLocalOnHeapVector.class; // IMPL NOTE per fixture
-
-        return clazz;
-    }
-
-    /** */
-    private void toDoubleTest(Function<double[], Double> calcRef, Function<Vector, Double> calcVec) {
-        consumeSampleVectors((v, desc) -> {
-            final int size = v.size();
-            final double[] ref = new double[size];
-
-            new ElementsChecker(v, ref, desc); // IMPL NOTE this initialises vector and reference array
-
-            final Metric metric = new Metric(calcRef.apply(ref), calcVec.apply(v));
-
-            assertTrue("Not close enough at " + desc
-                + ", " + metric, metric.closeEnough());
-        });
-    }
-
-    /** */
-    private void operationVectorTest(BiFunction<Double, Double, Double> operation,
-        BiFunction<Vector, Vector, Vector> vecOperation) {
-        consumeSampleVectors((v, desc) -> {
-            // TODO find out if more elaborate testing scenario is needed or it's okay as is.
-            final int size = v.size();
-            final double[] ref = new double[size];
-
-            final ElementsChecker checker = new ElementsChecker(v, ref, desc);
-            final Vector operand = v.copy();
-
-            for (int idx = 0; idx < size; idx++)
-                ref[idx] = operation.apply(ref[idx], ref[idx]);
-
-            checker.assertCloseEnough(vecOperation.apply(v, operand), ref);
-
-            assertWrongCardinality(v, desc, vecOperation);
-        });
-    }
-
-    /** */
-    private void assignDoubleArrWrongCardinality(Vector v, String desc) {
-        boolean expECaught = false;
-
-        try {
-            v.assign(new double[v.size() + 1]);
-        }
-        catch (CardinalityException ce) {
-            expECaught = true;
-        }
-
-        assertTrue("Expect exception at too large size in " + desc, expECaught);
-
-        if (v.size() < 2)
-            return;
-
-        expECaught = false;
-
-        try {
-            v.assign(new double[v.size() - 1]);
-        }
-        catch (CardinalityException ce) {
-            expECaught = true;
-        }
-
-        assertTrue("Expect exception at too small size in " + desc, expECaught);
-    }
-
-    /** */
-    private void assignVectorWrongCardinality(Vector v, String desc) {
-        boolean expECaught = false;
-
-        try {
-            v.assign(new DenseLocalOnHeapVector(v.size() + 1));
-        }
-        catch (CardinalityException ce) {
-            expECaught = true;
-        }
-
-        assertTrue("Expect exception at too large size in " + desc, expECaught);
-
-        if (v.size() < 2)
-            return;
-
-        expECaught = false;
-
-        try {
-            v.assign(new DenseLocalOnHeapVector(v.size() - 1));
-        }
-        catch (CardinalityException ce) {
-            expECaught = true;
-        }
-
-        assertTrue("Expect exception at too small size in " + desc, expECaught);
-    }
-
-    /** */
-    private void assertWrongCardinality(
-        Vector v, String desc, BiFunction<Vector, Vector, Vector> vecOperation) {
-        boolean expECaught = false;
-
-        try {
-            vecOperation.apply(v, new DenseLocalOnHeapVector(v.size() + 1));
-        }
-        catch (CardinalityException ce) {
-            expECaught = true;
-        }
-
-        assertTrue("Expect exception at too large size in " + desc, expECaught);
-
-        if (v.size() < 2)
-            return;
-
-        expECaught = false;
-
-        try {
-            vecOperation.apply(v, new DenseLocalOnHeapVector(v.size() - 1));
-        }
-        catch (CardinalityException ce) {
-            expECaught = true;
-        }
-
-        assertTrue("Expect exception at too small size in " + desc, expECaught);
-    }
-
-    /** */
-    private void operationTest(BiFunction<Double, Double, Double> operation,
-        BiFunction<Vector, Double, Vector> vecOperation) {
-        for (double val : new double[] {0, 0.1, 1, 2, 10})
-            consumeSampleVectors((v, desc) -> {
-                final int size = v.size();
-                final double[] ref = new double[size];
-
-                final ElementsChecker checker = new ElementsChecker(v, ref, "val " + val + ", " + desc);
-
-                for (int idx = 0; idx < size; idx++)
-                    ref[idx] = operation.apply(ref[idx], val);
-
-                checker.assertCloseEnough(vecOperation.apply(v, val), ref);
-            });
-    }
-
-    /** */
-    private void consumeSampleVectors(BiConsumer<Vector, String> consumer) {
-        consumeSampleVectors(null, consumer);
-    }
-
-    /** */
-    private void consumeSampleVectors(Consumer<Integer> paramsConsumer, BiConsumer<Vector, String> consumer) {
-        new VectorImplementationsFixtures().consumeSampleVectors(paramsConsumer, consumer);
-    }
-
-    /** */
-    private static boolean readOnly(Vector v) {
-        return v instanceof RandomVector || v instanceof ConstantVector;
-    }
-
-    /** */
-    private interface MutateAtIdx {
-        /** */
-        double apply(Vector v, int idx, double val);
-    }
-
-    /** */
-    static class ElementsChecker {
-        /** */
-        private final String fixtureDesc;
-
-        /** */
-        private final double[] refReadOnly;
-
-        /** */
-        private final boolean nonNegative;
-
-        /** */
-        ElementsChecker(Vector v, double[] ref, String fixtureDesc, boolean nonNegative) {
-            this.fixtureDesc = fixtureDesc;
-
-            this.nonNegative = nonNegative;
-
-            refReadOnly = readOnly(v) && ref == null ? new double[v.size()] : null;
-
-            init(v, ref);
-        }
-
-        /** */
-        ElementsChecker(Vector v, double[] ref, String fixtureDesc) {
-            this(v, ref, fixtureDesc, false);
-        }
-
-        /** */
-        ElementsChecker(Vector v, String fixtureDesc) {
-            this(v, null, fixtureDesc);
-        }
-
-        /** */
-        void assertCloseEnough(Vector obtained, double[] exp) {
-            final int size = obtained.size();
-
-            for (int i = 0; i < size; i++) {
-                final Vector.Element e = obtained.getElement(i);
-
-                if (refReadOnly != null && exp == null)
-                    exp = refReadOnly;
-
-                final Metric metric = new Metric(exp == null ? generated(i) : exp[i], e.get());
-
-                assertEquals("Unexpected vector index at " + fixtureDesc, i, e.index());
-                assertTrue("Not close enough at index " + i + ", size " + size + ", " + metric
-                    + ", " + fixtureDesc, metric.closeEnough());
-            }
-        }
-
-        /** */
-        void assertCloseEnough(Vector obtained) {
-            assertCloseEnough(obtained, null);
-        }
-
-        /** */
-        void assertNewMinElement(Vector v) {
-            if (readOnly(v))
-                return;
-
-            int exp = v.size() / 2;
-
-            v.set(exp, -(v.size() * 2 + 1));
-
-            assertEquals("Unexpected minElement index at " + fixtureDesc, exp, v.minElement().index());
-        }
-
-        /** */
-        void assertNewMaxElement(Vector v) {
-            if (readOnly(v))
-                return;
-
-            int exp = v.size() / 2;
-
-            v.set(exp, v.size() * 2 + 1);
-
-            assertEquals("Unexpected minElement index at " + fixtureDesc, exp, v.maxElement().index());
-        }
-
-        /** */
-        private void init(Vector v, double[] ref) {
-            if (readOnly(v)) {
-                initReadonly(v, ref);
-
-                return;
-            }
-
-            for (Vector.Element e : v.all()) {
-                int idx = e.index();
-
-                // IMPL NOTE introduce negative values because their absence
-                //    blocked catching an ugly bug in AbstractVector#kNorm
-                int val = generated(idx);
-
-                e.set(val);
-
-                if (ref != null)
-                    ref[idx] = val;
-            }
-        }
-
-        /** */
-        private void initReadonly(Vector v, double[] ref) {
-            if (refReadOnly != null)
-                for (Vector.Element e : v.all())
-                    refReadOnly[e.index()] = e.get();
-
-            if (ref != null)
-                for (Vector.Element e : v.all())
-                    ref[e.index()] = e.get();
-        }
-
-        /** */
-        private int generated(int idx) {
-            return nonNegative || (idx & 1) == 0 ? idx : -idx;
-        }
-    }
-
-    /** */
-    static class Metric { // todo consider if softer tolerance (like say 0.1 or 0.01) would make sense here
-        /** */
-        private final double exp;
-
-        /** */
-        private final double obtained;
-
-        /** **/
-        Metric(double exp, double obtained) {
-            this.exp = exp;
-            this.obtained = obtained;
-        }
-
-        /** */
-        boolean closeEnough() {
-            return new Double(exp).equals(obtained) || closeEnoughToZero();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return "Metric{" + "expected=" + exp +
-                ", obtained=" + obtained +
-                '}';
-        }
-
-        /** */
-        private boolean closeEnoughToZero() {
-            return (new Double(exp).equals(0.0) && new Double(obtained).equals(-0.0))
-                || (new Double(exp).equals(-0.0) && new Double(obtained).equals(0.0));
-        }
-    }
-}


[42/65] [abbrv] ignite git commit: IGNITE-4699: Added custom executors for compute tasls. This closes #1718.

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorSelfTest.java
new file mode 100644
index 0000000..18c52c0
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorSelfTest.java
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.compute;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskSplitAdapter;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.ExecutorConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteReducer;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Tests custom executor named pools.
+ *
+ * https://issues.apache.org/jira/browse/IGNITE-4699
+ */
+public class IgniteComputeCustomExecutorSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final int GRID_CNT = 2;
+
+    /** */
+    private static final String EXEC_NAME0 = "executor_0";
+
+    /** */
+    private static final String EXEC_NAME1 = "executor_1";
+
+    /** */
+    private static final String CACHE_NAME = "testcache";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        cfg.setExecutorConfiguration(createExecConfiguration(EXEC_NAME0), createExecConfiguration(EXEC_NAME1));
+        cfg.setPublicThreadPoolSize(1);
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+        ccfg.setName(CACHE_NAME);
+
+        cfg.setCacheConfiguration(ccfg);
+
+        return cfg;
+    }
+
+    /**
+     * @param name Custom executor name.
+     * @return Executor configuration.
+     */
+    private ExecutorConfiguration createExecConfiguration(String name) {
+        ExecutorConfiguration exec = new ExecutorConfiguration();
+
+        exec.setName(name);
+        exec.setSize(1);
+
+        return exec;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        startGrids(GRID_CNT);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If fails.
+     */
+    public void testInvalidCustomExecutor() throws Exception {
+        grid(0).compute().withExecutor("invalid").broadcast(new IgniteRunnable() {
+            @Override public void run() {
+                assertTrue(Thread.currentThread().getName().contains("pub"));
+            }
+        });
+    }
+
+    /**
+     * @throws Exception If fails.
+     */
+    public void testAllComputeApiByCustomExecutor() throws Exception {
+        IgniteCompute comp = grid(0).compute().withExecutor(EXEC_NAME0);
+
+        comp.affinityRun(CACHE_NAME, primaryKey(grid(1).cache(CACHE_NAME)), new IgniteRunnable() {
+            @Override public void run() {
+                assertTrue(Thread.currentThread().getName().contains(EXEC_NAME0));
+            }
+        });
+
+        comp.affinityCall(CACHE_NAME, 0, new IgniteCallable<Object>() {
+            @Override public Object call() throws Exception {
+                assertTrue(Thread.currentThread().getName().contains(EXEC_NAME0));
+                return null;
+            }
+        });
+
+        comp.broadcast(new IgniteRunnable() {
+            @Override public void run() {
+                assertTrue(Thread.currentThread().getName().contains(EXEC_NAME0));
+            }
+        });
+
+        comp.broadcast(new IgniteCallable<Object>() {
+            @Override public Object call() throws Exception {
+                assertTrue(Thread.currentThread().getName().contains(EXEC_NAME0));
+                return null;
+            }
+        });
+
+        comp.broadcast(new IgniteClosure<Object, Object>() {
+            @Override public Object apply(Object o) {
+                assertTrue(Thread.currentThread().getName().contains(EXEC_NAME0));
+                return null;
+            }
+        }, 0);
+
+        comp.apply(new IgniteClosure<Object, Object>() {
+            @Override public Object apply(Object o) {
+                assertTrue(Thread.currentThread().getName().contains(EXEC_NAME0));
+                return null;
+            }
+        }, 0);
+
+        comp.apply(new IgniteClosure<Integer, Object>() {
+            @Override public Object apply(Integer o) {
+                assertTrue(Thread.currentThread().getName().contains(EXEC_NAME0));
+                return null;
+            }
+        }, Collections.singletonList(0));
+
+        comp.apply(new IgniteClosure<Integer, Object>() {
+                       @Override public Object apply(Integer o) {
+                           assertTrue(Thread.currentThread().getName().contains(EXEC_NAME0));
+                           return null;
+                       }
+                   }, Collections.singletonList(0),
+            new IgniteReducer<Object, Object>() {
+                @Override public boolean collect(@Nullable Object o) {
+                    return true;
+                }
+
+                @Override public Object reduce() {
+                    return null;
+                }
+            });
+
+        List<IgniteCallable<Object>> calls = new ArrayList<>();
+
+        for (int i = 0; i < GRID_CNT * 2; ++i) {
+            calls.add(new IgniteCallable<Object>() {
+                @Override public Object call() throws Exception {
+                    assertTrue(Thread.currentThread().getName().contains(EXEC_NAME0));
+                    return null;
+                }
+            });
+        }
+
+        comp.call(calls.get(0));
+
+        comp.call(calls);
+
+        comp.call(calls,
+            new IgniteReducer<Object, Object>() {
+                @Override public boolean collect(@Nullable Object o) {
+                    return true;
+                }
+
+                @Override public Object reduce() {
+                    return null;
+                }
+            });
+
+        List<IgniteRunnable> runs = new ArrayList<>();
+
+        for (int i = 0; i < GRID_CNT * 2; ++i) {
+            runs.add(new IgniteRunnable() {
+                @Override public void run() {
+                    assertTrue(Thread.currentThread().getName().contains(EXEC_NAME0));
+                }
+            });
+        }
+
+        comp.run(runs.get(0));
+
+        comp.run(runs);
+
+        comp.execute(TestTask.class, null);
+    }
+
+    /**
+     * Test task
+     */
+    static class TestTask extends ComputeTaskSplitAdapter<Object, Object> {
+        /** {@inheritDoc} */
+        @Override protected Collection<? extends ComputeJob> split(int gridSize, Object arg) throws IgniteException {
+            List<ComputeJob> jobs = new ArrayList<>(gridSize * 2);
+
+            for (int i = 0; i < gridSize * 2; ++i) {
+                jobs.add(new ComputeJobAdapter() {
+                    @Override public Object execute() throws IgniteException {
+                        assertTrue(Thread.currentThread().getName().contains(EXEC_NAME0));
+
+                        return null;
+                    }
+                });
+            }
+
+            return jobs;
+        }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public Object reduce(List<ComputeJobResult> results) throws IgniteException {
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
index ff67b77..b8d1ce9 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
@@ -39,7 +39,7 @@ public class GridTestKernalContext extends GridKernalContextImpl {
     /**
      * @param log Logger to use in context config.
      */
-    public GridTestKernalContext(IgniteLogger log) throws IgniteCheckedException {
+    public GridTestKernalContext(IgniteLogger log) {
         this(log, new IgniteConfiguration());
     }
 
@@ -47,7 +47,7 @@ public class GridTestKernalContext extends GridKernalContextImpl {
      * @param log Logger to use in context config.
      * @param cfg Configuration to use in Test
      */
-    public GridTestKernalContext(IgniteLogger log, IgniteConfiguration cfg) throws IgniteCheckedException {
+    public GridTestKernalContext(IgniteLogger log, IgniteConfiguration cfg) {
         super(new GridLoggerProxy(log, null, null, null),
                 new IgniteKernal(null),
                 cfg,
@@ -67,6 +67,7 @@ public class GridTestKernalContext extends GridKernalContextImpl {
                 null,
                 null,
                 null,
+                null,
                 U.allPluginProviders()
         );
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
index abd74b3..3f3bc53 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
@@ -73,6 +73,8 @@ import org.apache.ignite.internal.TaskNodeRestartTest;
 import org.apache.ignite.internal.managers.checkpoint.GridCheckpointManagerSelfTest;
 import org.apache.ignite.internal.managers.checkpoint.GridCheckpointTaskSelfTest;
 import org.apache.ignite.internal.managers.communication.GridCommunicationManagerListenersSelfTest;
+import org.apache.ignite.internal.processors.compute.IgniteComputeCustomExecutorConfigurationSelfTest;
+import org.apache.ignite.internal.processors.compute.IgniteComputeCustomExecutorSelfTest;
 import org.apache.ignite.internal.processors.compute.PublicThreadpoolStarvationTest;
 import org.apache.ignite.internal.util.StripedExecutorTest;
 import org.apache.ignite.p2p.GridMultinodeRedeployContinuousModeSelfTest;
@@ -158,6 +160,9 @@ public class IgniteComputeGridTestSuite {
         suite.addTestSuite(PublicThreadpoolStarvationTest.class);
         suite.addTestSuite(StripedExecutorTest.class);
 
+        suite.addTestSuite(IgniteComputeCustomExecutorConfigurationSelfTest.class);
+        suite.addTestSuite(IgniteComputeCustomExecutorSelfTest.class);
+
         return suite;
     }
 }


[54/65] [abbrv] ignite git commit: ignite-4984 Fixed potential double processing of node failed event. Removed unused 'tryPut' operation.

Posted by ag...@apache.org.
ignite-4984 Fixed potential double processing of node failed event. Removed unused 'tryPut' operation.


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

Branch: refs/heads/ignite-5024
Commit: 0c1db6777bf0ef49b1219e90e2e2b932d17dfa82
Parents: 6e2c51d
Author: sboikov <sb...@gridgain.com>
Authored: Fri Apr 21 17:35:23 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Apr 21 17:35:23 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      |   6 -
 .../processors/cache/GridCacheAtomicFuture.java |   5 -
 .../processors/cache/GridCacheMvccManager.java  |  10 +-
 .../processors/cache/GridCacheProxyImpl.java    |  12 --
 .../cache/GridCacheTryPutFailedException.java   |  28 ----
 .../processors/cache/IgniteInternalCache.java   |  11 --
 .../dht/GridPartitionedSingleGetFuture.java     |   3 -
 .../GridDhtAtomicAbstractUpdateFuture.java      |   9 +-
 .../dht/atomic/GridDhtAtomicCache.java          |  54 +------
 .../atomic/GridDhtAtomicSingleUpdateFuture.java |   3 -
 .../dht/atomic/GridDhtAtomicUpdateFuture.java   |   3 -
 .../GridNearAtomicAbstractUpdateFuture.java     |  79 +++++++--
 .../GridNearAtomicSingleUpdateFuture.java       | 134 +++++-----------
 .../dht/atomic/GridNearAtomicUpdateFuture.java  | 159 +++++++------------
 .../distributed/near/GridNearAtomicCache.java   |   5 -
 .../cache/local/GridLocalLockFuture.java        |   3 -
 .../cache/hibernate/HibernateCacheProxy.java    |   5 -
 .../cache/hibernate/HibernateCacheProxy.java    |   5 -
 18 files changed, 180 insertions(+), 354 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 5438163..c9f7430 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -2708,12 +2708,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public V tryGetAndPut(K key, V val) throws IgniteCheckedException {
-        // Supported only in ATOMIC cache.
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
     @Nullable @Override public final V getAndPutIfAbsent(final K key, final V val) throws IgniteCheckedException {
         return getAndPut(key, val, ctx.noVal());
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicFuture.java
index 87ae29c..35e49c4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicFuture.java
@@ -25,11 +25,6 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
  */
 public interface GridCacheAtomicFuture<R> extends GridCacheFuture<R> {
     /**
-     * @return Future ID.
-     */
-    public long id();
-
-    /**
      * Gets future that will be completed when it is safe when update is finished on the given version of topology.
      *
      * @param topVer Topology version to finish.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index 712d136..3ae9f92 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -262,16 +262,8 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
             for (GridCacheFuture<?> fut : activeFutures())
                 fut.onNodeLeft(discoEvt.eventNode().id());
 
-            for (GridCacheAtomicFuture<?> cacheFut : atomicFuts.values()) {
+            for (GridCacheAtomicFuture<?> cacheFut : atomicFuts.values())
                 cacheFut.onNodeLeft(discoEvt.eventNode().id());
-
-                if (cacheFut.isCancelled() || cacheFut.isDone()) {
-                    long futId = cacheFut.id();
-
-                    if (futId > 0)
-                        atomicFuts.remove(futId, cacheFut);
-                }
-            }
         }
     };
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
index eaa448f..2979a57 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
@@ -1274,18 +1274,6 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public V tryGetAndPut(K key, V val) throws IgniteCheckedException {
-        CacheOperationContext prev = gate.enter(opCtx);
-
-        try {
-            return delegate.tryGetAndPut(key, val);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
     @Nullable @Override public <T> EntryProcessorResult<T> invoke(
         AffinityTopologyVersion topVer,
         K key,

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTryPutFailedException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTryPutFailedException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTryPutFailedException.java
deleted file mode 100644
index e4217e3..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTryPutFailedException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.IgniteCheckedException;
-
-/**
- * Try put failed exception.
- */
-public class GridCacheTryPutFailedException extends IgniteCheckedException {
-    /** */
-    private static final long serialVersionUID = 0L;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
index ca8c7fc..ce65fd2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
@@ -1887,17 +1887,6 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
     public V getTopologySafe(K key) throws IgniteCheckedException;
 
     /**
-     * Tries to get and put value in cache. Will fail with {@link GridCacheTryPutFailedException}
-     * if topology exchange is in progress.
-     *
-     * @param key Key.
-     * @param val value.
-     * @return Old value.
-     * @throws IgniteCheckedException In case of error.
-     */
-    @Nullable public V tryGetAndPut(K key, V val) throws IgniteCheckedException;
-
-    /**
      * @param topVer Locked topology version.
      * @param key Key.
      * @param entryProcessor Entry processor.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index 3dfae6f..dbf1fe1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -63,9 +63,6 @@ import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDh
  */
 public class GridPartitionedSingleGetFuture extends GridCacheFutureAdapter<Object> implements GridCacheFuture<Object>,
     CacheGetFuture {
-    /** */
-    private static final long serialVersionUID = 0L;
-
     /** Logger reference. */
     private static final AtomicReference<IgniteLogger> logRef = new AtomicReference<>();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateFuture.java
index 039cb99..5c7c027 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateFuture.java
@@ -60,9 +60,6 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC
  */
 public abstract class GridDhtAtomicAbstractUpdateFuture extends GridCacheFutureAdapter<Void>
     implements GridCacheAtomicFuture<Void> {
-    /** */
-    private static final long serialVersionUID = 0L;
-
     /** Logger. */
     protected static IgniteLogger log;
 
@@ -294,8 +291,10 @@ public abstract class GridDhtAtomicAbstractUpdateFuture extends GridCacheFutureA
         throw new UnsupportedOperationException();
     }
 
-    /** {@inheritDoc} */
-    @Override public final long id() {
+    /**
+     * @return Future ID.
+     */
+    final long id() {
         return futId;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 5bbfe14..e477592 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -643,7 +643,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             null,
             true,
             filter,
-            true,
             false).get();
     }
 
@@ -656,7 +655,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             null,
             false,
             filter,
-            true,
             false).get();
 
         assert res != null;
@@ -674,7 +672,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             null,
             true,
             filter,
-            true,
             true);
     }
 
@@ -688,26 +685,10 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             null,
             false,
             filter,
-            true,
             true);
     }
 
     /** {@inheritDoc} */
-    @Override public V tryGetAndPut(K key, V val) throws IgniteCheckedException {
-        A.notNull(key, "key", val, "val");
-
-        return (V)update0(
-            key,
-            val,
-            null,
-            null,
-            true,
-            null,
-            false,
-            false).get();
-    }
-
-    /** {@inheritDoc} */
     @Override protected void putAll0(Map<? extends K, ? extends V> m) throws IgniteCheckedException {
         updateAll0(m,
             null,
@@ -716,7 +697,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             null,
             false,
             false,
-            true,
             UPDATE,
             false).get();
     }
@@ -730,7 +710,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             null,
             false,
             false,
-            true,
             UPDATE,
             true).chain(RET2NULL);
     }
@@ -752,7 +731,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             null,
             false,
             false,
-            true,
             UPDATE,
             true);
     }
@@ -897,7 +875,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             args,
             false,
             null,
-            true,
             async);
 
         return fut.chain(new CX1<IgniteInternalFuture<Map<K, EntryProcessorResult<T>>>, EntryProcessorResult<T>>() {
@@ -968,7 +945,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             null,
             false,
             false,
-            true,
             TRANSFORM,
             async);
 
@@ -1000,7 +976,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             null,
             false,
             false,
-            true,
             TRANSFORM,
             false).get();
     }
@@ -1022,7 +997,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             null,
             false,
             false,
-            true,
             TRANSFORM,
             true);
     }
@@ -1037,7 +1011,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
      * @param conflictRmvMap Conflict remove map.
      * @param retval Return value required flag.
      * @param rawRetval Return {@code GridCacheReturn} instance.
-     * @param waitTopFut Whether to wait for topology future.
      * @param async Async operation flag.
      * @return Completion future.
      */
@@ -1050,7 +1023,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         @Nullable Map<KeyCacheObject, GridCacheVersion> conflictRmvMap,
         final boolean retval,
         final boolean rawRetval,
-        final boolean waitTopFut,
         final GridCacheOperation op,
         boolean async
     ) {
@@ -1127,8 +1099,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             opCtx != null && opCtx.skipStore(),
             opCtx != null && opCtx.isKeepBinary(),
             opCtx != null && opCtx.recovery(),
-            opCtx != null && opCtx.noRetries() ? 1 : MAX_RETRIES,
-            waitTopFut);
+            opCtx != null && opCtx.noRetries() ? 1 : MAX_RETRIES);
 
         if (async) {
             return asyncOp(new CO<IgniteInternalFuture<Object>>() {
@@ -1155,7 +1126,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
      * @param invokeArgs Invoke arguments.
      * @param retval Return value flag.
      * @param filter Filter.
-     * @param waitTopFut Whether to wait for topology future.
      * @param async Async operation flag.
      * @return Future.
      */
@@ -1166,7 +1136,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         @Nullable Object[] invokeArgs,
         final boolean retval,
         @Nullable final CacheEntryPredicate filter,
-        final boolean waitTopFut,
         boolean async
     ) {
         assert val == null || proc == null;
@@ -1178,7 +1147,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         ctx.checkSecurity(SecurityPermission.CACHE_PUT);
 
         final GridNearAtomicAbstractUpdateFuture updateFut =
-            createSingleUpdateFuture(key, val, proc, invokeArgs, retval, filter, waitTopFut);
+            createSingleUpdateFuture(key, val, proc, invokeArgs, retval, filter);
 
         if (async) {
             return asyncOp(new CO<IgniteInternalFuture<Object>>() {
@@ -1217,8 +1186,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             null,
             null,
             retval,
-            filter,
-            true);
+            filter);
 
         if (async) {
             return asyncOp(new CO<IgniteInternalFuture<Object>>() {
@@ -1245,7 +1213,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
      * @param invokeArgs Invoke arguments.
      * @param retval Return value flag.
      * @param filter Filter.
-     * @param waitTopFut Whether to wait for topology future.
      * @return Future.
      */
     private GridNearAtomicAbstractUpdateFuture createSingleUpdateFuture(
@@ -1254,8 +1221,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         @Nullable EntryProcessor proc,
         @Nullable Object[] invokeArgs,
         boolean retval,
-        @Nullable CacheEntryPredicate filter,
-        boolean waitTopFut
+        @Nullable CacheEntryPredicate filter
     ) {
         CacheOperationContext opCtx = ctx.operationContextPerCall();
 
@@ -1317,8 +1283,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                 opCtx != null && opCtx.skipStore(),
                 opCtx != null && opCtx.isKeepBinary(),
                 opCtx != null && opCtx.recovery(),
-                opCtx != null && opCtx.noRetries() ? 1 : MAX_RETRIES,
-                waitTopFut
+                opCtx != null && opCtx.noRetries() ? 1 : MAX_RETRIES
             );
         }
         else {
@@ -1341,8 +1306,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                 opCtx != null && opCtx.skipStore(),
                 opCtx != null && opCtx.isKeepBinary(),
                 opCtx != null && opCtx.recovery(),
-                opCtx != null && opCtx.noRetries() ? 1 : MAX_RETRIES,
-                waitTopFut);
+                opCtx != null && opCtx.noRetries() ? 1 : MAX_RETRIES);
         }
     }
 
@@ -1408,8 +1372,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             opCtx != null && opCtx.skipStore(),
             opCtx != null && opCtx.isKeepBinary(),
             opCtx != null && opCtx.recovery(),
-            opCtx != null && opCtx.noRetries() ? 1 : MAX_RETRIES,
-            true);
+            opCtx != null && opCtx.noRetries() ? 1 : MAX_RETRIES);
 
         if (async) {
             return asyncOp(new CO<IgniteInternalFuture<Object>>() {
@@ -3018,8 +2981,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             req.skipStore(),
             req.keepBinary(),
             req.recovery(),
-            MAX_RETRIES,
-            true);
+            MAX_RETRIES);
 
         updateFut.map();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateFuture.java
index 8ebe9c3..f053d21 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateFuture.java
@@ -37,9 +37,6 @@ import org.jetbrains.annotations.Nullable;
  */
 class GridDhtAtomicSingleUpdateFuture extends GridDhtAtomicAbstractUpdateFuture {
     /** */
-    private static final long serialVersionUID = 0L;
-
-    /** */
     private boolean allUpdated;
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
index 5d5ddf0..2a84445 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
@@ -36,9 +36,6 @@ import org.jetbrains.annotations.Nullable;
  */
 class GridDhtAtomicUpdateFuture extends GridDhtAtomicAbstractUpdateFuture {
     /** */
-    private static final long serialVersionUID = 0L;
-
-    /** */
     private int updateCntr;
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
index cf5aa19..6969971 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
@@ -55,6 +55,7 @@ import org.jetbrains.annotations.Nullable;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_ASYNC;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC;
+import static org.apache.ignite.internal.processors.cache.GridCacheOperation.TRANSFORM;
 
 /**
  * Base for near atomic update futures.
@@ -112,9 +113,6 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridCacheFuture
     /** Recovery flag. */
     protected final boolean recovery;
 
-    /** Wait for topology future flag. */
-    protected final boolean waitTopFut;
-
     /** Near cache flag. */
     protected final boolean nearEnabled;
 
@@ -137,9 +135,9 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridCacheFuture
     @GridToStringInclude
     protected CachePartialUpdateCheckedException err;
 
-    /** Future ID. */
+    /** Future ID, changes when operation is remapped. */
     @GridToStringInclude
-    protected volatile long futId;
+    protected long futId;
 
     /** Operation result. */
     protected GridCacheReturn opRes;
@@ -162,7 +160,6 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridCacheFuture
      * @param keepBinary Keep binary flag.
      * @param recovery {@code True} if cache operation is called in recovery mode.
      * @param remapCnt Remap count.
-     * @param waitTopFut Wait topology future flag.
      */
     protected GridNearAtomicAbstractUpdateFuture(
         GridCacheContext cctx,
@@ -179,8 +176,7 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridCacheFuture
         boolean skipStore,
         boolean keepBinary,
         boolean recovery,
-        int remapCnt,
-        boolean waitTopFut
+        int remapCnt
     ) {
         if (log == null) {
             msgLog = cctx.shared().atomicMessageLogger();
@@ -201,16 +197,27 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridCacheFuture
         this.skipStore = skipStore;
         this.keepBinary = keepBinary;
         this.recovery = recovery;
-        this.waitTopFut = waitTopFut;
 
         nearEnabled = CU.isNearEnabled(cctx);
 
-        if (!waitTopFut)
-            remapCnt = 1;
-
         this.remapCnt = remapCnt;
     }
 
+    /**
+     * @return {@code True} if future was initialized and waits for responses.
+     */
+    final boolean futureMapped() {
+        return topVer != AffinityTopologyVersion.ZERO;
+    }
+
+    /**
+     * @param futId Expected future ID.
+     * @return {@code True} if future was initialized with the same ID.
+     */
+    final boolean checkFutureId(long futId) {
+        return topVer != AffinityTopologyVersion.ZERO && this.futId == futId;
+    }
+
     /** {@inheritDoc} */
     @Override public final IgniteInternalFuture<Void> completeFuture(AffinityTopologyVersion topVer) {
         return null;
@@ -227,7 +234,7 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridCacheFuture
             onSendError(req, e);
         }
         catch (IgniteCheckedException e) {
-            onDone(e);
+            completeFuture(null, e, req.futureId());
         }
     }
 
@@ -336,6 +343,50 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridCacheFuture
     public abstract void onDhtResponse(UUID nodeId, GridDhtAtomicNearResponse res);
 
     /**
+     * @param ret Result.
+     * @param err Error.
+     * @param futId Not null ID if need remove future.
+     */
+    final void completeFuture(@Nullable GridCacheReturn ret, Throwable err, @Nullable Long futId) {
+        Object retval = ret == null ? null : rawRetval ? ret : (this.retval || op == TRANSFORM) ?
+                cctx.unwrapBinaryIfNeeded(ret.value(), keepBinary) : ret.success();
+
+        if (op == TRANSFORM && retval == null)
+            retval = Collections.emptyMap();
+
+        if (futId != null)
+            cctx.mvcc().removeAtomicFuture(futId);
+
+        super.onDone(retval, err);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("ConstantConditions")
+    @Override public final boolean onDone(@Nullable Object res, @Nullable Throwable err) {
+        assert err != null : "onDone should be called only to finish future with error on cache/node stop";
+
+        Long futId = null;
+
+        synchronized (this) {
+            if (futureMapped()) {
+                futId = this.futId;
+
+                topVer = AffinityTopologyVersion.ZERO;
+                this.futId = 0;
+            }
+        }
+
+        if (super.onDone(null, err)) {
+            if (futId != null)
+                cctx.mvcc().removeAtomicFuture(futId);
+
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
      * @param req Request.
      * @param res Response.
      */
@@ -533,7 +584,7 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridCacheFuture
          * @return Request if need process primary fail response, {@code null} otherwise.
          */
         @Nullable GridNearAtomicAbstractUpdateRequest onPrimaryFail() {
-            if (finished())
+            if (finished() || req.nodeFailedResponse())
                 return null;
 
             /*

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
index 1a8ae1c..6ffa373 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
@@ -36,7 +36,6 @@ import org.apache.ignite.internal.processors.cache.EntryProcessorResourceInjecto
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheOperation;
 import org.apache.ignite.internal.processors.cache.GridCacheReturn;
-import org.apache.ignite.internal.processors.cache.GridCacheTryPutFailedException;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearAtomicCache;
@@ -82,7 +81,6 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
      * @param keepBinary Keep binary flag.
      * @param recovery {@code True} if cache operation is called in recovery mode.
      * @param remapCnt Maximum number of retries.
-     * @param waitTopFut If {@code false} does not wait for affinity change future.
      */
     public GridNearAtomicSingleUpdateFuture(
         GridCacheContext cctx,
@@ -101,8 +99,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
         boolean skipStore,
         boolean keepBinary,
         boolean recovery,
-        int remapCnt,
-        boolean waitTopFut
+        int remapCnt
     ) {
         super(cctx,
             cache,
@@ -118,8 +115,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
             skipStore,
             keepBinary,
             recovery,
-            remapCnt,
-            waitTopFut);
+            remapCnt);
 
         assert subjId != null;
 
@@ -128,11 +124,6 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
     }
 
     /** {@inheritDoc} */
-    @Override public long id() {
-        return futId;
-    }
-
-    /** {@inheritDoc} */
     @Override public boolean onNodeLeft(UUID nodeId) {
         GridCacheReturn opRes0 = null;
         CachePartialUpdateCheckedException err0 = null;
@@ -142,10 +133,14 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
 
         boolean rcvAll = false;
 
+        long futId;
+
         synchronized (this) {
-            if (reqState == null)
+            if (!futureMapped())
                 return false;
 
+            futId = this.futId;
+
             if (reqState.req.nodeId.equals(nodeId)) {
                 GridNearAtomicAbstractUpdateRequest req = reqState.onPrimaryFail();
 
@@ -180,32 +175,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
         if (checkReq != null)
             sendCheckUpdateRequest(checkReq);
         else if (rcvAll)
-            finishUpdateFuture(opRes0, err0, remapTopVer0);
-
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("ConstantConditions")
-    @Override public boolean onDone(@Nullable Object res, @Nullable Throwable err) {
-        assert res == null || res instanceof GridCacheReturn;
-
-        GridCacheReturn ret = (GridCacheReturn)res;
-
-        Object retval = res == null ? null : rawRetval ? ret : (this.retval || op == TRANSFORM) ?
-            cctx.unwrapBinaryIfNeeded(ret.value(), keepBinary) : ret.success();
-
-        if (op == TRANSFORM && retval == null)
-            retval = Collections.emptyMap();
-
-        if (super.onDone(retval, err)) {
-            Long futVer = onFutureDone();
-
-            if (futVer != null)
-                cctx.mvcc().removeAtomicFuture(futVer);
-
-            return true;
-        }
+            finishUpdateFuture(opRes0, err0, remapTopVer0, futId);
 
         return false;
     }
@@ -217,7 +187,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
         AffinityTopologyVersion remapTopVer0;
 
         synchronized (this) {
-            if (futId == 0 || futId != res.futureId())
+            if (!checkFutureId(res.futureId()))
                 return;
 
             assert reqState != null;
@@ -240,12 +210,12 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
         if (errors != null) {
             assert errors.error() != null;
 
-            onDone(errors.error());
+            completeFuture(null, errors.error(), res.futureId());
 
             return;
         }
 
-        finishUpdateFuture(opRes0, err0, remapTopVer0);
+        finishUpdateFuture(opRes0, err0, remapTopVer0, res.futureId());
     }
 
     /** {@inheritDoc} */
@@ -259,7 +229,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
         CachePartialUpdateCheckedException err0 = null;
 
         synchronized (this) {
-            if (futId == 0 || futId != res.futureId())
+            if (!checkFutureId(res.futureId()))
                 return;
 
             req = reqState.processPrimaryResponse(nodeId, res);
@@ -311,7 +281,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
         }
 
         if (res.error() != null && res.failedKeys() == null) {
-            onDone(res.error());
+            completeFuture(null, res.error(), res.futureId());
 
             return;
         }
@@ -325,7 +295,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
         if (nearEnabled && !nodeErr)
             updateNear(req, res);
 
-        onDone(opRes0, err0);
+        completeFuture(opRes0, err0, res.futureId());
     }
 
     /**
@@ -333,7 +303,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
      */
     private AffinityTopologyVersion onAllReceived() {
         assert Thread.holdsLock(this);
-        assert futId > 0;
+        assert futureMapped() : this;
 
         AffinityTopologyVersion remapTopVer0 = null;
 
@@ -364,8 +334,8 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
             cctx.mvcc().removeAtomicFuture(futId);
 
             reqState = null;
-            futId = 0;
             topVer = AffinityTopologyVersion.ZERO;
+            futId = 0;
 
             remapTopVer = null;
         }
@@ -377,12 +347,6 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
      * @param remapTopVer New topology version.
      */
     private void waitAndRemap(AffinityTopologyVersion remapTopVer) {
-        if (!waitTopFut) {
-            onDone(new GridCacheTryPutFailedException());
-
-            return;
-        }
-
         if (topLocked) {
             CachePartialUpdateCheckedException e =
                 new CachePartialUpdateCheckedException("Failed to update keys (retry update if possible).");
@@ -394,7 +358,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
 
             e.add(Collections.singleton(cctx.toCacheKeyObject(key)), cause);
 
-            onDone(e);
+            completeFuture(null, e, null);
 
             return;
         }
@@ -437,8 +401,9 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
         AffinityTopologyVersion topVer;
 
         if (cache.topology().stopping()) {
-            onDone(new IgniteCheckedException("Failed to perform cache operation (cache is stopped): " +
-                cache.name()));
+            completeFuture(null,
+                new IgniteCheckedException("Failed to perform cache operation (cache is stopped): " + cache.name()),
+                null);
 
             return;
         }
@@ -449,7 +414,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
             Throwable err = fut.validateCache(cctx, recovery, /*read*/false, key, null);
 
             if (err != null) {
-                onDone(err);
+                completeFuture(null, err, null);
 
                 return;
             }
@@ -457,21 +422,17 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
             topVer = fut.topologyVersion();
         }
         else {
-            if (waitTopFut) {
-                assert !topLocked : this;
-
-                fut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
-                    @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> t) {
-                        cctx.kernalContext().closure().runLocalSafe(new Runnable() {
-                            @Override public void run() {
-                                mapOnTopology();
-                            }
-                        });
-                    }
-                });
-            }
-            else
-                onDone(new GridCacheTryPutFailedException());
+            assert !topLocked : this;
+
+            fut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
+                @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> t) {
+                    cctx.kernalContext().closure().runLocalSafe(new Runnable() {
+                        @Override public void run() {
+                            mapOnTopology();
+                        }
+                    });
+                }
+            });
 
             return;
         }
@@ -490,7 +451,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
             reqState0 = mapSingleUpdate(topVer, futId);
 
             synchronized (this) {
-                assert this.futId == 0 : this;
+                assert topVer.topologyVersion() > 0 : topVer;
                 assert this.topVer == AffinityTopologyVersion.ZERO : this;
 
                 this.topVer = topVer;
@@ -510,7 +471,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
         }
 
         if (err != null) {
-            onDone(err);
+            completeFuture(null, err, futId);
 
             return;
         }
@@ -519,7 +480,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
         sendSingleRequest(reqState0.req.nodeId(), reqState0.req);
 
         if (syncMode == FULL_ASYNC) {
-            onDone(new GridCacheReturn(cctx, true, true, null, true));
+            completeFuture(new GridCacheReturn(cctx, true, true, null, true), null, null);
 
             return;
         }
@@ -539,7 +500,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
         GridNearAtomicCheckUpdateRequest checkReq = null;
 
         synchronized (this) {
-            if (this.futId == 0 || this.futId != futId)
+            if (!checkFutureId(futId))
                 return;
 
             assert reqState != null;
@@ -560,22 +521,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
         if (checkReq != null)
             sendCheckUpdateRequest(checkReq);
         else
-            finishUpdateFuture(opRes0, err0, remapTopVer0);
-    }
-
-    /**
-     * @return Future ID.
-     */
-    private Long onFutureDone() {
-        Long id0;
-
-        synchronized (this) {
-            id0 = futId;
-
-            futId = 0;
-        }
-
-        return id0;
+            finishUpdateFuture(opRes0, err0, remapTopVer0, futId);
     }
 
     /**
@@ -712,10 +658,12 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
      * @param opRes Operation result.
      * @param err Operation error.
      * @param remapTopVer Not-null topology version if need remap update.
+     * @param futId Future ID.
      */
     private void finishUpdateFuture(GridCacheReturn opRes,
         CachePartialUpdateCheckedException err,
-        @Nullable AffinityTopologyVersion remapTopVer) {
+        @Nullable AffinityTopologyVersion remapTopVer,
+        long futId) {
         if (remapTopVer != null) {
             waitAndRemap(remapTopVer);
 
@@ -728,7 +676,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
             updateNear(reqState.req, reqState.req.response());
         }
 
-        onDone(opRes, err);
+        completeFuture(opRes, err, futId);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
index 82af2a6..46a3c34 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
@@ -39,7 +39,6 @@ import org.apache.ignite.internal.processors.cache.EntryProcessorResourceInjecto
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheOperation;
 import org.apache.ignite.internal.processors.cache.GridCacheReturn;
-import org.apache.ignite.internal.processors.cache.GridCacheTryPutFailedException;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearAtomicCache;
@@ -112,7 +111,6 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
      * @param skipStore Skip store flag.
      * @param keepBinary Keep binary flag.
      * @param remapCnt Maximum number of retries.
-     * @param waitTopFut If {@code false} does not wait for affinity change future.
      */
     public GridNearAtomicUpdateFuture(
         GridCacheContext cctx,
@@ -133,11 +131,23 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
         boolean skipStore,
         boolean keepBinary,
         boolean recovery,
-        int remapCnt,
-        boolean waitTopFut
+        int remapCnt
     ) {
-        super(cctx, cache, syncMode, op, invokeArgs, retval, rawRetval, expiryPlc, filter, subjId, taskNameHash,
-            skipStore, keepBinary, recovery, remapCnt, waitTopFut);
+        super(cctx,
+            cache,
+            syncMode,
+            op,
+            invokeArgs,
+            retval,
+            rawRetval,
+            expiryPlc,
+            filter,
+            subjId,
+            taskNameHash,
+            skipStore,
+            keepBinary,
+            recovery,
+            remapCnt);
 
         assert vals == null || vals.size() == keys.size();
         assert conflictPutVals == null || conflictPutVals.size() == keys.size();
@@ -151,11 +161,6 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
     }
 
     /** {@inheritDoc} */
-    @Override public long id() {
-        return futId;
-    }
-
-    /** {@inheritDoc} */
     @Override public boolean onNodeLeft(UUID nodeId) {
         GridCacheReturn opRes0 = null;
         CachePartialUpdateCheckedException err0 = null;
@@ -165,10 +170,14 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
 
         List<GridNearAtomicCheckUpdateRequest> checkReqs = null;
 
+        long futId;
+
         synchronized (this) {
-            if (futId == 0)
+            if (!futureMapped())
                 return false;
 
+            futId = this.futId;
+
             if (singleReq != null) {
                 if (singleReq.req.nodeId.equals(nodeId)) {
                     GridNearAtomicAbstractUpdateRequest req = singleReq.onPrimaryFail();
@@ -261,33 +270,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
                 sendCheckUpdateRequest(checkReqs.get(i));
         }
         else if (rcvAll)
-            finishUpdateFuture(opRes0, err0, remapTopVer0);
-
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("ConstantConditions")
-    @Override public boolean onDone(@Nullable Object res, @Nullable Throwable err) {
-        assert res == null || res instanceof GridCacheReturn;
-
-        GridCacheReturn ret = (GridCacheReturn)res;
-
-        Object retval =
-            res == null ? null : rawRetval ? ret : (this.retval || op == TRANSFORM) ?
-                cctx.unwrapBinaryIfNeeded(ret.value(), keepBinary) : ret.success();
-
-        if (op == TRANSFORM && retval == null)
-            retval = Collections.emptyMap();
-
-        if (super.onDone(retval, err)) {
-            Long futId = onFutureDone();
-
-            if (futId != null)
-                cctx.mvcc().removeAtomicFuture(futId);
-
-            return true;
-        }
+            finishUpdateFuture(opRes0, err0, remapTopVer0, futId);
 
         return false;
     }
@@ -299,7 +282,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
         AffinityTopologyVersion remapTopVer0;
 
         synchronized (this) {
-            if (futId == 0 || futId != res.futureId())
+            if (!checkFutureId(res.futureId()))
                 return;
 
             PrimaryRequestState reqState;
@@ -351,12 +334,12 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
         if (errors != null) {
             assert errors.error() != null;
 
-            onDone(errors.error());
+            completeFuture(null, errors.error(), res.futureId());
 
             return;
         }
 
-        finishUpdateFuture(opRes0, err0, remapTopVer0);
+        finishUpdateFuture(opRes0, err0, remapTopVer0, res.futureId());
     }
 
     /** {@inheritDoc} */
@@ -372,7 +355,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
         boolean rcvAll;
 
         synchronized (this) {
-            if (futId == 0 || futId != res.futureId())
+            if (!checkFutureId(res.futureId()))
                 return;
 
             if (singleReq != null) {
@@ -457,7 +440,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
         }
 
         if (res.error() != null && res.failedKeys() == null) {
-            onDone(res.error());
+            completeFuture(null, res.error(), res.futureId());
 
             return;
         }
@@ -483,18 +466,12 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
         }
 
         if (rcvAll)
-            onDone(opRes0, err0);
+            completeFuture(opRes0, err0, res.futureId());
     }
 
     private void waitAndRemap(AffinityTopologyVersion remapTopVer) {
         assert remapTopVer != null;
 
-        if (!waitTopFut) {
-            onDone(new GridCacheTryPutFailedException());
-
-            return;
-        }
-
         if (topLocked) {
             assert !F.isEmpty(remapKeys) : remapKeys;
 
@@ -508,7 +485,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
 
             e.add(remapKeys, cause);
 
-            onDone(e);
+            completeFuture(null, e, null);
 
             return;
         }
@@ -534,7 +511,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
      */
     @Nullable private AffinityTopologyVersion onAllReceived() {
         assert Thread.holdsLock(this);
-        assert futId > 0;
+        assert futureMapped() : this;
 
         AffinityTopologyVersion remapTopVer0 = null;
 
@@ -577,8 +554,8 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
         if (remapTopVer0 != null) {
             cctx.mvcc().removeAtomicFuture(futId);
 
-            futId = 0;
             topVer = AffinityTopologyVersion.ZERO;
+            futId = 0;
 
             remapTopVer = null;
         }
@@ -589,10 +566,13 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
     /**
      * @param opRes Operation result.
      * @param err Operation error.
+     * @param remapTopVer Not-null topology version if need remap update.
+     * @param futId Future ID.
      */
     private void finishUpdateFuture(GridCacheReturn opRes,
         CachePartialUpdateCheckedException err,
-        @Nullable AffinityTopologyVersion remapTopVer) {
+        @Nullable AffinityTopologyVersion remapTopVer,
+        long futId) {
         if (nearEnabled) {
             if (mappings != null) {
                 for (PrimaryRequestState reqState : mappings.values()) {
@@ -618,7 +598,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
             return;
         }
 
-        onDone(opRes, err);
+        completeFuture(opRes, err, futId);
     }
 
     /**
@@ -643,8 +623,9 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
         AffinityTopologyVersion topVer;
 
         if (cache.topology().stopping()) {
-            onDone(new IgniteCheckedException("Failed to perform cache operation (cache is stopped): " +
-                cache.name()));
+            completeFuture(null,
+                new IgniteCheckedException("Failed to perform cache operation (cache is stopped): " + cache.name()),
+                null);
 
             return;
         }
@@ -655,7 +636,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
             Throwable err = fut.validateCache(cctx, recovery, false, null, keys);
 
             if (err != null) {
-                onDone(err);
+                completeFuture(null, err, null);
 
                 return;
             }
@@ -663,21 +644,17 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
             topVer = fut.topologyVersion();
         }
         else {
-            if (waitTopFut) {
-                assert !topLocked : this;
-
-                fut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
-                    @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> t) {
-                        cctx.kernalContext().closure().runLocalSafe(new Runnable() {
-                            @Override public void run() {
-                                mapOnTopology();
-                            }
-                        });
-                    }
-                });
-            }
-            else
-                onDone(new GridCacheTryPutFailedException());
+            assert !topLocked : this;
+
+            fut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
+                @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> t) {
+                    cctx.kernalContext().closure().runLocalSafe(new Runnable() {
+                        @Override public void run() {
+                            mapOnTopology();
+                        }
+                    });
+                }
+            });
 
             return;
         }
@@ -745,7 +722,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
         }
 
         if (syncMode == FULL_ASYNC)
-            onDone(new GridCacheReturn(cctx, true, true, null, true));
+            completeFuture(new GridCacheReturn(cctx, true, true, null, true), null, null);
     }
 
     /** {@inheritDoc} */
@@ -761,8 +738,9 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
         Collection<ClusterNode> topNodes = CU.affinityNodes(cctx, topVer);
 
         if (F.isEmpty(topNodes)) {
-            onDone(new ClusterTopologyServerNotFoundException("Failed to map keys for cache (all partition nodes " +
-                "left the grid)."));
+            completeFuture(null,
+                new ClusterTopologyServerNotFoundException("Failed to map keys for cache (all partition nodes left the grid)."),
+                null);
 
             return;
         }
@@ -801,7 +779,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
             }
 
             synchronized (this) {
-                assert this.futId == 0 : this;
+                assert topVer.topologyVersion() > 0 : topVer;
                 assert this.topVer == AffinityTopologyVersion.ZERO : this;
 
                 this.topVer = topVer;
@@ -826,7 +804,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
         }
 
         if (err != null) {
-            onDone(err);
+            completeFuture(null, err, futId);
 
             return;
         }
@@ -838,7 +816,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
             assert mappings0 != null;
 
             if (size == 0) {
-                onDone(new GridCacheReturn(cctx, true, true, null, true));
+                completeFuture(new GridCacheReturn(cctx, true, true, null, true), null, futId);
 
                 return;
             }
@@ -847,7 +825,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
         }
 
         if (syncMode == FULL_ASYNC) {
-            onDone(new GridCacheReturn(cctx, true, true, null, true));
+            completeFuture(new GridCacheReturn(cctx, true, true, null, true), null, futId);
 
             return;
         }
@@ -866,7 +844,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
         boolean rcvAll = false;
 
         synchronized (this) {
-            if (this.futId == 0 || this.futId != futId)
+            if (!checkFutureId(futId))
                 return;
 
             if (singleReq != null) {
@@ -928,22 +906,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
                 sendCheckUpdateRequest(checkReqs.get(i));
         }
         else if (rcvAll)
-            finishUpdateFuture(opRes0, err0, remapTopVer0);
-    }
-
-    /**
-     * @return Future version.
-     */
-    private Long onFutureDone() {
-        Long id0;
-
-        synchronized (this) {
-            id0 = futId;
-
-            futId = 0;
-        }
-
-        return id0;
+            finishUpdateFuture(opRes0, err0, remapTopVer0, futId);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
index 422a3fc..2d5c8a5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
@@ -457,11 +457,6 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public V tryGetAndPut(K key, V val) throws IgniteCheckedException {
-        return dht.tryGetAndPut(key, val);
-    }
-
-    /** {@inheritDoc} */
     @Override public void putAll(Map<? extends K, ? extends V> m)
         throws IgniteCheckedException {
         dht.putAll(m);

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalLockFuture.java
index d8e95b9..59d0adb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalLockFuture.java
@@ -55,9 +55,6 @@ import org.jetbrains.annotations.Nullable;
  */
 public final class GridLocalLockFuture<K, V> extends GridCacheFutureAdapter<Boolean>
     implements GridCacheMvccFuture<Boolean> {
-    /** */
-    private static final long serialVersionUID = 0L;
-
     /** Logger reference. */
     private static final AtomicReference<IgniteLogger> logRef = new AtomicReference<>();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
index c814f9a..48fc1f8 100644
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
@@ -683,11 +683,6 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object>
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public Object tryGetAndPut(Object key, Object val) throws IgniteCheckedException {
-        return delegate.tryGetAndPut(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
     @Override public Collection<Integer> lostPartitions() {
         return delegate.lostPartitions();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c1db677/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
index c814f9a..48fc1f8 100644
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
+++ b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
@@ -683,11 +683,6 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object>
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public Object tryGetAndPut(Object key, Object val) throws IgniteCheckedException {
-        return delegate.tryGetAndPut(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
     @Override public Collection<Integer> lostPartitions() {
         return delegate.lostPartitions();
     }


[34/65] [abbrv] ignite git commit: IGNITE-5023 .NET: IgniteConfiguration.MemoryConfiguration

Posted by ag...@apache.org.
IGNITE-5023 .NET: IgniteConfiguration.MemoryConfiguration


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

Branch: refs/heads/ignite-5024
Commit: 800fb87a1c095edfdbeb090ea2125a6fcc0f742f
Parents: 6cc43ca
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Thu Apr 20 19:08:05 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Thu Apr 20 19:08:05 2017 +0300

----------------------------------------------------------------------
 .../configuration/DataPageEvictionMode.java     |  10 +-
 .../utils/PlatformConfigurationUtils.java       | 170 ++++++++++++++++---
 .../Cache/CacheConfigurationTest.cs             |  15 +-
 .../IgniteConfigurationSerializerTest.cs        |  48 ++++++
 .../IgniteConfigurationTest.cs                  |  56 ++++++
 .../Apache.Ignite.Core.csproj                   |   3 +
 .../Cache/Configuration/CacheConfiguration.cs   |   8 +
 .../Cache/Configuration/DataPageEvictionMode.cs |  59 +++++++
 .../Cache/Configuration/MemoryConfiguration.cs  | 151 ++++++++++++++++
 .../Configuration/MemoryPolicyConfiguration.cs  | 119 +++++++++++++
 .../Apache.Ignite.Core/IgniteConfiguration.cs   |  21 +++
 .../IgniteConfigurationSection.xsd              |  85 ++++++++++
 12 files changed, 714 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/800fb87a/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java b/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
index 91f707e..437721b 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
@@ -18,16 +18,16 @@
 package org.apache.ignite.configuration;
 
 /**
- * The enumeration defines an algorithm to be used for memory pages eviction. A mode is set for a specific
+ * Defines memory page eviction algorithm. A mode is set for a specific
  * {@link MemoryPolicyConfiguration}. Only data pages, that store key-value entries, are eligible for eviction. The
- * other types of pages like index or system pages are evictable.
+ * other types of pages, like index or system pages, are not evictable.
  */
 public enum DataPageEvictionMode {
     /** Eviction is disabled. */
     DISABLED,
 
     /**
-     * Activates Random-LRU algorithm that works the way below:
+     * Random-LRU algorithm.
      * <ul>
      * <li>Once a memory region defined by a memory policy is configured, an off-heap array is allocated to track
      * last usage timestamp for every individual data page. The size of the array is calculated this way - size =
@@ -36,13 +36,13 @@ public enum DataPageEvictionMode {
      * tracking array is calculated this way - index = (pageAddress / {@link MemoryPolicyConfiguration#getSize()}</li>
      * <li>When it's required to evict some pages, the algorithm randomly chooses 5 indexes from the tracking array and
      * evicts a page with the latest timestamp. If some of the indexes point to non-data pages (index or system pages)
-     * then the algorithm peaks another ones.</li>
+     * then the algorithm picks other pages.</li>
      * </ul>
      */
     RANDOM_LRU,
 
     /**
-     * Activates Random-2-LRU algorithm which is a scan resistant version of Random-LRU.
+     * Random-2-LRU algorithm: scan-resistant version of Random-LRU.
      * <p>
      * This algorithm differs from Random-LRU only in a way that two latest access timestamps are stored for every
      * data page. At the eviction time, a minimum between two latest timestamps is taken for further comparison with

http://git-wip-us.apache.org/repos/asf/ignite/blob/800fb87a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index 98ce61d..b79ab4b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -52,7 +52,10 @@ import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy;
 import org.apache.ignite.configuration.AtomicConfiguration;
 import org.apache.ignite.configuration.BinaryConfiguration;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataPageEvictionMode;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.configuration.TransactionConfiguration;
 import org.apache.ignite.internal.binary.BinaryArrayIdentityResolver;
@@ -169,6 +172,11 @@ public class PlatformConfigurationUtils {
         ccfg.setWriteThrough(in.readBoolean());
         ccfg.setStatisticsEnabled(in.readBoolean());
 
+        String memoryPolicyName = in.readString();
+
+        if (memoryPolicyName != null)
+            ccfg.setMemoryPolicyName(memoryPolicyName);
+
         Object storeFactory = in.readObjectDetached();
 
         if (storeFactory != null)
@@ -516,20 +524,36 @@ public class PlatformConfigurationUtils {
      * @param cfg Configuration.
      */
     public static void readIgniteConfiguration(BinaryRawReaderEx in, IgniteConfiguration cfg) {
-        if (in.readBoolean()) cfg.setClientMode(in.readBoolean());
-        int[] eventTypes = in.readIntArray(); if (eventTypes != null) cfg.setIncludeEventTypes(eventTypes);
-        if (in.readBoolean()) cfg.setMetricsExpireTime(in.readLong());
-        if (in.readBoolean()) cfg.setMetricsHistorySize(in.readInt());
-        if (in.readBoolean()) cfg.setMetricsLogFrequency(in.readLong());
-        if (in.readBoolean()) cfg.setMetricsUpdateFrequency(in.readLong());
-        if (in.readBoolean()) cfg.setNetworkSendRetryCount(in.readInt());
-        if (in.readBoolean()) cfg.setNetworkSendRetryDelay(in.readLong());
-        if (in.readBoolean()) cfg.setNetworkTimeout(in.readLong());
-        String workDir = in.readString(); if (workDir != null) cfg.setWorkDirectory(workDir);
-        String localHost = in.readString(); if (localHost != null) cfg.setLocalHost(localHost);
-        if (in.readBoolean()) cfg.setDaemon(in.readBoolean());
-        if (in.readBoolean()) cfg.setLateAffinityAssignment(in.readBoolean());
-        if (in.readBoolean()) cfg.setFailureDetectionTimeout(in.readLong());
+        if (in.readBoolean())
+            cfg.setClientMode(in.readBoolean());
+        int[] eventTypes = in.readIntArray();
+        if (eventTypes != null) cfg.setIncludeEventTypes(eventTypes);
+        if (in.readBoolean())
+            cfg.setMetricsExpireTime(in.readLong());
+        if (in.readBoolean())
+            cfg.setMetricsHistorySize(in.readInt());
+        if (in.readBoolean())
+            cfg.setMetricsLogFrequency(in.readLong());
+        if (in.readBoolean())
+            cfg.setMetricsUpdateFrequency(in.readLong());
+        if (in.readBoolean())
+            cfg.setNetworkSendRetryCount(in.readInt());
+        if (in.readBoolean())
+            cfg.setNetworkSendRetryDelay(in.readLong());
+        if (in.readBoolean())
+            cfg.setNetworkTimeout(in.readLong());
+        String workDir = in.readString();
+        if (workDir != null)
+            cfg.setWorkDirectory(workDir);
+        String localHost = in.readString();
+        if (localHost != null)
+            cfg.setLocalHost(localHost);
+        if (in.readBoolean())
+            cfg.setDaemon(in.readBoolean());
+        if (in.readBoolean())
+            cfg.setLateAffinityAssignment(in.readBoolean());
+        if (in.readBoolean())
+            cfg.setFailureDetectionTimeout(in.readLong());
 
         readCacheConfigurations(in, cfg);
         readDiscoveryConfiguration(in, cfg);
@@ -616,6 +640,8 @@ public class PlatformConfigurationUtils {
                 break;
         }
 
+        cfg.setMemoryConfiguration(readMemoryConfiguration(in));
+
         readPluginConfiguration(cfg, in);
     }
 
@@ -772,6 +798,7 @@ public class PlatformConfigurationUtils {
         writer.writeBoolean(ccfg.isReadThrough());
         writer.writeBoolean(ccfg.isWriteThrough());
         writer.writeBoolean(ccfg.isStatisticsEnabled());
+        writer.writeString(ccfg.getMemoryPolicyName());
 
         if (ccfg.getCacheStoreFactory() instanceof PlatformDotNetCacheStoreFactoryNative)
             writer.writeObject(((PlatformDotNetCacheStoreFactoryNative)ccfg.getCacheStoreFactory()).getNativeFactory());
@@ -914,20 +941,30 @@ public class PlatformConfigurationUtils {
         assert w != null;
         assert cfg != null;
 
-        w.writeBoolean(true); w.writeBoolean(cfg.isClientMode());
+        w.writeBoolean(true);
+        w.writeBoolean(cfg.isClientMode());
         w.writeIntArray(cfg.getIncludeEventTypes());
-        w.writeBoolean(true); w.writeLong(cfg.getMetricsExpireTime());
-        w.writeBoolean(true); w.writeInt(cfg.getMetricsHistorySize());
-        w.writeBoolean(true); w.writeLong(cfg.getMetricsLogFrequency());
-        w.writeBoolean(true); w.writeLong(cfg.getMetricsUpdateFrequency());
-        w.writeBoolean(true); w.writeInt(cfg.getNetworkSendRetryCount());
-        w.writeBoolean(true); w.writeLong(cfg.getNetworkSendRetryDelay());
-        w.writeBoolean(true); w.writeLong(cfg.getNetworkTimeout());
+        w.writeBoolean(true);
+        w.writeLong(cfg.getMetricsExpireTime());
+        w.writeBoolean(true);
+        w.writeInt(cfg.getMetricsHistorySize());
+        w.writeBoolean(true);
+        w.writeLong(cfg.getMetricsLogFrequency());
+        w.writeBoolean(true);
+        w.writeLong(cfg.getMetricsUpdateFrequency());
+        w.writeBoolean(true);
+        w.writeInt(cfg.getNetworkSendRetryCount());
+        w.writeBoolean(true);w.writeLong(cfg.getNetworkSendRetryDelay());
+        w.writeBoolean(true);
+        w.writeLong(cfg.getNetworkTimeout());
         w.writeString(cfg.getWorkDirectory());
         w.writeString(cfg.getLocalHost());
-        w.writeBoolean(true); w.writeBoolean(cfg.isDaemon());
-        w.writeBoolean(true); w.writeBoolean(cfg.isLateAffinityAssignment());
-        w.writeBoolean(true); w.writeLong(cfg.getFailureDetectionTimeout());
+        w.writeBoolean(true);
+        w.writeBoolean(cfg.isDaemon());
+        w.writeBoolean(true);
+        w.writeBoolean(cfg.isLateAffinityAssignment());
+        w.writeBoolean(true);
+        w.writeLong(cfg.getFailureDetectionTimeout());
 
         CacheConfiguration[] cacheCfg = cfg.getCacheConfiguration();
 
@@ -1033,6 +1070,8 @@ public class PlatformConfigurationUtils {
             w.writeLong(((MemoryEventStorageSpi)eventStorageSpi).getExpireAgeMs());
         }
 
+        writeMemoryConfiguration(w, cfg.getMemoryConfiguration());
+
         w.writeString(cfg.getIgniteHome());
 
         w.writeLong(ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getInit());
@@ -1273,6 +1312,87 @@ public class PlatformConfigurationUtils {
     }
 
     /**
+     * Reads the memory configuration.
+     *
+     * @param in Reader
+     * @return Config.
+     */
+    private static MemoryConfiguration readMemoryConfiguration(BinaryRawReader in) {
+        if (!in.readBoolean())
+            return null;
+
+        MemoryConfiguration res = new MemoryConfiguration();
+
+        res.setSystemCacheMemorySize(in.readLong())
+                .setPageSize(in.readInt())
+                .setConcurrencyLevel(in.readInt())
+                .setDefaultMemoryPolicyName(in.readString());
+
+        int cnt = in.readInt();
+
+        if (cnt > 0) {
+            MemoryPolicyConfiguration[] plcs = new MemoryPolicyConfiguration[cnt];
+
+            for (int i = 0; i < cnt; i++) {
+                MemoryPolicyConfiguration cfg = new MemoryPolicyConfiguration();
+
+                cfg.setName(in.readString())
+                        .setSize(in.readLong())
+                        .setSwapFilePath(in.readString())
+                        .setPageEvictionMode(DataPageEvictionMode.values()[in.readInt()])
+                        .setEvictionThreshold(in.readDouble())
+                        .setEmptyPagesPoolSize(in.readInt());
+
+                plcs[i] = cfg;
+            }
+
+            res.setMemoryPolicies(plcs);
+        }
+
+        return res;
+    }
+
+    /**
+     * Writes the memory configuration.
+     *
+     * @param w Writer.
+     * @param cfg Config.
+     */
+    private static void writeMemoryConfiguration(BinaryRawWriter w, MemoryConfiguration cfg) {
+        if (cfg == null) {
+            w.writeBoolean(false);
+            return;
+        }
+
+        w.writeBoolean(true);
+
+        w.writeLong(cfg.getSystemCacheMemorySize());
+        w.writeInt(cfg.getPageSize());
+        w.writeInt(cfg.getConcurrencyLevel());
+        w.writeString(cfg.getDefaultMemoryPolicyName());
+
+        MemoryPolicyConfiguration[] plcs = cfg.getMemoryPolicies();
+
+        if (plcs != null) {
+            w.writeInt(plcs.length);
+
+            for (MemoryPolicyConfiguration plc : plcs) {
+                w.writeString(plc.getName());
+                w.writeLong(plc.getSize());
+                w.writeString(plc.getSwapFilePath());
+                w.writeInt(plc.getPageEvictionMode().ordinal());
+                w.writeDouble(plc.getEvictionThreshold());
+                w.writeInt(plc.getEmptyPagesPoolSize());
+            }
+        }
+        else {
+            w.writeInt(0);
+        }
+    }
+
+
+
+    /**
      * Private constructor.
      */
     private PlatformConfigurationUtils() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/800fb87a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
index 7a120bc..6406d32 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
@@ -64,7 +64,18 @@ namespace Apache.Ignite.Core.Tests.Cache
                     GetCustomCacheConfiguration2()
                 },
                 IgniteInstanceName = CacheName,
-                BinaryConfiguration = new BinaryConfiguration(typeof (Entity))
+                BinaryConfiguration = new BinaryConfiguration(typeof(Entity)),
+                MemoryConfiguration = new MemoryConfiguration
+                {
+                    MemoryPolicies = new[]
+                    {
+                        new MemoryPolicyConfiguration
+                        {
+                            Name = "myMemPolicy",
+                            Size = 99 * 1024 * 1024
+                        }
+                    }
+                }
             };
 
             _ignite = Ignition.Start(cfg);
@@ -233,6 +244,7 @@ namespace Apache.Ignite.Core.Tests.Cache
             Assert.AreEqual(x.WriteBehindFlushFrequency, y.WriteBehindFlushFrequency);
             Assert.AreEqual(x.WriteBehindFlushSize, y.WriteBehindFlushSize);
             Assert.AreEqual(x.EnableStatistics, y.EnableStatistics);
+            Assert.AreEqual(x.MemoryPolicyName, y.MemoryPolicyName);
 
             if (x.ExpiryPolicyFactory != null)
                 Assert.AreEqual(x.ExpiryPolicyFactory.CreateInstance().GetType(),
@@ -546,6 +558,7 @@ namespace Apache.Ignite.Core.Tests.Cache
                 },
                 ExpiryPolicyFactory = new ExpiryFactory(),
                 EnableStatistics = true,
+                MemoryPolicyName = "myMemPolicy",
                 PluginConfigurations = new[] { new MyPluginConfiguration() }
             };
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/800fb87a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index 4a197e5..2d8cc20 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -134,6 +134,11 @@ namespace Apache.Ignite.Core.Tests
                                 <iPluginConfiguration type='Apache.Ignite.Core.Tests.Plugin.TestIgnitePluginConfiguration, Apache.Ignite.Core.Tests' />
                             </pluginConfigurations>
                             <eventStorageSpi type='MemoryEventStorageSpi' expirationTimeout='00:00:23.45' maxEventCount='129' />
+                            <memoryConfiguration concurrencyLevel='3' defaultMemoryPolicyName='dfPlc' pageSize='45' systemCacheMemorySize='67'>
+                                <memoryPolicies>
+                                    <memoryPolicyConfiguration emptyPagesPoolSize='1' evictionThreshold='0.2' name='dfPlc' pageEvictionMode='RandomLru' size='89' swapFilePath='abc' />
+                                </memoryPolicies>
+                            </memoryConfiguration>
                         </igniteConfig>";
 
             var cfg = IgniteConfiguration.FromXml(xml);
@@ -248,6 +253,21 @@ namespace Apache.Ignite.Core.Tests
             Assert.IsNotNull(eventStorage);
             Assert.AreEqual(23.45, eventStorage.ExpirationTimeout.TotalSeconds);
             Assert.AreEqual(129, eventStorage.MaxEventCount);
+
+            var memCfg = cfg.MemoryConfiguration;
+            Assert.IsNotNull(memCfg);
+            Assert.AreEqual(3, memCfg.ConcurrencyLevel);
+            Assert.AreEqual("dfPlc", memCfg.DefaultMemoryPolicyName);
+            Assert.AreEqual(45, memCfg.PageSize);
+            Assert.AreEqual(67, memCfg.SystemCacheMemorySize);
+
+            var memPlc = memCfg.MemoryPolicies.Single();
+            Assert.AreEqual(1, memPlc.EmptyPagesPoolSize);
+            Assert.AreEqual(0.2, memPlc.EvictionThreshold);
+            Assert.AreEqual("dfPlc", memPlc.Name);
+            Assert.AreEqual(DataPageEvictionMode.RandomLru, memPlc.PageEvictionMode);
+            Assert.AreEqual("abc", memPlc.SwapFilePath);
+            Assert.AreEqual(89, memPlc.Size);
         }
 
         /// <summary>
@@ -774,6 +794,34 @@ namespace Apache.Ignite.Core.Tests
                 {
                     ExpirationTimeout = TimeSpan.FromMilliseconds(12345),
                     MaxEventCount = 257
+                },
+                MemoryConfiguration = new MemoryConfiguration
+                {
+                    ConcurrencyLevel = 3,
+                    DefaultMemoryPolicyName = "somePolicy",
+                    PageSize = 4,
+                    SystemCacheMemorySize = 5,
+                    MemoryPolicies = new[]
+                    {
+                        new MemoryPolicyConfiguration
+                        {
+                            Name = "myDefaultPlc",
+                            PageEvictionMode = DataPageEvictionMode.Random2Lru,
+                            Size = 345 * 1024 * 1024,
+                            EvictionThreshold = 0.88,
+                            EmptyPagesPoolSize = 77,
+                            SwapFilePath = "myPath1"
+                        },
+                        new MemoryPolicyConfiguration
+                        {
+                            Name = "customPlc",
+                            PageEvictionMode = DataPageEvictionMode.RandomLru,
+                            Size = 456 * 1024 * 1024,
+                            EvictionThreshold = 0.77,
+                            EmptyPagesPoolSize = 66,
+                            SwapFilePath = "somePath2"
+                        }
+                    }
                 }
             };
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/800fb87a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
index 19053f2..8da2616 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -79,6 +79,8 @@ namespace Apache.Ignite.Core.Tests
             CheckDefaultValueAttributes(new AtomicConfiguration());
             CheckDefaultValueAttributes(new TransactionConfiguration());
             CheckDefaultValueAttributes(new MemoryEventStorageSpi());
+            CheckDefaultValueAttributes(new MemoryConfiguration());
+            CheckDefaultValueAttributes(new MemoryPolicyConfiguration());
         }
 
         /// <summary>
@@ -190,6 +192,32 @@ namespace Apache.Ignite.Core.Tests
                 Assert.IsNotNull(resEventCfg);
                 Assert.AreEqual(eventCfg.ExpirationTimeout, resEventCfg.ExpirationTimeout);
                 Assert.AreEqual(eventCfg.MaxEventCount, resEventCfg.MaxEventCount);
+
+                var memCfg = cfg.MemoryConfiguration;
+                var resMemCfg = resCfg.MemoryConfiguration;
+                Assert.IsNotNull(memCfg);
+                Assert.IsNotNull(resMemCfg);
+                Assert.AreEqual(memCfg.PageSize, resMemCfg.PageSize);
+                Assert.AreEqual(memCfg.ConcurrencyLevel, resMemCfg.ConcurrencyLevel);
+                Assert.AreEqual(memCfg.DefaultMemoryPolicyName, resMemCfg.DefaultMemoryPolicyName);
+                Assert.AreEqual(memCfg.SystemCacheMemorySize, resMemCfg.SystemCacheMemorySize);
+                Assert.IsNotNull(memCfg.MemoryPolicies);
+                Assert.IsNotNull(resMemCfg.MemoryPolicies);
+                Assert.AreEqual(2, memCfg.MemoryPolicies.Count);
+                Assert.AreEqual(2, resMemCfg.MemoryPolicies.Count);
+
+                for (var i = 0; i < memCfg.MemoryPolicies.Count; i++)
+                {
+                    var plc = memCfg.MemoryPolicies.Skip(i).First();
+                    var resPlc = resMemCfg.MemoryPolicies.Skip(i).First();
+
+                    Assert.AreEqual(plc.PageEvictionMode, resPlc.PageEvictionMode);
+                    Assert.AreEqual(plc.Size, resPlc.Size);
+                    Assert.AreEqual(plc.EmptyPagesPoolSize, resPlc.EmptyPagesPoolSize);
+                    Assert.AreEqual(plc.EvictionThreshold, resPlc.EvictionThreshold);
+                    Assert.AreEqual(plc.Name, resPlc.Name);
+                    Assert.AreEqual(plc.SwapFilePath, resPlc.SwapFilePath);
+                }
             }
         }
 
@@ -534,6 +562,34 @@ namespace Apache.Ignite.Core.Tests
                 {
                     ExpirationTimeout = TimeSpan.FromSeconds(5),
                     MaxEventCount = 10
+                },
+                MemoryConfiguration = new MemoryConfiguration
+                {
+                    ConcurrencyLevel = 3,
+                    DefaultMemoryPolicyName = "myDefaultPlc",
+                    PageSize = 2048,
+                    SystemCacheMemorySize = 13 * 1024 * 1024,
+                    MemoryPolicies = new[]
+                    {
+                        new MemoryPolicyConfiguration
+                        {
+                            Name = "myDefaultPlc",
+                            PageEvictionMode = DataPageEvictionMode.Random2Lru,
+                            Size = 345 * 1024 * 1024,
+                            EvictionThreshold = 0.88,
+                            EmptyPagesPoolSize = 77,
+                            SwapFilePath = "myPath1"
+                        },
+                        new MemoryPolicyConfiguration
+                        {
+                            Name = "customPlc",
+                            PageEvictionMode = DataPageEvictionMode.RandomLru,
+                            Size = 456 * 1024 * 1024,
+                            EvictionThreshold = 0.77,
+                            EmptyPagesPoolSize = 66,
+                            SwapFilePath = "somePath2"
+                        } 
+                    }
                 }
             };
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/800fb87a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index a298f6f..9d1f9fc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -92,6 +92,8 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Binary\BinaryBasicNameMapper.cs" />
+    <Compile Include="Cache\Configuration\DataPageEvictionMode.cs" />
+    <Compile Include="Cache\Configuration\MemoryPolicyConfiguration.cs" />
     <Compile Include="Common\ExceptionFactory.cs" />
     <Compile Include="Events\IEventStorageSpi.cs" />
     <Compile Include="Events\MemoryEventStorageSpi.cs" />
@@ -458,6 +460,7 @@
     <Compile Include="Log\ILogger.cs" />
     <Compile Include="Log\LoggerExtensions.cs" />
     <Compile Include="Log\LogLevel.cs" />
+    <Compile Include="Cache\Configuration\MemoryConfiguration.cs" />
     <Compile Include="Messaging\Package-Info.cs" />
     <Compile Include="Package-Info.cs" />
     <Compile Include="Lifecycle\ILifecycleHandler.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/800fb87a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
index 91a5b1e..3586989 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
@@ -233,6 +233,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
             ReadThrough = reader.ReadBoolean();
             WriteThrough = reader.ReadBoolean();
             EnableStatistics = reader.ReadBoolean();
+            MemoryPolicyName = reader.ReadString();
             CacheStoreFactory = reader.ReadObject<IFactory<ICacheStore>>();
 
             var count = reader.ReadInt();
@@ -288,6 +289,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
             writer.WriteBoolean(ReadThrough);
             writer.WriteBoolean(WriteThrough);
             writer.WriteBoolean(EnableStatistics);
+            writer.WriteString(MemoryPolicyName);
             writer.WriteObject(CacheStoreFactory);
 
             if (QueryEntities != null)
@@ -623,5 +625,11 @@ namespace Apache.Ignite.Core.Cache.Configuration
         /// </summary>
         [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public ICollection<ICachePluginConfiguration> PluginConfigurations { get; set; }
+
+        /// <summary>
+        /// Gets or sets the name of the <see cref="MemoryPolicyConfiguration"/> for this cache.
+        /// See <see cref="IgniteConfiguration.MemoryConfiguration"/>.
+        /// </summary>
+        public string MemoryPolicyName { get; set; }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/800fb87a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/DataPageEvictionMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/DataPageEvictionMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/DataPageEvictionMode.cs
new file mode 100644
index 0000000..f3897e6
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/DataPageEvictionMode.cs
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    /// <summary>
+    /// Memory page eviction mode.
+    /// Only data pages, that store key-value entries, are eligible for eviction.
+    /// The other types of pages, like index or system pages, are not evictable.
+    /// </summary>
+    public enum DataPageEvictionMode
+    {
+        /// <summary>
+        /// Eviction is disabled.
+        /// </summary>
+        Disabled,
+
+        /// <summary>
+        /// Random-LRU algorithm.
+        /// <para />
+        /// Once a memory region defined by a memory policy is configured, an off-heap array is allocated to track
+        /// last usage timestamp for every individual data page. The size of the array equals to
+        /// <see cref="MemoryPolicyConfiguration.Size"/> / <see cref="MemoryConfiguration.PageSize"/>.
+        /// <para />
+        /// When a data page is accessed, its timestamp gets updated in the tracking array. The page index in the
+        /// tracking array equals to pageAddress / <see cref="MemoryPolicyConfiguration.Size"/>.
+        /// <para />
+        /// When some pages need to be evicted, the algorithm randomly chooses 5 indexes from the tracking array and
+        /// evicts a page with the latest timestamp. If some of the indexes point to non-data pages
+        /// (index or system pages) then the algorithm picks other pages.
+        /// </summary>
+        RandomLru,
+
+        /// <summary>
+        /// Activates Random-2-LRU algorithm which is a scan resistant version of Random-LRU.
+        /// <para />
+        /// This algorithm differs from Random-LRU only in a way that two latest access timestamps are stored for every
+        /// data page. At the eviction time, a minimum between two latest timestamps is taken for further
+        /// comparison with minimums of other pages that might be evicted. LRU-2 outperforms LRU by
+        /// resolving "one-hit wonder" problem - if a data page is accessed rarely, but accidentally accessed once,
+        /// its protected from eviction for a long time.
+        /// </summary>
+        Random2Lru
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/800fb87a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs
new file mode 100644
index 0000000..9b1016d
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs
@@ -0,0 +1,151 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// A page memory configuration for an Apache Ignite node. The page memory is a manageable off-heap based
+    /// memory architecture that divides all continuously allocated memory regions into pages of fixed size.
+    /// An individual page can store one or many cache key-value entries that allows reusing the memory
+    /// in the most efficient way and avoid memory fragmentation issues. 
+    /// <para />
+    /// By default, the page memory allocates a single continuous memory region. All the caches that
+    /// will be configured in an application will be mapped to this memory region by default,
+    /// thus, all the cache data will reside in that memory region.
+    /// <para />
+    /// If initial size of the default memory region doesn't satisfy requirements or it's
+    /// required to have multiple memory regions with different properties
+    /// then <see cref="MemoryPolicyConfiguration" /> can be used for both scenarios.
+    /// For instance, using memory policies you can define memory regions of different maximum size,
+    /// eviction policies, swapping options, etc. Once you define a new memory region you can bind
+    /// particular Ignite caches to it. <para />
+    /// To learn more about memory policies refer to <see cref="MemoryPolicyConfiguration" /> documentation.
+    /// </summary>
+    public class MemoryConfiguration
+    {
+        /// <summary>
+        /// The default system cache memory size.
+        /// </summary>
+        public const long DefaultSystemCacheMemorySize = 100 * 1024 * 1024;
+
+        /// <summary>
+        /// The default page size.
+        /// </summary>
+        public const int DefaultPageSize = 2 * 1024;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="MemoryConfiguration"/> class.
+        /// </summary>
+        public MemoryConfiguration()
+        {
+            SystemCacheMemorySize = DefaultSystemCacheMemorySize;
+            PageSize = DefaultPageSize;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="MemoryConfiguration"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public MemoryConfiguration(IBinaryRawReader reader)
+        {
+            Debug.Assert(reader != null);
+
+            SystemCacheMemorySize = reader.ReadLong();
+            PageSize = reader.ReadInt();
+            ConcurrencyLevel = reader.ReadInt();
+            DefaultMemoryPolicyName = reader.ReadString();
+
+            var count = reader.ReadInt();
+
+            if (count > 0)
+            {
+                MemoryPolicies = Enumerable.Range(0, count)
+                    .Select(x => new MemoryPolicyConfiguration(reader))
+                    .ToArray();
+            }
+        }
+
+        /// <summary>
+        /// Writes this instance to a writer.
+        /// </summary>
+        /// <param name="writer">The writer.</param>
+        internal void Write(IBinaryRawWriter writer)
+        {
+            Debug.Assert(writer != null);
+
+            writer.WriteLong(SystemCacheMemorySize);
+            writer.WriteInt(PageSize);
+            writer.WriteInt(ConcurrencyLevel);
+            writer.WriteString(DefaultMemoryPolicyName);
+
+            if (MemoryPolicies != null)
+            {
+                writer.WriteInt(MemoryPolicies.Count);
+
+                foreach (var policy in MemoryPolicies)
+                {
+                    if (policy == null)
+                    {
+                        throw new IgniteException("MemoryConfiguration.MemoryPolicies must not contain null items.");
+                    }
+
+                    policy.Write(writer);
+                }
+            }
+            else
+            {
+                writer.WriteInt(0);
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the size of a memory chunk reserved for system cache needs.
+        /// </summary>
+        [DefaultValue(DefaultSystemCacheMemorySize)]
+        public long SystemCacheMemorySize { get; set; }
+
+        /// <summary>
+        /// Gets or sets the size of the memory page.
+        /// </summary>
+        [DefaultValue(DefaultPageSize)]
+        public int PageSize { get; set; }
+
+        /// <summary>
+        /// Gets or sets the number of concurrent segments in Ignite internal page mapping tables.
+        /// </summary>
+        public int ConcurrencyLevel { get;set; }
+
+        /// <summary>
+        /// Gets or sets the name of the default memory policy in <see cref="MemoryPolicies"/>.
+        /// </summary>
+        public string DefaultMemoryPolicyName { get; set; }
+
+        /// <summary>
+        /// Gets or sets the memory policies.
+        /// </summary>
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public ICollection<MemoryPolicyConfiguration> MemoryPolicies { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/800fb87a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
new file mode 100644
index 0000000..9e21910
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    using System.ComponentModel;
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Defines page memory policy configuration. See <see cref="MemoryConfiguration.MemoryPolicies"/>.
+    /// </summary>
+    public class MemoryPolicyConfiguration
+    {
+        /// <summary>
+        /// The default eviction threshold.
+        /// </summary>
+        public const double DefaultEvictionThreshold = 0.9;
+
+        /// <summary>
+        /// The default empty pages pool size.
+        /// </summary>
+        public const int DefaultEmptyPagesPoolSize = 100;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="MemoryPolicyConfiguration"/> class.
+        /// </summary>
+        public MemoryPolicyConfiguration()
+        {
+            EvictionThreshold = DefaultEvictionThreshold;
+            EmptyPagesPoolSize = DefaultEmptyPagesPoolSize;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="MemoryPolicyConfiguration"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        internal MemoryPolicyConfiguration(IBinaryRawReader reader)
+        {
+            Name = reader.ReadString();
+            Size = reader.ReadLong();
+            SwapFilePath = reader.ReadString();
+            PageEvictionMode = (DataPageEvictionMode) reader.ReadInt();
+            EvictionThreshold = reader.ReadDouble();
+            EmptyPagesPoolSize = reader.ReadInt();
+        }
+
+        /// <summary>
+        /// Writes this instance to a writer.
+        /// </summary>
+        internal void Write(IBinaryRawWriter writer)
+        {
+            writer.WriteString(Name);
+            writer.WriteLong(Size);
+            writer.WriteString(SwapFilePath);
+            writer.WriteInt((int) PageEvictionMode);
+            writer.WriteDouble(EvictionThreshold);
+            writer.WriteInt(EmptyPagesPoolSize);
+        }
+
+        /// <summary>
+        /// Gets or sets the memory policy name.
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Gets or sets the maximum memory region size defined by this memory policy.
+        /// If the whole data can not fit into the memory region an out of memory exception will be thrown.
+        /// </summary>
+        public long Size { get; set; }
+
+        /// <summary>
+        /// Gets or sets the the path to the memory-mapped file the memory region defined by this memory policy
+        /// will be mapped to. Having the path set, allows relying on swapping capabilities of an underlying
+        /// operating system for the memory region.
+        /// <para />
+        /// Null for no swap.
+        /// </summary>
+        public string SwapFilePath { get; set; }
+
+        /// <summary>
+        /// Gets or sets the page eviction mode. If <see cref="DataPageEvictionMode.Disabled"/> is used (default)
+        /// then an out of memory exception will be thrown if the memory region usage,
+        /// defined by this memory policy, goes beyond <see cref="Size"/>.
+        /// </summary>
+        public DataPageEvictionMode PageEvictionMode { get; set; }
+
+        /// <summary>
+        /// Gets or sets the threshold for memory pages eviction initiation. For instance, if the threshold is 0.9
+        /// it means that the page memory will start the eviction only after 90% of the memory region
+        /// (defined by this policy) is occupied.
+        /// </summary>
+        [DefaultValue(DefaultEvictionThreshold)]
+        public double EvictionThreshold { get; set; }
+
+        /// <summary>
+        /// Gets or sets the minimal number of empty pages to be present in reuse lists for this memory policy.
+        /// This parameter ensures that Ignite will be able to successfully evict old data entries when the size of
+        /// (key, value) pair is slightly larger than page size / 2.
+        /// Increase this parameter if cache can contain very big entries (total size of pages in this pool
+        /// should be enough to contain largest cache entry).
+        /// </summary>
+        [DefaultValue(DefaultEmptyPagesPoolSize)]
+        public int EmptyPagesPoolSize { get;set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/800fb87a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
index 85c7548..1f7a184 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
@@ -350,6 +350,16 @@ namespace Apache.Ignite.Core
                 memEventStorage.Write(writer);
             }
 
+            if (MemoryConfiguration != null)
+            {
+                writer.WriteBoolean(true);
+                MemoryConfiguration.Write(writer);
+            }
+            else
+            {
+                writer.WriteBoolean(false);
+            }
+
             // Plugins (should be last)
             if (PluginConfigurations != null)
             {
@@ -482,6 +492,11 @@ namespace Apache.Ignite.Core
                     EventStorageSpi = MemoryEventStorageSpi.Read(r);
                     break;
             }
+
+            if (r.ReadBoolean())
+            {
+                MemoryConfiguration = new MemoryConfiguration(r);
+            }
         }
 
         /// <summary>
@@ -937,5 +952,11 @@ namespace Apache.Ignite.Core
         /// <see cref="NoopEventStorageSpi"/>, <see cref="MemoryEventStorageSpi"/>.
         /// </summary>
         public IEventStorageSpi EventStorageSpi { get; set; }
+
+        /// <summary>
+        /// Gets or sets the page memory configuration.
+        /// <see cref="MemoryConfiguration"/> for more details.
+        /// </summary>
+        public MemoryConfiguration MemoryConfiguration { get; set; }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/800fb87a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
index 1d2a948..ba2f756 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -78,6 +78,14 @@
         </xs:restriction>
     </xs:simpleType>
 
+    <xs:simpleType name="dataPageEvictionMode" final="restriction">
+        <xs:restriction base="xs:string">
+            <xs:enumeration value="Disabled" />
+            <xs:enumeration value="RandomLru" />
+            <xs:enumeration value="Random2Lru" />
+        </xs:restriction>
+    </xs:simpleType>
+
     <xs:element name="igniteConfiguration">
         <xs:annotation>
             <xs:documentation>Ignite configuration root.</xs:documentation>
@@ -697,6 +705,11 @@
                                             <xs:documentation>Value indicating whether statistics gathering is enabled on a cache. These statistics can be retrieved via ICache.GetMetrics().</xs:documentation>
                                         </xs:annotation>
                                     </xs:attribute>
+                                    <xs:attribute name="memoryPolicyName" type="xs:string">
+                                        <xs:annotation>
+                                            <xs:documentation>Name of the MemoryPolicyConfiguration for this cache.</xs:documentation>
+                                        </xs:annotation>
+                                    </xs:attribute>
                                 </xs:complexType>
                             </xs:element>
                         </xs:sequence>
@@ -1120,6 +1133,78 @@
                         </xs:attribute>
                     </xs:complexType>
                 </xs:element>
+                <xs:element name="memoryConfiguration" minOccurs="0">
+                    <xs:annotation>
+                        <xs:documentation>Page memory configuration.</xs:documentation>
+                    </xs:annotation>
+                    <xs:complexType>
+                        <xs:sequence>
+                            <xs:element name="memoryPolicies" minOccurs="0" maxOccurs="1">
+                                <xs:annotation>
+                                    <xs:documentation>Memory policies.</xs:documentation>
+                                </xs:annotation>
+                                <xs:complexType>
+                                    <xs:sequence>
+                                        <xs:element name="memoryPolicyConfiguration" minOccurs="0" maxOccurs="unbounded">
+                                            <xs:complexType>
+                                                <xs:attribute name="emptyPagesPoolSize" type="xs:int">
+                                                    <xs:annotation>
+                                                        <xs:documentation>Minimal number of empty pages to be present in reuse lists for this memory policy.</xs:documentation>
+                                                    </xs:annotation>
+                                                </xs:attribute>
+                                                <xs:attribute name="evictionThreshold" type="xs:double">
+                                                    <xs:annotation>
+                                                        <xs:documentation>Threshold for memory pages eviction initiation. For instance, if the threshold is 0.9 it means that the page memory will start the eviction only after 90% of the memory region (defined by this policy) is occupied.</xs:documentation>
+                                                    </xs:annotation>
+                                                </xs:attribute>
+                                                <xs:attribute name="name" type="xs:string" use="required">
+                                                    <xs:annotation>
+                                                        <xs:documentation>Memory policy name.</xs:documentation>
+                                                    </xs:annotation>
+                                                </xs:attribute>
+                                                <xs:attribute name="pageEvictionMode" type="dataPageEvictionMode">
+                                                    <xs:annotation>
+                                                        <xs:documentation>Page eviction mode.</xs:documentation>
+                                                    </xs:annotation>
+                                                </xs:attribute>
+                                                <xs:attribute name="size" type="xs:int" use="required">
+                                                    <xs:annotation>
+                                                        <xs:documentation>Maximum memory region size defined by this memory policy.</xs:documentation>
+                                                    </xs:annotation>
+                                                </xs:attribute>
+                                                <xs:attribute name="swapFilePath" type="xs:string">
+                                                    <xs:annotation>
+                                                        <xs:documentation>Path to the memory-mapped file the memory region defined by this memory policy will be mapped to.</xs:documentation>
+                                                    </xs:annotation>
+                                                </xs:attribute>
+                                            </xs:complexType>
+                                        </xs:element>
+                                    </xs:sequence>
+                                </xs:complexType>
+                            </xs:element>
+                        </xs:sequence>
+                        <xs:attribute name="concurrencyLevel" type="xs:int">
+                            <xs:annotation>
+                                <xs:documentation>Number of concurrent segments in Ignite internal page mapping tables.</xs:documentation>
+                            </xs:annotation>
+                        </xs:attribute>
+                        <xs:attribute name="defaultMemoryPolicyName" type="xs:string">
+                            <xs:annotation>
+                                <xs:documentation>Name of the default memory policy in MemoryPolicies.</xs:documentation>
+                            </xs:annotation>
+                        </xs:attribute>
+                        <xs:attribute name="pageSize" type="xs:int">
+                            <xs:annotation>
+                                <xs:documentation>Size of the memory page.</xs:documentation>
+                            </xs:annotation>
+                        </xs:attribute>
+                        <xs:attribute name="systemCacheMemorySize" type="xs:int">
+                            <xs:annotation>
+                                <xs:documentation>Size of a memory chunk reserved for system cache needs.</xs:documentation>
+                            </xs:annotation>
+                        </xs:attribute>
+                    </xs:complexType>
+                </xs:element>
                 <xs:element name="pluginConfigurations" minOccurs="0">
                     <xs:annotation>
                         <xs:documentation>Plugin configurations.</xs:documentation>


[28/65] [abbrv] ignite git commit: Fixed service deployment tests.

Posted by ag...@apache.org.
Fixed service deployment tests.


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

Branch: refs/heads/ignite-5024
Commit: 9c954c93a9d93952354e784a75c45cecdf245a2d
Parents: 27fd74e
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Wed Apr 19 06:30:30 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Wed Apr 19 06:30:30 2017 +0300

----------------------------------------------------------------------
 .../GridServiceProcessorAbstractSelfTest.java   |  17 +++
 ...ServiceProcessorMultiNodeConfigSelfTest.java |  40 +++----
 .../GridServiceProcessorMultiNodeSelfTest.java  | 113 ++++++++++---------
 3 files changed, 95 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9c954c93/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java
index b9076b9..fafd24e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java
@@ -30,7 +30,9 @@ import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.processors.affinity.GridAffinityProcessor;
+import org.apache.ignite.internal.util.lang.GridAbsPredicateX;
 import org.apache.ignite.internal.util.typedef.CA;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.lang.IgniteFuture;
@@ -783,6 +785,21 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs
     }
 
     /**
+     * @param srvcName Service name
+     * @param expectedDeps Expected number of service deployments
+     *
+     */
+    protected boolean waitForDeployment(final String srvcName, final int expectedDeps) throws IgniteInterruptedCheckedException {
+        final Ignite g = randomGrid();
+
+        return GridTestUtils.waitForCondition(new GridAbsPredicateX() {
+            @Override public boolean applyx() {
+                return actualCount(srvcName, g.services().serviceDescriptors())  == expectedDeps;
+            }
+        }, 1500);
+    }
+
+    /**
      * Counter service.
      */
     protected interface CounterService {

http://git-wip-us.apache.org/repos/asf/ignite/blob/9c954c93/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeConfigSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeConfigSelfTest.java
index 9da62c0..16e5e30 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeConfigSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeConfigSelfTest.java
@@ -22,7 +22,6 @@ import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.util.lang.GridAbsPredicateX;
 import org.apache.ignite.services.ServiceConfiguration;
 import org.apache.ignite.testframework.GridTestUtils;
@@ -213,32 +212,20 @@ public class GridServiceProcessorMultiNodeConfigSelfTest extends GridServiceProc
         try {
             latch.await();
 
+            waitForDeployment(name, nodeCount() + 1);
+
             checkCount(name, g.services().serviceDescriptors(), nodeCount() + 1);
         }
         finally {
             stopExtraNodes(extraNodes);
         }
 
-        assertEquals(name, 1, DummyService.cancelled(name));
-
         waitForDeployment(name, nodeCount());
 
-        checkCount(name, g.services().serviceDescriptors(), nodeCount());
-    }
-
-    /**
-     * @param srvcName Service name
-     * @param expectedDeps Expected number of service deployments
-     *
-     */
-    private boolean waitForDeployment(final String srvcName, final int expectedDeps) throws IgniteInterruptedCheckedException {
-        final Ignite g = randomGrid();
+        // Service can be redeployed when nodes is stopping one-by-one.
+        assertEquals(0, DummyService.started(name) - DummyService.cancelled(name));
 
-        return GridTestUtils.waitForCondition(new GridAbsPredicateX() {
-            @Override public boolean applyx() {
-                return actualCount(srvcName, g.services().serviceDescriptors())  == expectedDeps;
-            }
-        }, 1500);
+        checkCount(name, g.services().serviceDescriptors(), nodeCount());
     }
 
     /**
@@ -281,8 +268,12 @@ public class GridServiceProcessorMultiNodeConfigSelfTest extends GridServiceProc
         try {
             latch.await();
 
-            assertEquals(name, newNodes, DummyService.started(name));
-            assertEquals(name, 0, DummyService.cancelled(name));
+            waitForDeployment(name, nodeCount() + newNodes);
+
+            assertEquals(name, newNodes,  DummyService.started(name) - DummyService.cancelled(name));
+// Next may fails. Server can be restarted on unstable topology.
+//            assertEquals(name, newNodes, DummyService.started(name));
+//            assertEquals(name, 0, DummyService.cancelled(name));
 
             checkCount(name, g.services().serviceDescriptors(), nodeCount() + newNodes);
         }
@@ -314,8 +305,13 @@ public class GridServiceProcessorMultiNodeConfigSelfTest extends GridServiceProc
         try {
             latch.await();
 
-            assertEquals(name, servers, DummyService.started(name));
-            assertEquals(name, 0, DummyService.cancelled(name));
+            waitForDeployment(name, nodeCount() + servers);
+
+            assertEquals(name, servers,  DummyService.started(name) - DummyService.cancelled(name));
+// Next may fails. Server can be restarted on unstable topology.
+//            assertEquals(name, servers, DummyService.started(name));
+//            assertEquals(name, 0, DummyService.cancelled(name));
+
 
             checkCount(name, g.services().serviceDescriptors(), nodeCount() + servers);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9c954c93/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java
index 50f5999..32d1462 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java
@@ -90,7 +90,7 @@ public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorA
         // Store a cache key.
         g.cache(CACHE_NAME).put(affKey, affKey.toString());
 
-        String name = "serviceAffinityUpdateTopology";
+        final String name = "serviceAffinityUpdateTopology";
 
         IgniteServices svcs = g.services();
 
@@ -125,9 +125,7 @@ public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorA
         Ignite client = startGrid("client", getConfiguration("client").setClientMode(true));
 
         try {
-            final int prestartedNodes = nodeCount() + 1;
-
-            String name = "serviceOnEachNodeButClientUpdateTopology";
+            final String name = "serviceOnEachNodeButClientUpdateTopology";
 
             Ignite g = randomGrid();
 
@@ -135,9 +133,9 @@ public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorA
 
             DummyService.exeLatch(name, latch);
 
-        IgniteServices svcs = g.services();
+            IgniteServices svcs = g.services();
 
-        IgniteFuture<?> fut = svcs.deployNodeSingletonAsync(name, new DummyService());
+            IgniteFuture<?> fut = svcs.deployNodeSingletonAsync(name, new DummyService());
 
             info("Deployed service: " + name);
 
@@ -150,8 +148,8 @@ public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorA
             // Ensure service is deployed
             assertNotNull(client.services().serviceProxy(name, Service.class, false, 2000));
 
-            TestCase.assertEquals(name, nodeCount(), DummyService.started(name));
-            TestCase.assertEquals(name, 0, DummyService.cancelled(name));
+            assertEquals(name, nodeCount(), DummyService.started(name));
+            assertEquals(name, 0, DummyService.cancelled(name));
 
             int servers = 2;
             int clients = 2;
@@ -165,12 +163,13 @@ public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorA
             try {
                 latch.await();
 
-                // Ensure service is deployed
-                assertNotNull(grid(prestartedNodes + servers - 1)
-                    .services().serviceProxy(name, Service.class, false, 2000));
+                waitForDeployment(name, servers);
+
+                assertEquals(name, nodeCount() + servers,  DummyService.started(name) - DummyService.cancelled(name));
 
-                TestCase.assertEquals(name, nodeCount() + servers, DummyService.started(name));
-                TestCase.assertEquals(name, 0, DummyService.cancelled(name));
+//                 Next may fails. Server can be restarted on unstable topology.
+//                assertEquals(name, nodeCount() + servers, DummyService.started(name));
+//                assertEquals(name, 0, DummyService.cancelled(name));
 
                 checkCount(name, g.services().serviceDescriptors(), nodeCount() + servers);
             }
@@ -191,7 +190,7 @@ public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorA
         Ignite client = startGrid("client", getConfiguration("client").setClientMode(true));
 
         try {
-            String name = "serviceOnEachNodeUpdateTopology";
+            final String name = "serviceOnEachNodeUpdateTopology";
 
             Ignite g = randomGrid();
 
@@ -223,8 +222,8 @@ public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorA
             // Ensure service is deployed
             assertNotNull(client.services().serviceProxy(name, Service.class, false, 2000));
 
-            TestCase.assertEquals(name, prestartedNodes, DummyService.started(name));
-            TestCase.assertEquals(name, 0, DummyService.cancelled(name));
+            assertEquals(name, prestartedNodes, DummyService.started(name));
+            assertEquals(name, 0, DummyService.cancelled(name));
 
             int servers = 2;
             int clients = 2;
@@ -240,11 +239,14 @@ public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorA
             try {
                 latch.await();
 
-                // Ensure service is deployed
-                assertNotNull(client.services().serviceProxy(name, Service.class, false, 2000));
+                waitForDeployment(name, prestartedNodes + extraNodes);
+
+                assertEquals(name, prestartedNodes + extraNodes,
+                    DummyService.started(name) - DummyService.cancelled(name));
 
-                TestCase.assertEquals(name, prestartedNodes + extraNodes, DummyService.started(name));
-                TestCase.assertEquals(name, 0, DummyService.cancelled(name));
+//                 Next may fails. Server can be restarted on unstable topology.
+//                assertEquals(name, prestartedNodes + extraNodes, DummyService.started(name));
+//                assertEquals(name, 0, DummyService.cancelled(name));
 
                 checkCount(name, g.services().serviceDescriptors(), prestartedNodes + extraNodes);
             }
@@ -261,60 +263,65 @@ public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorA
      * @throws Exception If failed.
      */
     public void testDeployLimits() throws Exception {
-            String name = "serviceWithLimitsUpdateTopology";
+        final String name = "serviceWithLimitsUpdateTopology";
 
-            Ignite g = randomGrid();
+        Ignite g = randomGrid();
 
-            final int totalInstances = nodeCount() + 1;
+        final int totalInstances = nodeCount() + 1;
 
-            CountDownLatch latch = new CountDownLatch(nodeCount());
+        CountDownLatch latch = new CountDownLatch(nodeCount());
 
-            DummyService.exeLatch(name, latch);
+        DummyService.exeLatch(name, latch);
 
-            ServiceConfiguration srvcCfg = new ServiceConfiguration();
+        ServiceConfiguration srvcCfg = new ServiceConfiguration();
 
-            srvcCfg.setName(name);
-            srvcCfg.setMaxPerNodeCount(1);
-            srvcCfg.setTotalCount(totalInstances);
-            srvcCfg.setService(new DummyService());
+        srvcCfg.setName(name);
+        srvcCfg.setMaxPerNodeCount(1);
+        srvcCfg.setTotalCount(totalInstances);
+        srvcCfg.setService(new DummyService());
 
-            IgniteServices svcs = g.services().withAsync();
+        IgniteServices svcs = g.services().withAsync();
 
-            svcs.deploy(srvcCfg);
+        svcs.deploy(srvcCfg);
 
-            IgniteFuture<?> fut = svcs.future();
+        IgniteFuture<?> fut = svcs.future();
 
-            info("Deployed service: " + name);
+        info("Deployed service: " + name);
 
-            fut.get();
+        fut.get();
 
-            info("Finished waiting for service future: " + name);
+        info("Finished waiting for service future: " + name);
 
-            latch.await();
+        latch.await();
 
-            TestCase.assertEquals(name, nodeCount(), DummyService.started(name));
-            TestCase.assertEquals(name, 0, DummyService.cancelled(name));
+        assertEquals(name, nodeCount(), DummyService.started(name));
+        assertEquals(name, 0, DummyService.cancelled(name));
 
-            checkCount(name, g.services().serviceDescriptors(), nodeCount());
+        checkCount(name, g.services().serviceDescriptors(), nodeCount());
 
-            int extraNodes = 2;
+        int extraNodes = 2;
 
-            latch = new CountDownLatch(1);
+        latch = new CountDownLatch(1);
 
-            DummyService.exeLatch(name, latch);
+        DummyService.exeLatch(name, latch);
 
-            startExtraNodes(2);
+        startExtraNodes(2);
 
-            try {
-                latch.await();
+        try {
+            latch.await();
 
-                TestCase.assertEquals(name, totalInstances, DummyService.started(name));
-                TestCase.assertEquals(name, 0, DummyService.cancelled(name));
+            waitForDeployment(name, totalInstances);
 
-                checkCount(name, g.services().serviceDescriptors(), totalInstances);
-            }
-            finally {
-                stopExtraNodes(extraNodes);
-            }
+            assertEquals(name, totalInstances,  DummyService.started(name) - DummyService.cancelled(name));
+
+//            Next may fails. Server can be restarted on unstable topology.
+//            assertEquals(name, totalInstances, DummyService.started(name));
+//            assertEquals(name, 0, DummyService.cancelled(name));
+
+            checkCount(name, g.services().serviceDescriptors(), totalInstances);
+        }
+        finally {
+            stopExtraNodes(extraNodes);
+        }
     }
 }
\ No newline at end of file


[37/65] [abbrv] ignite git commit: ignite-2.0 Fixed IGNITE_MODULES search path.

Posted by ag...@apache.org.
ignite-2.0 Fixed IGNITE_MODULES search path.


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

Branch: refs/heads/ignite-5024
Commit: 8ad5a945de9df6df6281b80dbec6c3c8c7e3c497
Parents: e41de0c
Author: vsisko <vs...@gridgain.com>
Authored: Fri Apr 21 09:42:15 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Apr 21 09:42:15 2017 +0700

----------------------------------------------------------------------
 modules/web-console/backend/index.js | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8ad5a945/modules/web-console/backend/index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/index.js b/modules/web-console/backend/index.js
index 7416f51..7db51c8 100644
--- a/modules/web-console/backend/index.js
+++ b/modules/web-console/backend/index.js
@@ -22,12 +22,13 @@ const path = require('path');
 const http = require('http');
 const https = require('https');
 
-const igniteModules = process.env.IGNITE_MODULES || './ignite_modules';
+const igniteModules = process.env.IGNITE_MODULES ?
+    path.join(path.normalize(process.env.IGNITE_MODULES), 'backend') : './ignite_modules';
 
 let injector;
 
 try {
-    const igniteModulesInjector = path.resolve(path.join(igniteModules, 'backend', 'injector.js'));
+    const igniteModulesInjector = path.resolve(path.join(igniteModules, 'injector.js'));
 
     fs.accessSync(igniteModulesInjector, fs.F_OK);
 


[29/65] [abbrv] ignite git commit: Fixed javadoc.

Posted by ag...@apache.org.
Fixed javadoc.


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

Branch: refs/heads/ignite-5024
Commit: 9ce62e64a7abfc59799f4edf8d057a12c7a0d11d
Parents: 9c954c9
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Wed Apr 19 06:45:08 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Wed Apr 19 06:45:08 2017 +0300

----------------------------------------------------------------------
 .../repository/support/IgniteRepositoryFactory.java          | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9ce62e64/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactory.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactory.java b/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactory.java
index bceee1f..de2549f 100644
--- a/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactory.java
+++ b/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactory.java
@@ -153,11 +153,11 @@ public class IgniteRepositoryFactory extends RepositoryFactorySupport {
     }
 
     /**
-     * @param s
-     * @return
+     * @param qry Query string.
+     * @return {@code true} if query is SQLFieldsQuery.
      */
-    private boolean isFieldQuery(String s) {
-        return s.matches("^SELECT.*") && !s.matches("^SELECT\\s+(?:\\w+\\.)?+\\*.*");
+    private boolean isFieldQuery(String qry) {
+        return qry.matches("^SELECT.*") && !qry.matches("^SELECT\\s+(?:\\w+\\.)?+\\*.*");
     }
 }
 


[22/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/decompositions/EigenDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/EigenDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/math/decompositions/EigenDecomposition.java
deleted file mode 100644
index 66fe13c..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/EigenDecomposition.java
+++ /dev/null
@@ -1,923 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.decompositions;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.functions.Functions;
-
-/**
- * This class provides EigenDecomposition of given matrix. The class is based on
- * class with similar name from <a href="http://mahout.apache.org/">Apache Mahout</a> library.
- *
- * @see <a href=http://mathworld.wolfram.com/EigenDecomposition.html>MathWorld</a>
- */
-public class EigenDecomposition extends DecompositionSupport {
-    /** Row and column dimension (square matrix). */
-    private final int n;
-
-    /** Array for internal storage of eigen vectors. */
-    private final Matrix v;
-
-    /** Array for internal storage of eigenvalues. */
-    private final Vector d;
-    /** Array for internal storage of eigenvalues. */
-    private final Vector e;
-
-    /** */
-    public EigenDecomposition(Matrix matrix) {
-        this(matrix, isSymmetric(matrix));
-    }
-
-    /** */
-    public EigenDecomposition(Matrix matrix, boolean isSymmetric) {
-        n = matrix.columnSize();
-
-        d = likeVector(matrix);
-        e = likeVector(matrix);
-        v = like(matrix);
-
-        if (isSymmetric) {
-            v.assign(matrix);
-
-            // Tridiagonalize.
-            tred2();
-
-            // Diagonalize.
-            tql2();
-
-        }
-        else
-            // Reduce to Hessenberg form.
-            // Reduce Hessenberg to real Schur form.
-            hqr2(orthes(matrix));
-    }
-
-    /**
-     * Return the eigen vector matrix
-     *
-     * @return V
-     */
-    public Matrix getV() {
-        return like(v).assign(v);
-    }
-
-    /**
-     * Return the real parts of the eigenvalues
-     */
-    public Vector getRealEigenValues() {
-        return d;
-    }
-
-    /**
-     * Return the imaginary parts of the eigenvalues
-     */
-    public Vector getImagEigenvalues() {
-        return e;
-    }
-
-    /**
-     * Return the block diagonal eigenvalue matrix
-     *
-     * @return D
-     */
-    public Matrix getD() {
-        Matrix res = like(v, d.size(), d.size());
-        res.assign(0);
-        res.viewDiagonal().assign(d);
-        for (int i = 0; i < n; i++) {
-            double v = e.getX(i);
-            if (v > 0)
-                res.setX(i, i + 1, v);
-            else if (v < 0)
-                res.setX(i, i - 1, v);
-        }
-        return res;
-    }
-
-    /**
-     * Destroys decomposition components and other internal components of decomposition.
-     */
-    @Override public void destroy() {
-        e.destroy();
-        v.destroy();
-        d.destroy();
-    }
-
-    /** */
-    private void tred2() {
-        //  This is derived from the Algol procedures tred2 by
-        //  Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
-        //  Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
-        //  Fortran subroutine in EISPACK.
-
-        d.assign(v.viewColumn(n - 1));
-
-        // Householder reduction to tridiagonal form.
-
-        for (int i = n - 1; i > 0; i--) {
-
-            // Scale to avoid under/overflow.
-            double scale = d.viewPart(0, i).kNorm(1);
-            double h = 0.0;
-
-            if (scale == 0.0) {
-                e.setX(i, d.getX(i - 1));
-                for (int j = 0; j < i; j++) {
-                    d.setX(j, v.getX(i - 1, j));
-                    v.setX(i, j, 0.0);
-                    v.setX(j, i, 0.0);
-                }
-            }
-            else {
-
-                // Generate Householder vector.
-
-                for (int k = 0; k < i; k++) {
-                    d.setX(k, d.getX(k) / scale);
-                    h += d.getX(k) * d.getX(k);
-                }
-
-                double f = d.getX(i - 1);
-                double g = Math.sqrt(h);
-
-                if (f > 0)
-                    g = -g;
-
-                e.setX(i, scale * g);
-                h -= f * g;
-                d.setX(i - 1, f - g);
-
-                for (int j = 0; j < i; j++)
-                    e.setX(j, 0.0);
-
-                // Apply similarity transformation to remaining columns.
-
-                for (int j = 0; j < i; j++) {
-                    f = d.getX(j);
-                    v.setX(j, i, f);
-                    g = e.getX(j) + v.getX(j, j) * f;
-
-                    for (int k = j + 1; k <= i - 1; k++) {
-                        g += v.getX(k, j) * d.getX(k);
-                        e.setX(k, e.getX(k) + v.getX(k, j) * f);
-                    }
-
-                    e.setX(j, g);
-                }
-
-                f = 0.0;
-
-                for (int j = 0; j < i; j++) {
-                    e.setX(j, e.getX(j) / h);
-                    f += e.getX(j) * d.getX(j);
-                }
-
-                double hh = f / (h + h);
-
-                for (int j = 0; j < i; j++)
-                    e.setX(j, e.getX(j) - hh * d.getX(j));
-
-                for (int j = 0; j < i; j++) {
-                    f = d.getX(j);
-                    g = e.getX(j);
-
-                    for (int k = j; k <= i - 1; k++)
-                        v.setX(k, j, v.getX(k, j) - (f * e.getX(k) + g * d.getX(k)));
-
-                    d.setX(j, v.getX(i - 1, j));
-                    v.setX(i, j, 0.0);
-                }
-            }
-
-            d.setX(i, h);
-        }
-    }
-
-    /** */
-    private Matrix orthes(Matrix matrix) {
-        // Working storage for nonsymmetric algorithm.
-        Vector ort = likeVector(matrix);
-        Matrix hessenBerg = like(matrix).assign(matrix);
-
-        //  This is derived from the Algol procedures orthes and ortran,
-        //  by Martin and Wilkinson, Handbook for Auto. Comp.,
-        //  Vol.ii-Linear Algebra, and the corresponding
-        //  Fortran subroutines in EISPACK.
-
-        int low = 0;
-        int high = n - 1;
-
-        for (int m = low + 1; m <= high - 1; m++) {
-
-            // Scale column.
-
-            Vector hCol = hessenBerg.viewColumn(m - 1).viewPart(m, high - m + 1);
-            double scale = hCol.kNorm(1);
-
-            if (scale != 0.0) {
-                // Compute Householder transformation.
-                ort.viewPart(m, high - m + 1).map(hCol, Functions.plusMult(1 / scale));
-                double h = ort.viewPart(m, high - m + 1).getLengthSquared();
-
-                double g = Math.sqrt(h);
-
-                if (ort.getX(m) > 0)
-                    g = -g;
-
-                h -= ort.getX(m) * g;
-                ort.setX(m, ort.getX(m) - g);
-
-                // Apply Householder similarity transformation
-                // H = (I-u*u'/h)*H*(I-u*u')/h)
-
-                Vector ortPiece = ort.viewPart(m, high - m + 1);
-
-                for (int j = m; j < n; j++) {
-                    double f = ortPiece.dot(hessenBerg.viewColumn(j).viewPart(m, high - m + 1)) / h;
-                    hessenBerg.viewColumn(j).viewPart(m, high - m + 1).map(ortPiece, Functions.plusMult(-f));
-                }
-
-                for (int i = 0; i <= high; i++) {
-                    double f = ortPiece.dot(hessenBerg.viewRow(i).viewPart(m, high - m + 1)) / h;
-                    hessenBerg.viewRow(i).viewPart(m, high - m + 1).map(ortPiece, Functions.plusMult(-f));
-                }
-
-                ort.setX(m, scale * ort.getX(m));
-                hessenBerg.setX(m, m - 1, scale * g);
-            }
-        }
-
-        // Accumulate transformations (Algol's ortran).
-
-        v.assign(0);
-        v.viewDiagonal().assign(1);
-
-        for (int m = high - 1; m >= low + 1; m--) {
-            if (hessenBerg.getX(m, m - 1) != 0.0) {
-                ort.viewPart(m + 1, high - m).assign(hessenBerg.viewColumn(m - 1).viewPart(m + 1, high - m));
-
-                for (int j = m; j <= high; j++) {
-                    double g = ort.viewPart(m, high - m + 1).dot(v.viewColumn(j).viewPart(m, high - m + 1));
-
-                    // Double division avoids possible underflow
-                    g = g / ort.getX(m) / hessenBerg.getX(m, m - 1);
-                    v.viewColumn(j).viewPart(m, high - m + 1).map(ort.viewPart(m, high - m + 1), Functions.plusMult(g));
-                }
-            }
-        }
-
-        return hessenBerg;
-    }
-
-    /** Symmetric tridiagonal QL algorithm. */
-    private void tql2() {
-        //  This is derived from the Algol procedures tql2, by
-        //  Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
-        //  Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
-        //  Fortran subroutine in EISPACK.
-
-        e.viewPart(0, n - 1).assign(e.viewPart(1, n - 1));
-        e.setX(n - 1, 0.0);
-
-        double f = 0.0;
-        double tst1 = 0.0;
-        double eps = Math.pow(2.0, -52.0);
-
-        for (int l = 0; l < n; l++) {
-            // Find small subdiagonal element.
-
-            tst1 = Math.max(tst1, Math.abs(d.getX(l)) + Math.abs(e.getX(l)));
-            int m = l;
-
-            while (m < n) {
-                if (Math.abs(e.getX(m)) <= eps * tst1)
-                    break;
-
-                m++;
-            }
-
-            // If m == l, d.getX(l) is an eigenvalue,
-            // otherwise, iterate.
-
-            if (m > l) {
-                do {
-                    // Compute implicit shift
-
-                    double g = d.getX(l);
-                    double p = (d.getX(l + 1) - g) / (2.0 * e.getX(l));
-                    double r = Math.hypot(p, 1.0);
-
-                    if (p < 0)
-                        r = -r;
-
-                    d.setX(l, e.getX(l) / (p + r));
-                    d.setX(l + 1, e.getX(l) * (p + r));
-                    double dl1 = d.getX(l + 1);
-                    double h = g - d.getX(l);
-
-                    for (int i = l + 2; i < n; i++)
-                        d.setX(i, d.getX(i) - h);
-
-                    f += h;
-
-                    // Implicit QL transformation.
-
-                    p = d.getX(m);
-                    double c = 1.0;
-                    double c2 = c;
-                    double c3 = c;
-                    double el1 = e.getX(l + 1);
-                    double s = 0.0;
-                    double s2 = 0.0;
-
-                    for (int i = m - 1; i >= l; i--) {
-                        c3 = c2;
-                        c2 = c;
-                        s2 = s;
-                        g = c * e.getX(i);
-                        h = c * p;
-                        r = Math.hypot(p, e.getX(i));
-                        e.setX(i + 1, s * r);
-                        s = e.getX(i) / r;
-                        c = p / r;
-                        p = c * d.getX(i) - s * g;
-                        d.setX(i + 1, h + s * (c * g + s * d.getX(i)));
-
-                        // Accumulate transformation.
-
-                        for (int k = 0; k < n; k++) {
-                            h = v.getX(k, i + 1);
-                            v.setX(k, i + 1, s * v.getX(k, i) + c * h);
-                            v.setX(k, i, c * v.getX(k, i) - s * h);
-                        }
-                    }
-
-                    p = -s * s2 * c3 * el1 * e.getX(l) / dl1;
-                    e.setX(l, s * p);
-                    d.setX(l, c * p);
-
-                    // Check for convergence.
-
-                }
-                while (Math.abs(e.getX(l)) > eps * tst1);
-            }
-
-            d.setX(l, d.getX(l) + f);
-            e.setX(l, 0.0);
-        }
-
-        // Sort eigenvalues and corresponding vectors.
-
-        for (int i = 0; i < n - 1; i++) {
-            int k = i;
-            double p = d.getX(i);
-
-            for (int j = i + 1; j < n; j++)
-                if (d.getX(j) > p) {
-                    k = j;
-                    p = d.getX(j);
-                }
-
-            if (k != i) {
-                d.setX(k, d.getX(i));
-                d.setX(i, p);
-
-                for (int j = 0; j < n; j++) {
-                    p = v.getX(j, i);
-                    v.setX(j, i, v.getX(j, k));
-                    v.setX(j, k, p);
-                }
-            }
-        }
-    }
-
-    /** */
-    private void hqr2(Matrix h) {
-        //  This is derived from the Algol procedure hqr2,
-        //  by Martin and Wilkinson, Handbook for Auto. Comp.,
-        //  Vol.ii-Linear Algebra, and the corresponding
-        //  Fortran subroutine in EISPACK.
-
-        // Initialize
-
-        int nn = this.n;
-        int n = nn - 1;
-        int low = 0;
-        int high = nn - 1;
-        double eps = Math.pow(2.0, -52.0);
-        double exshift = 0.0;
-        double p = 0;
-        double q = 0;
-        double r = 0;
-        double s = 0;
-        double z = 0;
-        double w;
-        double x;
-        double y;
-
-        // Store roots isolated by balanc and compute matrix norm
-
-        double norm = h.foldMap(Functions.PLUS, Functions.ABS, 0.0);
-
-        // Outer loop over eigenvalue index
-
-        int iter = 0;
-        while (n >= low) {
-            // Look for single small sub-diagonal element
-            int l = n;
-
-            while (l > low) {
-                s = Math.abs(h.getX(l - 1, l - 1)) + Math.abs(h.getX(l, l));
-
-                if (s == 0.0)
-                    s = norm;
-
-                if (Math.abs(h.getX(l, l - 1)) < eps * s)
-                    break;
-
-                l--;
-            }
-
-            // Check for convergence
-
-            if (l == n) {
-                // One root found
-                h.setX(n, n, h.getX(n, n) + exshift);
-                d.setX(n, h.getX(n, n));
-                e.setX(n, 0.0);
-                n--;
-                iter = 0;
-            }
-            else if (l == n - 1) {
-                // Two roots found
-                w = h.getX(n, n - 1) * h.getX(n - 1, n);
-                p = (h.getX(n - 1, n - 1) - h.getX(n, n)) / 2.0;
-                q = p * p + w;
-                z = Math.sqrt(Math.abs(q));
-                h.setX(n, n, h.getX(n, n) + exshift);
-                h.setX(n - 1, n - 1, h.getX(n - 1, n - 1) + exshift);
-                x = h.getX(n, n);
-
-                // Real pair
-                if (q >= 0) {
-                    if (p >= 0)
-                        z = p + z;
-                    else
-                        z = p - z;
-
-                    d.setX(n - 1, x + z);
-                    d.setX(n, d.getX(n - 1));
-
-                    if (z != 0.0)
-                        d.setX(n, x - w / z);
-
-                    e.setX(n - 1, 0.0);
-                    e.setX(n, 0.0);
-                    x = h.getX(n, n - 1);
-                    s = Math.abs(x) + Math.abs(z);
-                    p = x / s;
-                    q = z / s;
-                    r = Math.sqrt(p * p + q * q);
-                    p /= r;
-                    q /= r;
-
-                    // Row modification
-
-                    for (int j = n - 1; j < nn; j++) {
-                        z = h.getX(n - 1, j);
-                        h.setX(n - 1, j, q * z + p * h.getX(n, j));
-                        h.setX(n, j, q * h.getX(n, j) - p * z);
-                    }
-
-                    // Column modification
-
-                    for (int i = 0; i <= n; i++) {
-                        z = h.getX(i, n - 1);
-                        h.setX(i, n - 1, q * z + p * h.getX(i, n));
-                        h.setX(i, n, q * h.getX(i, n) - p * z);
-                    }
-
-                    // Accumulate transformations
-
-                    for (int i = low; i <= high; i++) {
-                        z = v.getX(i, n - 1);
-                        v.setX(i, n - 1, q * z + p * v.getX(i, n));
-                        v.setX(i, n, q * v.getX(i, n) - p * z);
-                    }
-
-                    // Complex pair
-
-                }
-                else {
-                    d.setX(n - 1, x + p);
-                    d.setX(n, x + p);
-                    e.setX(n - 1, z);
-                    e.setX(n, -z);
-                }
-
-                n -= 2;
-                iter = 0;
-
-                // No convergence yet
-
-            }
-            else {
-                // Form shift
-                x = h.getX(n, n);
-                y = 0.0;
-                w = 0.0;
-
-                if (l < n) {
-                    y = h.getX(n - 1, n - 1);
-                    w = h.getX(n, n - 1) * h.getX(n - 1, n);
-                }
-
-                // Wilkinson's original ad hoc shift
-
-                if (iter == 10) {
-                    exshift += x;
-
-                    for (int i = low; i <= n; i++)
-                        h.setX(i, i, x);
-
-                    s = Math.abs(h.getX(n, n - 1)) + Math.abs(h.getX(n - 1, n - 2));
-                    x = y = 0.75 * s;
-                    w = -0.4375 * s * s;
-                }
-
-                // MATLAB's new ad hoc shift
-
-                if (iter == 30) {
-                    s = (y - x) / 2.0;
-                    s = s * s + w;
-
-                    if (s > 0) {
-                        s = Math.sqrt(s);
-
-                        if (y < x)
-                            s = -s;
-
-                        s = x - w / ((y - x) / 2.0 + s);
-
-                        for (int i = low; i <= n; i++)
-                            h.setX(i, i, h.getX(i, i) - s);
-
-                        exshift += s;
-                        x = y = w = 0.964;
-                    }
-                }
-
-                iter++;   // (Could check iteration count here.)
-
-                // Look for two consecutive small sub-diagonal elements
-
-                int m = n - 2;
-
-                while (m >= l) {
-                    z = h.getX(m, m);
-                    r = x - z;
-                    s = y - z;
-                    p = (r * s - w) / h.getX(m + 1, m) + h.getX(m, m + 1);
-                    q = h.getX(m + 1, m + 1) - z - r - s;
-                    r = h.getX(m + 2, m + 1);
-                    s = Math.abs(p) + Math.abs(q) + Math.abs(r);
-                    p /= s;
-                    q /= s;
-                    r /= s;
-
-                    if (m == l)
-                        break;
-
-                    double hmag = Math.abs(h.getX(m - 1, m - 1)) + Math.abs(h.getX(m + 1, m + 1));
-                    double threshold = eps * Math.abs(p) * (Math.abs(z) + hmag);
-
-                    if (Math.abs(h.getX(m, m - 1)) * (Math.abs(q) + Math.abs(r)) < threshold)
-                        break;
-
-                    m--;
-                }
-
-                for (int i = m + 2; i <= n; i++) {
-                    h.setX(i, i - 2, 0.0);
-
-                    if (i > m + 2)
-                        h.setX(i, i - 3, 0.0);
-                }
-
-                // Double QR step involving rows l:n and columns m:n
-
-                for (int k = m; k <= n - 1; k++) {
-                    boolean notlast = k != n - 1;
-
-                    if (k != m) {
-                        p = h.getX(k, k - 1);
-                        q = h.getX(k + 1, k - 1);
-                        r = notlast ? h.getX(k + 2, k - 1) : 0.0;
-                        x = Math.abs(p) + Math.abs(q) + Math.abs(r);
-                        if (x != 0.0) {
-                            p /= x;
-                            q /= x;
-                            r /= x;
-                        }
-                    }
-
-                    if (x == 0.0)
-                        break;
-
-                    s = Math.sqrt(p * p + q * q + r * r);
-
-                    if (p < 0)
-                        s = -s;
-
-                    if (s != 0) {
-                        if (k != m)
-                            h.setX(k, k - 1, -s * x);
-                        else if (l != m)
-                            h.setX(k, k - 1, -h.getX(k, k - 1));
-
-                        p += s;
-                        x = p / s;
-                        y = q / s;
-                        z = r / s;
-                        q /= p;
-                        r /= p;
-
-                        // Row modification
-
-                        for (int j = k; j < nn; j++) {
-                            p = h.getX(k, j) + q * h.getX(k + 1, j);
-
-                            if (notlast) {
-                                p += r * h.getX(k + 2, j);
-                                h.setX(k + 2, j, h.getX(k + 2, j) - p * z);
-                            }
-
-                            h.setX(k, j, h.getX(k, j) - p * x);
-                            h.setX(k + 1, j, h.getX(k + 1, j) - p * y);
-                        }
-
-                        // Column modification
-
-                        for (int i = 0; i <= Math.min(n, k + 3); i++) {
-                            p = x * h.getX(i, k) + y * h.getX(i, k + 1);
-
-                            if (notlast) {
-                                p += z * h.getX(i, k + 2);
-                                h.setX(i, k + 2, h.getX(i, k + 2) - p * r);
-                            }
-
-                            h.setX(i, k, h.getX(i, k) - p);
-                            h.setX(i, k + 1, h.getX(i, k + 1) - p * q);
-                        }
-
-                        // Accumulate transformations
-
-                        for (int i = low; i <= high; i++) {
-                            p = x * v.getX(i, k) + y * v.getX(i, k + 1);
-
-                            if (notlast) {
-                                p += z * v.getX(i, k + 2);
-                                v.setX(i, k + 2, v.getX(i, k + 2) - p * r);
-                            }
-
-                            v.setX(i, k, v.getX(i, k) - p);
-                            v.setX(i, k + 1, v.getX(i, k + 1) - p * q);
-                        }
-                    }  // (s != 0)
-                }  // k loop
-            }  // check convergence
-        }  // while (n >= low)
-
-        // Back substitute to find vectors of upper triangular form
-
-        if (norm == 0.0)
-            return;
-
-        for (n = nn - 1; n >= 0; n--) {
-            p = d.getX(n);
-            q = e.getX(n);
-
-            // Real vector
-
-            double t;
-
-            if (q == 0) {
-                int l = n;
-                h.setX(n, n, 1.0);
-
-                for (int i = n - 1; i >= 0; i--) {
-                    w = h.getX(i, i) - p;
-                    r = 0.0;
-
-                    for (int j = l; j <= n; j++)
-                        r += h.getX(i, j) * h.getX(j, n);
-
-                    if (e.getX(i) < 0.0) {
-                        z = w;
-                        s = r;
-                    }
-                    else {
-                        l = i;
-
-                        if (e.getX(i) == 0.0) {
-                            if (w == 0.0)
-                                h.setX(i, n, -r / (eps * norm));
-                            else
-                                h.setX(i, n, -r / w);
-
-                            // Solve real equations
-
-                        }
-                        else {
-                            x = h.getX(i, i + 1);
-                            y = h.getX(i + 1, i);
-                            q = (d.getX(i) - p) * (d.getX(i) - p) + e.getX(i) * e.getX(i);
-                            t = (x * s - z * r) / q;
-                            h.setX(i, n, t);
-
-                            if (Math.abs(x) > Math.abs(z))
-                                h.setX(i + 1, n, (-r - w * t) / x);
-                            else
-                                h.setX(i + 1, n, (-s - y * t) / z);
-                        }
-
-                        // Overflow control
-
-                        t = Math.abs(h.getX(i, n));
-
-                        if (eps * t * t > 1) {
-                            for (int j = i; j <= n; j++)
-                                h.setX(j, n, h.getX(j, n) / t);
-                        }
-                    }
-                }
-
-                // Complex vector
-
-            }
-            else if (q < 0) {
-                int l = n - 1;
-
-                // Last vector component imaginary so matrix is triangular
-
-                if (Math.abs(h.getX(n, n - 1)) > Math.abs(h.getX(n - 1, n))) {
-                    h.setX(n - 1, n - 1, q / h.getX(n, n - 1));
-                    h.setX(n - 1, n, -(h.getX(n, n) - p) / h.getX(n, n - 1));
-                }
-                else {
-                    cdiv(0.0, -h.getX(n - 1, n), h.getX(n - 1, n - 1) - p, q);
-                    h.setX(n - 1, n - 1, cdivr);
-                    h.setX(n - 1, n, cdivi);
-                }
-
-                h.setX(n, n - 1, 0.0);
-                h.setX(n, n, 1.0);
-
-                for (int i = n - 2; i >= 0; i--) {
-                    double ra = 0.0;
-                    double sa = 0.0;
-
-                    for (int j = l; j <= n; j++) {
-                        ra += h.getX(i, j) * h.getX(j, n - 1);
-                        sa += h.getX(i, j) * h.getX(j, n);
-                    }
-
-                    w = h.getX(i, i) - p;
-
-                    if (e.getX(i) < 0.0) {
-                        z = w;
-                        r = ra;
-                        s = sa;
-                    }
-                    else {
-                        l = i;
-
-                        if (e.getX(i) == 0) {
-                            cdiv(-ra, -sa, w, q);
-                            h.setX(i, n - 1, cdivr);
-                            h.setX(i, n, cdivi);
-                        }
-                        else {
-
-                            // Solve complex equations
-
-                            x = h.getX(i, i + 1);
-                            y = h.getX(i + 1, i);
-
-                            double vr = (d.getX(i) - p) * (d.getX(i) - p) + e.getX(i) * e.getX(i) - q * q;
-                            double vi = (d.getX(i) - p) * 2.0 * q;
-
-                            if (vr == 0.0 && vi == 0.0) {
-                                double hmag = Math.abs(x) + Math.abs(y);
-                                vr = eps * norm * (Math.abs(w) + Math.abs(q) + hmag + Math.abs(z));
-                            }
-
-                            cdiv(x * r - z * ra + q * sa, x * s - z * sa - q * ra, vr, vi);
-
-                            h.setX(i, n - 1, cdivr);
-                            h.setX(i, n, cdivi);
-
-                            if (Math.abs(x) > (Math.abs(z) + Math.abs(q))) {
-                                h.setX(i + 1, n - 1, (-ra - w * h.getX(i, n - 1) + q * h.getX(i, n)) / x);
-                                h.setX(i + 1, n, (-sa - w * h.getX(i, n) - q * h.getX(i, n - 1)) / x);
-                            }
-                            else {
-                                cdiv(-r - y * h.getX(i, n - 1), -s - y * h.getX(i, n), z, q);
-
-                                h.setX(i + 1, n - 1, cdivr);
-                                h.setX(i + 1, n, cdivi);
-                            }
-                        }
-
-                        // Overflow control
-
-                        t = Math.max(Math.abs(h.getX(i, n - 1)), Math.abs(h.getX(i, n)));
-
-                        if (eps * t * t > 1)
-                            for (int j = i; j <= n; j++) {
-                                h.setX(j, n - 1, h.getX(j, n - 1) / t);
-                                h.setX(j, n, h.getX(j, n) / t);
-                            }
-                    }
-                }
-            }
-        }
-
-        // Vectors of isolated roots
-
-        for (int i = 0; i < nn; i++)
-            if (i < low || i > high) {
-                for (int j = i; j < nn; j++)
-                    v.setX(i, j, h.getX(i, j));
-            }
-
-        // Back transformation to get eigen vectors of original matrix
-
-        for (int j = nn - 1; j >= low; j--)
-            for (int i = low; i <= high; i++) {
-                z = 0.0;
-
-                for (int k = low; k <= Math.min(j, high); k++)
-                    z += v.getX(i, k) * h.getX(k, j);
-
-                v.setX(i, j, z);
-            }
-    }
-
-    /** */
-    private static boolean isSymmetric(Matrix matrix) {
-        int cols = matrix.columnSize();
-        int rows = matrix.rowSize();
-
-        if (cols != rows)
-            return false;
-
-        for (int i = 0; i < cols; i++)
-            for (int j = 0; j < rows; j++) {
-                if (matrix.getX(i, j) != matrix.get(j, i))
-                    return false;
-            }
-
-        return true;
-    }
-
-    /** Complex scalar division - real part. */
-    private double cdivr;
-    /** Complex scalar division - imaginary part. */
-    private double cdivi;
-
-    /** */
-    private void cdiv(double xr, double xi, double yr, double yi) {
-        double r;
-        double d;
-
-        if (Math.abs(yr) > Math.abs(yi)) {
-            r = yi / yr;
-            d = yr + r * yi;
-            cdivr = (xr + r * xi) / d;
-            cdivi = (xi - r * xr) / d;
-        }
-        else {
-            r = yr / yi;
-            d = yi + r * yr;
-            cdivr = (r * xr + xi) / d;
-            cdivi = (r * xi - xr) / d;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/decompositions/LUDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/LUDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/math/decompositions/LUDecomposition.java
deleted file mode 100644
index 82c90ec..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/LUDecomposition.java
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.decompositions;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.CardinalityException;
-import org.apache.ignite.math.exceptions.SingularMatrixException;
-
-/**
- * Calculates the LU-decomposition of a square matrix.
- *
- * This class inspired by class from Apache Common Math with similar name.
- *
- * @see <a href="http://mathworld.wolfram.com/LUDecomposition.html">MathWorld</a>
- * @see <a href="http://en.wikipedia.org/wiki/LU_decomposition">Wikipedia</a>
- */
-public class LUDecomposition extends DecompositionSupport {
-    /** Default bound to determine effective singularity in LU decomposition. */
-    private static final double DEFAULT_TOO_SMALL = 1e-11;
-
-    /** Pivot permutation associated with LU decomposition. */
-    private final Vector pivot;
-    /** Parity of the permutation associated with the LU decomposition. */
-    private boolean even;
-    /** Singularity indicator. */
-    private boolean singular;
-    /** Cached value of L. */
-    private Matrix cachedL;
-    /** Cached value of U. */
-    private Matrix cachedU;
-    /** Cached value of P. */
-    private Matrix cachedP;
-    /** Original matrix. */
-    private Matrix matrix;
-    /** Entries of LU decomposition. */
-    private Matrix lu;
-
-    /**
-     * Calculates the LU-decomposition of the given matrix.
-     * This constructor uses 1e-11 as default value for the singularity
-     * threshold.
-     *
-     * @param matrix Matrix to decompose.
-     * @throws CardinalityException if matrix is not square.
-     */
-    public LUDecomposition(Matrix matrix) {
-        this(matrix, DEFAULT_TOO_SMALL);
-    }
-
-    /**
-     * Calculates the LUP-decomposition of the given matrix.
-     *
-     * @param matrix Matrix to decompose.
-     * @param singularityThreshold threshold (based on partial row norm).
-     * @throws CardinalityException if matrix is not square.
-     */
-    public LUDecomposition(Matrix matrix, double singularityThreshold) {
-        assert matrix != null;
-
-        int rows = matrix.rowSize();
-        int cols = matrix.columnSize();
-
-        if (rows != cols)
-            throw new CardinalityException(rows, cols);
-
-        this.matrix = matrix;
-
-        lu = copy(matrix);
-
-        pivot = likeVector(matrix);
-
-        for (int i = 0; i < pivot.size(); i++)
-            pivot.setX(i, i);
-
-        even = true;
-        singular = false;
-
-        cachedL = null;
-        cachedU = null;
-        cachedP = null;
-
-        for (int col = 0; col < cols; col++) {
-
-            //upper
-            for (int row = 0; row < col; row++) {
-                Vector luRow = lu.viewRow(row);
-                double sum = luRow.get(col);
-
-                for (int i = 0; i < row; i++)
-                    sum -= luRow.getX(i) * lu.getX(i, col);
-
-                luRow.setX(col, sum);
-            }
-
-            // permutation row
-            int max = col;
-
-            double largest = Double.NEGATIVE_INFINITY;
-
-            // lower
-            for (int row = col; row < rows; row++) {
-                Vector luRow = lu.viewRow(row);
-                double sum = luRow.getX(col);
-
-                for (int i = 0; i < col; i++)
-                    sum -= luRow.getX(i) * lu.getX(i, col);
-
-                luRow.setX(col, sum);
-
-                if (Math.abs(sum) > largest) {
-                    largest = Math.abs(sum);
-                    max = row;
-                }
-            }
-
-            // Singularity check
-            if (Math.abs(lu.getX(max, col)) < singularityThreshold) {
-                singular = true;
-                return;
-            }
-
-            // Pivot if necessary
-            if (max != col) {
-                double tmp;
-                Vector luMax = lu.viewRow(max);
-                Vector luCol = lu.viewRow(col);
-
-                for (int i = 0; i < cols; i++) {
-                    tmp = luMax.getX(i);
-                    luMax.setX(i, luCol.getX(i));
-                    luCol.setX(i, tmp);
-                }
-
-                int temp = (int)pivot.getX(max);
-                pivot.setX(max, pivot.getX(col));
-                pivot.setX(col, temp);
-
-                even = !even;
-            }
-
-            // Divide the lower elements by the "winning" diagonal elt.
-            final double luDiag = lu.getX(col, col);
-
-            for (int row = col + 1; row < cols; row++) {
-                double val = lu.getX(row, col) / luDiag;
-                lu.setX(row, col, val);
-            }
-        }
-    }
-
-    /**
-     * Destroys decomposition components and other internal components of decomposition.
-     */
-    @Override public void destroy() {
-        if (cachedL != null)
-            cachedL.destroy();
-        if (cachedU != null)
-            cachedU.destroy();
-        if (cachedP != null)
-            cachedP.destroy();
-        lu.destroy();
-    }
-
-    /**
-     * Returns the matrix L of the decomposition.
-     * <p>L is a lower-triangular matrix</p>
-     *
-     * @return the L matrix (or null if decomposed matrix is singular).
-     */
-    public Matrix getL() {
-        if ((cachedL == null) && !singular) {
-            final int m = pivot.size();
-
-            cachedL = like(matrix);
-            cachedL.assign(0.0);
-
-            for (int i = 0; i < m; ++i) {
-                for (int j = 0; j < i; ++j)
-                    cachedL.setX(i, j, lu.getX(i, j));
-
-                cachedL.setX(i, i, 1.0);
-            }
-        }
-
-        return cachedL;
-    }
-
-    /**
-     * Returns the matrix U of the decomposition.
-     * <p>U is an upper-triangular matrix</p>
-     *
-     * @return the U matrix (or null if decomposed matrix is singular).
-     */
-    public Matrix getU() {
-        if ((cachedU == null) && !singular) {
-            final int m = pivot.size();
-
-            cachedU = like(matrix);
-            cachedU.assign(0.0);
-
-            for (int i = 0; i < m; ++i)
-                for (int j = i; j < m; ++j)
-                    cachedU.setX(i, j, lu.getX(i, j));
-        }
-
-        return cachedU;
-    }
-
-    /**
-     * Returns the P rows permutation matrix.
-     * <p>P is a sparse matrix with exactly one element set to 1.0 in
-     * each row and each column, all other elements being set to 0.0.</p>
-     * <p>The positions of the 1 elements are given by the {@link #getPivot()
-     * pivot permutation vector}.</p>
-     *
-     * @return the P rows permutation matrix (or null if decomposed matrix is singular).
-     * @see #getPivot()
-     */
-    public Matrix getP() {
-        if ((cachedP == null) && !singular) {
-            final int m = pivot.size();
-
-            cachedP = like(matrix);
-            cachedP.assign(0.0);
-
-            for (int i = 0; i < m; ++i)
-                cachedP.setX(i, (int)pivot.get(i), 1.0);
-        }
-
-        return cachedP;
-    }
-
-    /**
-     * Returns the pivot permutation vector.
-     *
-     * @return the pivot permutation vector.
-     * @see #getP()
-     */
-    public Vector getPivot() {
-        return pivot.copy();
-    }
-
-    /**
-     * Return the determinant of the matrix.
-     *
-     * @return determinant of the matrix.
-     */
-    public double determinant() {
-        if (singular)
-            return 0;
-
-        final int m = pivot.size();
-        double determinant = even ? 1 : -1;
-
-        for (int i = 0; i < m; i++)
-            determinant *= lu.getX(i, i);
-
-        return determinant;
-    }
-
-    /** */
-    public Vector solve(Vector b) {
-        final int m = pivot.size();
-
-        if (b.size() != m)
-            throw new CardinalityException(b.size(), m);
-
-        if (singular)
-            throw new SingularMatrixException();
-
-        final double[] bp = new double[m];
-
-        // Apply permutations to b
-        for (int row = 0; row < m; row++)
-            bp[row] = b.get((int)pivot.get(row));
-
-        // Solve LY = b
-        for (int col = 0; col < m; col++) {
-            final double bpCol = bp[col];
-
-            for (int i = col + 1; i < m; i++)
-                bp[i] -= bpCol * lu.get(i, col);
-        }
-
-        // Solve UX = Y
-        for (int col = m - 1; col >= 0; col--) {
-            bp[col] /= lu.get(col, col);
-            final double bpCol = bp[col];
-
-            for (int i = 0; i < col; i++)
-                bp[i] -= bpCol * lu.get(i, col);
-        }
-
-        return b.like(m).assign(bp);
-    }
-
-    /** */
-    public Matrix solve(Matrix b) {
-        final int m = pivot.size();
-
-        if (b.rowSize() != m)
-            throw new CardinalityException(b.rowSize(), m);
-
-        if (singular)
-            throw new SingularMatrixException();
-
-        final int nColB = b.columnSize();
-
-        // Apply permutations to b
-        final double[][] bp = new double[m][nColB];
-        for (int row = 0; row < m; row++) {
-            final double[] bpRow = bp[row];
-            final int pRow = (int)pivot.get(row);
-
-            for (int col = 0; col < nColB; col++)
-                bpRow[col] = b.get(pRow, col);
-        }
-
-        // Solve LY = b
-        for (int col = 0; col < m; col++) {
-            final double[] bpCol = bp[col];
-            for (int i = col + 1; i < m; i++) {
-                final double[] bpI = bp[i];
-                final double luICol = lu.get(i, col);
-
-                for (int j = 0; j < nColB; j++)
-                    bpI[j] -= bpCol[j] * luICol;
-            }
-        }
-
-        // Solve UX = Y
-        for (int col = m - 1; col >= 0; col--) {
-            final double[] bpCol = bp[col];
-            final double luDiag = lu.getX(col, col);
-
-            for (int j = 0; j < nColB; j++)
-                bpCol[j] /= luDiag;
-
-            for (int i = 0; i < col; i++) {
-                final double[] bpI = bp[i];
-                final double luICol = lu.get(i, col);
-
-                for (int j = 0; j < nColB; j++)
-                    bpI[j] -= bpCol[j] * luICol;
-            }
-        }
-
-        return b.like(b.rowSize(), b.columnSize()).assign(bp);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/decompositions/QRDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/QRDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/math/decompositions/QRDecomposition.java
deleted file mode 100644
index 9608ed5..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/QRDecomposition.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.decompositions;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.functions.Functions;
-
-/**
- * For an {@code m x n} matrix {@code A} with {@code m >= n}, the QR decomposition
- * is an {@code m x n} orthogonal matrix {@code Q} and an {@code n x n} upper
- * triangular matrix {@code R} so that {@code A = Q*R}.
- */
-public class QRDecomposition extends DecompositionSupport {
-    /** */
-    private final Matrix q;
-    /** */
-    private final Matrix r;
-
-    /** */
-    private final Matrix mType;
-    /** */
-    private final boolean fullRank;
-
-    /** */
-    private final int rows;
-    /** */
-    private final int cols;
-
-    /**
-     * @param v Value to be checked for being an ordinary double.
-     */
-    private void checkDouble(double v) {
-        if (Double.isInfinite(v) || Double.isNaN(v))
-            throw new ArithmeticException("Invalid intermediate result");
-    }
-
-    /**
-     * Constructs a new QR decomposition object computed by Householder reflections.
-     *
-     * @param mtx A rectangular matrix.
-     */
-    public QRDecomposition(Matrix mtx) {
-        assert mtx != null;
-
-        rows = mtx.rowSize();
-
-        int min = Math.min(mtx.rowSize(), mtx.columnSize());
-
-        cols = mtx.columnSize();
-
-        mType = like(mtx, 1, 1);
-
-        Matrix qTmp = copy(mtx);
-
-        boolean fullRank = true;
-
-        r = like(mtx, min, cols);
-
-        for (int i = 0; i < min; i++) {
-            Vector qi = qTmp.viewColumn(i);
-
-            double alpha = qi.kNorm(2);
-
-            if (Math.abs(alpha) > Double.MIN_VALUE)
-                qi.map(Functions.div(alpha));
-            else {
-                checkDouble(alpha);
-
-                fullRank = false;
-            }
-
-            r.set(i, i, alpha);
-
-            for (int j = i + 1; j < cols; j++) {
-                Vector qj = qTmp.viewColumn(j);
-
-                double norm = qj.kNorm(2);
-
-                if (Math.abs(norm) > Double.MIN_VALUE) {
-                    double beta = qi.dot(qj);
-
-                    r.set(i, j, beta);
-
-                    if (j < min)
-                        qj.map(qi, Functions.plusMult(-beta));
-                }
-                else
-                    checkDouble(norm);
-            }
-        }
-
-        if (cols > min)
-            q = qTmp.viewPart(0, rows, 0, min).copy();
-        else
-            q = qTmp;
-
-        this.fullRank = fullRank;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void destroy() {
-        q.destroy();
-        r.destroy();
-        mType.destroy();
-    }
-
-    /**
-     * Gets orthogonal factor {@code Q}.
-     */
-    public Matrix getQ() {
-        return q;
-    }
-
-    /**
-     * Gets triangular factor {@code R}.
-     */
-    public Matrix getR() {
-        return r;
-    }
-
-    /**
-     * Returns whether the matrix {@code A} has full rank.
-     *
-     * @return true if {@code R}, and hence {@code A} , has full rank.
-     */
-    public boolean hasFullRank() {
-        return fullRank;
-    }
-
-    /**
-     * Least squares solution of {@code A*X = B}; {@code returns X}.
-     *
-     * @param mtx A matrix with as many rows as {@code A} and any number of cols.
-     * @return {@code X<} that minimizes the two norm of {@code Q*R*X - B}.
-     * @throws IllegalArgumentException if {@code B.rows() != A.rows()}.
-     */
-    public Matrix solve(Matrix mtx) {
-        if (mtx.rowSize() != rows)
-            throw new IllegalArgumentException("Matrix row dimensions must agree.");
-
-        int cols = mtx.columnSize();
-
-        Matrix x = like(mType, this.cols, cols);
-
-        Matrix qt = getQ().transpose();
-        Matrix y = qt.times(mtx);
-
-        Matrix r = getR();
-
-        for (int k = Math.min(this.cols, rows) - 1; k > 0; k--) {
-            // X[k,] = Y[k,] / R[k,k], note that X[k,] starts with 0 so += is same as =
-            x.viewRow(k).map(y.viewRow(k), Functions.plusMult(1 / r.get(k, k)));
-
-            // Y[0:(k-1),] -= R[0:(k-1),k] * X[k,]
-            Vector rCol = r.viewColumn(k).viewPart(0, k);
-
-            for (int c = 0; c < cols; c++)
-                y.viewColumn(c).viewPart(0, k).map(rCol, Functions.plusMult(-x.get(k, c)));
-        }
-
-        return x;
-    }
-
-    /**
-     * Returns a rough string rendition of a QR.
-     */
-    @Override public String toString() {
-        return String.format("QR(%d x %d, fullRank=%s)", rows, cols, hasFullRank());
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/decompositions/SingularValueDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/SingularValueDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/math/decompositions/SingularValueDecomposition.java
deleted file mode 100644
index 75eb206..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/SingularValueDecomposition.java
+++ /dev/null
@@ -1,620 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.decompositions;
-
-import org.apache.ignite.math.Algebra;
-import org.apache.ignite.math.Matrix;
-
-/**
- * Compute a singular value decomposition (SVD) of {@code (l x k)} matrix {@code m}.
- * <p>This decomposition can be thought
- * as an extension of {@link EigenDecomposition} to rectangular matrices. The factorization we get is following:</p>
- * <p>{@code m = u * s * v^{*}}, where</p>
- * <ul><li>{@code u} is a real or complex unitary matrix.</li>
- * <li>{@code s} is a rectangular diagonal matrix with non-negative real numbers on diagonal
- * (these numbers are singular values of {@code m}).</li>
- * <li>{@code v} is a real or complex unitary matrix.</li></ul>
- * <p>If {@code m} is real then {@code u} and {@code v} are also real.</p>
- * <p>See also: <a href="https://en.wikipedia.org/wiki/Singular_value_decomposition">Wikipedia article on SVD</a>.</p>
- * <p>Note: complex case is currently not supported.</p>
- */
-public class SingularValueDecomposition extends DecompositionSupport {
-    // U and V.
-    /** */
-    private final double[][] u;
-    /** */
-    private final double[][] v;
-
-    /** Singular values. */
-    private final double[] s;
-
-    /** Row dimension. */
-    private final int m;
-    /** Column dimension. */
-    private final int n;
-
-    /** */
-    private Matrix arg;
-
-    /** */
-    private boolean transpositionNeeded;
-
-    /**
-     * Singular value decomposition object.
-     *
-     * @param arg A rectangular matrix.
-     */
-    public SingularValueDecomposition(Matrix arg) {
-        assert arg != null;
-
-        this.arg = arg;
-
-        if (arg.rowSize() < arg.columnSize())
-            transpositionNeeded = true;
-
-        double[][] a;
-
-        if (transpositionNeeded) {
-            // Use the transpose matrix.
-            m = arg.columnSize();
-            n = arg.rowSize();
-
-            a = new double[m][n];
-
-            for (int i = 0; i < m; i++)
-                for (int j = 0; j < n; j++)
-                    a[i][j] = arg.get(j, i);
-        }
-        else {
-            m = arg.rowSize();
-            n = arg.columnSize();
-
-            a = new double[m][n];
-
-            for (int i = 0; i < m; i++)
-                for (int j = 0; j < n; j++)
-                    a[i][j] = arg.get(i, j);
-        }
-
-        int nu = Math.min(m, n);
-
-        s = new double[Math.min(m + 1, n)];
-        u = new double[m][nu];
-        v = new double[n][n];
-
-        double[] e = new double[n];
-        double[] work = new double[m];
-
-        int nct = Math.min(m - 1, n);
-        int nrt = Math.max(0, Math.min(n - 2, m));
-
-        for (int k = 0; k < Math.max(nct, nrt); k++) {
-            if (k < nct) {
-                // Compute the transformation for the k-th column and
-                // place the k-th diagonal in s[k]. Compute 2-norm of k-th
-                // column without under/overflow.
-                s[k] = 0;
-
-                for (int i = k; i < m; i++)
-                    s[k] = Algebra.hypot(s[k], a[i][k]);
-
-                if (s[k] != 0.0) {
-                    if (a[k][k] < 0.0)
-                        s[k] = -s[k];
-
-                    for (int i = k; i < m; i++)
-                        a[i][k] /= s[k];
-
-                    a[k][k] += 1.0;
-                }
-
-                s[k] = -s[k];
-            }
-
-            for (int j = k + 1; j < n; j++) {
-                if (k < nct && s[k] != 0.0) {
-                    // Apply the transformation.
-                    double t = 0;
-
-                    for (int i = k; i < m; i++)
-                        t += a[i][k] * a[i][j];
-
-                    t = -t / a[k][k];
-
-                    for (int i = k; i < m; i++)
-                        a[i][j] += t * a[i][k];
-                }
-
-                // Place the k-th row of A into e for the
-                // subsequent calculation of the row transformation.
-                e[j] = a[k][j];
-            }
-
-            if (k < nct)
-                // Place the transformation in U for subsequent back
-                // multiplication.
-                for (int i = k; i < m; i++)
-                    u[i][k] = a[i][k];
-
-            if (k < nrt) {
-                // Compute the k-th row transformation and place the
-                // k-th super-diagonal in e[k].
-                // Compute 2-norm without under/overflow.
-                e[k] = 0;
-
-                for (int i = k + 1; i < n; i++)
-                    e[k] = Algebra.hypot(e[k], e[i]);
-
-                if (e[k] != 0.0) {
-                    if (e[k + 1] < 0.0)
-                        e[k] = -e[k];
-
-                    for (int i = k + 1; i < n; i++)
-                        e[i] /= e[k];
-
-                    e[k + 1] += 1.0;
-                }
-
-                e[k] = -e[k];
-
-                if (k + 1 < m && e[k] != 0.0) {
-                    // Apply the transformation.
-                    for (int i = k + 1; i < m; i++)
-                        work[i] = 0.0;
-
-                    for (int j = k + 1; j < n; j++)
-                        for (int i = k + 1; i < m; i++)
-                            work[i] += e[j] * a[i][j];
-
-                    for (int j = k + 1; j < n; j++) {
-                        double t = -e[j] / e[k + 1];
-
-                        for (int i = k + 1; i < m; i++)
-                            a[i][j] += t * work[i];
-                    }
-                }
-
-                // Place the transformation in V for subsequent
-                // back multiplication.
-                for (int i = k + 1; i < n; i++)
-                    v[i][k] = e[i];
-            }
-        }
-
-        // Set up the final bi-diagonal matrix or order p.
-        int p = Math.min(n, m + 1);
-
-        if (nct < n)
-            s[nct] = a[nct][nct];
-
-        if (m < p)
-            s[p - 1] = 0.0;
-
-        if (nrt + 1 < p)
-            e[nrt] = a[nrt][p - 1];
-
-        e[p - 1] = 0.0;
-
-        // Generate U.
-        for (int j = nct; j < nu; j++) {
-            for (int i = 0; i < m; i++)
-                u[i][j] = 0.0;
-
-            u[j][j] = 1.0;
-        }
-
-        for (int k = nct - 1; k >= 0; k--) {
-            if (s[k] != 0.0) {
-                for (int j = k + 1; j < nu; j++) {
-                    double t = 0;
-
-                    for (int i = k; i < m; i++)
-                        t += u[i][k] * u[i][j];
-
-                    t = -t / u[k][k];
-
-                    for (int i = k; i < m; i++)
-                        u[i][j] += t * u[i][k];
-                }
-
-                for (int i = k; i < m; i++)
-                    u[i][k] = -u[i][k];
-
-                u[k][k] = 1.0 + u[k][k];
-
-                for (int i = 0; i < k - 1; i++)
-                    u[i][k] = 0.0;
-            }
-            else {
-                for (int i = 0; i < m; i++)
-                    u[i][k] = 0.0;
-
-                u[k][k] = 1.0;
-            }
-        }
-
-        // Generate V.
-        for (int k = n - 1; k >= 0; k--) {
-            if (k < nrt && e[k] != 0.0) {
-                for (int j = k + 1; j < nu; j++) {
-                    double t = 0;
-
-                    for (int i = k + 1; i < n; i++)
-                        t += v[i][k] * v[i][j];
-
-                    t = -t / v[k + 1][k];
-
-                    for (int i = k + 1; i < n; i++)
-                        v[i][j] += t * v[i][k];
-                }
-            }
-
-            for (int i = 0; i < n; i++)
-                v[i][k] = 0.0;
-
-            v[k][k] = 1.0;
-        }
-
-        // Main iteration loop for the singular values.
-        int pp = p - 1;
-        int iter = 0;
-
-        double eps = Math.pow(2.0, -52.0);
-        double tiny = Math.pow(2.0, -966.0);
-
-        while (p > 0) {
-            int k;
-
-            for (k = p - 2; k >= -1; k--) {
-                if (k == -1)
-                    break;
-
-                if (Math.abs(e[k]) <= tiny + eps * (Math.abs(s[k]) + Math.abs(s[k + 1]))) {
-                    e[k] = 0.0;
-
-                    break;
-                }
-            }
-
-            int kase;
-
-            if (k == p - 2)
-                kase = 4;
-            else {
-                int ks;
-
-                for (ks = p - 1; ks >= k; ks--) {
-                    if (ks == k)
-                        break;
-
-                    double t =
-                        (ks != p ? Math.abs(e[ks]) : 0.) +
-                            (ks != k + 1 ? Math.abs(e[ks - 1]) : 0.);
-
-                    if (Math.abs(s[ks]) <= tiny + eps * t) {
-                        s[ks] = 0.0;
-
-                        break;
-                    }
-                }
-
-                if (ks == k)
-                    kase = 3;
-                else if (ks == p - 1)
-                    kase = 1;
-                else {
-                    kase = 2;
-
-                    k = ks;
-                }
-            }
-
-            k++;
-
-            // Perform the task indicated by kase.
-            switch (kase) {
-                // Deflate negligible s(p).
-                case 1: {
-                    double f = e[p - 2];
-
-                    e[p - 2] = 0.0;
-
-                    for (int j = p - 2; j >= k; j--) {
-                        double t = Algebra.hypot(s[j], f);
-                        double cs = s[j] / t;
-                        double sn = f / t;
-
-                        s[j] = t;
-
-                        if (j != k) {
-                            f = -sn * e[j - 1];
-                            e[j - 1] = cs * e[j - 1];
-                        }
-
-                        for (int i = 0; i < n; i++) {
-                            t = cs * v[i][j] + sn * v[i][p - 1];
-
-                            v[i][p - 1] = -sn * v[i][j] + cs * v[i][p - 1];
-                            v[i][j] = t;
-                        }
-                    }
-                }
-
-                break;
-
-                // Split at negligible s(k).
-                case 2: {
-                    double f = e[k - 1];
-                    e[k - 1] = 0.0;
-
-                    for (int j = k; j < p; j++) {
-                        double t = Algebra.hypot(s[j], f);
-                        double cs = s[j] / t;
-                        double sn = f / t;
-
-                        s[j] = t;
-                        f = -sn * e[j];
-                        e[j] = cs * e[j];
-
-                        for (int i = 0; i < m; i++) {
-                            t = cs * u[i][j] + sn * u[i][k - 1];
-
-                            u[i][k - 1] = -sn * u[i][j] + cs * u[i][k - 1];
-                            u[i][j] = t;
-                        }
-                    }
-                }
-
-                break;
-
-                // Perform one qr step.
-                case 3: {
-                    // Calculate the shift.
-                    double scale = Math.max(Math.max(Math.max(Math.max(
-                        Math.abs(s[p - 1]), Math.abs(s[p - 2])), Math.abs(e[p - 2])),
-                        Math.abs(s[k])), Math.abs(e[k]));
-
-                    double sp = s[p - 1] / scale;
-                    double spm1 = s[p - 2] / scale;
-                    double epm1 = e[p - 2] / scale;
-                    double sk = s[k] / scale;
-                    double ek = e[k] / scale;
-                    double b = ((spm1 + sp) * (spm1 - sp) + epm1 * epm1) / 2.0;
-                    double c = sp * epm1 * sp * epm1;
-                    double shift = 0.0;
-
-                    if (b != 0.0 || c != 0.0) {
-                        shift = Math.sqrt(b * b + c);
-
-                        if (b < 0.0)
-                            shift = -shift;
-
-                        shift = c / (b + shift);
-                    }
-
-                    double f = (sk + sp) * (sk - sp) + shift;
-                    double g = sk * ek;
-
-                    // Chase zeros.
-                    for (int j = k; j < p - 1; j++) {
-                        double t = Algebra.hypot(f, g);
-                        double cs = f / t;
-                        double sn = g / t;
-
-                        if (j != k)
-                            e[j - 1] = t;
-
-                        f = cs * s[j] + sn * e[j];
-                        e[j] = cs * e[j] - sn * s[j];
-                        g = sn * s[j + 1];
-                        s[j + 1] = cs * s[j + 1];
-
-                        for (int i = 0; i < n; i++) {
-                            t = cs * v[i][j] + sn * v[i][j + 1];
-
-                            v[i][j + 1] = -sn * v[i][j] + cs * v[i][j + 1];
-                            v[i][j] = t;
-                        }
-
-                        t = Algebra.hypot(f, g);
-                        cs = f / t;
-                        sn = g / t;
-                        s[j] = t;
-                        f = cs * e[j] + sn * s[j + 1];
-                        s[j + 1] = -sn * e[j] + cs * s[j + 1];
-                        g = sn * e[j + 1];
-                        e[j + 1] = cs * e[j + 1];
-
-                        if (j < m - 1)
-                            for (int i = 0; i < m; i++) {
-                                t = cs * u[i][j] + sn * u[i][j + 1];
-
-                                u[i][j + 1] = -sn * u[i][j] + cs * u[i][j + 1];
-                                u[i][j] = t;
-                            }
-                    }
-
-                    e[p - 2] = f;
-                    iter = iter + 1;
-                }
-
-                break;
-
-                // Convergence.
-                case 4: {
-                    // Make the singular values positive.
-                    if (s[k] <= 0.0) {
-                        s[k] = s[k] < 0.0 ? -s[k] : 0.0;
-
-                        for (int i = 0; i <= pp; i++)
-                            v[i][k] = -v[i][k];
-                    }
-
-                    // Order the singular values.
-                    while (k < pp) {
-                        if (s[k] >= s[k + 1])
-                            break;
-
-                        double t = s[k];
-
-                        s[k] = s[k + 1];
-                        s[k + 1] = t;
-
-                        if (k < n - 1)
-                            for (int i = 0; i < n; i++) {
-                                t = v[i][k + 1];
-
-                                v[i][k + 1] = v[i][k];
-                                v[i][k] = t;
-                            }
-
-                        if (k < m - 1)
-                            for (int i = 0; i < m; i++) {
-                                t = u[i][k + 1];
-
-                                u[i][k + 1] = u[i][k];
-                                u[i][k] = t;
-                            }
-
-                        k++;
-                    }
-
-                    iter = 0;
-                    p--;
-                }
-
-                break;
-
-                default:
-                    throw new IllegalStateException();
-            }
-        }
-    }
-
-    /**
-     * Gets the two norm condition number, which is {@code max(S) / min(S)} .
-     */
-    public double cond() {
-        return s[0] / s[Math.min(m, n) - 1];
-    }
-
-    /**
-     * @return the diagonal matrix of singular values.
-     */
-    public Matrix getS() {
-        double[][] s = new double[n][n];
-
-        for (int i = 0; i < n; i++) {
-            for (int j = 0; j < n; j++)
-                s[i][j] = 0.0;
-
-            s[i][i] = this.s[i];
-        }
-
-        return like(arg, n, n).assign(s);
-    }
-
-    /**
-     * Gets the diagonal of {@code S}, which is a one-dimensional array of
-     * singular values.
-     *
-     * @return diagonal of {@code S}.
-     */
-    public double[] getSingularValues() {
-        return s;
-    }
-
-    /**
-     * Gets the left singular vectors {@code U}.
-     *
-     * @return {@code U}
-     */
-    public Matrix getU() {
-        if (transpositionNeeded)
-            return like(arg, v.length, v.length).assign(v);
-        else {
-            int numCols = Math.min(m + 1, n);
-
-            Matrix r = like(arg, m, numCols);
-
-            for (int i = 0; i < m; i++)
-                for (int j = 0; j < numCols; j++)
-                    r.set(i, j, u[i][j]);
-
-            return r;
-        }
-    }
-
-    /**
-     * Gets the right singular vectors {@code V}.
-     *
-     * @return {@code V}
-     */
-    public Matrix getV() {
-        if (transpositionNeeded) {
-            int numCols = Math.min(m + 1, n);
-
-            Matrix r = like(arg, m, numCols);
-
-            for (int i = 0; i < m; i++)
-                for (int j = 0; j < numCols; j++)
-                    r.set(i, j, u[i][j]);
-
-            return r;
-        }
-        else
-            return like(arg, v.length, v.length).assign(v);
-    }
-
-    /**
-     * Gets the two norm, which is {@code max(S)}.
-     */
-    public double norm2() {
-        return s[0];
-    }
-
-    /**
-     * Gets effective numerical matrix rank.
-     */
-    public int rank() {
-        double eps = Math.pow(2.0, -52.0);
-        double tol = Math.max(m, n) * s[0] * eps;
-        int r = 0;
-
-        for (double value : s)
-            if (value > tol)
-                r++;
-
-        return r;
-    }
-
-    /**
-     * Gets [n � n] covariance matrix.
-     *
-     * @param minSingularVal Value below which singular values are ignored.
-     */
-    Matrix getCovariance(double minSingularVal) {
-        Matrix j = like(arg, s.length, s.length);
-        Matrix vMat = like(arg, v.length, v.length).assign(v);
-
-        for (int i = 0; i < s.length; i++)
-            j.set(i, i, s[i] >= minSingularVal ? 1 / (s[i] * s[i]) : 0.0);
-
-        return vMat.times(j).times(vMat.transpose());
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/decompositions/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/package-info.java b/modules/ml/src/main/java/org/apache/ignite/math/decompositions/package-info.java
deleted file mode 100644
index dcfa0f8..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/decompositions/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Contains matrix decompositions for distributed code algebra.
- */
-package org.apache.ignite.math.decompositions;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/exceptions/CardinalityException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/CardinalityException.java b/modules/ml/src/main/java/org/apache/ignite/math/exceptions/CardinalityException.java
deleted file mode 100644
index fc87a27..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/CardinalityException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.exceptions;
-
-import org.apache.ignite.IgniteException;
-
-/**
- * Indicates a cardinality mismatch in matrix or vector operations.
- */
-public class CardinalityException extends IgniteException {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /**
-     * Creates new cardinality violation exception.
-     *
-     * @param exp Expected cardinality.
-     * @param act Actual cardinality.
-     */
-    public CardinalityException(int exp, int act) {
-        super("Cardinality violation [expected=" + exp + ", actual=" + act + "]");
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/exceptions/ColumnIndexException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/ColumnIndexException.java b/modules/ml/src/main/java/org/apache/ignite/math/exceptions/ColumnIndexException.java
deleted file mode 100644
index 7670caf..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/ColumnIndexException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.exceptions;
-
-import org.apache.ignite.IgniteException;
-
-/**
- * This exception is used to indicate any error condition accessing matrix elements by invalid column index.
- */
-public class ColumnIndexException extends IgniteException {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /**
-     * @param idx Index value that caused this exception.
-     */
-    public ColumnIndexException(int idx) {
-        super("Invalid (out of bound) column index: " + idx);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/exceptions/IndexException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/IndexException.java b/modules/ml/src/main/java/org/apache/ignite/math/exceptions/IndexException.java
deleted file mode 100644
index 9ada706..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/IndexException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.exceptions;
-
-import org.apache.ignite.IgniteException;
-
-/**
- * Indicates an invalid, i.e. out of bound, index on matrix or vector operations.
- */
-public class IndexException extends IgniteException {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /**
-     * @param idx Index value that caused this exception.
-     */
-    public IndexException(int idx) {
-        super("Invalid (out of bound) index: " + idx);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/exceptions/NonPositiveDefiniteMatrixException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/NonPositiveDefiniteMatrixException.java b/modules/ml/src/main/java/org/apache/ignite/math/exceptions/NonPositiveDefiniteMatrixException.java
deleted file mode 100644
index b6017c2..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/NonPositiveDefiniteMatrixException.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.apache.ignite.math.exceptions;
-
-import org.apache.ignite.IgniteException;
-
-/**
- * This exception is used to indicate error condition of matrix elements failing the positivity check.
- */
-public class NonPositiveDefiniteMatrixException extends IgniteException {
-    /**
-     * Construct an exception.
-     *
-     * @param wrong Value that fails the positivity check.
-     * @param idx Row (and column) index.
-     * @param threshold Absolute positivity threshold.
-     */
-    public NonPositiveDefiniteMatrixException(double wrong, int idx, double threshold) {
-        super("Matrix must be positive, wrong element located on diagonal with index "
-            + idx + " and has value " + wrong + " with this threshold " + threshold);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/exceptions/NonSymmetricMatrixException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/NonSymmetricMatrixException.java b/modules/ml/src/main/java/org/apache/ignite/math/exceptions/NonSymmetricMatrixException.java
deleted file mode 100644
index 8b4cbdb..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/NonSymmetricMatrixException.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.apache.ignite.math.exceptions;
-
-import org.apache.ignite.IgniteException;
-
-/**
- * This exception is used to indicate error condition of matrix failing the symmetry check.
- */
-public class NonSymmetricMatrixException extends IgniteException {
-    /**
-     * @param row Row.
-     * @param col Column.
-     * @param threshold Threshold.
-     */
-    public NonSymmetricMatrixException(int row, int col, double threshold) {
-        super("Symmetric matrix expected, the symmetry is broken on row "
-            + row + " and col " + col + " with this threshold " + threshold);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/exceptions/RowIndexException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/RowIndexException.java b/modules/ml/src/main/java/org/apache/ignite/math/exceptions/RowIndexException.java
deleted file mode 100644
index f74ae2c..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/RowIndexException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.exceptions;
-
-import org.apache.ignite.IgniteException;
-
-/**
- * This exception is used to indicate any error condition accessing matrix elements by invalid row index.
- */
-public class RowIndexException extends IgniteException {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /**
-     * @param idx Index value that caused this exception.
-     */
-    public RowIndexException(int idx) {
-        super("Invalid (out of bound) row index: " + idx);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/exceptions/SingularMatrixException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/SingularMatrixException.java b/modules/ml/src/main/java/org/apache/ignite/math/exceptions/SingularMatrixException.java
deleted file mode 100644
index 4ed3410..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/SingularMatrixException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.exceptions;
-
-import org.apache.ignite.IgniteException;
-
-/**
- * Exception to be thrown when a non-singular matrix is expected.
- */
-public class SingularMatrixException extends IgniteException {
-    /** */
-    public SingularMatrixException() {
-        super("Regular (or non-singular) matrix expected.");
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/exceptions/UnknownProviderException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/UnknownProviderException.java b/modules/ml/src/main/java/org/apache/ignite/math/exceptions/UnknownProviderException.java
deleted file mode 100644
index 3e6498a..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/UnknownProviderException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.exceptions;
-
-import org.apache.ignite.IgniteException;
-
-/**
- * Indicates that no provider has been found for a given vector or matrix flavor.
- */
-public class UnknownProviderException extends IgniteException {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /**
-     * @param flv Flavor (a.k.a. operation performance hints) that has no registered provider for.
-     */
-    public UnknownProviderException(String flv) {
-        super("No provider has been found for the flavor: " + flv);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/exceptions/UnsupportedOperationException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/UnsupportedOperationException.java b/modules/ml/src/main/java/org/apache/ignite/math/exceptions/UnsupportedOperationException.java
deleted file mode 100644
index be5264c..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/UnsupportedOperationException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.exceptions;
-
-import org.apache.ignite.IgniteException;
-
-/**
- * Indicate that a specific operation is not supported by the underlying implementation.
- * In some cases, an operation may be unsupported only in certain cases where, for example,
- * it could not be deterministically completed in polynomial time.
- */
-public class UnsupportedOperationException extends IgniteException {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /**
-     * @param errMsg Error message.
-     */
-    public UnsupportedOperationException(String errMsg) {
-        super(errMsg);
-    }
-
-    /**
-     *
-     */
-    public UnsupportedOperationException() {
-        this("Unsupported operation.");
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/exceptions/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/package-info.java b/modules/ml/src/main/java/org/apache/ignite/math/exceptions/package-info.java
deleted file mode 100644
index 83f3fa4..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/exceptions/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Contains exceptions for distributed code algebra.
- */
-package org.apache.ignite.math.exceptions;
\ No newline at end of file


[58/65] [abbrv] ignite git commit: ignite-2893 Restored explicit tx usages to avoid issues when there are no classes on servers

Posted by ag...@apache.org.
ignite-2893 Restored explicit tx usages to avoid issues when there are no classes on servers


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

Branch: refs/heads/ignite-5024
Commit: 3a5c6f3590f9355cb63045bf0dea91b92b96b1c4
Parents: a4e8296
Author: sboikov <sb...@gridgain.com>
Authored: Sat Apr 22 09:55:17 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Sat Apr 22 09:55:17 2017 +0300

----------------------------------------------------------------------
 .../IgniteCacheDatabaseSharedManager.java       |   4 +-
 .../CacheDataStructuresManager.java             |  34 +++
 .../GridCacheAtomicReferenceImpl.java           | 108 +++++++--
 .../GridCacheAtomicStampedImpl.java             |  70 +++++-
 .../GridCacheCountDownLatchImpl.java            |   2 +-
 .../datastructures/GridCacheSemaphoreImpl.java  | 240 +++++++++----------
 ...CacheAtomicReferenceApiSelfAbstractTest.java |   4 +-
 ...IgniteDataStructuresNoClassOnServerTest.java |  30 +++
 .../CacheNoValueClassOnServerNodeTest.java      | 112 +--------
 .../IgniteNoClassOnServerAbstractTest.java      | 135 +++++++++++
 ...ObjectsCacheDataStructuresSelfTestSuite.java |   7 +-
 modules/extdata/p2p/pom.xml                     |   6 +
 .../p2p/NoValueClassOnServerAbstractClient.java |  90 +++++++
 .../CacheNoValueClassOnServerTestClient.java    |  79 +++---
 ...DataStructuresNoClassOnServerTestClient.java | 181 ++++++++++++++
 15 files changed, 798 insertions(+), 304 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
index e6fe7cd..705e74c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
@@ -706,12 +706,12 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
 
     /** {@inheritDoc} */
     @Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException {
-
+        // No-op.
     }
 
     /** {@inheritDoc} */
     @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
-
+        // No-op.
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/datastructures/CacheDataStructuresManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/datastructures/CacheDataStructuresManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/datastructures/CacheDataStructuresManager.java
index d864d3c..45f0cee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/datastructures/CacheDataStructuresManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/datastructures/CacheDataStructuresManager.java
@@ -21,8 +21,10 @@ import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.UUID;
@@ -35,6 +37,7 @@ import javax.cache.event.CacheEntryUpdatedListener;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteSet;
+import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.IgniteKernal;
@@ -75,6 +78,29 @@ import static org.apache.ignite.internal.GridClosureCallMode.BROADCAST;
  *
  */
 public class CacheDataStructuresManager extends GridCacheManagerAdapter {
+    /** Known classes which are safe to use on server nodes. */
+    private static final Collection<Class<?>> KNOWN_CLS = new HashSet<>();
+
+    /**
+     *
+     */
+    static {
+        KNOWN_CLS.add(String.class);
+        KNOWN_CLS.add(Boolean.class);
+        KNOWN_CLS.add(Byte.class);
+        KNOWN_CLS.add(Short.class);
+        KNOWN_CLS.add(Character.class);
+        KNOWN_CLS.add(Integer.class);
+        KNOWN_CLS.add(Long.class);
+        KNOWN_CLS.add(Float.class);
+        KNOWN_CLS.add(Double.class);
+        KNOWN_CLS.add(String.class);
+        KNOWN_CLS.add(UUID.class);
+        KNOWN_CLS.add(IgniteUuid.class);
+        KNOWN_CLS.add(BigDecimal.class);
+        KNOWN_CLS.add(BinaryObject.class);
+    }
+
     /** Sets map. */
     private final ConcurrentMap<IgniteUuid, GridCacheSetProxy> setsMap;
 
@@ -419,6 +445,14 @@ public class CacheDataStructuresManager extends GridCacheManagerAdapter {
     }
 
     /**
+     * @param obj Object.
+     * @return {@code True}
+     */
+    public boolean knownType(Object obj) {
+        return obj == null || KNOWN_CLS.contains(obj.getClass());
+    }
+
+    /**
      * @param id Set ID.
      * @return Data for given set.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
index b7dc007..0b0c202 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
@@ -23,6 +23,7 @@ import java.io.InvalidObjectException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.io.ObjectStreamException;
+import java.util.concurrent.Callable;
 import javax.cache.processor.EntryProcessorException;
 import javax.cache.processor.EntryProcessorResult;
 import javax.cache.processor.MutableEntry;
@@ -32,16 +33,22 @@ import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
+import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport;
 import org.apache.ignite.lang.IgniteBiTuple;
 
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
 /**
  * Cache atomic reference implementation.
  */
-public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicReferenceEx<T>, IgniteChangeGlobalStateSupport, Externalizable {
+public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicReferenceEx<T>,
+    IgniteChangeGlobalStateSupport, Externalizable {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -124,11 +131,30 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef
     }
 
     /** {@inheritDoc} */
-    @Override public void set(T val) {
+    @Override public void set(final T val) {
         checkRemoved();
 
         try {
-            atomicView.invoke(key, new ReferenceSetEntryProcessor<>(val));
+            if (ctx.dataStructures().knownType(val))
+                atomicView.invoke(key, new ReferenceSetEntryProcessor<>(val));
+            else {
+                CU.retryTopologySafe(new Callable<Void>() {
+                    @Override public Void call() throws Exception {
+                        try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+                            GridCacheAtomicReferenceValue<T> ref = atomicView.get(key);
+
+                            if (ref == null)
+                                throw new IgniteException("Failed to find atomic reference with given name: " + name);
+
+                            atomicView.put(key, new GridCacheAtomicReferenceValue<>(val));
+
+                            tx.commit();
+                        }
+
+                        return null;
+                    }
+                });
+            }
         }
         catch (EntryProcessorException e) {
             throw new IgniteException(e.getMessage(), e);
@@ -139,14 +165,40 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef
     }
 
     /** {@inheritDoc} */
-    @Override public boolean compareAndSet(T expVal, T newVal) {
+    @Override public boolean compareAndSet(final T expVal, final T newVal) {
         try {
-            EntryProcessorResult<Boolean> res =
-                atomicView.invoke(key, new ReferenceCompareAndSetEntryProcessor<>(expVal, newVal));
+            if (ctx.dataStructures().knownType(expVal) && ctx.dataStructures().knownType(newVal)) {
+                EntryProcessorResult<Boolean> res =
+                    atomicView.invoke(key, new ReferenceCompareAndSetEntryProcessor<>(expVal, newVal));
+
+                assert res != null && res.get() != null : res;
+
+                return res.get();
+            }
+            else {
+                return CU.retryTopologySafe(new Callable<Boolean>() {
+                    @Override public Boolean call() throws Exception {
+                        try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+                            GridCacheAtomicReferenceValue<T> ref = atomicView.get(key);
+
+                            if (ref == null)
+                                throw new IgniteException("Failed to find atomic reference with given name: " + name);
 
-            assert res != null && res.get() != null : res;
+                            T curVal = ref.get();
 
-            return res.get();
+                            if (!F.eq(expVal, curVal))
+                                return false;
+                            else {
+                                atomicView.put(key, new GridCacheAtomicReferenceValue<>(newVal));
+
+                                tx.commit();
+
+                                return true;
+                            }
+                        }
+                    }
+                });
+            }
         }
         catch (EntryProcessorException e) {
             throw new IgniteException(e.getMessage(), e);
@@ -163,16 +215,42 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef
      * @param expVal Expected value.
      * @return Original value.
      */
-    public T compareAndSetAndGet(T newVal, T expVal) {
+    public T compareAndSetAndGet(final T newVal, final T expVal) {
         checkRemoved();
 
         try {
-            EntryProcessorResult<T> res =
-                atomicView.invoke(key, new ReferenceCompareAndSetAndGetEntryProcessor<T>(expVal, newVal));
+            if (ctx.dataStructures().knownType(expVal) && ctx.dataStructures().knownType(newVal)) {
+                EntryProcessorResult<T> res =
+                    atomicView.invoke(key, new ReferenceCompareAndSetAndGetEntryProcessor<T>(expVal, newVal));
+
+                assert res != null;
+
+                return res.get();
+            }
+            else {
+                return CU.retryTopologySafe(new Callable<T>() {
+                    @Override public T call() throws Exception {
+                        try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+                            GridCacheAtomicReferenceValue<T> ref = atomicView.get(key);
 
-            assert res != null;
+                            if (ref == null)
+                                throw new IgniteException("Failed to find atomic reference with given name: " + name);
 
-            return res.get();
+                            T curVal = ref.get();
+
+                            if (!F.eq(expVal, curVal))
+                                return curVal;
+                            else {
+                                atomicView.put(key, new GridCacheAtomicReferenceValue<>(newVal));
+
+                                tx.commit();
+
+                                return expVal;
+                            }
+                        }
+                    }
+                });
+            }
         }
         catch (EntryProcessorException e) {
             throw new IgniteException(e.getMessage(), e);
@@ -251,8 +329,6 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef
                 throw removedError();
             }
         }
-
-
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
index 3f14942..9449995 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
@@ -23,6 +23,7 @@ import java.io.InvalidObjectException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.io.ObjectStreamException;
+import java.util.concurrent.Callable;
 import javax.cache.processor.EntryProcessorException;
 import javax.cache.processor.EntryProcessorResult;
 import javax.cache.processor.MutableEntry;
@@ -32,12 +33,17 @@ import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
+import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport;
 import org.apache.ignite.internal.util.tostring.GridToStringBuilder;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport;
 import org.apache.ignite.lang.IgniteBiTuple;
 
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
 /**
  * Cache atomic stamped implementation.
  */
@@ -124,11 +130,30 @@ public final class GridCacheAtomicStampedImpl<T, S> implements GridCacheAtomicSt
     }
 
     /** {@inheritDoc} */
-    @Override public void set(T val, S stamp) {
+    @Override public void set(final T val, final S stamp) {
         checkRemoved();
 
         try {
-            atomicView.invoke(key, new StampedSetEntryProcessor<>(val, stamp));
+            if (ctx.dataStructures().knownType(val) && ctx.dataStructures().knownType(stamp))
+                atomicView.invoke(key, new StampedSetEntryProcessor<>(val, stamp));
+            else {
+                CU.retryTopologySafe(new Callable<Void>() {
+                    @Override public Void call() throws Exception {
+                        try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+                            GridCacheAtomicStampedValue<T, S> ref = atomicView.get(key);
+
+                            if (ref == null)
+                                throw new IgniteException("Failed to find atomic stamped with given name: " + name);
+
+                            atomicView.put(key, new GridCacheAtomicStampedValue<>(val, stamp));
+
+                            tx.commit();
+                        }
+
+                        return null;
+                    }
+                });
+            }
         }
         catch (EntryProcessorException e) {
             throw new IgniteException(e.getMessage(), e);
@@ -139,16 +164,43 @@ public final class GridCacheAtomicStampedImpl<T, S> implements GridCacheAtomicSt
     }
 
     /** {@inheritDoc} */
-    @Override public boolean compareAndSet(T expVal, T newVal, S expStamp, S newStamp) {
+    @Override public boolean compareAndSet(final T expVal, final T newVal, final S expStamp, final S newStamp) {
         checkRemoved();
 
         try {
-            EntryProcessorResult<Boolean> res =
-                atomicView.invoke(key, new StampedCompareAndSetEntryProcessor<>(expVal, expStamp, newVal, newStamp));
+            if (ctx.dataStructures().knownType(expVal) &&
+                ctx.dataStructures().knownType(newVal) &&
+                ctx.dataStructures().knownType(expStamp) &&
+                ctx.dataStructures().knownType(newStamp)) {
+                EntryProcessorResult<Boolean> res =
+                    atomicView.invoke(key, new StampedCompareAndSetEntryProcessor<>(expVal, expStamp, newVal, newStamp));
 
-            assert res != null && res.get() != null : res;
+                assert res != null && res.get() != null : res;
 
-            return res.get();
+                return res.get();
+            }
+            else {
+                return CU.retryTopologySafe(new Callable<Boolean>() {
+                    @Override public Boolean call() throws Exception {
+                        try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+                            GridCacheAtomicStampedValue<T, S> val = atomicView.get(key);
+
+                            if (val == null)
+                                throw new IgniteException("Failed to find atomic stamped with given name: " + name);
+
+                            if (F.eq(expVal, val.value()) && F.eq(expStamp, val.stamp())) {
+                                atomicView.put(key, new GridCacheAtomicStampedValue<>(newVal, newStamp));
+
+                                tx.commit();
+
+                                return true;
+                            }
+
+                            return false;
+                        }
+                    }
+                });
+            }
         }
         catch (EntryProcessorException e) {
             throw new IgniteException(e.getMessage(), e);
@@ -295,7 +347,7 @@ public final class GridCacheAtomicStampedImpl<T, S> implements GridCacheAtomicSt
 
     /** {@inheritDoc} */
     @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
-
+        // No-op.
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
index 86e99a9..b93e600 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
@@ -344,7 +344,7 @@ public final class GridCacheCountDownLatchImpl implements GridCacheCountDownLatc
 
     /** {@inheritDoc} */
     @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
-
+        // No-op.
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
index edc322e..2d5147b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
@@ -288,61 +288,61 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Ignit
         boolean compareAndSetGlobalState(final int expVal, final int newVal, final boolean draining) {
             try {
                 return retryTopologySafe(new Callable<Boolean>() {
-                        @Override public Boolean call() throws Exception {
-                            try (GridNearTxLocal tx = CU.txStartInternal(ctx,
-                                semView,
-                                PESSIMISTIC, REPEATABLE_READ)
-                            ) {
-                                GridCacheSemaphoreState val = semView.get(key);
-
-                                if (val == null)
-                                    throw new IgniteCheckedException("Failed to find semaphore with given name: " +
-                                        name);
+                    @Override public Boolean call() throws Exception {
+                        try (GridNearTxLocal tx = CU.txStartInternal(ctx,
+                            semView,
+                            PESSIMISTIC, REPEATABLE_READ)
+                        ) {
+                            GridCacheSemaphoreState val = semView.get(key);
 
-                                // Abort if state is already broken.
-                                if (val.isBroken()) {
-                                    tx.rollback();
+                            if (val == null)
+                                throw new IgniteCheckedException("Failed to find semaphore with given name: " +
+                                    name);
 
-                                    return true;
-                                }
+                            // Abort if state is already broken.
+                            if (val.isBroken()) {
+                                tx.rollback();
 
-                                boolean retVal = val.getCount() == expVal;
+                                return true;
+                            }
 
-                                if (retVal) {
-                                    // If this is not a call to drain permits,
-                                    // Modify global permission count for the calling node.
-                                    if (!draining) {
-                                        UUID nodeID = ctx.localNodeId();
+                            boolean retVal = val.getCount() == expVal;
 
-                                        Map<UUID, Integer> map = val.getWaiters();
+                            if (retVal) {
+                                // If this is not a call to drain permits,
+                                // Modify global permission count for the calling node.
+                                if (!draining) {
+                                    UUID nodeID = ctx.localNodeId();
 
-                                        int waitingCnt = expVal - newVal;
+                                    Map<UUID, Integer> map = val.getWaiters();
 
-                                        if (map.containsKey(nodeID))
-                                            waitingCnt += map.get(nodeID);
+                                    int waitingCnt = expVal - newVal;
 
-                                        map.put(nodeID, waitingCnt);
+                                    if (map.containsKey(nodeID))
+                                        waitingCnt += map.get(nodeID);
 
-                                        val.setWaiters(map);
-                                    }
+                                    map.put(nodeID, waitingCnt);
 
-                                    val.setCount(newVal);
+                                    val.setWaiters(map);
+                                }
 
-                                    semView.put(key, val);
+                                val.setCount(newVal);
 
-                                    tx.commit();
-                                }
+                                semView.put(key, val);
 
-                                return retVal;
+                                tx.commit();
                             }
-                            catch (Error | Exception e) {
-                                if (!ctx.kernalContext().isStopping())
-                                    U.error(log, "Failed to compare and set: " + this, e);
 
-                                throw e;
-                            }
+                            return retVal;
+                        }
+                        catch (Error | Exception e) {
+                            if (!ctx.kernalContext().isStopping())
+                                U.error(log, "Failed to compare and set: " + this, e);
+
+                            throw e;
                         }
-                    });
+                    }
+                });
             }
             catch (IgniteCheckedException e) {
                 if (ctx.kernalContext().isStopping()) {
@@ -367,70 +367,70 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Ignit
         boolean releaseFailedNode(final UUID nodeId, final boolean broken) {
             try {
                 return retryTopologySafe(new Callable<Boolean>() {
-                        @Override public Boolean call() throws Exception {
-                            try (
-                                GridNearTxLocal tx = CU.txStartInternal(ctx,
-                                    semView,
-                                    PESSIMISTIC, REPEATABLE_READ)
-                            ) {
-                                GridCacheSemaphoreState val = semView.get(key);
-
-                                if (val == null)
-                                    throw new IgniteCheckedException("Failed to find semaphore with given name: " +
-                                        name);
-
-                                // Quit early if semaphore is already broken.
-                                if( val.isBroken()) {
-                                    tx.rollback();
-
-                                    return false;
-                                }
+                    @Override public Boolean call() throws Exception {
+                        try (
+                            GridNearTxLocal tx = CU.txStartInternal(ctx,
+                                semView,
+                                PESSIMISTIC, REPEATABLE_READ)
+                        ) {
+                            GridCacheSemaphoreState val = semView.get(key);
 
-                                // Mark semaphore as broken. No permits are released,
-                                // since semaphore is useless from now on.
-                                if (broken) {
-                                    val.setBroken(true);
+                            if (val == null)
+                                throw new IgniteCheckedException("Failed to find semaphore with given name: " +
+                                    name);
 
-                                    semView.put(key, val);
+                            // Quit early if semaphore is already broken.
+                            if( val.isBroken()) {
+                                tx.rollback();
 
-                                    tx.commit();
+                                return false;
+                            }
 
-                                    return true;
-                                }
+                            // Mark semaphore as broken. No permits are released,
+                            // since semaphore is useless from now on.
+                            if (broken) {
+                                val.setBroken(true);
 
-                                Map<UUID, Integer> map = val.getWaiters();
+                                semView.put(key, val);
 
-                                if (!map.containsKey(nodeId)) {
-                                    tx.rollback();
+                                tx.commit();
 
-                                    return false;
-                                }
+                                return true;
+                            }
 
-                                int numPermits = map.get(nodeId);
+                            Map<UUID, Integer> map = val.getWaiters();
 
-                                if (numPermits > 0)
-                                    val.setCount(val.getCount() + numPermits);
+                            if (!map.containsKey(nodeId)) {
+                                tx.rollback();
 
-                                map.remove(nodeId);
+                                return false;
+                            }
 
-                                val.setWaiters(map);
+                            int numPermits = map.get(nodeId);
 
-                                semView.put(key, val);
+                            if (numPermits > 0)
+                                val.setCount(val.getCount() + numPermits);
 
-                                sync.nodeMap = map;
+                            map.remove(nodeId);
 
-                                tx.commit();
+                            val.setWaiters(map);
 
-                                return true;
-                            }
-                            catch (Error | Exception e) {
-                                if (!ctx.kernalContext().isStopping())
-                                    U.error(log, "Failed to compare and set: " + this, e);
+                            semView.put(key, val);
 
-                                throw e;
-                            }
+                            sync.nodeMap = map;
+
+                            tx.commit();
+
+                            return true;
+                        }
+                        catch (Error | Exception e) {
+                            if (!ctx.kernalContext().isStopping())
+                                U.error(log, "Failed to compare and set: " + this, e);
+
+                            throw e;
                         }
-                    });
+                    }
+                });
             }
             catch (IgniteCheckedException e) {
                 if (ctx.kernalContext().isStopping()) {
@@ -479,34 +479,34 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Ignit
         if (!initGuard.get() && initGuard.compareAndSet(false, true)) {
             try {
                 sync = retryTopologySafe(new Callable<Sync>() {
-                        @Override public Sync call() throws Exception {
-                            try (GridNearTxLocal tx = CU.txStartInternal(ctx,
-                                semView, PESSIMISTIC, REPEATABLE_READ)) {
-                                GridCacheSemaphoreState val = semView.get(key);
+                    @Override public Sync call() throws Exception {
+                        try (GridNearTxLocal tx = CU.txStartInternal(ctx,
+                            semView, PESSIMISTIC, REPEATABLE_READ)) {
+                            GridCacheSemaphoreState val = semView.get(key);
 
-                                if (val == null) {
-                                    if (log.isDebugEnabled())
-                                        log.debug("Failed to find semaphore with given name: " + name);
+                            if (val == null) {
+                                if (log.isDebugEnabled())
+                                    log.debug("Failed to find semaphore with given name: " + name);
 
-                                    return null;
-                                }
+                                return null;
+                            }
 
-                                final int cnt = val.getCount();
+                            final int cnt = val.getCount();
 
-                                Map<UUID, Integer> waiters = val.getWaiters();
+                            Map<UUID, Integer> waiters = val.getWaiters();
 
-                                final boolean failoverSafe = val.isFailoverSafe();
+                            final boolean failoverSafe = val.isFailoverSafe();
 
-                                tx.commit();
+                            tx.commit();
 
-                                Sync sync = new Sync(cnt, waiters, failoverSafe);
+                            Sync sync = new Sync(cnt, waiters, failoverSafe);
 
-                                sync.setBroken(val.isBroken());
+                            sync.setBroken(val.isBroken());
 
-                                return sync;
-                            }
+                            return sync;
                         }
-                    });
+                    }
+                });
 
                 if (log.isDebugEnabled())
                     log.debug("Initialized internal sync structure: " + sync);
@@ -722,24 +722,24 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Ignit
             initializeSemaphore();
 
             ret = retryTopologySafe(new Callable<Integer>() {
-                    @Override public Integer call() throws Exception {
-                        try (
-                            GridNearTxLocal tx = CU.txStartInternal(ctx,
-                                semView, PESSIMISTIC, REPEATABLE_READ)
-                        ) {
-                            GridCacheSemaphoreState val = semView.get(key);
+                @Override public Integer call() throws Exception {
+                    try (
+                        GridNearTxLocal tx = CU.txStartInternal(ctx,
+                            semView, PESSIMISTIC, REPEATABLE_READ)
+                    ) {
+                        GridCacheSemaphoreState val = semView.get(key);
 
-                            if (val == null)
-                                throw new IgniteException("Failed to find semaphore with given name: " + name);
+                        if (val == null)
+                            throw new IgniteException("Failed to find semaphore with given name: " + name);
 
-                            int cnt = val.getCount();
+                        int cnt = val.getCount();
 
-                            tx.rollback();
+                        tx.rollback();
 
-                            return cnt;
-                        }
+                        return cnt;
                     }
-                });
+                }
+            });
         }
         catch (IgniteCheckedException e) {
             throw U.convertException(e);
@@ -875,7 +875,7 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Ignit
         try {
             initializeSemaphore();
 
-            boolean result = sync.tryAcquireSharedNanos(permits, unit.toNanos(timeout));
+            boolean res = sync.tryAcquireSharedNanos(permits, unit.toNanos(timeout));
 
             if (isBroken()) {
                 Thread.interrupted();
@@ -883,7 +883,7 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Ignit
                 throw new InterruptedException();
             }
 
-            return result;
+            return res;
         }
         catch (IgniteCheckedException e) {
             throw U.convertException(e);
@@ -972,7 +972,7 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Ignit
 
     /** {@inheritDoc} */
     @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
-
+        // No-op.
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
index 3c4b3a7..b82da58 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
@@ -43,10 +43,10 @@ public abstract class GridCacheAtomicReferenceApiSelfAbstractTest extends Ignite
      * @throws Exception If failed.
      */
     public void testPrepareAtomicReference() throws Exception {
-        /** Name of first atomic. */
+        /* Name of first atomic. */
         String atomicName1 = UUID.randomUUID().toString();
 
-        /** Name of second atomic. */
+        /* Name of second atomic. */
         String atomicName2 = UUID.randomUUID().toString();
 
         String initVal = "1";

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructuresNoClassOnServerTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructuresNoClassOnServerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructuresNoClassOnServerTest.java
new file mode 100644
index 0000000..9808107
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructuresNoClassOnServerTest.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.datastructures;
+
+import org.apache.ignite.internal.processors.cache.distributed.IgniteNoClassOnServerAbstractTest;
+
+/**
+ *
+ */
+public class IgniteDataStructuresNoClassOnServerTest extends IgniteNoClassOnServerAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected String clientClassName() {
+        return "org.apache.ignite.tests.p2p.datastructures.DataStructuresNoClassOnServerTestClient";
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
index c6ce81e..625a95b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
@@ -17,116 +17,12 @@
 
 package org.apache.ignite.internal.processors.cache.distributed;
 
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.concurrent.CountDownLatch;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.GridJavaProcess;
-import org.apache.ignite.internal.util.typedef.CI1;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-
 /**
  *
  */
-public class CacheNoValueClassOnServerNodeTest extends GridCommonAbstractTest {
-    /** */
-    public static final String NODE_START_MSG = "Test external node started";
-
-    /** */
-    private static final String CLIENT_CLS_NAME =
-        "org.apache.ignite.tests.p2p.cache.CacheNoValueClassOnServerTestClient";
-
-    /**
-     * @return Configuration.
-     */
-    private IgniteConfiguration createConfiguration() {
-        IgniteConfiguration cfg = new IgniteConfiguration();
-
-        cfg.setPeerClassLoadingEnabled(false);
-
-        cfg.setLocalHost("127.0.0.1");
-
-        TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
-        disco.setIpFinderCleanFrequency(1000);
-
-        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
-
-        ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
-
-        disco.setIpFinder(ipFinder);
-
-        cfg.setDiscoverySpi(disco);
-
-        return cfg;
+public class CacheNoValueClassOnServerNodeTest extends IgniteNoClassOnServerAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected String clientClassName() {
+        return "org.apache.ignite.tests.p2p.cache.CacheNoValueClassOnServerTestClient";
     }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testNoValueClassOnServerNode() throws Exception {
-        // Check class is really not available.
-        try {
-            Class.forName("org.apache.ignite.tests.p2p.cache.Person");
-
-            fail();
-        }
-        catch (ClassNotFoundException ignore) {
-            // Expected exception.
-        }
-
-        try (Ignite ignite = Ignition.start(createConfiguration())) {
-            CacheConfiguration cfg = new CacheConfiguration();
-
-            cfg.setCopyOnRead(true); // To store only value bytes.
-
-            ignite.createCache(cfg);
-
-            final CountDownLatch clientReadyLatch = new CountDownLatch(1);
-
-            Collection<String> jvmArgs = Arrays.asList("-ea", "-DIGNITE_QUIET=false");
-
-            GridJavaProcess clientNode = null;
-
-            try {
-                String cp = U.getIgniteHome() + "/modules/extdata/p2p/target/classes/";
-
-                clientNode = GridJavaProcess.exec(
-                    CLIENT_CLS_NAME, null,
-                    log,
-                    new CI1<String>() {
-                        @Override public void apply(String s) {
-                            info("Client node: " + s);
-
-                            if (s.contains(NODE_START_MSG))
-                                clientReadyLatch.countDown();
-                        }
-                    },
-                    null,
-                    null,
-                    jvmArgs,
-                    cp
-                );
-
-                assertTrue(clientReadyLatch.await(60, SECONDS));
-
-                int exitCode = clientNode.getProcess().waitFor();
-
-                assertEquals("Unexpected exit code", 0, exitCode);
-            }
-            finally {
-                if (clientNode != null)
-                    clientNode.killProcess();
-            }
-        }
-    }
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteNoClassOnServerAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteNoClassOnServerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteNoClassOnServerAbstractTest.java
new file mode 100644
index 0000000..4357ae7
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteNoClassOnServerAbstractTest.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.concurrent.CountDownLatch;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.GridJavaProcess;
+import org.apache.ignite.internal.util.typedef.CI1;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+/**
+ *
+ */
+public abstract class IgniteNoClassOnServerAbstractTest extends GridCommonAbstractTest {
+    /** */
+    private static final String NODE_START_MSG = "Test external node started";
+
+    /**
+     * @return Client class name.
+     */
+    protected abstract String clientClassName();
+
+    /**
+     * @return Configuration.
+     */
+    private IgniteConfiguration createConfiguration() {
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        cfg.setPeerClassLoadingEnabled(false);
+
+        cfg.setLocalHost("127.0.0.1");
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinderCleanFrequency(1000);
+
+        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
+
+        ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
+
+        disco.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(disco);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public final void testNoClassOnServerNode() throws Exception {
+        info("Run test with client: " + clientClassName());
+
+        // Check class is really not available.
+        try {
+            Class.forName("org.apache.ignite.tests.p2p.cache.Person");
+
+            fail();
+        }
+        catch (ClassNotFoundException ignore) {
+            // Expected exception.
+        }
+
+        try (Ignite ignite = Ignition.start(createConfiguration())) {
+            CacheConfiguration cfg = new CacheConfiguration();
+
+            cfg.setCopyOnRead(true); // To store only value bytes.
+
+            ignite.createCache(cfg);
+
+            final CountDownLatch clientReadyLatch = new CountDownLatch(1);
+
+            Collection<String> jvmArgs = Arrays.asList("-ea", "-DIGNITE_QUIET=false");
+
+            GridJavaProcess clientNode = null;
+
+            try {
+                String cp = U.getIgniteHome() + "/modules/extdata/p2p/target/classes/";
+
+                clientNode = GridJavaProcess.exec(
+                    clientClassName(), null,
+                    log,
+                    new CI1<String>() {
+                        @Override public void apply(String s) {
+                            info("Client node: " + s);
+
+                            if (s.contains(NODE_START_MSG))
+                                clientReadyLatch.countDown();
+                        }
+                    },
+                    null,
+                    null,
+                    jvmArgs,
+                    cp
+                );
+
+                assertTrue(clientReadyLatch.await(60, SECONDS));
+
+                int exitCode = clientNode.getProcess().waitFor();
+
+                assertEquals("Unexpected exit code", 0, exitCode);
+            }
+            finally {
+                if (clientNode != null)
+                    clientNode.killProcess();
+            }
+        }
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsCacheDataStructuresSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsCacheDataStructuresSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsCacheDataStructuresSelfTestSuite.java
index e15540a..f8769a0 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsCacheDataStructuresSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsCacheDataStructuresSelfTestSuite.java
@@ -19,6 +19,7 @@ package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.processors.cache.datastructures.IgniteDataStructuresNoClassOnServerTest;
 import org.apache.ignite.testframework.config.GridTestProperties;
 
 /**
@@ -32,6 +33,10 @@ public class IgniteBinaryObjectsCacheDataStructuresSelfTestSuite {
     public static TestSuite suite() throws Exception {
         GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
 
-        return IgniteCacheDataStructuresSelfTestSuite.suite();
+        TestSuite suite = IgniteCacheDataStructuresSelfTestSuite.suite();
+
+        suite.addTestSuite(IgniteDataStructuresNoClassOnServerTest.class);
+
+        return suite;
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/extdata/p2p/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/pom.xml b/modules/extdata/p2p/pom.xml
index 4863fdd..ec14930 100644
--- a/modules/extdata/p2p/pom.xml
+++ b/modules/extdata/p2p/pom.xml
@@ -39,6 +39,12 @@
             <artifactId>ignite-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.11</version>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/NoValueClassOnServerAbstractClient.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/NoValueClassOnServerAbstractClient.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/NoValueClassOnServerAbstractClient.java
new file mode 100644
index 0000000..9c9338b
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/NoValueClassOnServerAbstractClient.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.tests.p2p;
+
+import java.util.Arrays;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+
+/**
+ *
+ */
+public abstract class NoValueClassOnServerAbstractClient implements AutoCloseable {
+    /** */
+    protected final Ignite ignite;
+
+    /** */
+    private final IgniteLogger log;
+
+    /**
+     * @param args Command line arguments.
+     * @throws Exception If failed.
+     */
+    public NoValueClassOnServerAbstractClient(String[] args) throws Exception {
+        System.out.println("Starting test client node.");
+
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        cfg.setPeerClassLoadingEnabled(false);
+
+        cfg.setClientMode(true);
+
+        cfg.setLocalHost("127.0.0.1");
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
+
+        ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
+
+        disco.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(disco);
+
+        ignite = Ignition.start(cfg);
+
+        System.out.println("Test external node started");
+
+        log = ignite.log().getLogger(getClass());
+
+        log.info("Started node [id=" + ignite.cluster().localNode().id() +
+            ", marsh=" + ignite.configuration().getMarshaller().getClass().getSimpleName() + ']');
+    }
+
+    /**
+     * @param msg Message.
+     */
+    protected final void info(String msg) {
+        log.info(msg);
+    }
+
+
+    /** {@inheritDoc} */
+    @Override public void close() throws Exception {
+        ignite.close();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    protected abstract void runTest() throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
index bbf8abf..c1f3ff6 100644
--- a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
@@ -17,70 +17,59 @@
 
 package org.apache.ignite.tests.p2p.cache;
 
-import java.util.Arrays;
-import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.tests.p2p.NoValueClassOnServerAbstractClient;
+
+import static junit.framework.TestCase.assertEquals;
 
 /**
  *
  */
-public class CacheNoValueClassOnServerTestClient {
+public class CacheNoValueClassOnServerTestClient extends NoValueClassOnServerAbstractClient {
     /**
      * @param args Arguments.
      * @throws Exception If failed.
      */
-    public static void main(String[] args) throws Exception {
-        System.out.println("Starting test client node.");
-
-        IgniteConfiguration cfg = new IgniteConfiguration();
-
-        cfg.setPeerClassLoadingEnabled(false);
-
-        cfg.setClientMode(true);
-
-        cfg.setLocalHost("127.0.0.1");
-
-        TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
-        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
-
-        ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
-
-        disco.setIpFinder(ipFinder);
-
-        cfg.setDiscoverySpi(disco);
+    private CacheNoValueClassOnServerTestClient(String[] args) throws Exception {
+        super(args);
+    }
 
-        try (Ignite ignite = Ignition.start(cfg)) {
-            System.out.println("Test external node started");
+    /** {@inheritDoc} */
+    @Override protected void runTest() throws Exception {
+        IgniteCache<Integer, Person> cache = ignite.cache(null);
 
-            int nodes = ignite.cluster().nodes().size();
+        for (int i = 0; i < 100; i++)
+            cache.put(i, new Person("name-" + i));
 
-            if (nodes != 2)
-                throw new Exception("Unexpected nodes number: " + nodes);
+        for (int i = 0; i < 100; i++) {
+            Person p = cache.get(i);
 
-            IgniteCache<Integer, Person> cache = ignite.cache(null);
+            if (p == null)
+                throw new Exception("Null result key: " + i);
 
-            for (int i = 0; i < 100; i++)
-                cache.put(i, new Person("name-" + i));
+            String expName = "name-" + i;
 
-            for (int i = 0; i < 100; i++) {
-                Person p = cache.get(i);
+            assertEquals(expName, p.getName());
 
-                if (p == null)
-                    throw new Exception("Null result key: " + i);
+            if (i % 10 == 0)
+                System.out.println("Get expected value: " + p.name());
+        }
+    }
 
-                String expName = "name-" + i;
+    /**
+     * @param args Arguments.
+     * @throws Exception If failed.
+     */
+    public static void main(String[] args) throws Exception {
+        try (CacheNoValueClassOnServerTestClient client = new CacheNoValueClassOnServerTestClient(args)) {
+            client.runTest();
+        }
+        catch (Throwable e) {
+            System.out.println("Unexpected error: " + e);
 
-                if (!expName.equals(p.name()))
-                    throw new Exception("Unexpected data: " + p.name());
+            e.printStackTrace(System.out);
 
-                if (i % 10 == 0)
-                    System.out.println("Get expected value: " + p.name());
-            }
+            System.exit(1);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a5c6f35/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/datastructures/DataStructuresNoClassOnServerTestClient.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/datastructures/DataStructuresNoClassOnServerTestClient.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/datastructures/DataStructuresNoClassOnServerTestClient.java
new file mode 100644
index 0000000..7cf2cc7
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/datastructures/DataStructuresNoClassOnServerTestClient.java
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.tests.p2p.datastructures;
+
+import org.apache.ignite.IgniteAtomicReference;
+import org.apache.ignite.IgniteAtomicStamped;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.tests.p2p.NoValueClassOnServerAbstractClient;
+import org.apache.ignite.tests.p2p.cache.Person;
+import org.apache.ignite.tests.p2p.cache.PersonKey;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ *
+ */
+public class DataStructuresNoClassOnServerTestClient extends NoValueClassOnServerAbstractClient {
+    /**
+     * @param args Arguments.
+     * @throws Exception If failed.
+     */
+    private DataStructuresNoClassOnServerTestClient(String[] args) throws Exception {
+        super(args);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void runTest() throws Exception {
+        testAtomicReference();
+
+        testAtomicStamped();
+    }
+
+    /**
+     *
+     */
+    private void testAtomicReference() {
+        info("Test atomic reference");
+
+        IgniteAtomicReference<Person> ref = ignite.atomicReference("ref1", null, true);
+
+        assertNull(ref.get());
+
+        ref.set(person("p1"));
+
+        assertEquals(person("p1"), ref.get());
+
+        assertTrue(ref.compareAndSet(person("p1"), person("p2")));
+
+        assertEquals(person("p2"), ref.get());
+
+        assertFalse(ref.compareAndSet(person("p1"), person("p3")));
+
+        assertEquals(person("p2"), ref.get());
+
+        assertTrue(ref.compareAndSet(person("p2"), null));
+
+        assertNull(ref.get());
+
+        assertTrue(ref.compareAndSet(null, person("p2")));
+
+        assertEquals(person("p2"), ref.get());
+
+        ref.close();
+
+        ref = ignite.atomicReference("ref2", person("p1"), true);
+
+        assertEquals(person("p1"), ref.get());
+    }
+
+    /**
+     *
+     */
+    private void testAtomicStamped() {
+        info("Test atomic stamped");
+
+        IgniteAtomicStamped<Person, PersonKey> stamped = ignite.atomicStamped("s1", null, null, true);
+
+        stamped.set(person("p1"), key(1));
+
+        checkStamped(stamped, "p1", 1);
+
+        assertTrue(stamped.compareAndSet(person("p1"), person("p2"), key(1), key(2)));
+
+        checkStamped(stamped, "p2", 2);
+
+        assertFalse(stamped.compareAndSet(person("p1"), person("p3"), key(1), key(3)));
+
+        checkStamped(stamped, "p2", 2);
+
+        assertFalse(stamped.compareAndSet(person("p2"), person("p3"), key(1), key(3)));
+
+        checkStamped(stamped, "p2", 2);
+
+        assertTrue(stamped.compareAndSet(person("p2"), null, key(2), key(3)));
+
+        checkStamped(stamped, null, 3);
+
+        assertTrue(stamped.compareAndSet(null, person("p2"), key(3), key(4)));
+
+        checkStamped(stamped, "p2", 4);
+
+        stamped.close();
+
+        stamped = ignite.atomicStamped("s2", person("p5"), key(5), true);
+
+        checkStamped(stamped, "p5", 5);
+    }
+
+    /**
+     * @param stamped Stamped.
+     * @param personName Expected person name.
+     * @param id Expected stamp.
+     */
+    private void checkStamped(IgniteAtomicStamped<Person, PersonKey> stamped, String personName, int id) {
+        assertEquals(person(personName), stamped.value());
+        assertEquals(key(id), stamped.stamp());
+
+        IgniteBiTuple<Person, PersonKey> t = stamped.get();
+
+        assertEquals(person(personName), t.get1());
+        assertEquals(key(id), t.get2());
+    }
+
+    /**
+     * @param name Person name.
+     * @return Person instance.
+     */
+    private Person person(String name) {
+        if (name == null)
+            return null;
+
+        Person p = new Person();
+
+        p.setName(name);
+
+        return p;
+    }
+
+    /**
+     * @param id Key ID.
+     * @return Key.
+     */
+    private PersonKey key(int id) {
+        return new PersonKey(id);
+    }
+
+    /**
+     * @param args Arguments.
+     * @throws Exception If failed.
+     */
+    public static void main(String[] args) throws Exception {
+        try (DataStructuresNoClassOnServerTestClient client = new DataStructuresNoClassOnServerTestClient(args)) {
+            client.runTest();
+        }
+        catch (Throwable e) {
+            System.out.println("Unexpected error: " + e);
+
+            e.printStackTrace(System.out);
+
+            System.exit(1);
+        }
+    }
+}


[26/65] [abbrv] ignite git commit: master - Fix mvcc tests after CLOCK mode removal

Posted by ag...@apache.org.
master - Fix mvcc tests after CLOCK mode removal


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

Branch: refs/heads/ignite-5024
Commit: 0da51d4110ab13f42f0ee5a2fc3181fc50656cd4
Parents: 364c386
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Tue Apr 18 18:40:55 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Apr 18 18:40:55 2017 +0300

----------------------------------------------------------------------
 .../cache/GridCacheMvccPartitionedSelfTest.java | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0da51d41/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccPartitionedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccPartitionedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccPartitionedSelfTest.java
index 2fb5d25..0c53fee 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccPartitionedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccPartitionedSelfTest.java
@@ -604,9 +604,9 @@ public class GridCacheMvccPartitionedSelfTest extends GridCommonAbstractTest {
     public void testSerializableReadLocksAdd() throws Exception {
         GridCacheAdapter<String, String> cache = grid.internalCache();
 
-        GridCacheVersion serOrder1 = new GridCacheVersion(0, 0, 1);
-        GridCacheVersion serOrder2 = new GridCacheVersion(0, 0, 1);
-        GridCacheVersion serOrder3 = new GridCacheVersion(0, 0, 1);
+        GridCacheVersion serOrder1 = new GridCacheVersion(0, 10, 1);
+        GridCacheVersion serOrder2 = new GridCacheVersion(0, 20, 1);
+        GridCacheVersion serOrder3 = new GridCacheVersion(0, 15, 1);
 
         {
             GridCacheMvcc mvcc = new GridCacheMvcc(cache.context());
@@ -681,9 +681,9 @@ public class GridCacheMvccPartitionedSelfTest extends GridCommonAbstractTest {
     public void testSerializableReadLocksAssign() throws Exception {
         GridCacheAdapter<String, String> cache = grid.internalCache();
 
-        GridCacheVersion serOrder1 = new GridCacheVersion(0, 0, 1);
-        GridCacheVersion serOrder2 = new GridCacheVersion(0, 0, 1);
-        GridCacheVersion serOrder3 = new GridCacheVersion(0, 0, 1);
+        GridCacheVersion serOrder1 = new GridCacheVersion(0, 10, 1);
+        GridCacheVersion serOrder2 = new GridCacheVersion(0, 20, 1);
+        GridCacheVersion serOrder3 = new GridCacheVersion(0, 15, 1);
 
         {
             GridCacheMvcc mvcc = new GridCacheMvcc(cache.context());
@@ -883,10 +883,10 @@ public class GridCacheMvccPartitionedSelfTest extends GridCommonAbstractTest {
 
         GridCacheTestEntryEx e = new GridCacheTestEntryEx(cache.context(), "1");
 
-        GridCacheVersion serOrder1 = new GridCacheVersion(0, 0, 1);
-        GridCacheVersion serOrder2 = new GridCacheVersion(0, 0, 1);
-        GridCacheVersion serOrder3 = new GridCacheVersion(0, 0, 1);
-        GridCacheVersion serOrder4 = new GridCacheVersion(0, 0, 1);
+        GridCacheVersion serOrder1 = new GridCacheVersion(0, 10, 1);
+        GridCacheVersion serOrder2 = new GridCacheVersion(0, 20, 1);
+        GridCacheVersion serOrder3 = new GridCacheVersion(0, 15, 1);
+        GridCacheVersion serOrder4 = new GridCacheVersion(0, 30, 1);
 
         GridCacheVersion ver1 = incVer ? version(1) : version(4);
         GridCacheVersion ver2 = incVer ? version(2) : version(3);


[21/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/functions/Functions.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/functions/Functions.java b/modules/ml/src/main/java/org/apache/ignite/math/functions/Functions.java
deleted file mode 100644
index 7100908..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/functions/Functions.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.functions;
-
-/**
- * Compatibility with Apache Mahout.
- */
-public final class Functions {
-    /** Function that returns {@code Math.abs(a)}. */
-    public static final IgniteDoubleFunction<Double> ABS = Math::abs;
-
-    /** Function that returns its argument. */
-    public static final IgniteDoubleFunction<Double> IDENTITY = (a) -> a;
-
-    /** Function that returns {@code Math.log(a) / Math.log(2)}. */
-    public static final IgniteDoubleFunction<Double> LOG2 = (a) -> Math.log(a) * 1.4426950408889634;
-
-    /** Function that returns {@code -a}. */
-    public static final IgniteDoubleFunction<Double> NEGATE = (a) -> -a;
-
-    /** Function that returns {@code  a < 0 ? -1 : a > 0 ? 1 : 0 }. */
-    public static final IgniteDoubleFunction<Double> SIGN = (a) -> a < 0.0 ? -1.0 : a > 0.0 ? 1.0 : 0.0;
-
-    /** Function that returns {@code a * a}. */
-    public static final IgniteDoubleFunction<Double> SQUARE = (a) -> a * a;
-
-    /** Function that returns {@code  1 / (1 + exp(-a) } */
-    public static final IgniteDoubleFunction<Double> SIGMOID = (a) -> 1.0 / (1.0 + Math.exp(-a));
-
-    /** Function that returns {@code  1 / a } */
-    public static final IgniteDoubleFunction<Double> INV = (a) -> 1.0 / a;
-
-    /** Function that returns {@code  a * (1-a) } */
-    public static final IgniteDoubleFunction<Double> SIGMOIDGRADIENT = (a) -> a * (1.0 - a);
-
-    /** Function that returns {@code a % b}. */
-    public static final IgniteBiFunction<Double, Double, Double> MOD = (a, b) -> a % b;
-
-    /** Function that returns {@code a * b}. */
-    public static final IgniteBiFunction<Double, Double, Double> MULT = (a, b) -> a * b;
-
-    /** Function that returns {@code Math.log(a) / Math.log(b)}. */
-    public static final IgniteBiFunction<Double, Double, Double> LG = (a, b) -> Math.log(a) / Math.log(b);
-
-    /** Function that returns {@code a + b}. */
-    public static final IgniteBiFunction<Double, Double, Double> PLUS = (a, b) -> a + b;
-
-    /** Function that returns {@code a - b}. */
-    public static final IgniteBiFunction<Double, Double, Double> MINUS = (a, b) -> a - b;
-
-    /** Function that returns {@code abs(a - b)}. */
-    public static final IgniteBiFunction<Double, Double, Double> MINUS_ABS = (a, b) -> Math.abs(a - b);
-
-    /** Function that returns {@code max(abs(a), abs(b))}. */
-    public static final IgniteBiFunction<Double, Double, Double> MAX_ABS = (a, b) -> Math.max(Math.abs(a), Math.abs(b));
-
-    /** Function that returns {@code min(abs(a), abs(b))}. */
-    public static final IgniteBiFunction<Double, Double, Double> MIN_ABS = (a, b) -> Math.min(Math.abs(a), Math.abs(b));
-
-    /** Function that returns {@code Math.abs(a) + Math.abs(b)}. */
-    public static final IgniteBiFunction<Double, Double, Double> PLUS_ABS = (a, b) -> Math.abs(a) + Math.abs(b);
-
-    /** Function that returns {@code (a - b) * (a - b)} */
-    public static final IgniteBiFunction<Double, Double, Double> MINUS_SQUARED = (a, b) -> (a - b) * (a - b);
-
-    /**
-     * Function that returns {@code a &lt; b ? -1 : a &gt; b ? 1 : 0}.
-     */
-    public static final IgniteBiFunction<Double, Double, Double> COMPARE = (a, b) -> a < b ? -1.0 : a > b ? 1.0 : 0.0;
-
-    /**
-     * Function that returns {@code a + b}. {@code a} is a variable, {@code b} is fixed.
-     *
-     * @param b
-     */
-    public static IgniteDoubleFunction<Double> plus(final double b) {
-        return (a) -> a + b;
-    }
-
-    /**
-     * Function that returns {@code a * b}. {@code a} is a variable, {@code b} is fixed.
-     *
-     * @param b
-     */
-    public static IgniteDoubleFunction<Double> mult(final double b) {
-        return (a) -> a * b;
-    }
-
-    /** Function that returns {@code a / b}. {@code a} is a variable, {@code b} is fixed. */
-    public static IgniteDoubleFunction<Double> div(double b) {
-        return mult(1 / b);
-    }
-
-    /**
-     * Function that returns {@code a + b*constant}. {@code a} and {@code b} are variables,
-     * {@code constant} is fixed.
-     */
-    public static IgniteBiFunction<Double, Double, Double> plusMult(double constant) {
-        return (a, b) -> a + b * constant;
-    }
-
-    /**
-     * Function that returns {@code a - b*constant}. {@code a} and {@code b} are variables,
-     * {@code constant} is fixed.
-     */
-    public static IgniteBiFunction<Double, Double, Double> minusMult(double constant) {
-        return (a, b) -> a - b * constant;
-    }
-
-    /**
-     * @param b
-     */
-    public static IgniteDoubleFunction<Double> pow(final double b) {
-        return (a) -> {
-            if (b == 2)
-                return a * a;
-            else
-                return Math.pow(a, b);
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteBiConsumer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteBiConsumer.java b/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteBiConsumer.java
deleted file mode 100644
index 22e8274..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteBiConsumer.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.apache.ignite.math.functions;
-
-import java.io.Serializable;
-import java.util.function.BiConsumer;
-
-/**
- * Serializable binary consumer.
- *
- * @see java.util.function.BiConsumer
- */
-public interface IgniteBiConsumer<T, U> extends BiConsumer<T, U>, Serializable {
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteBiFunction.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteBiFunction.java b/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteBiFunction.java
deleted file mode 100644
index 9d9c147..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteBiFunction.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.functions;
-
-import java.io.Serializable;
-import java.util.function.BiFunction;
-
-/**
- * Serializable binary function.
- *
- * @see java.util.function.BiFunction
- */
-public interface IgniteBiFunction<A, B, T> extends BiFunction<A, B, T>, Serializable {
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteConsumer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteConsumer.java b/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteConsumer.java
deleted file mode 100644
index 1f7ca07..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteConsumer.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.functions;
-
-import java.io.Serializable;
-import java.util.function.Consumer;
-
-/**
- * Serializable consumer.
- *
- * @see java.util.function.Consumer
- */
-public interface IgniteConsumer<T> extends Consumer<T>, Serializable {
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteDoubleFunction.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteDoubleFunction.java b/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteDoubleFunction.java
deleted file mode 100644
index 7a23d50..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteDoubleFunction.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.functions;
-
-import java.io.Serializable;
-import java.util.function.DoubleFunction;
-
-/**
- * Serializable double function.
- *
- * @see java.util.function.DoubleFunction
- */
-public interface IgniteDoubleFunction<Double> extends DoubleFunction<Double>, Serializable {
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteFunction.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteFunction.java b/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteFunction.java
deleted file mode 100644
index cfe89a4..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/functions/IgniteFunction.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.functions;
-
-import java.io.Serializable;
-import java.util.function.Function;
-
-/**
- * Serializable function.
- *
- * @see java.util.function.Function
- */
-public interface IgniteFunction<T, R> extends Function<T, R>, Serializable {
-
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/functions/IntDoubleToVoidFunction.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/functions/IntDoubleToVoidFunction.java b/modules/ml/src/main/java/org/apache/ignite/math/functions/IntDoubleToVoidFunction.java
deleted file mode 100644
index e5d69c7..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/functions/IntDoubleToVoidFunction.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.functions;
-
-/**
- * Setter function for the vector.
- */
-public interface IntDoubleToVoidFunction extends IgniteBiConsumer<Integer, Double> {
-
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/functions/IntIntDoubleToVoidFunction.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/functions/IntIntDoubleToVoidFunction.java b/modules/ml/src/main/java/org/apache/ignite/math/functions/IntIntDoubleToVoidFunction.java
deleted file mode 100644
index cad8c3c..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/functions/IntIntDoubleToVoidFunction.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.functions;
-
-import java.io.Serializable;
-
-/**
- * Setter function for matrices.
- */
-public interface IntIntDoubleToVoidFunction extends Serializable {
-    /** */
-    public void apply(int x, int y, double v);
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/functions/IntIntToDoubleFunction.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/functions/IntIntToDoubleFunction.java b/modules/ml/src/main/java/org/apache/ignite/math/functions/IntIntToDoubleFunction.java
deleted file mode 100644
index b31d9f9..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/functions/IntIntToDoubleFunction.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.functions;
-
-/**
- * Getters functions for matrices.
- */
-public interface IntIntToDoubleFunction extends IgniteBiFunction<Integer, Integer, Double> {
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/functions/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/functions/package-info.java b/modules/ml/src/main/java/org/apache/ignite/math/functions/package-info.java
deleted file mode 100644
index 133e62c..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/functions/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Contains serializable functions for distributed code algebra.
- */
-package org.apache.ignite.math.functions;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/CacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/CacheUtils.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/CacheUtils.java
deleted file mode 100644
index df33895..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/CacheUtils.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import javax.cache.Cache;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.Affinity;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.lang.IgniteCallable;
-import org.apache.ignite.lang.IgniteRunnable;
-import org.apache.ignite.math.KeyMapper;
-import org.apache.ignite.math.ValueMapper;
-import org.apache.ignite.math.functions.IgniteBiFunction;
-import org.apache.ignite.math.functions.IgniteConsumer;
-import org.apache.ignite.math.functions.IgniteFunction;
-
-/**
- * Distribution-related misc. support.
- */
-public class CacheUtils {
-    /**
-     * Cache entry support.
-     *
-     * @param <K>
-     * @param <V>
-     */
-    public static class CacheEntry<K, V> {
-        /** */
-        private Cache.Entry<K, V> entry;
-        /** */
-        private IgniteCache<K, V> cache;
-
-        /**
-         * @param entry Original cache entry.
-         * @param cache Cache instance.
-         */
-        CacheEntry(Cache.Entry<K, V> entry, IgniteCache<K, V> cache) {
-            this.entry = entry;
-            this.cache = cache;
-        }
-
-        /**
-         *
-         *
-         */
-        public Cache.Entry<K, V> entry() {
-            return entry;
-        }
-
-        /**
-         *
-         *
-         */
-        public IgniteCache<K, V> cache() {
-            return cache;
-        }
-    }
-
-    /**
-     * Gets local Ignite instance.
-     */
-    public static Ignite ignite() {
-        return Ignition.localIgnite();
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @param k Key into the cache.
-     * @param <K> Key type.
-     * @return Cluster group for given key.
-     */
-    public static <K> ClusterGroup groupForKey(String cacheName, K k) {
-        return ignite().cluster().forNode(ignite().affinity(cacheName).mapKeyToNode(k));
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @param keyMapper {@link KeyMapper} to validate cache key.
-     * @param valMapper {@link ValueMapper} to obtain double value for given cache key.
-     * @param <K> Cache key object type.
-     * @param <V> Cache value object type.
-     * @return Sum of the values obtained for valid keys.
-     */
-    public static <K, V> double sum(String cacheName, KeyMapper<K> keyMapper, ValueMapper<V> valMapper) {
-        Collection<Double> subSums = fold(cacheName, (CacheEntry<K, V> ce, Double acc) -> {
-            if (keyMapper.isValid(ce.entry().getKey())) {
-                double v = valMapper.toDouble(ce.entry().getValue());
-
-                return acc == null ? v : acc + v;
-            }
-            else
-                return acc;
-        });
-
-        return sum(subSums);
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @return Sum obtained using sparse logic.
-     */
-    public static <K, V> double sparseSum(String cacheName) {
-        Collection<Double> subSums = fold(cacheName, (CacheEntry<Integer, Map<Integer, Double>> ce, Double acc) -> {
-            Map<Integer, Double> map = ce.entry().getValue();
-
-            double sum = sum(map.values());
-
-            return acc == null ? sum : acc + sum;
-        });
-
-        return sum(subSums);
-    }
-
-    /**
-     * @param c {@link Collection} of double values to sum.
-     * @return Sum of the values.
-     */
-    private static double sum(Collection<Double> c) {
-        double sum = 0.0;
-
-        for (double d : c)
-            sum += d;
-
-        return sum;
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @param keyMapper {@link KeyMapper} to validate cache key.
-     * @param valMapper {@link ValueMapper} to obtain double value for given cache key.
-     * @param <K> Cache key object type.
-     * @param <V> Cache value object type.
-     * @return Minimum value for valid keys.
-     */
-    public static <K, V> double min(String cacheName, KeyMapper<K> keyMapper, ValueMapper<V> valMapper) {
-        Collection<Double> mins = fold(cacheName, (CacheEntry<K, V> ce, Double acc) -> {
-            if (keyMapper.isValid(ce.entry().getKey())) {
-                double v = valMapper.toDouble(ce.entry().getValue());
-
-                if (acc == null)
-                    return v;
-                else
-                    return Math.min(acc, v);
-            }
-            else
-                return acc;
-        });
-
-        return Collections.min(mins);
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @return Minimum value obtained using sparse logic.
-     */
-    public static <K, V> double sparseMin(String cacheName) {
-        Collection<Double> mins = fold(cacheName, (CacheEntry<Integer, Map<Integer, Double>> ce, Double acc) -> {
-            Map<Integer, Double> map = ce.entry().getValue();
-
-            double min = Collections.min(map.values());
-
-            if (acc == null)
-                return min;
-            else
-                return Math.min(acc, min);
-        });
-
-        return Collections.min(mins);
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @return Maximum value obtained using sparse logic.
-     */
-    public static <K, V> double sparseMax(String cacheName) {
-        Collection<Double> maxes = fold(cacheName, (CacheEntry<Integer, Map<Integer, Double>> ce, Double acc) -> {
-            Map<Integer, Double> map = ce.entry().getValue();
-
-            double max = Collections.max(map.values());
-
-            if (acc == null)
-                return max;
-            else
-                return Math.max(acc, max);
-        });
-
-        return Collections.max(maxes);
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @param keyMapper {@link KeyMapper} to validate cache key.
-     * @param valMapper {@link ValueMapper} to obtain double value for given cache key.
-     * @param <K> Cache key object type.
-     * @param <V> Cache value object type.
-     * @return Maximum value for valid keys.
-     */
-    public static <K, V> double max(String cacheName, KeyMapper<K> keyMapper, ValueMapper<V> valMapper) {
-        Collection<Double> maxes = fold(cacheName, (CacheEntry<K, V> ce, Double acc) -> {
-            if (keyMapper.isValid(ce.entry().getKey())) {
-                double v = valMapper.toDouble(ce.entry().getValue());
-
-                if (acc == null)
-                    return v;
-                else
-                    return Math.max(acc, v);
-            }
-            else
-                return acc;
-        });
-
-        return Collections.max(maxes);
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @param keyMapper {@link KeyMapper} to validate cache key.
-     * @param valMapper {@link ValueMapper} to obtain double value for given cache key.
-     * @param mapper Mapping {@link IgniteFunction}.
-     * @param <K> Cache key object type.
-     * @param <V> Cache value object type.
-     */
-    public static <K, V> void map(String cacheName, KeyMapper<K> keyMapper, ValueMapper<V> valMapper,
-        IgniteFunction<Double, Double> mapper) {
-        foreach(cacheName, (CacheEntry<K, V> ce) -> {
-            K k = ce.entry().getKey();
-
-            if (keyMapper.isValid(k))
-                // Actual assignment.
-                ce.cache().put(k, valMapper.fromDouble(mapper.apply(valMapper.toDouble(ce.entry().getValue()))));
-        });
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @param mapper Mapping {@link IgniteFunction}.
-     */
-    public static <K, V> void sparseMap(String cacheName, IgniteFunction<Double, Double> mapper) {
-        foreach(cacheName, (CacheEntry<Integer, Map<Integer, Double>> ce) -> {
-            Integer k = ce.entry().getKey();
-            Map<Integer, Double> v = ce.entry().getValue();
-
-            for (Map.Entry<Integer, Double> e : v.entrySet())
-                e.setValue(mapper.apply(e.getValue()));
-
-            ce.cache().put(k, v);
-        });
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @param fun An operation that accepts a cache entry and processes it.
-     * @param <K> Cache key object type.
-     * @param <V> Cache value object type.
-     */
-    public static <K, V> void foreach(String cacheName, IgniteConsumer<CacheEntry<K, V>> fun) {
-        bcast(cacheName, () -> {
-            Ignite ignite = Ignition.localIgnite();
-            IgniteCache<K, V> cache = ignite.getOrCreateCache(cacheName);
-
-            int partsCnt = ignite.affinity(cacheName).partitions();
-
-            // Use affinity in filter for scan query. Otherwise we accept consumer in each node which is wrong.
-            Affinity affinity = ignite.affinity(cacheName);
-            ClusterNode locNode = ignite.cluster().localNode();
-
-            // Iterate over all partitions. Some of them will be stored on that local node.
-            for (int part = 0; part < partsCnt; part++) {
-                int p = part;
-
-                // 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)))
-                    fun.accept(new CacheEntry<>(entry, cache));
-            }
-        });
-    }
-
-    /**
-     * <b>Currently fold supports only commutative operations.<b/>
-     *
-     * @param cacheName Cache name.
-     * @param folder Fold function operating over cache entries.
-     * @param <K> Cache key object type.
-     * @param <V> Cache value object type.
-     * @param <A> Fold result type.
-     * @return Fold operation result.
-     */
-    public static <K, V, A> Collection<A> fold(String cacheName, IgniteBiFunction<CacheEntry<K, V>, A, A> folder) {
-        return bcast(cacheName, () -> {
-            Ignite ignite = Ignition.localIgnite();
-            IgniteCache<K, V> cache = ignite.getOrCreateCache(cacheName);
-
-            int partsCnt = ignite.affinity(cacheName).partitions();
-
-            // Use affinity in filter for ScanQuery. Otherwise we accept consumer in each node which is wrong.
-            Affinity affinity = ignite.affinity(cacheName);
-            ClusterNode locNode = ignite.cluster().localNode();
-
-            A a = null;
-
-            // Iterate over all partitions. Some of them will be stored on that local node.
-            for (int part = 0; part < partsCnt; part++) {
-                int p = part;
-
-                // 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)))
-                    a = folder.apply(new CacheEntry<>(entry, cache), a);
-            }
-
-            return a;
-        });
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @param run {@link Runnable} to broadcast to cache nodes for given cache name.
-     */
-    public static void bcast(String cacheName, IgniteRunnable run) {
-        ignite().compute(ignite().cluster().forCacheNodes(cacheName)).broadcast(run);
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @param call {@link IgniteCallable} to broadcast to cache nodes for given cache name.
-     * @param <A> Type returned by the callable.
-     */
-    public static <A> Collection<A> bcast(String cacheName, IgniteCallable<A> call) {
-        return ignite().compute(ignite().cluster().forCacheNodes(cacheName)).broadcast(call);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/AbstractMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/AbstractMatrix.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/AbstractMatrix.java
deleted file mode 100644
index ca11e81..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/AbstractMatrix.java
+++ /dev/null
@@ -1,880 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-import org.apache.ignite.lang.IgniteUuid;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.decompositions.LUDecomposition;
-import org.apache.ignite.math.exceptions.CardinalityException;
-import org.apache.ignite.math.exceptions.ColumnIndexException;
-import org.apache.ignite.math.exceptions.RowIndexException;
-import org.apache.ignite.math.functions.Functions;
-import org.apache.ignite.math.functions.IgniteBiFunction;
-import org.apache.ignite.math.functions.IgniteDoubleFunction;
-import org.apache.ignite.math.functions.IgniteFunction;
-import org.apache.ignite.math.functions.IntIntToDoubleFunction;
-import org.apache.ignite.math.impls.vector.MatrixVectorView;
-
-/**
- * This class provides a helper implementation of the {@link Matrix}
- * interface to minimize the effort required to implement it.
- * Subclasses may override some of the implemented methods if a more
- * specific or optimized implementation is desirable.
- *
- * TODO: add row/column optimization.
- */
-public abstract class AbstractMatrix implements Matrix {
-    // Stochastic sparsity analysis.
-    /** */
-    private static final double Z95 = 1.959964;
-    /** */
-    private static final double Z80 = 1.281552;
-    /** */
-    private static final int MAX_SAMPLES = 500;
-    /** */
-    private static final int MIN_SAMPLES = 15;
-
-    /** Cached minimum element. */
-    private Element minElm;
-    /** Cached maximum element. */
-    private Element maxElm = null;
-
-    /** Matrix storage implementation. */
-    private MatrixStorage sto;
-
-    /** Meta attributes storage. */
-    private Map<String, Object> meta = new HashMap<>();
-
-    /** Matrix's GUID. */
-    private IgniteUuid guid = IgniteUuid.randomUuid();
-
-    /**
-     * @param sto Backing {@link MatrixStorage}.
-     */
-    public AbstractMatrix(MatrixStorage sto) {
-        this.sto = sto;
-    }
-
-    /**
-     *
-     */
-    public AbstractMatrix() {
-        // No-op.
-    }
-
-    /**
-     * @param sto Backing {@link MatrixStorage}.
-     */
-    protected void setStorage(MatrixStorage sto) {
-        assert sto != null;
-
-        this.sto = sto;
-    }
-
-    /**
-     * @param row Row index in the matrix.
-     * @param col Column index in the matrix.
-     * @param v Value to set.
-     */
-    protected void storageSet(int row, int col, double v) {
-        sto.set(row, col, v);
-
-        // Reset cached values.
-        minElm = maxElm = null;
-    }
-
-    /**
-     * @param row Row index in the matrix.
-     * @param col Column index in the matrix.
-     */
-    protected double storageGet(int row, int col) {
-        return sto.get(row, col);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Element maxElement() {
-        if (maxElm == null) {
-            double max = Double.NEGATIVE_INFINITY;
-            int row = 0, col = 0;
-
-            int rows = rowSize();
-            int cols = columnSize();
-
-            for (int x = 0; x < rows; x++)
-                for (int y = 0; y < cols; y++) {
-                    double d = storageGet(x, y);
-
-                    if (d > max) {
-                        max = d;
-                        row = x;
-                        col = y;
-                    }
-                }
-
-            maxElm = mkElement(row, col);
-        }
-
-        return maxElm;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Element minElement() {
-        if (minElm == null) {
-            double min = Double.MAX_VALUE;
-            int row = 0, col = 0;
-
-            int rows = rowSize();
-            int cols = columnSize();
-
-            for (int x = 0; x < rows; x++)
-                for (int y = 0; y < cols; y++) {
-                    double d = storageGet(x, y);
-
-                    if (d < min) {
-                        min = d;
-                        row = x;
-                        col = y;
-                    }
-                }
-
-            minElm = mkElement(row, col);
-        }
-
-        return minElm;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double maxValue() {
-        return maxElement().get();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double minValue() {
-        return minElement().get();
-    }
-
-    /**
-     * @param row Row index in the matrix.
-     * @param col Column index in the matrix.
-     */
-    private Element mkElement(int row, int col) {
-        return new Element() {
-            /** {@inheritDoc} */
-            @Override public double get() {
-                return storageGet(row, col);
-            }
-
-            /** {@inheritDoc} */
-            @Override public int row() {
-                return row;
-            }
-
-            /** {@inheritDoc} */
-            @Override public int column() {
-                return col;
-            }
-
-            /** {@inheritDoc} */
-            @Override public void set(double d) {
-                storageSet(row, col, d);
-            }
-        };
-    }
-
-    /** {@inheritDoc} */
-    @Override public Element getElement(int row, int col) {
-        return mkElement(row, col);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix swapRows(int row1, int row2) {
-        checkRowIndex(row1);
-        checkRowIndex(row2);
-
-        int cols = columnSize();
-
-        for (int y = 0; y < cols; y++) {
-            double v = getX(row1, y);
-
-            setX(row1, y, getX(row2, y));
-            setX(row2, y, v);
-        }
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix swapColumns(int col1, int col2) {
-        checkColumnIndex(col1);
-        checkColumnIndex(col2);
-
-        int rows = rowSize();
-
-        for (int x = 0; x < rows; x++) {
-            double v = getX(x, col1);
-
-            setX(x, col1, getX(x, col2));
-            setX(x, col2, v);
-        }
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public MatrixStorage getStorage() {
-        return sto;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return sto.isSequentialAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return sto.isDense();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return sto.isRandomAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return sto.isDistributed();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return sto.isArrayBased();
-    }
-
-    /**
-     * Check row index bounds.
-     *
-     * @param row Row index.
-     */
-    private void checkRowIndex(int row) {
-        if (row < 0 || row >= rowSize())
-            throw new RowIndexException(row);
-    }
-
-    /**
-     * Check column index bounds.
-     *
-     * @param col Column index.
-     */
-    private void checkColumnIndex(int col) {
-        if (col < 0 || col >= columnSize())
-            throw new ColumnIndexException(col);
-    }
-
-    /**
-     * Check column and row index bounds.
-     *
-     * @param row Row index.
-     * @param col Column index.
-     */
-    protected void checkIndex(int row, int col) {
-        checkRowIndex(row);
-        checkColumnIndex(col);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(sto);
-        out.writeObject(meta);
-        out.writeObject(guid);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Map<String, Object> getMetaStorage() {
-        return meta;
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        sto = (MatrixStorage)in.readObject();
-        meta = (Map<String, Object>)in.readObject();
-        guid = (IgniteUuid)in.readObject();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix assign(double val) {
-        if (sto.isArrayBased())
-            for (double[] column : sto.data())
-                Arrays.fill(column, val);
-        else {
-            int rows = rowSize();
-            int cols = columnSize();
-
-            for (int x = 0; x < rows; x++)
-                for (int y = 0; y < cols; y++)
-                    storageSet(x, y, val);
-        }
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix assign(IntIntToDoubleFunction fun) {
-        int rows = rowSize();
-        int cols = columnSize();
-
-        for (int x = 0; x < rows; x++)
-            for (int y = 0; y < cols; y++)
-                storageSet(x, y, fun.apply(x, y));
-
-        return this;
-    }
-
-    /** */
-    private void checkCardinality(Matrix mtx) {
-        checkCardinality(mtx.rowSize(), mtx.columnSize());
-    }
-
-    /** */
-    private void checkCardinality(int rows, int cols) {
-        if (rows != rowSize())
-            throw new CardinalityException(rowSize(), rows);
-
-        if (cols != columnSize())
-            throw new CardinalityException(columnSize(), cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix assign(double[][] vals) {
-        checkCardinality(vals.length, vals[0].length);
-
-        int rows = rowSize();
-        int cols = columnSize();
-
-        for (int x = 0; x < rows; x++)
-            for (int y = 0; y < cols; y++)
-                storageSet(x, y, vals[x][y]);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix assign(Matrix mtx) {
-        checkCardinality(mtx);
-
-        int rows = rowSize();
-        int cols = columnSize();
-
-        for (int x = 0; x < rows; x++)
-            for (int y = 0; y < cols; y++)
-                storageSet(x, y, mtx.getX(x, y));
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix map(IgniteDoubleFunction<Double> fun) {
-        int rows = rowSize();
-        int cols = columnSize();
-
-        for (int x = 0; x < rows; x++)
-            for (int y = 0; y < cols; y++)
-                storageSet(x, y, fun.apply(storageGet(x, y)));
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix map(Matrix mtx, IgniteBiFunction<Double, Double, Double> fun) {
-        checkCardinality(mtx);
-
-        int rows = rowSize();
-        int cols = columnSize();
-
-        for (int x = 0; x < rows; x++)
-            for (int y = 0; y < cols; y++)
-                storageSet(x, y, fun.apply(storageGet(x, y), mtx.getX(x, y)));
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix assignColumn(int col, org.apache.ignite.math.Vector vec) {
-        checkColumnIndex(col);
-
-        int rows = rowSize();
-
-        for (int x = 0; x < rows; x++)
-            storageSet(x, col, vec.getX(x));
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix assignRow(int row, Vector vec) {
-        checkRowIndex(row);
-
-        int cols = columnSize();
-
-        if (cols != vec.size())
-            throw new CardinalityException(cols, vec.size());
-
-        if (sto.isArrayBased() && vec.getStorage().isArrayBased())
-            System.arraycopy(vec.getStorage().data(), 0, sto.data()[row], 0, cols);
-        else
-            for (int y = 0; y < cols; y++)
-                storageSet(row, y, vec.getX(y));
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector foldRows(IgniteFunction<Vector, Double> fun) {
-        int rows = rowSize();
-
-        Vector vec = likeVector(rows);
-
-        for (int i = 0; i < rows; i++)
-            vec.setX(i, fun.apply(viewRow(i)));
-
-        return vec;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector foldColumns(IgniteFunction<Vector, Double> fun) {
-        int cols = columnSize();
-
-        Vector vec = likeVector(cols);
-
-        for (int i = 0; i < cols; i++)
-            vec.setX(i, fun.apply(viewColumn(i)));
-
-        return vec;
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> T foldMap(IgniteBiFunction<T, Double, T> foldFun, IgniteDoubleFunction<Double> mapFun,
-        T zeroVal) {
-        T res = zeroVal;
-
-        int rows = rowSize();
-        int cols = columnSize();
-
-        for (int x = 0; x < rows; x++)
-            for (int y = 0; y < cols; y++)
-                res = foldFun.apply(res, mapFun.apply(storageGet(x, y)));
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int columnSize() {
-        return sto.columnSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int rowSize() {
-        return sto.rowSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double determinant() {
-        //TODO: This decomposition should be cached
-        LUDecomposition dec = new LUDecomposition(this);
-        double res = dec.determinant();
-        dec.destroy();
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix inverse() {
-        if (rowSize() != columnSize())
-            throw new CardinalityException(rowSize(), columnSize());
-
-        //TODO: This decomposition should be cached
-        LUDecomposition dec = new LUDecomposition(this);
-
-        Matrix res = dec.solve(likeIdentity());
-        dec.destroy();
-
-        return res;
-    }
-
-    /** */
-    protected Matrix likeIdentity() {
-        int n = rowSize();
-        Matrix res = like(n, n);
-
-        for (int i = 0; i < n; i++)
-            res.setX(i, i, 1.0);
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix divide(double d) {
-        int rows = rowSize();
-        int cols = columnSize();
-
-        for (int x = 0; x < rows; x++)
-            for (int y = 0; y < cols; y++)
-                setX(x, y, getX(x, y) / d);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int row, int col) {
-        checkIndex(row, col);
-
-        return storageGet(row, col);
-    }
-
-    /** {@inheritDoc} */
-    @Override public double getX(int row, int col) {
-        return storageGet(row, col);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix minus(Matrix mtx) {
-        int rows = rowSize();
-        int cols = columnSize();
-
-        checkCardinality(rows, cols);
-
-        Matrix res = like(rows, cols);
-
-        for (int x = 0; x < rows; x++)
-            for (int y = 0; y < cols; y++)
-                res.setX(x, y, getX(x, y) - mtx.getX(x, y));
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix plus(double x) {
-        Matrix cp = copy();
-
-        cp.map(Functions.plus(x));
-
-        return cp;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix plus(Matrix mtx) {
-        int rows = rowSize();
-        int cols = columnSize();
-
-        checkCardinality(rows, cols);
-
-        Matrix res = like(rows, cols);
-
-        for (int x = 0; x < rows; x++)
-            for (int y = 0; y < cols; y++)
-                res.setX(x, y, getX(x, y) + mtx.getX(x, y));
-
-        return res;
-
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteUuid guid() {
-        return guid;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix set(int row, int col, double val) {
-        checkIndex(row, col);
-
-        storageSet(row, col, val);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix setRow(int row, double[] data) {
-        checkRowIndex(row);
-
-        int cols = columnSize();
-
-        if (cols != data.length)
-            throw new CardinalityException(cols, data.length);
-
-        if (sto.isArrayBased())
-            System.arraycopy(data, 0, sto.data()[row], 0, cols);
-        else
-            for (int y = 0; y < cols; y++)
-                setX(row, y, data[y]);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix setColumn(int col, double[] data) {
-        checkColumnIndex(col);
-
-        int rows = rowSize();
-
-        if (rows != data.length)
-            throw new CardinalityException(rows, data.length);
-
-        for (int x = 0; x < rows; x++)
-            setX(x, col, data[x]);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix setX(int row, int col, double val) {
-        storageSet(row, col, val);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix times(double x) {
-        Matrix cp = copy();
-
-        cp.map(Functions.mult(x));
-
-        return cp;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double maxAbsRowSumNorm() {
-        double max = 0.0;
-
-        int rows = rowSize();
-        int cols = columnSize();
-
-        for (int x = 0; x < rows; x++) {
-            double sum = 0;
-
-            for (int y = 0; y < cols; y++)
-                sum += Math.abs(getX(x, y));
-
-            if (sum > max)
-                max = sum;
-        }
-
-        return max;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector times(Vector vec) {
-        int cols = columnSize();
-
-        if (cols != vec.size())
-            throw new CardinalityException(cols, vec.size());
-
-        int rows = rowSize();
-
-        Vector res = likeVector(rows);
-
-        for (int x = 0; x < rows; x++)
-            res.setX(x, vec.dot(viewRow(x)));
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix times(Matrix mtx) {
-        int cols = columnSize();
-
-        if (cols != mtx.rowSize())
-            throw new CardinalityException(cols, mtx.rowSize());
-
-        int rows = rowSize();
-
-        int mtxCols = mtx.columnSize();
-
-        Matrix res = like(rows, mtxCols);
-
-        for (int x = 0; x < rows; x++)
-            for (int y = 0; y < mtxCols; y++) {
-                double sum = 0.0;
-
-                for (int k = 0; k < cols; k++)
-                    sum += getX(x, k) * mtx.getX(k, y);
-
-                res.setX(x, y, sum);
-            }
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double sum() {
-        int rows = rowSize();
-        int cols = columnSize();
-
-        double sum = 0.0;
-
-        for (int x = 0; x < rows; x++)
-            for (int y = 0; y < cols; y++)
-                sum += getX(x, y);
-
-        return sum;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix transpose() {
-        int rows = rowSize();
-        int cols = columnSize();
-
-        Matrix mtx = like(cols, rows);
-
-        for (int x = 0; x < rows; x++)
-            for (int y = 0; y < cols; y++)
-                mtx.setX(y, x, getX(x, y));
-
-        return mtx;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean density(double threshold) {
-        assert threshold >= 0.0 && threshold <= 1.0;
-
-        int n = MIN_SAMPLES;
-        int rows = rowSize();
-        int cols = columnSize();
-
-        double mean = 0.0;
-        double pq = threshold * (1 - threshold);
-
-        Random rnd = new Random();
-
-        for (int i = 0; i < MIN_SAMPLES; i++)
-            if (getX(rnd.nextInt(rows), rnd.nextInt(cols)) != 0.0)
-                mean++;
-
-        mean /= MIN_SAMPLES;
-
-        double iv = Z80 * Math.sqrt(pq / n);
-
-        if (mean < threshold - iv)
-            return false; // Sparse.
-        else if (mean > threshold + iv)
-            return true; // Dense.
-
-        while (n < MAX_SAMPLES) {
-            // Determine upper bound we may need for 'n' to likely relinquish the uncertainty.
-            // Here, we use confidence interval formula but solved for 'n'.
-            double ivX = Math.max(Math.abs(threshold - mean), 1e-11);
-
-            double stdErr = ivX / Z80;
-            double nX = Math.min(Math.max((int)Math.ceil(pq / (stdErr * stdErr)), n), MAX_SAMPLES) - n;
-
-            if (nX < 1.0) // IMPL NOTE this can happen with threshold 1.0
-                nX = 1.0;
-
-            double meanNext = 0.0;
-
-            for (int i = 0; i < nX; i++)
-                if (getX(rnd.nextInt(rows), rnd.nextInt(cols)) != 0.0)
-                    meanNext++;
-
-            mean = (n * mean + meanNext) / (n + nX);
-
-            n += nX;
-
-            // Are we good now?
-            iv = Z80 * Math.sqrt(pq / n);
-
-            if (mean < threshold - iv)
-                return false; // Sparse.
-            else if (mean > threshold + iv)
-                return true; // Dense.
-        }
-
-        return mean > threshold; // Dense if mean > threshold.
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix viewPart(int[] off, int[] size) {
-        return new MatrixView(this, off[0], off[1], size[0], size[1]);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix viewPart(int rowOff, int rows, int colOff, int cols) {
-        return viewPart(new int[] {rowOff, colOff}, new int[] {rows, cols});
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector viewRow(int row) {
-        return new MatrixVectorView(this, row, 0, 0, 1);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector viewColumn(int col) {
-        return new MatrixVectorView(this, 0, col, 1, 0);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector viewDiagonal() {
-        return new MatrixVectorView(this, 0, 0, 1, 1);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix copy() {
-        Matrix cp = like(rowSize(), columnSize());
-
-        cp.assign(this);
-
-        return cp;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + guid.hashCode();
-        res = res * 37 + sto.hashCode();
-        res = res * 37 + meta.hashCode();
-
-        return res;
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * We ignore guid's for comparisons.
-     */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        AbstractMatrix that = (AbstractMatrix)o;
-
-        MatrixStorage sto = getStorage();
-
-        return (sto != null ? sto.equals(that.getStorage()) : that.getStorage() == null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/CacheMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/CacheMatrix.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/CacheMatrix.java
deleted file mode 100644
index 8ce1192..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/CacheMatrix.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.MatrixKeyMapper;
-import org.apache.ignite.math.ValueMapper;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.IgniteDoubleFunction;
-import org.apache.ignite.math.functions.IgniteFunction;
-import org.apache.ignite.math.impls.CacheUtils;
-import org.apache.ignite.math.impls.storage.matrix.CacheMatrixStorage;
-
-/**
- * Matrix based on existing cache and key and value mapping functions.
- */
-public class CacheMatrix<K, V> extends AbstractMatrix {
-    /**
-     *
-     */
-    public CacheMatrix() {
-        // No-op.
-    }
-
-    /**
-     * Creates new matrix over existing cache.
-     *
-     * @param rows
-     * @param cols
-     * @param cache
-     * @param keyMapper
-     * @param valMapper
-     */
-    public CacheMatrix(
-        int rows,
-        int cols,
-        IgniteCache<K, V> cache,
-        MatrixKeyMapper<K> keyMapper,
-        ValueMapper<V> valMapper) {
-        assert rows > 0;
-        assert cols > 0;
-        assert cache != null;
-        assert keyMapper != null;
-        assert valMapper != null;
-
-        setStorage(new CacheMatrixStorage<>(rows, cols, cache, keyMapper, valMapper));
-    }
-
-    /**
-     *
-     *
-     */
-    @SuppressWarnings({"unchecked"})
-    private CacheMatrixStorage<K, V> storage() {
-        return (CacheMatrixStorage<K, V>)getStorage();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix copy() {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix like(int rows, int cols) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector likeVector(int crd) {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * Return the same matrix with updates values (broken contract).
-     *
-     * @param d
-     */
-    @Override public Matrix divide(double d) {
-        return mapOverValues((Double v) -> v / d);
-    }
-
-    /**
-     * Return the same matrix with updates values (broken contract).
-     *
-     * @param x
-     */
-    @Override public Matrix plus(double x) {
-        return mapOverValues((Double v) -> v + x);
-    }
-
-    /**
-     * Return the same matrix with updates values (broken contract).
-     *
-     * @param x
-     */
-    @Override public Matrix times(double x) {
-        return mapOverValues((Double v) -> v * x);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix assign(double val) {
-        return mapOverValues((Double v) -> val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix map(IgniteDoubleFunction<Double> fun) {
-        return mapOverValues(fun::apply);
-    }
-
-    /** {@inheritDoc} */
-    @Override public double sum() {
-        CacheMatrixStorage<K, V> sto = storage();
-
-        return CacheUtils.sum(sto.cache().getName(), sto.keyMapper(), sto.valueMapper());
-    }
-
-    /** {@inheritDoc} */
-    @Override public double maxValue() {
-        CacheMatrixStorage<K, V> sto = storage();
-
-        return CacheUtils.max(sto.cache().getName(), sto.keyMapper(), sto.valueMapper());
-    }
-
-    /** {@inheritDoc} */
-    @Override public double minValue() {
-        CacheMatrixStorage<K, V> sto = storage();
-
-        return CacheUtils.min(sto.cache().getName(), sto.keyMapper(), sto.valueMapper());
-    }
-
-    /**
-     * @param mapper
-     */
-    private Matrix mapOverValues(IgniteFunction<Double, Double> mapper) {
-        CacheMatrixStorage<K, V> sto = storage();
-
-        CacheUtils.map(sto.cache().getName(), sto.keyMapper(), sto.valueMapper(), mapper);
-
-        return this;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/DenseLocalOffHeapMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/DenseLocalOffHeapMatrix.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/DenseLocalOffHeapMatrix.java
deleted file mode 100644
index d5f8eca..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/DenseLocalOffHeapMatrix.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.storage.matrix.DenseOffHeapMatrixStorage;
-import org.apache.ignite.math.impls.vector.DenseLocalOffHeapVector;
-
-/**
- * Dense local off-heap implementation of the {@link Matrix} interface.
- */
-public class DenseLocalOffHeapMatrix extends AbstractMatrix {
-    /** */
-    public DenseLocalOffHeapMatrix() {
-        // No-op.
-    }
-
-    /**
-     * @param data Backing data array.
-     */
-    public DenseLocalOffHeapMatrix(double[][] data) {
-        assert data != null;
-
-        setStorage(new DenseOffHeapMatrixStorage(data));
-    }
-
-    /**
-     * @param rows Amount of rows in matrix.
-     * @param cols Amount of columns in matrix.
-     */
-    public DenseLocalOffHeapMatrix(int rows, int cols) {
-        assert rows > 0;
-        assert cols > 0;
-
-        setStorage(new DenseOffHeapMatrixStorage(rows, cols));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix copy() {
-        DenseLocalOffHeapMatrix cp = new DenseLocalOffHeapMatrix(getStorage().rowSize(), getStorage().columnSize());
-
-        cp.assign(this);
-
-        return cp;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix like(int rows, int cols) {
-        return new DenseLocalOffHeapMatrix(rows, cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector likeVector(int crd) {
-        return new DenseLocalOffHeapVector(crd);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void destroy() {
-        getStorage().destroy();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Matrix likeIdentity() {
-        int n = rowSize();
-        Matrix res = like(n, n);
-
-        // IMPL NOTE as opposed to on-heap matrices this one isn't initialized with zeroes
-        for (int i = 0; i < n; i++)
-            for (int j = 0; j < n; j++)
-                res.setX(i, j, i == j ? 1.0 : 0.0);
-
-        return res;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/DenseLocalOnHeapMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/DenseLocalOnHeapMatrix.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/DenseLocalOnHeapMatrix.java
deleted file mode 100644
index 3cc3e4f..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/DenseLocalOnHeapMatrix.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.storage.matrix.ArrayMatrixStorage;
-import org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector;
-
-/**
- * Basic implementation for matrix.
- *
- * This is a trivial implementation for matrix assuming dense logic, local on-heap JVM storage
- * based on <code>double[][]</code> array. It is only suitable for data sets where
- * local, non-distributed execution is satisfactory and on-heap JVM storage is enough
- * to keep the entire data set.
- */
-public class DenseLocalOnHeapMatrix extends AbstractMatrix {
-    /**
-     *
-     */
-    public DenseLocalOnHeapMatrix() {
-        // No-op.
-    }
-
-    /**
-     * @param rows Amount of rows in matrix.
-     * @param cols Amount of columns in matrix.
-     */
-    public DenseLocalOnHeapMatrix(int rows, int cols) {
-        assert rows > 0;
-        assert cols > 0;
-
-        setStorage(new ArrayMatrixStorage(rows, cols));
-    }
-
-    /**
-     * @param mtx Backing data array.
-     */
-    public DenseLocalOnHeapMatrix(double[][] mtx) {
-        assert mtx != null;
-
-        setStorage(new ArrayMatrixStorage(mtx));
-    }
-
-    /**
-     * @param orig Original matrix.
-     */
-    private DenseLocalOnHeapMatrix(DenseLocalOnHeapMatrix orig) {
-        assert orig != null;
-
-        setStorage(new ArrayMatrixStorage(orig.rowSize(), orig.columnSize()));
-
-        assign(orig);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix copy() {
-        return new DenseLocalOnHeapMatrix(this);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix like(int rows, int cols) {
-        return new DenseLocalOnHeapMatrix(rows, cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector likeVector(int crd) {
-        return new DenseLocalOnHeapVector(crd);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/DiagonalMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/DiagonalMatrix.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/DiagonalMatrix.java
deleted file mode 100644
index 0b1f97e..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/DiagonalMatrix.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.storage.matrix.DiagonalMatrixStorage;
-import org.apache.ignite.math.impls.vector.ConstantVector;
-import org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector;
-import org.apache.ignite.math.impls.vector.SingleElementVectorView;
-
-/**
- * Implementation of diagonal view of the {@link Matrix}.
- *
- * <p>See also: <a href="https://en.wikipedia.org/wiki/Diagonal_matrix">Wikipedia article</a>.</p>
- */
-public class DiagonalMatrix extends AbstractMatrix {
-    /**
-     *
-     */
-    public DiagonalMatrix() {
-        // No-op.
-    }
-
-    /**
-     * @param diagonal Backing {@link Vector}.
-     */
-    public DiagonalMatrix(Vector diagonal) {
-        super(new DiagonalMatrixStorage(diagonal));
-    }
-
-    /**
-     * @param mtx Backing {@link Matrix}.
-     */
-    public DiagonalMatrix(Matrix mtx) {
-        super(new DiagonalMatrixStorage(mtx == null ? null : mtx.viewDiagonal()));
-    }
-
-    /**
-     * @param vals Backing array of values at diagonal.
-     */
-    public DiagonalMatrix(double[] vals) {
-        super(new DiagonalMatrixStorage(new DenseLocalOnHeapVector(vals)));
-    }
-
-    /**
-     *
-     *
-     */
-    private DiagonalMatrixStorage storage() {
-        return (DiagonalMatrixStorage)getStorage();
-    }
-
-    /**
-     * @param size Size of diagonal.
-     * @param val Constant value at diagonal.
-     */
-    public DiagonalMatrix(int size, double val) {
-        super(new DiagonalMatrixStorage(new ConstantVector(size, val)));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector viewRow(int row) {
-        return new SingleElementVectorView(storage().diagonal(), row);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector viewColumn(int col) {
-        return new SingleElementVectorView(storage().diagonal(), col);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix copy() {
-        return new DiagonalMatrix(storage().diagonal());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix like(int rows, int cols) {
-        return storage().diagonal().likeMatrix(rows, cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector likeVector(int crd) {
-        return storage().diagonal().like(crd);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/FunctionMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/FunctionMatrix.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/FunctionMatrix.java
deleted file mode 100644
index b180b5b..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/FunctionMatrix.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.IntIntDoubleToVoidFunction;
-import org.apache.ignite.math.functions.IntIntToDoubleFunction;
-import org.apache.ignite.math.impls.storage.matrix.FunctionMatrixStorage;
-
-/**
- * Implementation of {@link Matrix} that maps row and column index to {@link java.util.function} interfaces.
- */
-public class FunctionMatrix extends AbstractMatrix {
-    /**
-     *
-     */
-    public FunctionMatrix() {
-        // No-op.
-    }
-
-    /**
-     * Creates read-write or read-only function matrix.
-     *
-     * @param rows Amount of rows in the matrix.
-     * @param cols Amount of columns in the matrix.
-     * @param getFunc Function that returns value corresponding to given row and column index.
-     * @param setFunc Set function. If {@code null} - this will be a read-only matrix.
-     */
-    public FunctionMatrix(int rows, int cols, IntIntToDoubleFunction getFunc, IntIntDoubleToVoidFunction setFunc) {
-        assert rows > 0;
-        assert cols > 0;
-        assert getFunc != null;
-
-        setStorage(new FunctionMatrixStorage(rows, cols, getFunc, setFunc));
-    }
-
-    /**
-     * Creates read-only function matrix.
-     *
-     * @param rows Amount of rows in the matrix.
-     * @param cols Amount of columns in the matrix.
-     * @param getFunc Function that returns value corresponding to given row and column index.
-     */
-    public FunctionMatrix(int rows, int cols, IntIntToDoubleFunction getFunc) {
-        assert rows > 0;
-        assert cols > 0;
-        assert getFunc != null;
-
-        setStorage(new FunctionMatrixStorage(rows, cols, getFunc));
-    }
-
-    /**
-     *
-     *
-     */
-    private FunctionMatrixStorage storage() {
-        return (FunctionMatrixStorage)getStorage();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix copy() {
-        FunctionMatrixStorage sto = storage();
-
-        return new FunctionMatrix(sto.rowSize(), sto.columnSize(), sto.getFunction(), sto.setFunction());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix like(int rows, int cols) {
-        FunctionMatrixStorage sto = storage();
-
-        return new FunctionMatrix(rows, cols, sto.getFunction(), sto.setFunction());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector likeVector(int crd) {
-        throw new UnsupportedOperationException();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/MatrixView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/MatrixView.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/MatrixView.java
deleted file mode 100644
index 7b04dde..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/MatrixView.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import java.io.Externalizable;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.storage.matrix.MatrixDelegateStorage;
-
-/**
- * Implements the rectangular view into the parent {@link Matrix}.
- */
-public class MatrixView extends AbstractMatrix {
-    /**
-     * Constructor for {@link Externalizable} interface.
-     */
-    public MatrixView() {
-        // No-op.
-    }
-
-    /**
-     * @param parent Backing parent {@link Matrix}.
-     * @param rowOff Row offset to parent matrix.
-     * @param colOff Column offset to parent matrix.
-     * @param rows Amount of rows in the view.
-     * @param cols Amount of columns in the view.
-     */
-    public MatrixView(Matrix parent, int rowOff, int colOff, int rows, int cols) {
-        this(parent == null ? null : parent.getStorage(), rowOff, colOff, rows, cols);
-    }
-
-    /**
-     * @param sto Backing parent {@link MatrixStorage}.
-     * @param rowOff Row offset to parent storage.
-     * @param colOff Column offset to parent storage.
-     * @param rows Amount of rows in the view.
-     * @param cols Amount of columns in the view.
-     */
-    public MatrixView(MatrixStorage sto, int rowOff, int colOff, int rows, int cols) {
-        super(new MatrixDelegateStorage(sto, rowOff, colOff, rows, cols));
-    }
-
-    /**
-     *
-     *
-     */
-    private MatrixDelegateStorage storage() {
-        return (MatrixDelegateStorage)getStorage();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix copy() {
-        MatrixDelegateStorage sto = storage();
-
-        return new MatrixView(sto.delegate(), sto.rowOffset(), sto.columnOffset(), sto.rowSize(), sto.columnSize());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix like(int rows, int cols) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector likeVector(int crd) {
-        throw new UnsupportedOperationException();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/PivotedMatrixView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/PivotedMatrixView.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/PivotedMatrixView.java
deleted file mode 100644
index 1f7b008..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/matrix/PivotedMatrixView.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.IndexException;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.storage.matrix.PivotedMatrixStorage;
-import org.apache.ignite.math.impls.vector.PivotedVectorView;
-
-/**
- * Pivoted (index mapped) view over another matrix implementation.
- */
-public class PivotedMatrixView extends AbstractMatrix {
-    /** Pivoted matrix. */
-    private Matrix mtx;
-
-    /**
-     *
-     */
-    public PivotedMatrixView() {
-        // No-op.
-    }
-
-    /**
-     * @param mtx
-     * @param rowPivot
-     * @param colPivot
-     */
-    public PivotedMatrixView(Matrix mtx, int[] rowPivot, int[] colPivot) {
-        super(new PivotedMatrixStorage(mtx == null ? null : mtx.getStorage(), rowPivot, colPivot));
-
-        this.mtx = mtx;
-    }
-
-    /**
-     * @param mtx
-     */
-    public PivotedMatrixView(Matrix mtx) {
-        super(new PivotedMatrixStorage(mtx == null ? null : mtx.getStorage()));
-
-        this.mtx = mtx;
-    }
-
-    /**
-     * @param mtx
-     * @param pivot
-     */
-    public PivotedMatrixView(Matrix mtx, int[] pivot) {
-        super(new PivotedMatrixStorage(mtx == null ? null : mtx.getStorage(), pivot));
-
-        this.mtx = mtx;
-    }
-
-    /**
-     * Swaps indexes {@code i} and {@code j} for both both row and column.
-     *
-     * @param i First index to swap.
-     * @param j Second index to swap.
-     */
-    public Matrix swap(int i, int j) {
-        swapRows(i, j);
-        swapColumns(i, j);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix swapRows(int i, int j) {
-        if (i < 0 || i >= storage().rowPivot().length)
-            throw new IndexException(i);
-        if (j < 0 || j >= storage().rowPivot().length)
-            throw new IndexException(j);
-
-        storage().swapRows(i, j);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix swapColumns(int i, int j) {
-        if (i < 0 || i >= storage().columnPivot().length)
-            throw new IndexException(i);
-        if (j < 0 || j >= storage().columnPivot().length)
-            throw new IndexException(j);
-
-        storage().swapColumns(i, j);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector viewRow(int row) {
-        return new PivotedVectorView(
-            mtx.viewRow(storage().rowPivot()[row]),
-            storage().columnPivot(),
-            storage().columnUnpivot()
-        );
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector viewColumn(int col) {
-        return new PivotedVectorView(
-            mtx.viewColumn(storage().columnPivot()[col]),
-            storage().rowPivot(),
-            storage().rowUnpivot()
-        );
-    }
-
-    /**
-     *
-     *
-     */
-    public Matrix getBaseMatrix() {
-        return mtx;
-    }
-
-    /**
-     *
-     *
-     */
-    public int[] rowPivot() {
-        return storage().rowPivot();
-    }
-
-    /**
-     *
-     *
-     */
-    public int[] columnPivot() {
-        return storage().columnPivot();
-    }
-
-    /**
-     * @param i
-     */
-    public int rowPivot(int i) {
-        return storage().rowPivot()[i];
-    }
-
-    /**
-     * @param i
-     */
-    public int columnPivot(int i) {
-        return storage().columnPivot()[i];
-    }
-
-    /**
-     * @param i
-     */
-    public int rowUnpivot(int i) {
-        return storage().rowUnpivot()[i];
-    }
-
-    /**
-     * @param i
-     */
-    public int columnUnpivot(int i) {
-        return storage().columnUnpivot()[i];
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        super.writeExternal(out);
-
-        out.writeObject(mtx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        super.readExternal(in);
-
-        mtx = (Matrix)in.readObject();
-    }
-
-    /**
-     *
-     *
-     */
-    private PivotedMatrixStorage storage() {
-        return (PivotedMatrixStorage)getStorage();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix copy() {
-        return new PivotedMatrixView(mtx, storage().rowPivot(), storage().columnPivot());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix like(int rows, int cols) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector likeVector(int crd) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + mtx.hashCode();
-        res = res * 37 + getStorage().hashCode();
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        PivotedMatrixView that = (PivotedMatrixView)o;
-
-        MatrixStorage sto = storage();
-
-        return mtx.equals(that.mtx) && sto.equals(that.storage());
-    }
-}


[32/65] [abbrv] ignite git commit: Replaced partsToEvict from queue to map to do not add the same partition several times.

Posted by ag...@apache.org.
Replaced partsToEvict from queue to map to do not add the same partition several times.


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

Branch: refs/heads/ignite-5024
Commit: d1f637f799c307b34ddabd7abb8d2f0dcf9d73b3
Parents: a826c61
Author: sboikov <sb...@gridgain.com>
Authored: Thu Apr 20 18:35:12 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Apr 20 18:35:12 2017 +0300

----------------------------------------------------------------------
 .../dht/preloader/GridDhtPreloader.java           | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d1f637f7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
index 517f04a..9f1b96e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
@@ -22,6 +22,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.ReadWriteLock;
@@ -106,7 +107,7 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
     private final ReadWriteLock demandLock = new ReentrantReadWriteLock();
 
     /** */
-    private final ConcurrentLinkedDeque8<GridDhtLocalPartition> partsToEvict = new ConcurrentLinkedDeque8<>();
+    private final ConcurrentHashMap<Integer, GridDhtLocalPartition> partsToEvict = new ConcurrentHashMap<>();
 
     /** */
     private final AtomicInteger partsEvictOwning = new AtomicInteger();
@@ -774,28 +775,28 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
 
     /** {@inheritDoc} */
     @Override public void evictPartitionAsync(GridDhtLocalPartition part) {
-        partsToEvict.add(part);
+        partsToEvict.putIfAbsent(part.id(), part);
 
         if (partsEvictOwning.get() == 0 && partsEvictOwning.compareAndSet(0, 1)) {
             cctx.closures().callLocalSafe(new GPC<Boolean>() {
                 @Override public Boolean call() {
                     boolean locked = true;
 
-                    while (locked || !partsToEvict.isEmptyx()) {
+                    while (locked || !partsToEvict.isEmpty()) {
                         if (!locked && !partsEvictOwning.compareAndSet(0, 1))
                             return false;
 
                         try {
-                            GridDhtLocalPartition part = partsToEvict.poll();
-
-                            if (part != null)
+                            for (GridDhtLocalPartition part : partsToEvict.values()) {
                                 try {
+                                    partsToEvict.remove(part.id());
+
                                     part.tryEvict();
 
                                     GridDhtPartitionState state = part.state();
 
                                     if (state == RENTING || ((state == MOVING || state == OWNING) && part.shouldBeRenting()))
-                                        partsToEvict.push(part);
+                                        partsToEvict.put(part.id(), part);
                                 }
                                 catch (Throwable ex) {
                                     if (cctx.kernalContext().isStopping()) {
@@ -810,9 +811,10 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
                                     else
                                         LT.error(log, ex, "Partition eviction failed, this can cause grid hang.");
                                 }
+                            }
                         }
                         finally {
-                            if (!partsToEvict.isEmptyx())
+                            if (!partsToEvict.isEmpty())
                                 locked = true;
                             else {
                                 boolean res = partsEvictOwning.compareAndSet(1, 0);


[02/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/RandomVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/RandomVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/RandomVectorConstructorTest.java
new file mode 100644
index 0000000..49e1a50
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/RandomVectorConstructorTest.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class RandomVectorConstructorTest {
+    /** */
+    private static final int IMPOSSIBLE_SIZE = -1;
+
+    /** */
+    @Test(expected = UnsupportedOperationException.class)
+    public void mapInvalidArgsTest() {
+        assertEquals("Expect exception due to invalid args.", IMPOSSIBLE_SIZE,
+            new RandomVector(new HashMap<String, Object>() {{
+                put("invalid", 99);
+            }}).size());
+    }
+
+    /** */
+    @Test(expected = UnsupportedOperationException.class)
+    public void mapMissingArgsTest() {
+        final Map<String, Object> test = new HashMap<String, Object>() {{
+            put("paramMissing", "whatever");
+        }};
+
+        assertEquals("Expect exception due to missing args.",
+            -1, new RandomVector(test).size());
+    }
+
+    /** */
+    @Test(expected = ClassCastException.class)
+    public void mapInvalidParamTypeTest() {
+        final Map<String, Object> test = new HashMap<String, Object>() {{
+            put("size", "whatever");
+            put("fastHash", true);
+        }};
+
+        assertEquals("Expect exception due to invalid param type.", IMPOSSIBLE_SIZE,
+            new RandomVector(test).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void mapNullTest() {
+        //noinspection ConstantConditions
+        assertEquals("Null map args.", IMPOSSIBLE_SIZE,
+            new RandomVector(null).size());
+    }
+
+    /** */
+    @Test
+    public void mapTest() {
+        assertEquals("Size from args.", 99,
+            new RandomVector(new HashMap<String, Object>() {{
+                put("size", 99);
+            }}).size());
+
+        final int test = 99;
+
+        assertEquals("Size from args with fastHash false.", test,
+            new RandomVector(new HashMap<String, Object>() {{
+                put("size", test);
+                put("fastHash", false);
+            }}).size());
+
+        assertEquals("Size from args with fastHash true.", test,
+            new RandomVector(new HashMap<String, Object>() {{
+                put("size", test);
+                put("fastHash", true);
+            }}).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void negativeSizeTest() {
+        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
+            new RandomVector(-1).size());
+    }
+
+    /** */
+    @Test
+    public void basicTest() {
+        final int basicSize = 3;
+
+        Vector v1 = new RandomVector(basicSize);
+
+        //noinspection EqualsWithItself
+        assertTrue("Expect vector to be equal to self", v1.equals(v1));
+
+        //noinspection ObjectEqualsNull
+        assertFalse("Expect vector to be not equal to null", v1.equals(null));
+
+        assertEquals("Size differs from expected", basicSize, v1.size());
+
+        verifyValues(v1);
+
+        Vector v2 = new RandomVector(basicSize, true);
+
+        assertEquals("Size differs from expected", basicSize, v2.size());
+
+        verifyValues(v2);
+
+        Vector v3 = new RandomVector(basicSize, false);
+
+        assertEquals("Size differs from expected", basicSize, v3.size());
+
+        verifyValues(v3);
+    }
+
+    /** */
+    private void verifyValues(Vector v) {
+        for (Vector.Element e : v.all()) {
+            double val = e.get();
+
+            assertTrue("Value too small: " + val + " at index " + e.index(), -1d <= val);
+
+            assertTrue("Value too large: " + val + " at index " + e.index(), val <= 1d);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SingleElementVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SingleElementVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SingleElementVectorConstructorTest.java
new file mode 100644
index 0000000..db4d5de
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SingleElementVectorConstructorTest.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class SingleElementVectorConstructorTest {
+    /** */
+    private static final int IMPOSSIBLE_SIZE = -1;
+
+    /** */
+    @Test(expected = UnsupportedOperationException.class)
+    public void mapInvalidArgsTest() {
+        assertEquals("Expect exception due to invalid args.", IMPOSSIBLE_SIZE,
+            new SingleElementVector(new HashMap<String, Object>() {{
+                put("invalid", 99);
+            }}).size());
+    }
+
+    /** */
+    @Test(expected = UnsupportedOperationException.class)
+    public void mapMissingArgsTest() {
+        final Map<String, Object> test = new HashMap<String, Object>() {{
+            put("size", 1);
+
+            put("paramMissing", "whatever");
+        }};
+
+        assertEquals("Expect exception due to missing args.",
+            -1, new SingleElementVector(test).size());
+    }
+
+    /** */
+    @Test(expected = ClassCastException.class)
+    public void mapInvalidParamTypeTest() {
+        final Map<String, Object> test = new HashMap<String, Object>() {{
+            put("size", "whatever");
+
+            put("index", 0);
+            put("value", 1.0);
+        }};
+
+        assertEquals("Expect exception due to invalid param type.", IMPOSSIBLE_SIZE,
+            new SingleElementVector(test).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void mapNullTest() {
+        //noinspection ConstantConditions
+        assertEquals("Null map args.", IMPOSSIBLE_SIZE,
+            new SingleElementVector(null).size());
+    }
+
+    /** */
+    @Test
+    public void mapTest() {
+        assertEquals("Size from array in args.", 99,
+            new SingleElementVector(new HashMap<String, Object>() {{
+                put("size", 99);
+                put("index", 0);
+                put("value", 1.0);
+            }}).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void negativeSizeTest() {
+        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
+            new SingleElementVector(-1, 0, 1.0).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void zeroSizeTest() {
+        assertEquals("Zero size.", IMPOSSIBLE_SIZE,
+            new SingleElementVector(0, 0, 1.0).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void wrongIndexTest() {
+        //noinspection ConstantConditions
+        assertEquals("Wrong index.", IMPOSSIBLE_SIZE,
+            new SingleElementVector(1, 2, 1.0).size());
+    }
+
+    /** */
+    @Test
+    public void basicTest() {
+        final int[] sizes = new int[] {1, 4, 8};
+
+        for (int size : sizes)
+            for (int idx = 0; idx < size; idx++)
+                basicTest(size, idx);
+    }
+
+    /** */
+    private void basicTest(int size, int idx) {
+        final Double expVal = (double)(size - idx);
+
+        Vector v = new SingleElementVector(size, idx, expVal);
+
+        assertTrue("Expect value " + expVal + " at index " + idx + " for size " + size,
+            expVal.equals(v.get(idx)));
+
+        final double delta = 1.0;
+
+        v.set(idx, expVal - delta);
+
+        assertTrue("Expect value " + expVal + " at index " + idx + " for size " + size,
+            expVal.equals(v.get(idx) + delta));
+
+        final Double zero = 0.0;
+
+        for (int i = 0; i < size; i++) {
+            if (i == idx)
+                continue;
+
+            assertTrue("Expect zero at index " + i + " for size " + size,
+                zero.equals(v.get(i)));
+
+            boolean eCaught = false;
+
+            try {
+                v.set(i, 1.0);
+            }
+            catch (UnsupportedOperationException uoe) {
+                eCaught = true;
+            }
+
+            assertTrue("Expect " + java.lang.UnsupportedOperationException.class.getSimpleName()
+                + " at index " + i + " for size " + size, eCaught);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SingleElementVectorViewConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SingleElementVectorViewConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SingleElementVectorViewConstructorTest.java
new file mode 100644
index 0000000..a693319
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SingleElementVectorViewConstructorTest.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class SingleElementVectorViewConstructorTest {
+    /** */
+    private static final int IMPOSSIBLE_SIZE = -1;
+
+    /** */
+    private static final SampleHelper helper = new SampleHelper();
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void nullVecParamTest() {
+        assertEquals("Expect exception due to null vector param.", IMPOSSIBLE_SIZE,
+            new SingleElementVectorView(null, helper.idx).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void negativeIdxParamTest() {
+        assertEquals("Expect exception due to negative index param.", IMPOSSIBLE_SIZE,
+            new SingleElementVectorView(helper.vec, -1).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void tooLargeIdxParamTest() {
+        assertEquals("Expect exception due to too large index param.", IMPOSSIBLE_SIZE,
+            new SingleElementVectorView(helper.vec, helper.vec.size()).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void emptyVecParamTest() {
+        assertEquals("Expect exception due to empty vector param.", IMPOSSIBLE_SIZE,
+            new SingleElementVectorView(helper.vecEmpty, 0).size());
+    }
+
+    /** */
+    @Test
+    public void basicTest() {
+        final int[] sizes = new int[] {1, 4, 8};
+
+        for (int size : sizes)
+            for (int idx = 0; idx < size; idx++)
+                basicTest(size, idx);
+    }
+
+    /** */
+    private void basicTest(int size, int idx) {
+        final Double expVal = (double)(size - idx);
+
+        Vector orig = helper.newSample(size, idx, expVal);
+
+        SingleElementVectorView svv = new SingleElementVectorView(orig, idx);
+
+        assertEquals("Size differs from expected", size, svv.size());
+
+        assertTrue("Expect value " + expVal + " at index " + idx + " for size " + size,
+            expVal.equals(svv.get(idx)));
+
+        final double delta = 1.0;
+
+        svv.set(idx, expVal - delta);
+
+        assertTrue("Expect value " + expVal + " at index " + idx + " for size " + size,
+            expVal.equals(orig.get(idx) + delta));
+
+        final Double zero = 0.0;
+
+        for (int i = 0; i < size; i++) {
+            if (i == idx)
+                continue;
+
+            assertTrue("Expect zero at index " + i + " for size " + size,
+                zero.equals(svv.get(i)));
+
+            boolean eCaught = false;
+
+            try {
+                svv.set(i, 1.0);
+            }
+            catch (UnsupportedOperationException uoe) {
+                eCaught = true;
+            }
+
+            assertTrue("Expect " + UnsupportedOperationException.class.getSimpleName()
+                + " at index " + i + " for size " + size, eCaught);
+        }
+    }
+
+    /** */
+    private static class SampleHelper {
+        /** */
+        final double[] data = new double[] {0, 1};
+        /** */
+        final Vector vec = new DenseLocalOnHeapVector(data);
+        /** */
+        final Vector vecEmpty = new DenseLocalOnHeapVector(new double[] {});
+        /** */
+        final int idx = 0;
+
+        /** */
+        Vector newSample(int size, int idx, double expVal) {
+            final Vector v = new DenseLocalOnHeapVector(size);
+
+            for (int i = 0; i < size; i++)
+                v.set(i, i == idx ? expVal : i);
+
+            return v;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SparseLocalVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SparseLocalVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SparseLocalVectorConstructorTest.java
new file mode 100644
index 0000000..912168e
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/SparseLocalVectorConstructorTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import org.apache.ignite.ml.math.StorageConstants;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/** */
+public class SparseLocalVectorConstructorTest {
+    /** */
+    private static final int IMPOSSIBLE_SIZE = -1;
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void negativeSizeTest() {
+        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
+            new SparseLocalVector(-1, 1).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void zeroSizeTest() {
+        assertEquals("0 size.", IMPOSSIBLE_SIZE,
+            new SparseLocalVector(0, 1).size());
+    }
+
+    /** */
+    @Test
+    public void primitiveTest() {
+        assertEquals("1 size, random access.", 1,
+            new SparseLocalVector(1, StorageConstants.RANDOM_ACCESS_MODE).size());
+
+        assertEquals("1 size, sequential access.", 1,
+            new SparseLocalVector(1, StorageConstants.SEQUENTIAL_ACCESS_MODE).size());
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorAttributesTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorAttributesTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorAttributesTest.java
new file mode 100644
index 0000000..e2f6a40
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorAttributesTest.java
@@ -0,0 +1,217 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOffHeapMatrix;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/** */
+public class VectorAttributesTest {
+    /** */
+    private final List<AttrCfg> attrCfgs = Arrays.asList(
+        new AttrCfg("isDense", Vector::isDense,
+            DenseLocalOnHeapVector.class, DenseLocalOffHeapVector.class, RandomVector.class, ConstantVector.class,
+            SingleElementVector.class),
+        new AttrCfg("isArrayBased", Vector::isArrayBased,
+            DenseLocalOnHeapVector.class),
+        new AttrCfg("isSequentialAccess", Vector::isSequentialAccess,
+            DenseLocalOnHeapVector.class, DenseLocalOffHeapVector.class, SparseLocalVectorSequentialAccess.class,
+            RandomVector.class, ConstantVector.class, SingleElementVector.class),
+        new AttrCfg("guidNotNull", v -> v.guid() == null), // IMPL NOTE this is somewhat artificial
+        new AttrCfg("isRandomAccess", Vector::isRandomAccess,
+            DenseLocalOnHeapVector.class, DenseLocalOffHeapVector.class, RandomVector.class, ConstantVector.class,
+            SingleElementVector.class, SparseLocalVectorSequentialAccess.class, SparseLocalVectorRandomAccess.class),
+        new AttrCfg("isDistributed", Vector::isDistributed));
+
+    /** */
+    private final List<Specification> specFixture = Arrays.asList(
+        new Specification(new DenseLocalOnHeapVector(1)),
+        new Specification(new DenseLocalOffHeapVector(1)),
+        new Specification(new DelegatingVector(new DenseLocalOnHeapVector(1)),
+            DenseLocalOnHeapVector.class, "isDense", "isArrayBased", "isSequentialAccess",
+            "isRandomAccess", "isDistributed"),
+        new Specification(new DelegatingVector(new DenseLocalOffHeapVector(1)),
+            DenseLocalOffHeapVector.class, "isDense", "isArrayBased", "isSequentialAccess",
+            "isRandomAccess", "isDistributed"),
+        new Specification(new SparseLocalVectorSequentialAccess(1)),
+        new Specification(new SparseLocalVectorRandomAccess(1)),
+        new Specification(new RandomVector(1)),
+        new Specification(new ConstantVector(1, 1.0)),
+        new Specification(new FunctionVector(1, idx -> (double)idx)),
+        new Specification(new SingleElementVector(1, 0, 1.0)),
+        new Specification(new PivotedVectorView(new DenseLocalOnHeapVector(1), new int[] {0}),
+            DenseLocalOnHeapVector.class, "isDense", "isArrayBased", "isSequentialAccess",
+            "isRandomAccess", "isDistributed"),
+        new Specification(new PivotedVectorView(new DenseLocalOffHeapVector(1), new int[] {0}),
+            DenseLocalOffHeapVector.class, "isDense", "isArrayBased", "isSequentialAccess",
+            "isRandomAccess", "isDistributed"),
+        new Specification(new SingleElementVectorView(new DenseLocalOnHeapVector(1), 0),
+            DenseLocalOnHeapVector.class, "isDense", "isSequentialAccess",
+            "isRandomAccess", "isDistributed"),
+        new Specification(new SingleElementVectorView(new DenseLocalOffHeapVector(1), 0),
+            DenseLocalOffHeapVector.class, "isDense", "isSequentialAccess",
+            "isRandomAccess", "isDistributed"),
+        new Specification(new MatrixVectorView(new DenseLocalOnHeapMatrix(1, 1), 0, 0, 1, 1),
+            DenseLocalOnHeapVector.class, "isDense",
+            "isRandomAccess", "isDistributed"), // todo find out why "isSequentialAccess" fails here
+        new Specification(new MatrixVectorView(new DenseLocalOffHeapMatrix(1, 1), 0, 0, 1, 1),
+            DenseLocalOffHeapVector.class, "isDense",
+            "isRandomAccess", "isDistributed"));
+
+    /** */
+    @Test
+    public void isDenseTest() {
+        assertAttribute("isDense");
+    }
+
+    /** */
+    @Test
+    public void isArrayBasedTest() {
+        assertAttribute("isArrayBased");
+    }
+
+    /** */
+    @Test
+    public void isSequentialAccessTest() {
+        assertAttribute("isSequentialAccess");
+    }
+
+    /** */
+    @Test
+    public void guidTest() {
+        assertAttribute("guidNotNull");
+    }
+
+    /** */
+    @Test
+    public void isRandomAccessTest() {
+        assertAttribute("isRandomAccess");
+    }
+
+    /** */
+    @Test
+    public void isDistributedTest() {
+        assertAttribute("isDistributed");
+    }
+
+    /** */
+    private void assertAttribute(String name) {
+        final AttrCfg attr = attrCfg(name);
+
+        for (Specification spec : specFixture)
+            spec.verify(attr);
+    }
+
+    /** */
+    private AttrCfg attrCfg(String name) {
+        for (AttrCfg attr : attrCfgs)
+            if (attr.name.equals(name))
+                return attr;
+
+        throw new IllegalArgumentException("Undefined attribute " + name);
+    }
+
+    /** See http://en.wikipedia.org/wiki/Specification_pattern */
+    private static class Specification {
+        /** */
+        private final Vector v;
+        /** */
+        private final Class<? extends Vector> underlyingType;
+        /** */
+        private final List<String> attrsFromUnderlying;
+        /** */
+        final String desc;
+
+        /** */
+        Specification(Vector v, Class<? extends Vector> underlyingType, String... attrsFromUnderlying) {
+            this.v = v;
+            this.underlyingType = underlyingType;
+            this.attrsFromUnderlying = Arrays.asList(attrsFromUnderlying);
+            final Class<? extends Vector> clazz = v.getClass();
+            desc = clazz.getSimpleName() + (clazz.equals(underlyingType)
+                ? "" : " (underlying type " + underlyingType.getSimpleName() + ")");
+        }
+
+        /** */
+        Specification(Vector v) {
+            this(v, v.getClass());
+        }
+
+        /** */
+        void verify(AttrCfg attr) {
+            final boolean obtained = attr.obtain.apply(v);
+
+            final Class<? extends Vector> typeToCheck
+                = attrsFromUnderlying.contains(attr.name) ? underlyingType : v.getClass();
+
+            final boolean exp = attr.trueInTypes.contains(typeToCheck);
+
+            assertEquals("Unexpected " + attr.name + " value for " + desc, exp, obtained);
+        }
+    }
+
+    /** */
+    private static class AttrCfg {
+        /** */
+        final String name;
+        /** */
+        final Function<Vector, Boolean> obtain;
+        /** */
+        final List<Class> trueInTypes;
+
+        /** */
+        AttrCfg(String name, Function<Vector, Boolean> obtain, Class... trueInTypes) {
+            this.name = name;
+            this.obtain = obtain;
+            this.trueInTypes = Arrays.asList(trueInTypes);
+        }
+    }
+
+    /** */
+    private static class SparseLocalVectorSequentialAccess extends SparseLocalVector {
+        /** */
+        public SparseLocalVectorSequentialAccess() {
+            // No-op.
+        }
+
+        /** */
+        SparseLocalVectorSequentialAccess(int size) {
+            super(size, SEQUENTIAL_ACCESS_MODE);
+        }
+    }
+
+    /** */
+    private static class SparseLocalVectorRandomAccess extends SparseLocalVector {
+        /** */
+        public SparseLocalVectorRandomAccess() {
+            // No-op.
+        }
+
+        /** */
+        SparseLocalVectorRandomAccess(int size) {
+            super(size, RANDOM_ACCESS_MODE);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorFoldMapTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorFoldMapTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorFoldMapTest.java
new file mode 100644
index 0000000..676bb17
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorFoldMapTest.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.Arrays;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.functions.Functions;
+import org.junit.Test;
+
+import static java.util.function.DoubleUnaryOperator.identity;
+import static org.junit.Assert.assertTrue;
+
+/** See also: {@link AbstractVectorTest} and {@link VectorToMatrixTest}. */
+public class VectorFoldMapTest {
+    /** */
+    @Test
+    public void mapVectorTest() {
+        operationVectorTest((operand1, operand2) -> operand1 + operand2, (Vector v1, Vector v2) -> v1.map(v2, Functions.PLUS));
+    }
+
+    /** */
+    @Test
+    public void mapDoubleFunctionTest() {
+        consumeSampleVectors((v, desc) -> operatorTest(v, desc,
+            (vec) -> vec.map(Functions.INV), (val) -> 1.0 / val));
+    }
+
+    /** */
+    @Test
+    public void mapBiFunctionTest() {
+        consumeSampleVectors((v, desc) -> operatorTest(v, desc,
+            (vec) -> vec.map(Functions.PLUS, 1.0), (val) -> 1.0 + val));
+    }
+
+    /** */
+    @Test
+    public void foldMapTest() {
+        toDoubleTest(
+            ref -> Arrays.stream(ref).map(identity()).sum(),
+            (v) -> v.foldMap(Functions.PLUS, Functions.IDENTITY, 0.0));
+    }
+
+    /** */
+    @Test
+    public void foldMapVectorTest() {
+        toDoubleTest(
+            ref -> 2.0 * Arrays.stream(ref).sum(),
+            (v) -> v.foldMap(v, Functions.PLUS, Functions.PLUS, 0.0));
+
+    }
+
+    /** */
+    private void operatorTest(Vector v, String desc, Function<Vector, Vector> op, Function<Double, Double> refOp) {
+        final int size = v.size();
+        final double[] ref = new double[size];
+
+        VectorImplementationsTest.ElementsChecker checker = new VectorImplementationsTest.ElementsChecker(v, ref, desc);
+
+        Vector actual = op.apply(v);
+
+        for (int idx = 0; idx < size; idx++)
+            ref[idx] = refOp.apply(ref[idx]);
+
+        checker.assertCloseEnough(actual, ref);
+    }
+
+    /** */
+    private void toDoubleTest(Function<double[], Double> calcRef, Function<Vector, Double> calcVec) {
+        consumeSampleVectors((v, desc) -> {
+            final int size = v.size();
+            final double[] ref = new double[size];
+
+            new VectorImplementationsTest.ElementsChecker(v, ref, desc); // IMPL NOTE this initialises vector and reference array
+
+            final VectorImplementationsTest.Metric metric = new VectorImplementationsTest.Metric(calcRef.apply(ref), calcVec.apply(v));
+
+            assertTrue("Not close enough at " + desc
+                + ", " + metric, metric.closeEnough());
+        });
+    }
+
+    /** */
+    private void operationVectorTest(BiFunction<Double, Double, Double> operation,
+        BiFunction<Vector, Vector, Vector> vecOperation) {
+        consumeSampleVectors((v, desc) -> {
+            // TODO find out if more elaborate testing scenario is needed or it's okay as is.
+            final int size = v.size();
+            final double[] ref = new double[size];
+
+            final VectorImplementationsTest.ElementsChecker checker = new VectorImplementationsTest.ElementsChecker(v, ref, desc);
+            final Vector operand = v.copy();
+
+            for (int idx = 0; idx < size; idx++)
+                ref[idx] = operation.apply(ref[idx], ref[idx]);
+
+            checker.assertCloseEnough(vecOperation.apply(v, operand), ref);
+        });
+    }
+
+    /** */
+    private void consumeSampleVectors(BiConsumer<Vector, String> consumer) {
+        new VectorImplementationsFixtures().consumeSampleVectors(null, consumer);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsFixtures.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsFixtures.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsFixtures.java
new file mode 100644
index 0000000..be3bb22
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsFixtures.java
@@ -0,0 +1,655 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.impls.storage.vector.FunctionVectorStorage;
+import org.jetbrains.annotations.NotNull;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/** */
+class VectorImplementationsFixtures {
+    /** */
+    private static final List<Supplier<Iterable<Vector>>> suppliers = Arrays.asList(
+        (Supplier<Iterable<Vector>>)DenseLocalOnHeapVectorFixture::new,
+        (Supplier<Iterable<Vector>>)DenseLocalOffHeapVectorFixture::new,
+        (Supplier<Iterable<Vector>>)SparseLocalVectorFixture::new,
+        (Supplier<Iterable<Vector>>)RandomVectorFixture::new,
+        (Supplier<Iterable<Vector>>)ConstantVectorFixture::new,
+        (Supplier<Iterable<Vector>>)DelegatingVectorFixture::new,
+        (Supplier<Iterable<Vector>>)FunctionVectorFixture::new,
+        (Supplier<Iterable<Vector>>)SingleElementVectorFixture::new,
+        (Supplier<Iterable<Vector>>)PivotedVectorViewFixture::new,
+        (Supplier<Iterable<Vector>>)SingleElementVectorViewFixture::new,
+        (Supplier<Iterable<Vector>>)MatrixVectorViewFixture::new,
+        (Supplier<Iterable<Vector>>)SparseLocalOffHeapVectorFixture::new
+    );
+
+    /** */
+    void consumeSampleVectors(Consumer<Integer> paramsConsumer, BiConsumer<Vector, String> consumer) {
+        for (Supplier<Iterable<Vector>> fixtureSupplier : VectorImplementationsFixtures.suppliers) {
+            final Iterable<Vector> fixture = fixtureSupplier.get();
+
+            for (Vector v : fixture) {
+                if (paramsConsumer != null)
+                    paramsConsumer.accept(v.size());
+
+                consumer.accept(v, fixture.toString());
+            }
+        }
+    }
+
+    /** */
+    void selfTest() {
+        new VectorSizesExtraIterator<>("VectorSizesExtraIterator test",
+            (size, shallowCp) -> new DenseLocalOnHeapVector(new double[size], shallowCp),
+            null, "shallow copy", new Boolean[] {false, true, null}).selfTest();
+
+        new VectorSizesIterator("VectorSizesIterator test", DenseLocalOffHeapVector::new, null).selfTest();
+    }
+
+    /** */
+    private static class DenseLocalOnHeapVectorFixture extends VectorSizesExtraFixture<Boolean> {
+        /** */
+        DenseLocalOnHeapVectorFixture() {
+            super("DenseLocalOnHeapVector",
+                (size, shallowCp) -> new DenseLocalOnHeapVector(new double[size], shallowCp),
+                "shallow copy", new Boolean[] {false, true, null});
+        }
+    }
+
+    /** */
+    private static class DenseLocalOffHeapVectorFixture extends VectorSizesFixture {
+        /** */
+        DenseLocalOffHeapVectorFixture() {
+            super("DenseLocalOffHeapVector", DenseLocalOffHeapVector::new);
+        }
+    }
+
+    /** */
+    private static class SparseLocalVectorFixture extends VectorSizesExtraFixture<Integer> {
+        /** */
+        SparseLocalVectorFixture() {
+            super("SparseLocalVector", SparseLocalVector::new, "access mode",
+                new Integer[] {StorageConstants.SEQUENTIAL_ACCESS_MODE, StorageConstants.RANDOM_ACCESS_MODE, null});
+        }
+    }
+
+    /** */
+    private static class RandomVectorFixture extends VectorSizesFixture {
+        /** */
+        RandomVectorFixture() {
+            super("RandomVector", RandomVector::new);
+        }
+    }
+
+    /** */
+    private static class ConstantVectorFixture extends VectorSizesExtraFixture<Double> {
+        /** */
+        ConstantVectorFixture() {
+            super("ConstantVector", ConstantVector::new,
+                "value", new Double[] {-1.0, 0.0, 0.5, 1.0, 2.0, null});
+        }
+    }
+
+    /** */
+    private static class FunctionVectorFixture extends VectorSizesExtraFixture<Double> {
+        /** */
+        FunctionVectorFixture() {
+            super("FunctionVector",
+                (size, scale) -> new FunctionVectorForTest(new double[size], scale),
+                "scale", new Double[] {0.5, 1.0, 2.0, null});
+        }
+    }
+
+    /** */
+    private static class SingleElementVectorFixture implements Iterable<Vector> {
+        /** */
+        private final Supplier<TwoParamsIterator<Integer, Double>> iter;
+
+        /** */
+        private final AtomicReference<String> ctxDescrHolder = new AtomicReference<>("Iterator not started.");
+
+        /** */
+        SingleElementVectorFixture() {
+            iter = () -> new TwoParamsIterator<Integer, Double>("SingleElementVector",
+                null, ctxDescrHolder::set,
+                "size", new Integer[] {1, null},
+                "value", new Double[] {-1.0, 0.0, 0.5, 1.0, 2.0, null}) {
+
+                /** {@inheritDoc} */
+                @Override BiFunction<Integer, Double, Vector> ctor() {
+                    return (size, value) -> new SingleElementVector(size, 0, value);
+                }
+            };
+        }
+
+        /** {@inheritDoc} */
+        @NotNull
+        @Override public Iterator<Vector> iterator() {
+            return iter.get();//(
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
+            return ctxDescrHolder.get();
+        }
+    }
+
+    /** */
+    private static class PivotedVectorViewFixture extends VectorSizesFixture {
+        /** */
+        PivotedVectorViewFixture() {
+            super("PivotedVectorView", PivotedVectorViewFixture::pivotedVectorView);
+        }
+
+        /** */
+        private static PivotedVectorView pivotedVectorView(int size) {
+            final DenseLocalOnHeapVector vec = new DenseLocalOnHeapVector(size);
+
+            final int[] pivot = new int[size];
+
+            for (int idx = 0; idx < size; idx++)
+                pivot[idx] = size - 1 - idx;
+
+            PivotedVectorView tmp = new PivotedVectorView(vec, pivot);
+
+            final int[] unpivot = new int[size];
+
+            for (int idx = 0; idx < size; idx++)
+                unpivot[idx] = tmp.unpivot(idx);
+
+            final int[] idxRecovery = new int[size];
+
+            for (int idx = 0; idx < size; idx++)
+                idxRecovery[idx] = idx;
+
+            return new PivotedVectorView(new PivotedVectorView(tmp, unpivot), idxRecovery);
+        }
+    }
+
+    /** */
+    private static class SingleElementVectorViewFixture implements Iterable<Vector> {
+        /** */
+        private final Supplier<TwoParamsIterator<Integer, Double>> iter;
+
+        /** */
+        private final AtomicReference<String> ctxDescrHolder = new AtomicReference<>("Iterator not started.");
+
+        /** */
+        SingleElementVectorViewFixture() {
+            iter = () -> new TwoParamsIterator<Integer, Double>("SingleElementVectorView",
+                null, ctxDescrHolder::set,
+                "size", new Integer[] {1, null},
+                "value", new Double[] {-1.0, 0.0, 0.5, 1.0, 2.0, null}) {
+
+                /** {@inheritDoc} */
+                @Override BiFunction<Integer, Double, Vector> ctor() {
+                    return (size, value) -> new SingleElementVectorView(new SingleElementVector(size, 0, value), 0);
+                }
+            };
+        }
+
+        /** {@inheritDoc} */
+        @NotNull
+        @Override public Iterator<Vector> iterator() {
+            return iter.get();
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
+            return ctxDescrHolder.get();
+        }
+    }
+
+    /** */
+    private static class MatrixVectorViewFixture extends VectorSizesExtraFixture<Integer> {
+        /** */
+        MatrixVectorViewFixture() {
+            super("MatrixVectorView",
+                MatrixVectorViewFixture::newView,
+                "stride kind", new Integer[] {0, 1, 2, null});
+        }
+
+        /** */
+        private static Vector newView(int size, int strideKind) {
+            final Matrix parent = new DenseLocalOnHeapMatrix(size, size);
+
+            return new MatrixVectorView(parent, 0, 0, strideKind != 1 ? 1 : 0, strideKind != 0 ? 1 : 0);
+        }
+    }
+
+    /** */
+    private static class VectorSizesExtraFixture<T> implements Iterable<Vector> {
+        /** */
+        private final Supplier<VectorSizesExtraIterator<T>> iter;
+
+        /** */
+        private final AtomicReference<String> ctxDescrHolder = new AtomicReference<>("Iterator not started.");
+
+        /** */
+        VectorSizesExtraFixture(String vectorKind, BiFunction<Integer, T, Vector> ctor, String extraParamName,
+            T[] extras) {
+            iter = () -> new VectorSizesExtraIterator<>(vectorKind, ctor, ctxDescrHolder::set, extraParamName, extras);
+        }
+
+        /** {@inheritDoc} */
+        @NotNull
+        @Override public Iterator<Vector> iterator() {
+            return iter.get();
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
+            return ctxDescrHolder.get();
+        }
+    }
+
+    /** */
+    private static abstract class VectorSizesFixture implements Iterable<Vector> {
+        /** */
+        private final Supplier<VectorSizesIterator> iter;
+
+        /** */
+        private final AtomicReference<String> ctxDescrHolder = new AtomicReference<>("Iterator not started.");
+
+        /** */
+        VectorSizesFixture(String vectorKind, Function<Integer, Vector> ctor) {
+            iter = () -> new VectorSizesIterator(vectorKind, ctor, ctxDescrHolder::set);
+        }
+
+        /** {@inheritDoc} */
+        @NotNull
+        @Override public Iterator<Vector> iterator() {
+            return iter.get();
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
+            return ctxDescrHolder.get();
+        }
+    }
+
+    /** */
+    private static class VectorSizesExtraIterator<T> extends VectorSizesIterator {
+        /** */
+        private final T[] extras;
+        /** */
+        private int extraIdx = 0;
+        /** */
+        private final BiFunction<Integer, T, Vector> ctor;
+        /** */
+        private final String extraParamName;
+
+        /**
+         * @param vectorKind Descriptive name to use for context logging.
+         * @param ctor Constructor for objects to iterate over.
+         * @param ctxDescrConsumer Context logging consumer.
+         * @param extraParamName Name of extra parameter to iterate over.
+         * @param extras Array of extra parameter values to iterate over.
+         */
+        VectorSizesExtraIterator(String vectorKind, BiFunction<Integer, T, Vector> ctor,
+            Consumer<String> ctxDescrConsumer, String extraParamName, T[] extras) {
+            super(vectorKind, null, ctxDescrConsumer);
+
+            this.ctor = ctor;
+            this.extraParamName = extraParamName;
+            this.extras = extras;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean hasNext() {
+            return super.hasNext() && hasNextExtra(extraIdx);
+        }
+
+        /** {@inheritDoc} */
+        @Override void nextIdx() {
+            assert extras[extraIdx] != null
+                : "Index(es) out of bound at " + VectorSizesExtraIterator.this;
+
+            if (hasNextExtra(extraIdx + 1)) {
+                extraIdx++;
+
+                return;
+            }
+
+            extraIdx = 0;
+
+            super.nextIdx();
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
+            return "{" + super.toString() +
+                ", " + extraParamName + "=" + extras[extraIdx] +
+                '}';
+        }
+
+        /** {@inheritDoc} */
+        @Override BiFunction<Integer, Integer, Vector> ctor() {
+            return (size, delta) -> ctor.apply(size + delta, extras[extraIdx]);
+        }
+
+        /** */
+        void selfTest() {
+            final Set<Integer> extraIdxs = new HashSet<>();
+
+            int cnt = 0;
+
+            while (hasNext()) {
+                assertNotNull("Expect not null vector at " + this, next());
+
+                if (extras[extraIdx] != null)
+                    extraIdxs.add(extraIdx);
+
+                cnt++;
+            }
+
+            assertEquals("Extra param tested", extraIdxs.size(), extras.length - 1);
+
+            assertEquals("Combinations tested mismatch.",
+                7 * 3 * (extras.length - 1), cnt);
+        }
+
+        /** */
+        private boolean hasNextExtra(int idx) {
+            return extras[idx] != null;
+        }
+    }
+
+    /** */
+    private static class VectorSizesIterator extends TwoParamsIterator<Integer, Integer> {
+        /** */
+        private final Function<Integer, Vector> ctor;
+
+        /** */
+        VectorSizesIterator(String vectorKind, Function<Integer, Vector> ctor, Consumer<String> ctxDescrConsumer) {
+            super(vectorKind, null, ctxDescrConsumer,
+                "size", new Integer[] {2, 4, 8, 16, 32, 64, 128, null},
+                "size delta", new Integer[] {-1, 0, 1, null});
+
+            this.ctor = ctor;
+        }
+
+        /** {@inheritDoc} */
+        @Override BiFunction<Integer, Integer, Vector> ctor() {
+            return (size, delta) -> ctor.apply(size + delta);
+        }
+    }
+
+    /** */
+    private static class TwoParamsIterator<T, U> implements Iterator<Vector> {
+        /** */
+        private final T params1[];
+
+        /** */
+        private final U params2[];
+
+        /** */
+        private final String vectorKind;
+
+        /** */
+        private final String param1Name;
+
+        /** */
+        private final String param2Name;
+
+        /** */
+        private final BiFunction<T, U, Vector> ctor;
+
+        /** */
+        private final Consumer<String> ctxDescrConsumer;
+
+        /** */
+        private int param1Idx = 0;
+
+        /** */
+        private int param2Idx = 0;
+
+        /** */
+        TwoParamsIterator(String vectorKind, BiFunction<T, U, Vector> ctor,
+            Consumer<String> ctxDescrConsumer, String param1Name, T[] params1, String param2Name, U[] params2) {
+            this.param1Name = param1Name;
+            this.params1 = params1;
+
+            this.param2Name = param2Name;
+            this.params2 = params2;
+
+            this.vectorKind = vectorKind;
+
+            this.ctor = ctor;
+
+            this.ctxDescrConsumer = ctxDescrConsumer;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean hasNext() {
+            return hasNextParam1(param1Idx) && hasNextParam2(param2Idx);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Vector next() {
+            if (!hasNext())
+                throw new NoSuchElementException(TwoParamsIterator.this.toString());
+
+            if (ctxDescrConsumer != null)
+                ctxDescrConsumer.accept(toString());
+
+            Vector res = ctor().apply(params1[param1Idx], params2[param2Idx]);
+
+            nextIdx();
+
+            return res;
+        }
+
+        /** */
+        void selfTest() {
+            final Set<Integer> sizeIdxs = new HashSet<>(), deltaIdxs = new HashSet<>();
+
+            int cnt = 0;
+
+            while (hasNext()) {
+                assertNotNull("Expect not null vector at " + this, next());
+
+                if (params1[param1Idx] != null)
+                    sizeIdxs.add(param1Idx);
+
+                if (params2[param2Idx] != null)
+                    deltaIdxs.add(param2Idx);
+
+                cnt++;
+            }
+
+            assertEquals("Sizes tested mismatch.", sizeIdxs.size(), params1.length - 1);
+
+            assertEquals("Deltas tested", deltaIdxs.size(), params2.length - 1);
+
+            assertEquals("Combinations tested mismatch.",
+                (params1.length - 1) * (params2.length - 1), cnt);
+        }
+
+        /** IMPL NOTE override in subclasses if needed */
+        void nextIdx() {
+            assert params1[param1Idx] != null && params2[param2Idx] != null
+                : "Index(es) out of bound at " + TwoParamsIterator.this;
+
+            if (hasNextParam2(param2Idx + 1)) {
+                param2Idx++;
+
+                return;
+            }
+
+            param2Idx = 0;
+
+            param1Idx++;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
+            return vectorKind + "{" + param1Name + "=" + params1[param1Idx] +
+                ", " + param2Name + "=" + params2[param2Idx] +
+                '}';
+        }
+
+        /** IMPL NOTE override in subclasses if needed */
+        BiFunction<T, U, Vector> ctor() {
+            return ctor;
+        }
+
+        /** */
+        private boolean hasNextParam1(int idx) {
+            return params1[idx] != null;
+        }
+
+        /** */
+        private boolean hasNextParam2(int idx) {
+            return params2[idx] != null;
+        }
+    }
+
+    /** Delegating vector with dense local onheap vector */
+    private static class DelegatingVectorFixture implements Iterable<Vector> {
+
+        /** */
+        private final Supplier<VectorSizesExtraIterator<Boolean>> iter;
+
+        /** */
+        private final AtomicReference<String> ctxDescrHolder = new AtomicReference<>("Iterator not started.");
+
+        /** */
+        DelegatingVectorFixture() {
+            iter = () -> new VectorSizesExtraIterator<>("DelegatingVector with DenseLocalOnHeapVector",
+                (size, shallowCp) -> new DelegatingVector(new DenseLocalOnHeapVector(new double[size], shallowCp)),
+                ctxDescrHolder::set, "shallow copy", new Boolean[] {false, true, null});
+        }
+
+        /** {@inheritDoc} */
+        @NotNull
+        @Override public Iterator<Vector> iterator() {
+            return iter.get();
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            // IMPL NOTE index within bounds is expected to be guaranteed by proper code in this class
+            return ctxDescrHolder.get();
+        }
+    }
+
+    /** Subclass tweaked for serialization */
+    private static class FunctionVectorForTest extends FunctionVector {
+        /** */
+        double[] arr;
+
+        /** */
+        double scale;
+
+        /** */
+        public FunctionVectorForTest() {
+            // No-op.
+        }
+
+        /** */
+        FunctionVectorForTest(double[] arr, double scale) {
+            super(arr.length, idx -> arr[idx] * scale, (idx, value) -> arr[idx] = value / scale);
+
+            this.arr = arr;
+
+            this.scale = scale;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+            super.writeExternal(out);
+
+            out.writeObject(arr);
+
+            out.writeDouble(scale);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            super.readExternal(in);
+
+            arr = (double[])in.readObject();
+
+            scale = in.readDouble();
+
+            setStorage(new FunctionVectorStorage(arr.length, idx -> arr[idx] * scale, (idx, value) -> arr[idx] = value / scale));
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            int res = 1;
+
+            res = res * 37 + Double.hashCode(scale);
+            res = res * 37 + Integer.hashCode(getStorage().size());
+
+            return res;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            FunctionVectorForTest that = (FunctionVectorForTest)o;
+
+            return new Double(scale).equals(that.scale)
+                && (arr != null ? Arrays.equals(arr, that.arr) : that.arr == null);
+        }
+    }
+
+    /** */
+    private static class SparseLocalOffHeapVectorFixture extends VectorSizesFixture {
+
+        /** */
+        SparseLocalOffHeapVectorFixture() {
+            super("SparseLocalOffHeapVector", SparseLocalOffHeapVector::new);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsTest.java
new file mode 100644
index 0000000..48dcc36
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/VectorImplementationsTest.java
@@ -0,0 +1,861 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.ml.math.ExternalizeTest;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.CardinalityException;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/** See also: {@link AbstractVectorTest} and {@link VectorToMatrixTest}. */
+public class VectorImplementationsTest { // todo split this to smaller cohesive test classes
+    /** */
+    @Test
+    public void vectorImplementationsFixturesTest() {
+        new VectorImplementationsFixtures().selfTest();
+    }
+
+    /** */
+    @Test
+    public void setGetTest() {
+        consumeSampleVectors((v, desc) -> mutateAtIdxTest(v, desc, (vec, idx, val) -> {
+            vec.set(idx, val);
+
+            return val;
+        }));
+    }
+
+    /** */
+    @Test
+    public void setXTest() {
+        consumeSampleVectors((v, desc) -> mutateAtIdxTest(v, desc, (vec, idx, val) -> {
+            vec.setX(idx, val);
+
+            return val;
+        }));
+    }
+
+    /** */
+    @Test
+    public void incrementTest() {
+        consumeSampleVectors((v, desc) -> mutateAtIdxTest(v, desc, (vec, idx, val) -> {
+            double old = vec.get(idx);
+
+            vec.increment(idx, val);
+
+            return old + val;
+        }));
+    }
+
+    /** */
+    @Test
+    public void incrementXTest() {
+        consumeSampleVectors((v, desc) -> mutateAtIdxTest(v, desc, (vec, idx, val) -> {
+            double old = vec.getX(idx);
+
+            vec.incrementX(idx, val);
+
+            return old + val;
+        }));
+    }
+
+    /** */
+    @Test
+    public void operateXOutOfBoundsTest() {
+        consumeSampleVectors((v, desc) -> {
+            if (v instanceof DenseLocalOffHeapVector || v instanceof SparseLocalVector || v instanceof SparseLocalOffHeapVector)
+                return; // todo find out if it's OK to skip by instances here
+
+            boolean expECaught = false;
+
+            try {
+                v.getX(-1);
+            }
+            catch (ArrayIndexOutOfBoundsException | IgniteException e) {
+                expECaught = true;
+            }
+
+            if (!getXOutOfBoundsOK(v))
+                assertTrue("Expect exception at negative index getX in " + desc, expECaught);
+
+            expECaught = false;
+
+            try {
+                v.setX(-1, 0);
+            }
+            catch (ArrayIndexOutOfBoundsException | IgniteException e) {
+                expECaught = true;
+            }
+
+            assertTrue("Expect exception at negative index setX in " + desc, expECaught);
+
+            expECaught = false;
+
+            try {
+                v.incrementX(-1, 1);
+            }
+            catch (ArrayIndexOutOfBoundsException | IgniteException e) {
+                expECaught = true;
+            }
+
+            assertTrue("Expect exception at negative index incrementX in " + desc, expECaught);
+
+            expECaught = false;
+
+            try {
+                v.getX(v.size());
+            }
+            catch (ArrayIndexOutOfBoundsException | IgniteException e) {
+                expECaught = true;
+            }
+
+            if (!getXOutOfBoundsOK(v))
+                assertTrue("Expect exception at too large index getX in " + desc, expECaught);
+
+            expECaught = false;
+
+            try {
+                v.setX(v.size(), 1);
+            }
+            catch (ArrayIndexOutOfBoundsException | IgniteException e) {
+                expECaught = true;
+            }
+
+            assertTrue("Expect exception at too large index setX in " + desc, expECaught);
+
+            expECaught = false;
+
+            try {
+                v.incrementX(v.size(), 1);
+            }
+            catch (ArrayIndexOutOfBoundsException | IgniteException e) {
+                expECaught = true;
+            }
+
+            assertTrue("Expect exception at too large index incrementX in " + desc, expECaught);
+        });
+    }
+
+    /** */
+    @Test
+    public void sizeTest() {
+        final AtomicReference<Integer> expSize = new AtomicReference<>(0);
+
+        consumeSampleVectors(
+            expSize::set,
+            (v, desc) -> Assert.assertEquals("Expected size for " + desc,
+                (int)expSize.get(), v.size())
+        );
+    }
+
+    /** */
+    @Test
+    public void getElementTest() {
+        consumeSampleVectors((v, desc) -> new ElementsChecker(v, desc).assertCloseEnough(v));
+    }
+
+    /** */
+    @Test
+    public void copyTest() {
+        consumeSampleVectors((v, desc) -> new ElementsChecker(v, desc).assertCloseEnough(v.copy()));
+    }
+
+    /** */
+    @Test
+    public void divideTest() {
+        operationTest((val, operand) -> val / operand, Vector::divide);
+    }
+
+    /** */
+    @Test
+    public void likeTest() {
+        for (int card : new int[] {1, 2, 4, 8, 16, 32, 64, 128})
+            consumeSampleVectors((v, desc) -> {
+                Class<? extends Vector> expType = expLikeType(v);
+
+                if (expType == null) {
+                    try {
+                        v.like(card);
+                    }
+                    catch (UnsupportedOperationException uoe) {
+                        return;
+                    }
+
+                    fail("Expected exception wasn't caught for " + desc);
+
+                    return;
+                }
+
+                Vector vLike = v.like(card);
+
+                assertNotNull("Expect non-null like vector for " + expType.getSimpleName() + " in " + desc, vLike);
+                assertEquals("Expect size equal to cardinality at " + desc, card, vLike.size());
+
+                Class<? extends Vector> actualType = vLike.getClass();
+
+                assertTrue("Actual vector type " + actualType.getSimpleName()
+                        + " should be assignable from expected type " + expType.getSimpleName() + " in " + desc,
+                    actualType.isAssignableFrom(expType));
+            });
+    }
+
+    /** */
+    @Test
+    public void minusTest() {
+        operationVectorTest((operand1, operand2) -> operand1 - operand2, Vector::minus);
+    }
+
+    /** */
+    @Test
+    public void plusVectorTest() {
+        operationVectorTest((operand1, operand2) -> operand1 + operand2, Vector::plus);
+    }
+
+    /** */
+    @Test
+    public void plusDoubleTest() {
+        operationTest((val, operand) -> val + operand, Vector::plus);
+    }
+
+    /** */
+    @Test
+    public void timesVectorTest() {
+        operationVectorTest((operand1, operand2) -> operand1 * operand2, Vector::times);
+    }
+
+    /** */
+    @Test
+    public void timesDoubleTest() {
+        operationTest((val, operand) -> val * operand, Vector::times);
+    }
+
+    /** */
+    @Test
+    public void viewPartTest() {
+        consumeSampleVectors((v, desc) -> {
+            final int size = v.size();
+            final double[] ref = new double[size];
+            final int delta = size > 32 ? 3 : 1; // IMPL NOTE this is for faster test execution
+
+            final ElementsChecker checker = new ElementsChecker(v, ref, desc);
+
+            for (int off = 0; off < size; off += delta)
+                for (int len = 1; len < size - off; len += delta)
+                    checker.assertCloseEnough(v.viewPart(off, len), Arrays.copyOfRange(ref, off, off + len));
+        });
+    }
+
+    /** */
+    @Test
+    public void sumTest() {
+        toDoubleTest(
+            ref -> Arrays.stream(ref).sum(),
+            Vector::sum);
+    }
+
+    /** */
+    @Test
+    public void minValueTest() {
+        toDoubleTest(
+            ref -> Arrays.stream(ref).min().getAsDouble(),
+            Vector::minValue);
+    }
+
+    /** */
+    @Test
+    public void maxValueTest() {
+        toDoubleTest(
+            ref -> Arrays.stream(ref).max().getAsDouble(),
+            Vector::maxValue);
+    }
+
+    /** */
+    @Test
+    public void sortTest() {
+        consumeSampleVectors((v, desc) -> {
+            if (readOnly(v) || !v.isArrayBased()) {
+                boolean expECaught = false;
+
+                try {
+                    v.sort();
+                }
+                catch (UnsupportedOperationException uoe) {
+                    expECaught = true;
+                }
+
+                assertTrue("Expected exception was not caught for sort in " + desc, expECaught);
+
+                return;
+            }
+
+            final int size = v.size();
+            final double[] ref = new double[size];
+
+            new ElementsChecker(v, ref, desc).assertCloseEnough(v.sort(), Arrays.stream(ref).sorted().toArray());
+        });
+    }
+
+    /** */
+    @Test
+    public void metaAttributesTest() {
+        consumeSampleVectors((v, desc) -> {
+            assertNotNull("Null meta storage in " + desc, v.getMetaStorage());
+
+            final String key = "test key";
+            final String val = "test value";
+            final String details = "key [" + key + "] for " + desc;
+
+            v.setAttribute(key, val);
+            assertTrue("Expect to have meta attribute for " + details, v.hasAttribute(key));
+            assertEquals("Unexpected meta attribute value for " + details, val, v.getAttribute(key));
+
+            v.removeAttribute(key);
+            assertFalse("Expect not to have meta attribute for " + details, v.hasAttribute(key));
+            assertNull("Unexpected meta attribute value for " + details, v.getAttribute(key));
+        });
+    }
+
+    /** */
+    @Test
+    public void assignDoubleTest() {
+        consumeSampleVectors((v, desc) -> {
+            if (readOnly(v))
+                return;
+
+            for (double val : new double[] {0, -1, 0, 1}) {
+                v.assign(val);
+
+                for (int idx = 0; idx < v.size(); idx++) {
+                    final Metric metric = new Metric(val, v.get(idx));
+
+                    assertTrue("Not close enough at index " + idx + ", val " + val + ", " + metric
+                        + ", " + desc, metric.closeEnough());
+                }
+            }
+        });
+    }
+
+    /** */
+    @Test
+    public void assignDoubleArrTest() {
+        consumeSampleVectors((v, desc) -> {
+            if (readOnly(v))
+                return;
+
+            final int size = v.size();
+            final double[] ref = new double[size];
+
+            final ElementsChecker checker = new ElementsChecker(v, ref, desc);
+
+            for (int idx = 0; idx < size; idx++)
+                ref[idx] = -ref[idx];
+
+            v.assign(ref);
+
+            checker.assertCloseEnough(v, ref);
+
+            assignDoubleArrWrongCardinality(v, desc);
+        });
+    }
+
+    /** */
+    @Test
+    public void assignVectorTest() {
+        consumeSampleVectors((v, desc) -> {
+            if (readOnly(v))
+                return;
+
+            final int size = v.size();
+            final double[] ref = new double[size];
+
+            final ElementsChecker checker = new ElementsChecker(v, ref, desc);
+
+            for (int idx = 0; idx < size; idx++)
+                ref[idx] = -ref[idx];
+
+            v.assign(new DenseLocalOnHeapVector(ref));
+
+            checker.assertCloseEnough(v, ref);
+
+            assignVectorWrongCardinality(v, desc);
+        });
+    }
+
+    /** */
+    @Test
+    public void assignFunctionTest() {
+        consumeSampleVectors((v, desc) -> {
+            if (readOnly(v))
+                return;
+
+            final int size = v.size();
+            final double[] ref = new double[size];
+
+            final ElementsChecker checker = new ElementsChecker(v, ref, desc);
+
+            for (int idx = 0; idx < size; idx++)
+                ref[idx] = -ref[idx];
+
+            v.assign((idx) -> ref[idx]);
+
+            checker.assertCloseEnough(v, ref);
+        });
+    }
+
+    /** */
+    @Test
+    public void minElementTest() {
+        consumeSampleVectors((v, desc) -> {
+            final ElementsChecker checker = new ElementsChecker(v, desc);
+
+            final Vector.Element minE = v.minElement();
+
+            final int minEIdx = minE.index();
+
+            assertTrue("Unexpected index from minElement " + minEIdx + ", " + desc,
+                minEIdx >= 0 && minEIdx < v.size());
+
+            final Metric metric = new Metric(minE.get(), v.minValue());
+
+            assertTrue("Not close enough minElement at index " + minEIdx + ", " + metric
+                + ", " + desc, metric.closeEnough());
+
+            checker.assertNewMinElement(v);
+        });
+    }
+
+    /** */
+    @Test
+    public void maxElementTest() {
+        consumeSampleVectors((v, desc) -> {
+            final ElementsChecker checker = new ElementsChecker(v, desc);
+
+            final Vector.Element maxE = v.maxElement();
+
+            final int minEIdx = maxE.index();
+
+            assertTrue("Unexpected index from minElement " + minEIdx + ", " + desc,
+                minEIdx >= 0 && minEIdx < v.size());
+
+            final Metric metric = new Metric(maxE.get(), v.maxValue());
+
+            assertTrue("Not close enough maxElement at index " + minEIdx + ", " + metric
+                + ", " + desc, metric.closeEnough());
+
+            checker.assertNewMaxElement(v);
+        });
+    }
+
+    /** */
+    @Test
+    public void externalizeTest() {
+        (new ExternalizeTest<Vector>() {
+            /** {@inheritDoc} */
+            @Override public void externalizeTest() {
+                consumeSampleVectors((v, desc) -> {
+                    if (v instanceof SparseLocalOffHeapVector)
+                        return; //TODO: wait till SparseLocalOffHeapVector externalization support.
+
+                    externalizeTest(v);
+                });
+            }
+        }).externalizeTest();
+    }
+
+    /** */
+    @Test
+    public void hashCodeTest() {
+        consumeSampleVectors((v, desc) -> assertTrue("Zero hash code for " + desc, v.hashCode() != 0));
+    }
+
+    /** */
+    private boolean getXOutOfBoundsOK(Vector v) {
+        // todo find out if this is indeed OK
+        return v instanceof RandomVector || v instanceof ConstantVector
+            || v instanceof SingleElementVector || v instanceof SingleElementVectorView;
+    }
+
+    /** */
+    private void mutateAtIdxTest(Vector v, String desc, MutateAtIdx operation) {
+        if (readOnly(v)) {
+            if (v.size() < 1)
+                return;
+
+            boolean expECaught = false;
+
+            try {
+                operation.apply(v, 0, 1);
+            }
+            catch (UnsupportedOperationException uoe) {
+                expECaught = true;
+            }
+
+            assertTrue("Expect exception at attempt to mutate element in " + desc, expECaught);
+
+            return;
+        }
+
+        for (double val : new double[] {0, -1, 0, 1})
+            for (int idx = 0; idx < v.size(); idx++) {
+                double exp = operation.apply(v, idx, val);
+
+                final Metric metric = new Metric(exp, v.get(idx));
+
+                assertTrue("Not close enough at index " + idx + ", val " + val + ", " + metric
+                    + ", " + desc, metric.closeEnough());
+            }
+    }
+
+    /** */
+    private Class<? extends Vector> expLikeType(Vector v) {
+        Class<? extends Vector> clazz = v.getClass();
+
+        if (clazz.isAssignableFrom(PivotedVectorView.class) || clazz.isAssignableFrom(SingleElementVectorView.class))
+            return null;
+
+        if (clazz.isAssignableFrom(MatrixVectorView.class) || clazz.isAssignableFrom(DelegatingVector.class))
+            return DenseLocalOnHeapVector.class; // IMPL NOTE per fixture
+
+        return clazz;
+    }
+
+    /** */
+    private void toDoubleTest(Function<double[], Double> calcRef, Function<Vector, Double> calcVec) {
+        consumeSampleVectors((v, desc) -> {
+            final int size = v.size();
+            final double[] ref = new double[size];
+
+            new ElementsChecker(v, ref, desc); // IMPL NOTE this initialises vector and reference array
+
+            final Metric metric = new Metric(calcRef.apply(ref), calcVec.apply(v));
+
+            assertTrue("Not close enough at " + desc
+                + ", " + metric, metric.closeEnough());
+        });
+    }
+
+    /** */
+    private void operationVectorTest(BiFunction<Double, Double, Double> operation,
+        BiFunction<Vector, Vector, Vector> vecOperation) {
+        consumeSampleVectors((v, desc) -> {
+            // TODO find out if more elaborate testing scenario is needed or it's okay as is.
+            final int size = v.size();
+            final double[] ref = new double[size];
+
+            final ElementsChecker checker = new ElementsChecker(v, ref, desc);
+            final Vector operand = v.copy();
+
+            for (int idx = 0; idx < size; idx++)
+                ref[idx] = operation.apply(ref[idx], ref[idx]);
+
+            checker.assertCloseEnough(vecOperation.apply(v, operand), ref);
+
+            assertWrongCardinality(v, desc, vecOperation);
+        });
+    }
+
+    /** */
+    private void assignDoubleArrWrongCardinality(Vector v, String desc) {
+        boolean expECaught = false;
+
+        try {
+            v.assign(new double[v.size() + 1]);
+        }
+        catch (CardinalityException ce) {
+            expECaught = true;
+        }
+
+        assertTrue("Expect exception at too large size in " + desc, expECaught);
+
+        if (v.size() < 2)
+            return;
+
+        expECaught = false;
+
+        try {
+            v.assign(new double[v.size() - 1]);
+        }
+        catch (CardinalityException ce) {
+            expECaught = true;
+        }
+
+        assertTrue("Expect exception at too small size in " + desc, expECaught);
+    }
+
+    /** */
+    private void assignVectorWrongCardinality(Vector v, String desc) {
+        boolean expECaught = false;
+
+        try {
+            v.assign(new DenseLocalOnHeapVector(v.size() + 1));
+        }
+        catch (CardinalityException ce) {
+            expECaught = true;
+        }
+
+        assertTrue("Expect exception at too large size in " + desc, expECaught);
+
+        if (v.size() < 2)
+            return;
+
+        expECaught = false;
+
+        try {
+            v.assign(new DenseLocalOnHeapVector(v.size() - 1));
+        }
+        catch (CardinalityException ce) {
+            expECaught = true;
+        }
+
+        assertTrue("Expect exception at too small size in " + desc, expECaught);
+    }
+
+    /** */
+    private void assertWrongCardinality(
+        Vector v, String desc, BiFunction<Vector, Vector, Vector> vecOperation) {
+        boolean expECaught = false;
+
+        try {
+            vecOperation.apply(v, new DenseLocalOnHeapVector(v.size() + 1));
+        }
+        catch (CardinalityException ce) {
+            expECaught = true;
+        }
+
+        assertTrue("Expect exception at too large size in " + desc, expECaught);
+
+        if (v.size() < 2)
+            return;
+
+        expECaught = false;
+
+        try {
+            vecOperation.apply(v, new DenseLocalOnHeapVector(v.size() - 1));
+        }
+        catch (CardinalityException ce) {
+            expECaught = true;
+        }
+
+        assertTrue("Expect exception at too small size in " + desc, expECaught);
+    }
+
+    /** */
+    private void operationTest(BiFunction<Double, Double, Double> operation,
+        BiFunction<Vector, Double, Vector> vecOperation) {
+        for (double val : new double[] {0, 0.1, 1, 2, 10})
+            consumeSampleVectors((v, desc) -> {
+                final int size = v.size();
+                final double[] ref = new double[size];
+
+                final ElementsChecker checker = new ElementsChecker(v, ref, "val " + val + ", " + desc);
+
+                for (int idx = 0; idx < size; idx++)
+                    ref[idx] = operation.apply(ref[idx], val);
+
+                checker.assertCloseEnough(vecOperation.apply(v, val), ref);
+            });
+    }
+
+    /** */
+    private void consumeSampleVectors(BiConsumer<Vector, String> consumer) {
+        consumeSampleVectors(null, consumer);
+    }
+
+    /** */
+    private void consumeSampleVectors(Consumer<Integer> paramsConsumer, BiConsumer<Vector, String> consumer) {
+        new VectorImplementationsFixtures().consumeSampleVectors(paramsConsumer, consumer);
+    }
+
+    /** */
+    private static boolean readOnly(Vector v) {
+        return v instanceof RandomVector || v instanceof ConstantVector;
+    }
+
+    /** */
+    private interface MutateAtIdx {
+        /** */
+        double apply(Vector v, int idx, double val);
+    }
+
+    /** */
+    static class ElementsChecker {
+        /** */
+        private final String fixtureDesc;
+
+        /** */
+        private final double[] refReadOnly;
+
+        /** */
+        private final boolean nonNegative;
+
+        /** */
+        ElementsChecker(Vector v, double[] ref, String fixtureDesc, boolean nonNegative) {
+            this.fixtureDesc = fixtureDesc;
+
+            this.nonNegative = nonNegative;
+
+            refReadOnly = readOnly(v) && ref == null ? new double[v.size()] : null;
+
+            init(v, ref);
+        }
+
+        /** */
+        ElementsChecker(Vector v, double[] ref, String fixtureDesc) {
+            this(v, ref, fixtureDesc, false);
+        }
+
+        /** */
+        ElementsChecker(Vector v, String fixtureDesc) {
+            this(v, null, fixtureDesc);
+        }
+
+        /** */
+        void assertCloseEnough(Vector obtained, double[] exp) {
+            final int size = obtained.size();
+
+            for (int i = 0; i < size; i++) {
+                final Vector.Element e = obtained.getElement(i);
+
+                if (refReadOnly != null && exp == null)
+                    exp = refReadOnly;
+
+                final Metric metric = new Metric(exp == null ? generated(i) : exp[i], e.get());
+
+                assertEquals("Unexpected vector index at " + fixtureDesc, i, e.index());
+                assertTrue("Not close enough at index " + i + ", size " + size + ", " + metric
+                    + ", " + fixtureDesc, metric.closeEnough());
+            }
+        }
+
+        /** */
+        void assertCloseEnough(Vector obtained) {
+            assertCloseEnough(obtained, null);
+        }
+
+        /** */
+        void assertNewMinElement(Vector v) {
+            if (readOnly(v))
+                return;
+
+            int exp = v.size() / 2;
+
+            v.set(exp, -(v.size() * 2 + 1));
+
+            assertEquals("Unexpected minElement index at " + fixtureDesc, exp, v.minElement().index());
+        }
+
+        /** */
+        void assertNewMaxElement(Vector v) {
+            if (readOnly(v))
+                return;
+
+            int exp = v.size() / 2;
+
+            v.set(exp, v.size() * 2 + 1);
+
+            assertEquals("Unexpected minElement index at " + fixtureDesc, exp, v.maxElement().index());
+        }
+
+        /** */
+        private void init(Vector v, double[] ref) {
+            if (readOnly(v)) {
+                initReadonly(v, ref);
+
+                return;
+            }
+
+            for (Vector.Element e : v.all()) {
+                int idx = e.index();
+
+                // IMPL NOTE introduce negative values because their absence
+                //    blocked catching an ugly bug in AbstractVector#kNorm
+                int val = generated(idx);
+
+                e.set(val);
+
+                if (ref != null)
+                    ref[idx] = val;
+            }
+        }
+
+        /** */
+        private void initReadonly(Vector v, double[] ref) {
+            if (refReadOnly != null)
+                for (Vector.Element e : v.all())
+                    refReadOnly[e.index()] = e.get();
+
+            if (ref != null)
+                for (Vector.Element e : v.all())
+                    ref[e.index()] = e.get();
+        }
+
+        /** */
+        private int generated(int idx) {
+            return nonNegative || (idx & 1) == 0 ? idx : -idx;
+        }
+    }
+
+    /** */
+    static class Metric { // todo consider if softer tolerance (like say 0.1 or 0.01) would make sense here
+        /** */
+        private final double exp;
+
+        /** */
+        private final double obtained;
+
+        /** **/
+        Metric(double exp, double obtained) {
+            this.exp = exp;
+            this.obtained = obtained;
+        }
+
+        /** */
+        boolean closeEnough() {
+            return new Double(exp).equals(obtained) || closeEnoughToZero();
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return "Metric{" + "expected=" + exp +
+                ", obtained=" + obtained +
+                '}';
+        }
+
+        /** */
+        private boolean closeEnoughToZero() {
+            return (new Double(exp).equals(0.0) && new Double(obtained).equals(-0.0))
+                || (new Double(exp).equals(-0.0) && new Double(obtained).equals(0.0));
+        }
+    }
+}


[12/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
new file mode 100644
index 0000000..3c075f4
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
@@ -0,0 +1,903 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+import java.util.function.IntToDoubleFunction;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.exceptions.CardinalityException;
+import org.apache.ignite.ml.math.exceptions.IndexException;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.Functions;
+import org.apache.ignite.ml.math.functions.IgniteBiFunction;
+import org.apache.ignite.ml.math.functions.IgniteDoubleFunction;
+import org.apache.ignite.ml.math.impls.matrix.MatrixView;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * This class provides a helper implementation of the {@link Vector}
+ * interface to minimize the effort required to implement it.
+ * Subclasses may override some of the implemented methods if a more
+ * specific or optimized implementation is desirable.
+ */
+public abstract class AbstractVector implements Vector {
+    /** Vector storage implementation. */
+    private VectorStorage sto;
+
+    /** Meta attribute storage. */
+    private Map<String, Object> meta = new HashMap<>();
+
+    /** Vector's GUID. */
+    private IgniteUuid guid = IgniteUuid.randomUuid();
+
+    /** Cached value for length squared. */
+    private double lenSq = 0.0;
+
+    /** Maximum cached element. */
+    private Element maxElm = null;
+    /** Minimum cached element. */
+    private Element minElm = null;
+
+    /** Readonly flag (false by default). */
+    private boolean readOnly = false;
+
+    /** Read-only error message. */
+    private static final String RO_MSG = "Vector is read-only.";
+
+    /**
+     *
+     */
+    private void ensureReadOnly() {
+        if (readOnly)
+            throw new UnsupportedOperationException(RO_MSG);
+    }
+
+    /**
+     * @param sto Storage.
+     */
+    public AbstractVector(VectorStorage sto) {
+        this(false, sto);
+    }
+
+    /**
+     * @param readOnly Is read only.
+     * @param sto Storage.
+     */
+    public AbstractVector(boolean readOnly, VectorStorage sto) {
+        assert sto != null;
+
+        this.readOnly = readOnly;
+        this.sto = sto;
+    }
+
+    /**
+     *
+     */
+    public AbstractVector() {
+        // No-op.
+    }
+
+    /**
+     * Set storage.
+     *
+     * @param sto Storage.
+     */
+    protected void setStorage(VectorStorage sto) {
+        this.sto = sto;
+    }
+
+    /**
+     * @param i Index.
+     * @param v Value.
+     */
+    protected void storageSet(int i, double v) {
+        ensureReadOnly();
+
+        sto.set(i, v);
+
+        // Reset cached values.
+        lenSq = 0.0;
+        maxElm = minElm = null;
+    }
+
+    /**
+     * @param i Index.
+     * @return Value.
+     */
+    protected double storageGet(int i) {
+        return sto.get(i);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return sto.size();
+    }
+
+    /**
+     * Check index bounds.
+     *
+     * @param idx Index to check.
+     */
+    protected void checkIndex(int idx) {
+        if (idx < 0 || idx >= sto.size())
+            throw new IndexException(idx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int idx) {
+        checkIndex(idx);
+
+        return storageGet(idx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public double getX(int idx) {
+        return storageGet(idx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return sto.isArrayBased();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector sort() {
+        if (isArrayBased())
+            Arrays.parallelSort(sto.data());
+        else
+            throw new UnsupportedOperationException();
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector map(IgniteDoubleFunction<Double> fun) {
+        if (sto.isArrayBased()) {
+            double[] data = sto.data();
+
+            Arrays.setAll(data, (idx) -> fun.apply(data[idx]));
+        }
+        else {
+            int len = size();
+
+            for (int i = 0; i < len; i++)
+                storageSet(i, fun.apply(storageGet(i)));
+        }
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector map(Vector vec, IgniteBiFunction<Double, Double, Double> fun) {
+        checkCardinality(vec);
+
+        int len = size();
+
+        for (int i = 0; i < len; i++)
+            storageSet(i, fun.apply(storageGet(i), vec.get(i)));
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector map(IgniteBiFunction<Double, Double, Double> fun, double y) {
+        int len = size();
+
+        for (int i = 0; i < len; i++)
+            storageSet(i, fun.apply(storageGet(i), y));
+
+        return this;
+    }
+
+    /**
+     * @param idx Index.
+     * @return Value.
+     */
+    protected Element makeElement(int idx) {
+        checkIndex(idx);
+
+        return new Element() {
+            /** {@inheritDoc} */
+            @Override public double get() {
+                return storageGet(idx);
+            }
+
+            /** {@inheritDoc} */
+            @Override public int index() {
+                return idx;
+            }
+
+            /** {@inheritDoc} */
+            @Override public void set(double val) {
+                storageSet(idx, val);
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override public Element minElement() {
+        if (minElm == null) {
+            int minIdx = 0;
+            int len = size();
+
+            for (int i = 0; i < len; i++)
+                if (storageGet(i) < storageGet(minIdx))
+                    minIdx = i;
+
+            minElm = makeElement(minIdx);
+        }
+
+        return minElm;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Element maxElement() {
+        if (maxElm == null) {
+            int maxIdx = 0;
+            int len = size();
+
+            for (int i = 0; i < len; i++)
+                if (storageGet(i) > storageGet(maxIdx))
+                    maxIdx = i;
+
+            maxElm = makeElement(maxIdx);
+        }
+
+        return maxElm;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double minValue() {
+        return minElement().get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double maxValue() {
+        return maxElement().get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector set(int idx, double val) {
+        checkIndex(idx);
+
+        storageSet(idx, val);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector setX(int idx, double val) {
+        storageSet(idx, val);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector increment(int idx, double val) {
+        checkIndex(idx);
+
+        storageSet(idx, storageGet(idx) + val);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector incrementX(int idx, double val) {
+        storageSet(idx, storageGet(idx) + val);
+
+        return this;
+    }
+
+    /**
+     * Tests if given value is considered a zero value.
+     *
+     * @param val Value to check.
+     */
+    protected boolean isZero(double val) {
+        return val == 0.0;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double sum() {
+        double sum = 0;
+        int len = size();
+
+        for (int i = 0; i < len; i++)
+            sum += storageGet(i);
+
+        return sum;
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteUuid guid() {
+        return guid;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Iterable<Element> all() {
+        return new Iterable<Element>() {
+            private int idx = 0;
+
+            /** {@inheritDoc} */
+            @NotNull
+            @Override public Iterator<Element> iterator() {
+                return new Iterator<Element>() {
+                    /** {@inheritDoc} */
+                    @Override public boolean hasNext() {
+                        return size() > 0 && idx < size();
+                    }
+
+                    /** {@inheritDoc} */
+                    @Override public Element next() {
+                        if (hasNext())
+                            return getElement(idx++);
+
+                        throw new NoSuchElementException();
+                    }
+                };
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override public int nonZeroElements() {
+        int cnt = 0;
+
+        for (Element ignored : nonZeroes())
+            cnt++;
+
+        return cnt;
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T foldMap(IgniteBiFunction<T, Double, T> foldFun, IgniteDoubleFunction<Double> mapFun,
+        T zeroVal) {
+        T res = zeroVal;
+        int len = size();
+
+        for (int i = 0; i < len; i++)
+            res = foldFun.apply(res, mapFun.apply(storageGet(i)));
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T foldMap(Vector vec, IgniteBiFunction<T, Double, T> foldFun,
+        IgniteBiFunction<Double, Double, Double> combFun, T zeroVal) {
+        checkCardinality(vec);
+
+        T res = zeroVal;
+        int len = size();
+
+        for (int i = 0; i < len; i++)
+            res = foldFun.apply(res, combFun.apply(storageGet(i), vec.getX(i)));
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Iterable<Element> nonZeroes() {
+        return new Iterable<Element>() {
+            private int idx = 0;
+            private int idxNext = -1;
+
+            /** {@inheritDoc} */
+            @NotNull
+            @Override public Iterator<Element> iterator() {
+                return new Iterator<Element>() {
+                    @Override public boolean hasNext() {
+                        findNext();
+
+                        return !over();
+                    }
+
+                    @Override public Element next() {
+                        if (hasNext()) {
+                            idx = idxNext;
+
+                            return getElement(idxNext);
+                        }
+
+                        throw new NoSuchElementException();
+                    }
+
+                    private void findNext() {
+                        if (over())
+                            return;
+
+                        if (idxNextInitialized() && idx != idxNext)
+                            return;
+
+                        if (idxNextInitialized())
+                            idx = idxNext + 1;
+
+                        while (idx < size() && isZero(get(idx)))
+                            idx++;
+
+                        idxNext = idx++;
+                    }
+
+                    private boolean over() {
+                        return idxNext >= size();
+                    }
+
+                    private boolean idxNextInitialized() {
+                        return idxNext != -1;
+                    }
+                };
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override public Map<String, Object> getMetaStorage() {
+        return meta;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector assign(double val) {
+        if (sto.isArrayBased()) {
+            ensureReadOnly();
+
+            Arrays.fill(sto.data(), val);
+        }
+        else {
+            int len = size();
+
+            for (int i = 0; i < len; i++)
+                storageSet(i, val);
+        }
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector assign(double[] vals) {
+        checkCardinality(vals);
+
+        if (sto.isArrayBased()) {
+            ensureReadOnly();
+
+            System.arraycopy(vals, 0, sto.data(), 0, vals.length);
+
+            lenSq = 0.0;
+        }
+        else {
+            int len = size();
+
+            for (int i = 0; i < len; i++)
+                storageSet(i, vals[i]);
+        }
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector assign(Vector vec) {
+        checkCardinality(vec);
+
+        for (Vector.Element x : vec.all())
+            storageSet(x.index(), x.get());
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector assign(IntToDoubleFunction fun) {
+        assert fun != null;
+
+        if (sto.isArrayBased()) {
+            ensureReadOnly();
+
+            Arrays.setAll(sto.data(), fun);
+        }
+        else {
+            int len = size();
+
+            for (int i = 0; i < len; i++)
+                storageSet(i, fun.applyAsDouble(i));
+        }
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Spliterator<Double> allSpliterator() {
+        return new Spliterator<Double>() {
+            /** {@inheritDoc} */
+            @Override public boolean tryAdvance(Consumer<? super Double> act) {
+                int len = size();
+
+                for (int i = 0; i < len; i++)
+                    act.accept(storageGet(i));
+
+                return true;
+            }
+
+            /** {@inheritDoc} */
+            @Override public Spliterator<Double> trySplit() {
+                return null; // No Splitting.
+            }
+
+            /** {@inheritDoc} */
+            @Override public long estimateSize() {
+                return size();
+            }
+
+            /** {@inheritDoc} */
+            @Override public int characteristics() {
+                return ORDERED | SIZED;
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override public Spliterator<Double> nonZeroSpliterator() {
+        return new Spliterator<Double>() {
+            /** {@inheritDoc} */
+            @Override public boolean tryAdvance(Consumer<? super Double> act) {
+                int len = size();
+
+                for (int i = 0; i < len; i++) {
+                    double val = storageGet(i);
+
+                    if (!isZero(val))
+                        act.accept(val);
+                }
+
+                return true;
+            }
+
+            /** {@inheritDoc} */
+            @Override public Spliterator<Double> trySplit() {
+                return null; // No Splitting.
+            }
+
+            /** {@inheritDoc} */
+            @Override public long estimateSize() {
+                return nonZeroElements();
+            }
+
+            /** {@inheritDoc} */
+            @Override public int characteristics() {
+                return ORDERED | SIZED;
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override public double dot(Vector vec) {
+        checkCardinality(vec);
+
+        double sum = 0.0;
+        int len = size();
+
+        for (int i = 0; i < len; i++)
+            sum += storageGet(i) * vec.getX(i);
+
+        return sum;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double getLengthSquared() {
+        if (lenSq == 0.0)
+            lenSq = dotSelf();
+
+        return lenSq;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return sto.isDense();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return sto.isSequentialAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return sto.isRandomAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return sto.isDistributed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public VectorStorage getStorage() {
+        return sto;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector viewPart(int off, int len) {
+        return new VectorView(this, off, len);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix cross(Vector vec) {
+        Matrix res = likeMatrix(size(), vec.size());
+
+        if (res == null)
+            return null;
+
+        for (Element e : nonZeroes()) {
+            int row = e.index();
+
+            res.assignRow(row, vec.times(getX(row)));
+        }
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix toMatrix(boolean rowLike) {
+        Matrix res = likeMatrix(rowLike ? 1 : size(), rowLike ? size() : 1);
+
+        if (res == null)
+            return null;
+
+        if (rowLike)
+            res.assignRow(0, this);
+        else
+            res.assignColumn(0, this);
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix toMatrixPlusOne(boolean rowLike, double zeroVal) {
+        Matrix res = likeMatrix(rowLike ? 1 : size() + 1, rowLike ? size() + 1 : 1);
+
+        if (res == null)
+            return null;
+
+        res.set(0, 0, zeroVal);
+
+        if (rowLike)
+            new MatrixView(res, 0, 1, 1, size()).assignRow(0, this);
+        else
+            new MatrixView(res, 1, 0, size(), 1).assignColumn(0, this);
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double getDistanceSquared(Vector vec) {
+        checkCardinality(vec);
+
+        double thisLenSq = getLengthSquared();
+        double thatLenSq = vec.getLengthSquared();
+        double dot = dot(vec);
+        double distEst = thisLenSq + thatLenSq - 2 * dot;
+
+        if (distEst > 1.0e-3 * (thisLenSq + thatLenSq))
+            // The vectors are far enough from each other that the formula is accurate.
+            return Math.max(distEst, 0);
+        else
+            return foldMap(vec, Functions.PLUS, Functions.MINUS_SQUARED, 0d);
+    }
+
+    /** */
+    protected void checkCardinality(Vector vec) {
+        if (vec.size() != size())
+            throw new CardinalityException(size(), vec.size());
+    }
+
+    /** */
+    protected void checkCardinality(double[] vec) {
+        if (vec.length != size())
+            throw new CardinalityException(size(), vec.length);
+    }
+
+    /** */
+    protected void checkCardinality(int[] arr) {
+        if (arr.length != size())
+            throw new CardinalityException(size(), arr.length);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector minus(Vector vec) {
+        checkCardinality(vec);
+
+        Vector cp = copy();
+
+        return cp.map(vec, Functions.MINUS);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector plus(double x) {
+        Vector cp = copy();
+
+        return x != 0.0 ? cp.map(Functions.plus(x)) : cp;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector divide(double x) {
+        Vector cp = copy();
+
+        if (x != 1.0)
+            for (Element element : cp.all())
+                element.set(element.get() / x);
+
+        return cp;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector times(double x) {
+        if (x == 0.0)
+            return like(size());
+        else
+            return copy().map(Functions.mult(x));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector times(Vector vec) {
+        checkCardinality(vec);
+
+        return copy().map(vec, Functions.MULT);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector plus(Vector vec) {
+        checkCardinality(vec);
+
+        Vector cp = copy();
+
+        return cp.map(vec, Functions.PLUS);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector logNormalize() {
+        return logNormalize(2.0, Math.sqrt(getLengthSquared()));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector logNormalize(double power) {
+        return logNormalize(power, kNorm(power));
+    }
+
+    /**
+     * @param power Power.
+     * @param normLen Normalized length.
+     * @return logNormalized value.
+     */
+    private Vector logNormalize(double power, double normLen) {
+        assert !(Double.isInfinite(power) || power <= 1.0);
+
+        double denominator = normLen * Math.log(power);
+
+        Vector cp = copy();
+
+        for (Element element : cp.all())
+            element.set(Math.log1p(element.get()) / denominator);
+
+        return cp;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double kNorm(double power) {
+        assert power >= 0.0;
+
+        // Special cases.
+        if (Double.isInfinite(power))
+            return foldMap(Math::max, Math::abs, 0d);
+        else if (power == 2.0)
+            return Math.sqrt(getLengthSquared());
+        else if (power == 1.0)
+            return foldMap(Functions.PLUS, Math::abs, 0d);
+        else if (power == 0.0)
+            return nonZeroElements();
+        else
+            // Default case.
+            return Math.pow(foldMap(Functions.PLUS, Functions.pow(power), 0d), 1.0 / power);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector normalize() {
+        return divide(Math.sqrt(getLengthSquared()));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector normalize(double power) {
+        return divide(kNorm(power));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector copy() {
+        return like(size()).assign(this);
+    }
+
+    /**
+     * @return Result of dot with self.
+     */
+    protected double dotSelf() {
+        double sum = 0.0;
+        int len = size();
+
+        for (int i = 0; i < len; i++) {
+            double v = storageGet(i);
+
+            sum += v * v;
+        }
+
+        return sum;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Element getElement(int idx) {
+        return makeElement(idx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(sto);
+        out.writeObject(meta);
+        out.writeObject(guid);
+        out.writeBoolean(readOnly);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        sto = (VectorStorage)in.readObject();
+        meta = (Map<String, Object>)in.readObject();
+        guid = (IgniteUuid)in.readObject();
+        readOnly = in.readBoolean();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void destroy() {
+        sto.destroy();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+        res += res * 37 + guid.hashCode();
+        res += sto == null ? 0 : res * 37 + sto.hashCode();
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+
+        if (obj == null || getClass() != obj.getClass())
+            return false;
+
+        AbstractVector that = (AbstractVector)obj;
+
+        return (sto != null ? sto.equals(that.sto) : that.sto == null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/CacheVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/CacheVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/CacheVector.java
new file mode 100644
index 0000000..7e23791
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/CacheVector.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.ValueMapper;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorKeyMapper;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.IgniteBiFunction;
+import org.apache.ignite.ml.math.functions.IgniteDoubleFunction;
+import org.apache.ignite.ml.math.functions.IgniteFunction;
+import org.apache.ignite.ml.math.impls.CacheUtils;
+import org.apache.ignite.ml.math.impls.storage.vector.CacheVectorStorage;
+
+/**
+ * Vector based on existing cache and index and value mapping functions.
+ */
+public class CacheVector<K, V> extends AbstractVector {
+    /**
+     *
+     */
+    public CacheVector() {
+        // No-op.
+    }
+
+    /**
+     * Creates new vector over existing cache.
+     *
+     * @param size
+     * @param cache
+     * @param keyFunc
+     * @param valMapper
+     */
+    public CacheVector(
+        int size,
+        IgniteCache<K, V> cache,
+        VectorKeyMapper<K> keyFunc,
+        ValueMapper<V> valMapper) {
+        setStorage(new CacheVectorStorage<>(size, cache, keyFunc, valMapper));
+    }
+
+    /**
+     * @param mapper
+     */
+    private Vector mapOverCache(IgniteFunction<Double, Double> mapper) {
+        CacheVectorStorage<K, V> sto = storage();
+
+        CacheUtils.map(sto.cache().getName(), sto.keyMapper(), sto.valueMapper(), mapper);
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double minValue() {
+        CacheVectorStorage<K, V> sto = storage();
+
+        return CacheUtils.min(sto.cache().getName(), sto.keyMapper(), sto.valueMapper());
+    }
+
+    /** {@inheritDoc} */
+    @Override public double maxValue() {
+        CacheVectorStorage<K, V> sto = storage();
+
+        return CacheUtils.max(sto.cache().getName(), sto.keyMapper(), sto.valueMapper());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector map(IgniteDoubleFunction<Double> fun) {
+        return mapOverCache(fun::apply);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector map(IgniteBiFunction<Double, Double, Double> fun, double y) {
+        // TODO: provide cache-optimized implementation.
+        return super.map(fun, y); // TODO
+    }
+
+    /** {@inheritDoc} */
+    @Override public double sum() {
+        CacheVectorStorage<K, V> sto = storage();
+
+        return CacheUtils.sum(sto.cache().getName(), sto.keyMapper(), sto.valueMapper());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector assign(double val) {
+        return mapOverCache((Double d) -> val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector plus(double x) {
+        return mapOverCache((Double d) -> d + x);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector divide(double x) {
+        return mapOverCache((Double d) -> d / x);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector times(double x) {
+        return mapOverCache((Double d) -> d * x);
+    }
+
+    /**
+     *
+     *
+     */
+    @SuppressWarnings({"unchecked"})
+    private CacheVectorStorage<K, V> storage() {
+        return (CacheVectorStorage<K, V>)getStorage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        throw new UnsupportedOperationException();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/ConstantVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/ConstantVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/ConstantVector.java
new file mode 100644
index 0000000..71c9c3e
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/ConstantVector.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.storage.vector.ConstantVectorStorage;
+
+/**
+ * Constant value, read-only vector.
+ */
+public class ConstantVector extends AbstractReadOnlyVector {
+    /**
+     *
+     */
+    public ConstantVector() {
+        // No-op.
+    }
+
+    /**
+     * @param size
+     * @param val
+     */
+    public ConstantVector(int size, double val) {
+        super(new ConstantVectorStorage(size, val));
+    }
+
+    /**
+     *
+     *
+     */
+    private ConstantVectorStorage storage() {
+        return (ConstantVectorStorage)getStorage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector copy() {
+        ConstantVectorStorage sto = storage();
+
+        return new ConstantVector(sto.size(), sto.constant());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        return new ConstantVector(crd, storage().constant());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        ConstantVector that = (ConstantVector)o;
+
+        VectorStorage sto = getStorage();
+
+        return (sto != null ? sto.equals(that.getStorage()) : that.getStorage() == null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
new file mode 100644
index 0000000..891eb8e
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
@@ -0,0 +1,391 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Spliterator;
+import java.util.function.IntToDoubleFunction;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.functions.IgniteBiFunction;
+import org.apache.ignite.ml.math.functions.IgniteDoubleFunction;
+
+/**
+ * Convenient class that can be used to add decorations to an existing vector. Subclasses
+ * can add weights, indices, etc. while maintaining full vector functionality.
+ */
+public class DelegatingVector implements Vector {
+    /** Delegating vector. */
+    private Vector dlg;
+
+    /** Meta attribute storage. */
+    private Map<String, Object> meta = new HashMap<>();
+
+    /** GUID. */
+    private IgniteUuid guid = IgniteUuid.randomUuid();
+
+    /** */
+    public DelegatingVector() {
+        // No-op.
+    }
+
+    /**
+     * @param dlg
+     */
+    public DelegatingVector(Vector dlg) {
+        assert dlg != null;
+
+        this.dlg = dlg;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(dlg);
+        out.writeObject(meta);
+        out.writeObject(guid);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        dlg = (Vector)in.readObject();
+        meta = (Map<String, Object>)in.readObject();
+        guid = (IgniteUuid)in.readObject();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Map<String, Object> getMetaStorage() {
+        return meta;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        return dlg.likeMatrix(rows, cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix toMatrix(boolean rowLike) {
+        return dlg.toMatrix(rowLike);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix toMatrixPlusOne(boolean rowLike, double zeroVal) {
+        return dlg.toMatrixPlusOne(rowLike, zeroVal);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        return dlg.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDense() {
+        return dlg.isDense();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double minValue() {
+        return dlg.minValue();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double maxValue() {
+        return dlg.maxValue();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isSequentialAccess() {
+        return dlg.isSequentialAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isArrayBased() {
+        return dlg.isArrayBased();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector copy() {
+        return new DelegatingVector(dlg);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Iterable<Element> all() {
+        return dlg.all();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Iterable<Element> nonZeroes() {
+        return dlg.nonZeroes();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector sort() {
+        return dlg.sort();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Spliterator<Double> allSpliterator() {
+        return dlg.allSpliterator();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Spliterator<Double> nonZeroSpliterator() {
+        return dlg.nonZeroSpliterator();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Element getElement(int idx) {
+        return dlg.getElement(idx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector assign(double val) {
+        return dlg.assign(val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector assign(double[] vals) {
+        return dlg.assign(vals);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector assign(Vector vec) {
+        return dlg.assign(vec);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector assign(IntToDoubleFunction fun) {
+        return dlg.assign(fun);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector map(IgniteDoubleFunction<Double> fun) {
+        return dlg.map(fun);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector map(Vector vec, IgniteBiFunction<Double, Double, Double> fun) {
+        return dlg.map(vec, fun);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector map(IgniteBiFunction<Double, Double, Double> fun, double y) {
+        return dlg.map(fun, y);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector divide(double x) {
+        return dlg.divide(x);
+    }
+
+    /** {@inheritDoc} */
+    @Override public double dot(Vector vec) {
+        return dlg.dot(vec);
+    }
+
+    /** {@inheritDoc} */
+    @Override public double get(int idx) {
+        return dlg.get(idx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public double getX(int idx) {
+        return dlg.getX(idx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        return dlg.like(crd);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector minus(Vector vec) {
+        return dlg.minus(vec);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector normalize() {
+        return dlg.normalize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector normalize(double power) {
+        return dlg.normalize(power);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector logNormalize() {
+        return dlg.logNormalize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector logNormalize(double power) {
+        return dlg.logNormalize(power);
+    }
+
+    /** {@inheritDoc} */
+    @Override public double kNorm(double power) {
+        return dlg.kNorm(power);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Element minElement() {
+        return dlg.minElement();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Element maxElement() {
+        return dlg.maxElement();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector plus(double x) {
+        return dlg.plus(x);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector plus(Vector vec) {
+        return dlg.plus(vec);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector set(int idx, double val) {
+        return dlg.set(idx, val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector setX(int idx, double val) {
+        return dlg.setX(idx, val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector incrementX(int idx, double val) {
+        return dlg.incrementX(idx, val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector increment(int idx, double val) {
+        return dlg.increment(idx, val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int nonZeroElements() {
+        return dlg.nonZeroElements();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector times(double x) {
+        return dlg.times(x);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector times(Vector vec) {
+        return dlg.times(vec);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector viewPart(int off, int len) {
+        return dlg.viewPart(off, len);
+    }
+
+    /** {@inheritDoc} */
+    @Override public VectorStorage getStorage() {
+        return dlg.getStorage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double sum() {
+        return dlg.sum();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix cross(Vector vec) {
+        return dlg.cross(vec);
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T foldMap(IgniteBiFunction<T, Double, T> foldFun, IgniteDoubleFunction<Double> mapFun,
+        T zeroVal) {
+        return dlg.foldMap(foldFun, mapFun, zeroVal);
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T foldMap(Vector vec, IgniteBiFunction<T, Double, T> foldFun,
+        IgniteBiFunction<Double, Double, Double> combFun, T zeroVal) {
+        return dlg.foldMap(vec, foldFun, combFun, zeroVal);
+    }
+
+    /** {@inheritDoc} */
+    @Override public double getLengthSquared() {
+        return dlg.getLengthSquared();
+    }
+
+    /** {@inheritDoc} */
+    @Override public double getDistanceSquared(Vector vec) {
+        return dlg.getDistanceSquared(vec);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRandomAccess() {
+        return dlg.isRandomAccess();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDistributed() {
+        return dlg.isDistributed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteUuid guid() {
+        return guid;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void destroy() {
+        dlg.destroy();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + meta.hashCode();
+        res = res * 37 + dlg.hashCode();
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        DelegatingVector that = (DelegatingVector)o;
+
+        return meta.equals(that.meta) && dlg.equals(that.dlg);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOffHeapVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOffHeapVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOffHeapVector.java
new file mode 100644
index 0000000..c635572
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOffHeapVector.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.stream.IntStream;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOffHeapMatrix;
+import org.apache.ignite.ml.math.impls.storage.vector.DenseLocalOffHeapVectorStorage;
+
+/**
+ * Implementation for {@link Vector} assuming dense logic and local offheap JVM storage.
+ * It is suitable for data sets where local, non-distributed execution is satisfactory and on-heap JVM storage
+ * is not enough to keep the entire data set.
+ */
+public class DenseLocalOffHeapVector extends AbstractVector {
+    /** */
+    public DenseLocalOffHeapVector() {
+        // No-op.
+    }
+
+    /** */
+    private void makeOffheapStorage(int size) {
+        setStorage(new DenseLocalOffHeapVectorStorage(size));
+    }
+
+    /**
+     * @param arr Array to copy to offheap storage.
+     */
+    public DenseLocalOffHeapVector(double[] arr) {
+        makeOffheapStorage(arr.length);
+
+        assign(arr);
+    }
+
+    /**
+     * @param size Vector cardinality.
+     */
+    public DenseLocalOffHeapVector(int size) {
+        makeOffheapStorage(size);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector assign(Vector vec) {
+        checkCardinality(vec);
+
+        IntStream.range(0, size()).parallel().forEach(idx -> set(idx, vec.get(idx)));
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector times(double x) {
+        if (x == 0.0)
+            return like(size()).assign(0);
+        else
+            return super.times(x);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        return new DenseLocalOffHeapVector(crd);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        return new DenseLocalOffHeapMatrix(rows, cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        return o != null && getClass().equals(o.getClass()) && (getStorage().equals(((Vector)o).getStorage()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOnHeapVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOnHeapVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOnHeapVector.java
new file mode 100644
index 0000000..c37bda0
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOnHeapVector.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.Map;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.impls.storage.vector.ArrayVectorStorage;
+
+/**
+ * Basic implementation for vector.
+ * <p>
+ * This is a trivial implementation for vector assuming dense logic, local on-heap JVM storage
+ * based on {@code double[]} array. It is only suitable for data sets where
+ * local, non-distributed execution is satisfactory and on-heap JVM storage is enough
+ * to keep the entire data set.
+ */
+public class DenseLocalOnHeapVector extends AbstractVector {
+    /**
+     * @param size Vector cardinality.
+     */
+    private VectorStorage mkStorage(int size) {
+        return new ArrayVectorStorage(size);
+    }
+
+    /**
+     * @param arr Source array.
+     * @param cp {@code true} to clone array, reuse it otherwise.
+     */
+    private VectorStorage mkStorage(double[] arr, boolean cp) {
+        assert arr != null;
+
+        return new ArrayVectorStorage(cp ? arr.clone() : arr);
+    }
+
+    /**
+     * @param args Parameters for new Vector.
+     */
+    public DenseLocalOnHeapVector(Map<String, Object> args) {
+        assert args != null;
+
+        if (args.containsKey("size"))
+            setStorage(mkStorage((int)args.get("size")));
+        else if (args.containsKey("arr") && args.containsKey("copy"))
+            setStorage(mkStorage((double[])args.get("arr"), (boolean)args.get("copy")));
+        else
+            throw new UnsupportedOperationException("Invalid constructor argument(s).");
+    }
+
+    /** */
+    public DenseLocalOnHeapVector() {
+        // No-op.
+    }
+
+    /**
+     * @param size Vector cardinality.
+     */
+    public DenseLocalOnHeapVector(int size) {
+        setStorage(mkStorage(size));
+    }
+
+    /**
+     * @param arr Source array.
+     * @param shallowCp {@code true} to use shallow copy.
+     */
+    public DenseLocalOnHeapVector(double[] arr, boolean shallowCp) {
+        setStorage(mkStorage(arr, shallowCp));
+    }
+
+    /**
+     * @param arr Source array.
+     */
+    public DenseLocalOnHeapVector(double[] arr) {
+        this(arr, false);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        return new DenseLocalOnHeapMatrix(rows, cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        return new DenseLocalOnHeapVector(crd);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/FunctionVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/FunctionVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/FunctionVector.java
new file mode 100644
index 0000000..a2ffd90
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/FunctionVector.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.Map;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.IgniteFunction;
+import org.apache.ignite.ml.math.functions.IntDoubleToVoidFunction;
+import org.apache.ignite.ml.math.impls.storage.vector.FunctionVectorStorage;
+
+/**
+ * Implementation of {@link Vector} that maps vector element index to {@link java.util.function} interfaces.
+ */
+public class FunctionVector extends AbstractVector {
+    /**
+     *
+     */
+    public FunctionVector() {
+        // No-op.
+    }
+
+    /**
+     * Creates read-write or read-only function vector.
+     *
+     * @param size Vector size.
+     * @param getFunc Function that returns value corresponding to given element index.
+     * @param setFunc Set function. If {@code null} - this will be a read-only vector.
+     */
+    public FunctionVector(int size, IgniteFunction<Integer, Double> getFunc, IntDoubleToVoidFunction setFunc) {
+        setStorage(new FunctionVectorStorage(size, getFunc, setFunc));
+    }
+
+    /**
+     * Creates read-only function vector.
+     *
+     * @param size Vector size.
+     * @param getFunc Function that returns value corresponding to given element index.
+     */
+    public FunctionVector(int size, IgniteFunction<Integer, Double> getFunc) {
+        setStorage(new FunctionVectorStorage(size, getFunc));
+    }
+
+    /**
+     * @param args Arguments for vector constructor.
+     */
+    public FunctionVector(Map<String, Object> args) {
+        assert args != null;
+
+        if (args.containsKey("size") && args.containsKey("getFunc") && args.containsKey("setFunc")) {
+            @SuppressWarnings("unchecked")
+            IgniteFunction<Integer, Double> getFunc = (IgniteFunction<Integer, Double>)args.get("getFunc");
+            IntDoubleToVoidFunction setFunc = (IntDoubleToVoidFunction)args.get("setFunc");
+            int size = (int)args.get("size");
+
+            setStorage(new FunctionVectorStorage(size, getFunc, setFunc));
+        }
+        else if (args.containsKey("size") && args.containsKey("getFunc")) {
+            @SuppressWarnings("unchecked")
+            IgniteFunction<Integer, Double> getFunc = (IgniteFunction<Integer, Double>)args.get("getFunc");
+            int size = (int)args.get("size");
+
+            setStorage(new FunctionVectorStorage(size, getFunc));
+        }
+        else
+            throw new UnsupportedOperationException("Invalid constructor argument(s).");
+    }
+
+    /**
+     *
+     *
+     */
+    private FunctionVectorStorage storage() {
+        return (FunctionVectorStorage)getStorage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        FunctionVectorStorage sto = storage();
+
+        return new FunctionVector(crd, sto.getFunction(), sto.setFunction());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector times(double x) {
+        if (x == 0.0)
+            return like(size()).assign(0);
+        else
+            return super.times(x);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
new file mode 100644
index 0000000..723c585
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.IndexException;
+import org.apache.ignite.ml.math.impls.storage.vector.MatrixVectorStorage;
+
+/**
+ * Row or column vector view off the matrix.
+ */
+public class MatrixVectorView extends AbstractVector {
+    /** */ private Matrix parent;
+
+    /** */ private int row;
+    /** */ private int col;
+    
+    /** */ private int rowStride;
+    /** */ private int colStride;
+
+    /**
+     *
+     */
+    public MatrixVectorView() {
+        // No-op.
+    }
+
+    /**
+     * @param parent
+     * @param row
+     * @param col
+     * @param rowStride
+     * @param colStride
+     */
+    public MatrixVectorView(Matrix parent, int row, int col, int rowStride, int colStride) {
+        assert parent != null;
+
+        if (row < 0 || row >= parent.rowSize())
+            throw new IndexException(row);
+        if (col < 0 || col >= parent.columnSize())
+            throw new IndexException(col);
+
+        this.parent = parent;
+
+        this.row = row;
+        this.col = col;
+
+        this.rowStride = rowStride;
+        this.colStride = colStride;
+
+        setStorage(new MatrixVectorStorage(parent, row, col, rowStride, colStride));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector copy() {
+        return new MatrixVectorView(parent, row, col, rowStride, colStride);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        return parent.likeVector(crd);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        return parent.like(rows, cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        super.writeExternal(out);
+
+        out.writeObject(parent);
+        out.writeInt(row);
+        out.writeInt(col);
+        out.writeInt(rowStride);
+        out.writeInt(colStride);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        super.readExternal(in);
+
+        parent = (Matrix)in.readObject();
+        row = in.readInt();
+        col = in.readInt();
+        rowStride = in.readInt();
+        colStride = in.readInt();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + (parent == null ? 0 : parent.hashCode());
+        res = res * 37 + row;
+        res = res * 37 + col;
+        res = res * 37 + rowStride;
+        res = res * 37 + colStride;
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        MatrixVectorView that = (MatrixVectorView)o;
+
+        return (parent != null ? parent.equals(that.parent) : that.parent == null) &&
+            row == that.row &&
+            col == that.col &&
+            rowStride == that.rowStride &&
+            colStride == that.colStride;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
new file mode 100644
index 0000000..607bb72
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.Functions;
+import org.apache.ignite.ml.math.impls.storage.vector.PivotedVectorStorage;
+
+/**
+ * Pivoted (index mapped) view over another vector.
+ */
+public class PivotedVectorView extends AbstractVector {
+    /** */ private Vector vec;
+
+    /**
+     * @param vec
+     * @param pivot Mapping from external index to internal.
+     * @param unpivot Mapping from internal index to external.
+     */
+    public PivotedVectorView(Vector vec, int[] pivot, int[] unpivot) {
+        setStorage(new PivotedVectorStorage(vec.getStorage(), pivot, unpivot));
+
+        checkCardinality(pivot);
+        checkCardinality(unpivot);
+
+        this.vec = vec;
+    }
+
+    /**
+     * @param vec
+     * @param pivot
+     */
+    public PivotedVectorView(Vector vec, int[] pivot) {
+        setStorage(new PivotedVectorStorage(vec.getStorage(), pivot));
+
+        checkCardinality(pivot);
+
+        this.vec = vec;
+    }
+
+    /**
+     *
+     *
+     */
+    private PivotedVectorStorage storage() {
+        return (PivotedVectorStorage)getStorage();
+    }
+
+    /**
+     *
+     */
+    public PivotedVectorView() {
+        // No-op.
+    }
+
+    /**
+     *
+     *
+     */
+    public Vector getBaseVector() {
+        return vec;
+    }
+
+    /**
+     * @param i
+     */
+    public int pivot(int i) {
+        return storage().pivot()[i];
+    }
+
+    /**
+     * @param i
+     */
+    public int unpivot(int i) {
+        return storage().unpivot()[i];
+    }
+
+    /**
+     * @param idx
+     */
+    protected Vector.Element makeElement(int idx) {
+        checkIndex(idx);
+
+        // External index.
+        int exIdx = storage().pivot()[idx];
+
+        return new Vector.Element() {
+            /** {@inheritDoc */
+            @Override public double get() {
+                return storageGet(idx);
+            }
+
+            /** {@inheritDoc */
+            @Override public int index() {
+                return exIdx;
+            }
+
+            /** {@inheritDoc */
+            @Override public void set(double val) {
+                storageSet(idx, val);
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector copy() {
+        PivotedVectorStorage sto = storage();
+
+        return new PivotedVectorView(vec, sto.pivot(), sto.unpivot());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        return vec.likeMatrix(rows, cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector times(double x) {
+        if (x == 0.0)
+            return copy().map(Functions.mult(x));
+        else
+            return super.times(x);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        super.writeExternal(out);
+
+        out.writeObject(vec);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        super.readExternal(in);
+
+        vec = (Vector)in.readObject();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
new file mode 100644
index 0000000..08292eb
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Map;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.matrix.RandomMatrix;
+import org.apache.ignite.ml.math.impls.storage.vector.RandomVectorStorage;
+import org.apache.ignite.ml.math.Vector;
+
+/**
+ * Random vector. Each value is taken from {-1,0,1} with roughly equal probability. Note
+ * that by default, the value is determined by a relatively simple hash of the index.
+ */
+public class RandomVector extends AbstractReadOnlyVector {
+    /** */ private boolean fastHash;
+
+    /**
+     * @param size Vector cardinality.
+     * @param fastHash
+     */
+    private VectorStorage mkStorage(int size, boolean fastHash) {
+        this.fastHash = fastHash;
+
+        return new RandomVectorStorage(size, fastHash);
+    }
+
+    /**
+     * @param size
+     * @param fastHash
+     */
+    public RandomVector(int size, boolean fastHash) {
+        setStorage(mkStorage(size, fastHash));
+    }
+
+    /**
+     * @param size
+     */
+    public RandomVector(int size) {
+        this(size, true);
+    }
+
+    /**
+     * @param args
+     */
+    public RandomVector(Map<String, Object> args) {
+        assert args != null;
+
+        if (args.containsKey("size") && args.containsKey("fastHash"))
+            setStorage(mkStorage((int)args.get("size"), (boolean)args.get("fastHash")));
+        else if (args.containsKey("size"))
+            setStorage(mkStorage((int)args.get("size"), true));
+        else
+            throw new UnsupportedOperationException("Invalid constructor argument(s).");
+    }
+
+    /** */
+    public RandomVector() {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        return new RandomVector(crd, fastHash);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        return new RandomMatrix(rows, cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        super.writeExternal(out);
+
+        out.writeBoolean(fastHash);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        super.readExternal(in);
+
+        fastHash = in.readBoolean();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = 1;
+
+        res = res * 37 + Boolean.hashCode(fastHash);
+        res = res * 37 + getStorage().hashCode();
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        RandomVector that = (RandomVector)o;
+        VectorStorage sto = getStorage();
+
+        return fastHash == that.fastHash && (sto != null ? sto.equals(that.getStorage()) : that.getStorage() == null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
new file mode 100644
index 0000000..cae5ca3
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.Map;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorStorage;
+
+/**
+ * Read-write vector holding a single non-zero value at some index.
+ */
+public class SingleElementVector extends AbstractVector {
+    /**
+     *
+     */
+    public SingleElementVector() {
+        // No-op
+    }
+
+    /**
+     * @param size
+     * @param idx
+     * @param val
+     */
+    public SingleElementVector(int size, int idx, double val) {
+        super(new SingleElementVectorStorage(size, idx, val));
+    }
+
+    /**
+     * @param args
+     */
+    public SingleElementVector(Map<String, Object> args) {
+        assert args != null;
+
+        if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
+            int size = (int)args.get("size");
+            int idx = (int)args.get("index");
+            double val = (double)args.get("value");
+
+            setStorage(new SingleElementVectorStorage(size, idx, val));
+        }
+        else
+            throw new UnsupportedOperationException("Invalid constructor argument(s).");
+    }
+
+    /**
+     *
+     *
+     */
+    private SingleElementVectorStorage storage() {
+        return (SingleElementVectorStorage)getStorage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Element minElement() {
+        return makeElement(storage().index());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Element maxElement() {
+        return makeElement(storage().index());
+    }
+
+    /** {@inheritDoc} */
+    @Override public double sum() {
+        return getX(storage().index());
+    }
+
+    /** {@inheritDoc} */
+    @Override public int nonZeroElements() {
+        return isZero(get(storage().index())) ? 0 : 1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        int idx = storage().index();
+
+        return new SingleElementVector(crd, idx, getX(idx));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        throw new UnsupportedOperationException();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVectorView.java
new file mode 100644
index 0000000..0fb4105
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVectorView.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.Functions;
+import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorDelegateStorage;
+
+/**
+ * Single value vector view over another vector.
+ */
+public class SingleElementVectorView extends AbstractVector {
+    /**
+     *
+     */
+    public SingleElementVectorView() {
+        // No-op.
+    }
+
+    /**
+     * @param vec
+     * @param idx
+     */
+    public SingleElementVectorView(Vector vec, int idx) {
+        super(new SingleElementVectorDelegateStorage(vec, idx));
+    }
+
+    /**
+     *
+     *
+     */
+    private SingleElementVectorDelegateStorage storage() {
+        return (SingleElementVectorDelegateStorage)getStorage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector.Element minElement() {
+        return makeElement(storage().index());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector.Element maxElement() {
+        return makeElement(storage().index());
+    }
+
+    /** {@inheritDoc} */
+    @Override public double sum() {
+        return getX(storage().index());
+    }
+
+    /** {@inheritDoc} */
+    @Override public int nonZeroElements() {
+        return isZero(getX(storage().index())) ? 0 : 1;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector copy() {
+        SingleElementVectorDelegateStorage sto = storage();
+
+        return new SingleElementVectorView(sto.delegate(), sto.index());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector times(double x) {
+        if (x == 0.0)
+            return copy().map(Functions.mult(x));
+        else
+            return super.times(x);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        throw new UnsupportedOperationException();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SparseLocalOffHeapVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SparseLocalOffHeapVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SparseLocalOffHeapVector.java
new file mode 100644
index 0000000..fa216ff
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SparseLocalOffHeapVector.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.storage.vector.SparseLocalOffHeapVectorStorage;
+
+/**
+ * Implementation for {@link Vector} assuming sparse logic and local offheap JVM storage.
+ * It is suitable for data sets where local, non-distributed execution is satisfactory and on-heap JVM storage
+ * is not enough to keep the entire data set.
+ * <p>See also: <a href="https://en.wikipedia.org/wiki/Sparse_array">Wikipedia article</a>.</p>
+ */
+public class SparseLocalOffHeapVector extends AbstractVector {
+    /**
+     * @param crd Vector cardinality.
+     */
+    public SparseLocalOffHeapVector(int crd) {
+        setStorage(new SparseLocalOffHeapVectorStorage(crd));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        return new SparseLocalOffHeapVector(crd);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SparseLocalVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SparseLocalVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SparseLocalVector.java
new file mode 100644
index 0000000..d60eea8
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SparseLocalVector.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.matrix.SparseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.impls.storage.vector.SparseLocalOnHeapVectorStorage;
+
+/**
+ * Local on-heap sparse vector based on hash map storage.
+ */
+public class SparseLocalVector extends AbstractVector implements StorageConstants {
+    /**
+     *
+     */
+    public SparseLocalVector() {
+        // No-op.
+    }
+
+    /**
+     * @param size
+     * @param acsMode
+     */
+    public SparseLocalVector(int size, int acsMode) {
+        assertAccessMode(acsMode);
+
+        setStorage(new SparseLocalOnHeapVectorStorage(size, acsMode));
+    }
+
+    /** */
+    private SparseLocalOnHeapVectorStorage storage() {
+        return (SparseLocalOnHeapVectorStorage)getStorage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        SparseLocalOnHeapVectorStorage sto = storage();
+
+        return new SparseLocalVector(crd, sto.getAccessMode());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        return new SparseLocalOnHeapMatrix(rows, cols);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector times(double x) {
+        if (x == 0.0)
+            return assign(0);
+        else
+            return super.times(x);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/VectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/VectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/VectorView.java
new file mode 100644
index 0000000..f3bd4dd
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/VectorView.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.io.Externalizable;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.storage.vector.DelegateVectorStorage;
+
+/**
+ * Implements the partial view into the parent {@link Vector}.
+ */
+public class VectorView extends AbstractVector {
+    /**
+     * Constructor for {@link Externalizable} interface.
+     */
+    public VectorView() {
+        // No-op.
+    }
+
+    /**
+     * @param parent Backing parent {@link Vector}.
+     * @param off Offset to parent vector.
+     * @param len Size of the view.
+     */
+    public VectorView(Vector parent, int off, int len) {
+        super(new DelegateVectorStorage(parent.getStorage(), off, len));
+    }
+
+    /**
+     * @param sto Backing parent {@link VectorStorage}.
+     * @param off Offset to parent vector.
+     * @param len Size of the view.
+     */
+    public VectorView(VectorStorage sto, int off, int len) {
+        super(new DelegateVectorStorage(sto, off, len));
+    }
+
+    /** */
+    private DelegateVectorStorage storage() {
+        return (DelegateVectorStorage)getStorage();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector copy() {
+        DelegateVectorStorage sto = storage();
+
+        return new VectorView(sto.delegate(), sto.offset(), sto.length());
+    }
+
+    /** {@inheritDoc} */
+    @Override public Vector like(int crd) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Matrix likeMatrix(int rows, int cols) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        return this == o ||
+            ((o != null)
+                && o.getClass() == getClass()
+                && (getStorage().equals(((VectorView)o).getStorage())));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/package-info.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/package-info.java
new file mode 100644
index 0000000..b7f485c
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Contains specific implementations for vectors.
+ */
+package org.apache.ignite.ml.math.impls.vector;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/package-info.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/package-info.java
new file mode 100644
index 0000000..5887d4b
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Contains main APIs for distributed code algebra.
+ */
+package org.apache.ignite.ml.math;
\ No newline at end of file


[10/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/decompositions/SingularValueDecompositionTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/decompositions/SingularValueDecompositionTest.java b/modules/ml/src/test/java/org/apache/ignite/math/decompositions/SingularValueDecompositionTest.java
deleted file mode 100644
index d0b89f8..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/decompositions/SingularValueDecompositionTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.decompositions;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.math.impls.matrix.PivotedMatrixView;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/** */
-public class SingularValueDecompositionTest {
-    /** */
-    @Test
-    public void basicTest() {
-        basicTest(new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d, 0.0d},
-            {-1.0d, 2.0d, -1.0d},
-            {0.0d, -1.0d, 2.0d}
-        }));
-    }
-
-    /**
-     * Test for {@link DecompositionSupport} features.
-     */
-    @Test
-    public void decompositionSupportTest() {
-        basicTest(new PivotedMatrixView(new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d, 0.0d},
-            {-1.0d, 2.0d, -1.0d},
-            {0.0d, -1.0d, 2.0d}
-        })));
-    }
-
-    /** */
-    @Test
-    public void rowsLessThanColumnsTest() {
-        DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(new double[][] {
-            {2.0d, -1.0d, 0.0d},
-            {-1.0d, 2.0d, -1.0d}
-        });
-
-        SingularValueDecomposition dec = new SingularValueDecomposition(m);
-        assertEquals("Unexpected value for singular values size.",
-            2, dec.getSingularValues().length);
-
-        Matrix s = dec.getS();
-        Matrix u = dec.getU();
-        Matrix v = dec.getV();
-        Matrix covariance = dec.getCovariance(0.5);
-
-        assertNotNull("Matrix s is expected to be not null.", s);
-        assertNotNull("Matrix u is expected to be not null.", u);
-        assertNotNull("Matrix v is expected to be not null.", v);
-        assertNotNull("Covariance matrix is expected to be not null.", covariance);
-
-        dec.destroy();
-    }
-
-    /** */
-    @Test(expected = AssertionError.class)
-    public void nullMatrixTest() {
-        new SingularValueDecomposition(null);
-    }
-
-    /** */
-    private void basicTest(Matrix m) {
-        SingularValueDecomposition dec = new SingularValueDecomposition(m);
-        assertEquals("Unexpected value for singular values size.",
-            3, dec.getSingularValues().length);
-
-        Matrix s = dec.getS();
-        Matrix u = dec.getU();
-        Matrix v = dec.getV();
-        Matrix covariance = dec.getCovariance(0.5);
-
-        assertNotNull("Matrix s is expected to be not null.", s);
-        assertNotNull("Matrix u is expected to be not null.", u);
-        assertNotNull("Matrix v is expected to be not null.", v);
-        assertNotNull("Covariance matrix is expected to be not null.", covariance);
-
-        assertTrue("Decomposition cond is expected to be positive.", dec.cond() > 0);
-        assertTrue("Decomposition norm2 is expected to be positive.", dec.norm2() > 0);
-        assertEquals("Decomposition rank differs from expected.", 3, dec.rank());
-        assertEquals("Decomposition singular values size differs from expected.",
-            3, dec.getSingularValues().length);
-
-        Matrix recomposed = (u.times(s).times(v.transpose()));
-
-        for (int row = 0; row < m.rowSize(); row++)
-            for (int col = 0; col < m.columnSize(); col++)
-                assertEquals("Unexpected recomposed matrix value at (" + row + "," + col + ").",
-                    m.get(row, col), recomposed.get(row, col), 0.001);
-
-        for (int row = 0; row < covariance.rowSize(); row++)
-            for (int col = row + 1; col < covariance.columnSize(); col++)
-                assertEquals("Unexpected covariance matrix value at (" + row + "," + col + ").",
-                    covariance.get(row, col), covariance.get(col, row), 0.001);
-
-        dec.destroy();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/MathTestConstants.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/MathTestConstants.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/MathTestConstants.java
deleted file mode 100644
index 122c62e..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/MathTestConstants.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls;
-
-/**
- * Collect constants for org.apache.ignite.math tests
- */
-public interface MathTestConstants {
-    /** */
-    public double SECOND_ARG = 1d;
-
-    /**
-     * We assume that we will check calculation precision in other tests.
-     */
-    public double EXP_DELTA = 0.1d;
-
-    /** */
-    public String UNEXPECTED_VAL = "Unexpected value.";
-
-    /** */
-    public String NULL_GUID = "Null GUID.";
-
-    /** */
-    public String UNEXPECTED_GUID_VAL = "Unexpected GUID value.";
-
-    /** */
-    public String EMPTY_GUID = "Empty GUID.";
-
-    /** */
-    public String VALUES_SHOULD_BE_NOT_EQUALS = "Values should be not equals.";
-
-    /** */
-    public String NULL_VAL = "Null value.";
-
-    /** */
-    public String NULL_VALUES = "Null values.";
-
-    /** */
-    public String NOT_NULL_VAL = "Not null value.";
-
-    /** */
-    public double TEST_VAL = 1d;
-
-    /** */
-    public String VAL_NOT_EQUALS = "Values not equals.";
-
-    /** */
-    public String NO_NEXT_ELEMENT = "No next element.";
-
-    /** */
-    public int STORAGE_SIZE = 100;
-
-    /** */
-    public String WRONG_ATTRIBUTE_VAL = "Wrong attribute value.";
-
-    /** */
-    public String NULL_DATA_ELEMENT = "Null data element.";
-
-    /** */
-    public String WRONG_DATA_ELEMENT = "Wrong data element.";
-
-    /** */
-    public double NIL_DELTA = 0d;
-
-    /** */
-    public String NULL_DATA_STORAGE = "Null data storage.";
-
-    /** */
-    public String WRONG_DATA_SIZE = "Wrong data size.";
-
-    /** */
-    public String UNEXPECTED_DATA_VAL = "Unexpected data value.";
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/CacheMatrixTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/CacheMatrixTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/CacheMatrixTest.java
deleted file mode 100644
index 8a6d077..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/CacheMatrixTest.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.math.ExternalizeTest;
-import org.apache.ignite.math.IdentityValueMapper;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.MatrixKeyMapper;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.apache.ignite.testframework.junits.common.GridCommonTest;
-
-/**
- * Tests for {@link CacheMatrix}.
- */
-@GridCommonTest(group = "Distributed Models")
-public class CacheMatrixTest extends GridCommonAbstractTest {
-    /** Number of nodes in grid */
-    private static final int NODE_COUNT = 3;
-    /** Cache name. */
-    private static final String CACHE_NAME = "test-cache";
-    /** */
-    private static final String UNEXPECTED_ATTRIBUTE_VALUE = "Unexpected attribute value.";
-    /** Grid instance. */
-    private Ignite ignite;
-    /** Matrix rows */
-    private final int rows = MathTestConstants.STORAGE_SIZE;
-    /** Matrix cols */
-    private final int cols = MathTestConstants.STORAGE_SIZE;
-
-    /**
-     * Default constructor.
-     */
-    public CacheMatrixTest() {
-        super(false);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        for (int i = 1; i <= NODE_COUNT; i++)
-            startGrid(i);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        stopAllGrids();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override protected void beforeTest() throws Exception {
-        ignite = grid(NODE_COUNT);
-
-        ignite.configuration().setPeerClassLoadingEnabled(true);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        ignite.destroyCache(CACHE_NAME);
-    }
-
-    /** */
-    public void testGetSet() throws Exception {
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        for (int i = 0; i < rows; i++) {
-            for (int j = 0; j < cols; j++) {
-                double v = Math.random();
-                cacheMatrix.set(i, j, v);
-
-                assert Double.compare(v, cacheMatrix.get(i, j)) == 0;
-                assert Double.compare(v, cache.get(keyMapper.apply(i, j))) == 0;
-            }
-        }
-    }
-
-    /** */
-    public void testCopy() throws Exception {
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        fillMatrix(cacheMatrix);
-
-        try {
-            cacheMatrix.copy();
-
-            fail("UnsupportedOperationException expected");
-        }
-        catch (UnsupportedOperationException e) {
-            // No-op.
-        }
-    }
-
-    /** */
-    public void testLike() throws Exception {
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        try {
-            cacheMatrix.like(rows, cols);
-
-            fail("UnsupportedOperationException expected");
-        }
-        catch (UnsupportedOperationException e) {
-            // No-op.
-        }
-    }
-
-    /** */
-    public void testLikeVector() throws Exception {
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        try {
-            cacheMatrix.likeVector(cols);
-
-            fail("UnsupportedOperationException expected");
-        }
-        catch (UnsupportedOperationException e) {
-            // No-op.
-        }
-    }
-
-    /** */
-    public void testPlus() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        double plusVal = 2;
-
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        initMatrix(cacheMatrix);
-
-        cacheMatrix.plus(plusVal);
-
-        for (int i = 0; i < rows; i++)
-            for (int j = 0; j < cols; j++)
-                assertEquals(plusVal, cacheMatrix.get(i, j));
-    }
-
-    /** */
-    public void testDivide() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        double initVal = 1;
-        double divVal = 2;
-
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        initMatrix(cacheMatrix);
-        cacheMatrix.assign(initVal);
-        cacheMatrix.divide(divVal);
-
-        for (int i = 0; i < rows; i++)
-            for (int j = 0; j < cols; j++)
-                assertTrue(Double.compare(cacheMatrix.get(i, j), initVal / divVal) == 0);
-    }
-
-    /** */
-    public void testTimes() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        double initVal = 1;
-        double timVal = 2;
-
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        initMatrix(cacheMatrix);
-        cacheMatrix.assign(initVal);
-        cacheMatrix.times(timVal);
-
-        for (int i = 0; i < rows; i++)
-            for (int j = 0; j < cols; j++)
-                assertTrue(Double.compare(cacheMatrix.get(i, j), initVal * timVal) == 0);
-    }
-
-    /** */
-    public void testSum() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        double initVal = 1;
-
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        double sum = 0;
-
-        initMatrix(cacheMatrix);
-        sum = cacheMatrix.sum();
-
-        assertTrue(Double.compare(sum, 0d) == 0);
-
-        cacheMatrix.assign(1d);
-        sum = cacheMatrix.sum();
-
-        assertTrue(Double.compare(sum, rows * cols) == 0);
-    }
-
-    /** */
-    public void testAssignSingleValue() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        double initVal = 1;
-
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        initMatrix(cacheMatrix);
-
-        cacheMatrix.assign(initVal);
-
-        for (int i = 0; i < rows; i++)
-            for (int j = 0; j < cols; j++)
-                assertEquals(initVal, cacheMatrix.get(i, j));
-    }
-
-    /** */
-    public void testAssignArray() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        double[][] initVal = new double[rows][cols];
-
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        for (int i = 0; i < rows; i++)
-            for (int j = 0; j < cols; j++)
-                initVal[i][j] = Math.random();
-
-        cacheMatrix.assign(initVal);
-
-        for (int i = 0; i < rows; i++)
-            for (int j = 0; j < cols; j++)
-                assertEquals(initVal[i][j], cacheMatrix.get(i, j));
-    }
-
-    /** */
-    public void testAttributes() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        assertFalse(UNEXPECTED_ATTRIBUTE_VALUE, cacheMatrix.isSequentialAccess());
-        assertFalse(UNEXPECTED_ATTRIBUTE_VALUE, cacheMatrix.isDense());
-        assertFalse(UNEXPECTED_ATTRIBUTE_VALUE, cacheMatrix.isArrayBased());
-        assertTrue(UNEXPECTED_ATTRIBUTE_VALUE, cacheMatrix.isRandomAccess());
-        assertTrue(UNEXPECTED_ATTRIBUTE_VALUE, cacheMatrix.isDistributed());
-    }
-
-    /** */
-    public void testExternalization() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        final CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        ExternalizeTest<CacheMatrix<Integer, Double>> externalizeTest = new ExternalizeTest<CacheMatrix<Integer, Double>>() {
-
-            @Override public void externalizeTest() {
-                super.externalizeTest(cacheMatrix);
-            }
-        };
-
-        externalizeTest.externalizeTest();
-    }
-
-    /** */
-    public void testMinMax() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        final CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        for (int i = 0; i < rows; i++)
-            for (int j = 0; j < cols; j++)
-                cacheMatrix.set(i, j, i * rows + j);
-
-        assertEquals(0.0, cacheMatrix.minValue(), 0.0);
-        assertEquals(rows * cols - 1, cacheMatrix.maxValue(), 0.0);
-    }
-
-    /** */
-    public void testMap() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
-        IgniteCache<Integer, Double> cache = getCache();
-        final CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
-
-        initMatrix(cacheMatrix);
-
-        cacheMatrix.map(value -> value + 10);
-
-        for (int i = 0; i < rows; i++)
-            for (int j = 0; j < cols; j++)
-                assertEquals(10.0, cacheMatrix.getX(i, j), 0.0);
-    }
-
-    /** */
-    private IgniteCache<Integer, Double> getCache() {
-        assert ignite != null;
-
-        CacheConfiguration cfg = new CacheConfiguration();
-        cfg.setName(CACHE_NAME);
-
-        IgniteCache<Integer, Double> cache = ignite.getOrCreateCache(CACHE_NAME);
-
-        assert cache != null;
-        return cache;
-    }
-
-    /** */
-    private MatrixKeyMapper<Integer> getKeyMapper(final int rows, final int cols) {
-        return new MatrixKeyMapperForTests(rows, cols);
-    }
-
-    /** Init the given matrix by random values. */
-    private void fillMatrix(Matrix m) {
-        for (int i = 0; i < m.rowSize(); i++)
-            for (int j = 0; j < m.columnSize(); j++)
-                m.set(i, j, Math.random());
-    }
-
-    /** Init the given matrix by zeros. */
-    private void initMatrix(Matrix m) {
-        for (int i = 0; i < m.rowSize(); i++)
-            for (int j = 0; j < m.columnSize(); j++)
-                m.set(i, j, 0d);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/DenseLocalOffHeapMatrixConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/DenseLocalOffHeapMatrixConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/DenseLocalOffHeapMatrixConstructorTest.java
deleted file mode 100644
index 1f0537c..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/DenseLocalOffHeapMatrixConstructorTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/** */
-public class DenseLocalOffHeapMatrixConstructorTest {
-    /** */
-    @Test
-    public void invalidArgsTest() {
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DenseLocalOffHeapMatrix(0, 1), "invalid row parameter");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DenseLocalOffHeapMatrix(1, 0), "invalid col parameter");
-
-        //noinspection ConstantConditions
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DenseLocalOffHeapMatrix(null), "null matrix parameter");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DenseLocalOffHeapMatrix(new double[][] {null, new double[1]}),
-            "null row in matrix");
-    }
-
-    /** */
-    @Test
-    public void basicTest() {
-        assertEquals("Expected number of rows, int parameters.", 1,
-            new DenseLocalOffHeapMatrix(1, 2).rowSize());
-
-        assertEquals("Expected number of rows, double[][] parameter.", 1,
-            new DenseLocalOffHeapMatrix(new double[][] {new double[2]}).rowSize());
-
-        assertEquals("Expected number of cols, int parameters.", 1,
-            new DenseLocalOffHeapMatrix(2, 1).columnSize());
-
-        assertEquals("Expected number of cols, double[][] parameter.", 1,
-            new DenseLocalOffHeapMatrix(new double[][] {new double[1], new double[1]}).columnSize());
-
-        double[][] data1 = new double[][] {{1, 2}, {3, 4}}, data2 = new double[][] {{1, 2}, {3, 5}};
-
-        assertTrue("Matrices with same values are expected to be equal",
-            new DenseLocalOffHeapMatrix(data1).equals(new DenseLocalOffHeapMatrix(data1)));
-
-        assertFalse("Matrices with same values are expected to be equal",
-            new DenseLocalOffHeapMatrix(data1).equals(new DenseLocalOffHeapMatrix(data2)));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/DenseLocalOnHeapMatrixConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/DenseLocalOnHeapMatrixConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/DenseLocalOnHeapMatrixConstructorTest.java
deleted file mode 100644
index 0a25e31..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/DenseLocalOnHeapMatrixConstructorTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import java.util.function.Supplier;
-import org.apache.ignite.math.Matrix;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-/** */
-public class DenseLocalOnHeapMatrixConstructorTest {
-    /** */
-    @Test
-    public void invalidArgsTest() {
-        verifyAssertionError(() -> new DenseLocalOnHeapMatrix(0, 1), "invalid row parameter");
-
-        verifyAssertionError(() -> new DenseLocalOnHeapMatrix(1, 0), "invalid col parameter");
-
-        //noinspection ConstantConditions
-        verifyAssertionError(() -> new DenseLocalOnHeapMatrix(null), "null matrix parameter");
-
-        verifyAssertionError(() -> new DenseLocalOnHeapMatrix(new double[][] {null, new double[1]}),
-            "null row in matrix");
-    }
-
-    /** */
-    @Test
-    public void basicTest() {
-        assertEquals("Expected number of rows, int parameters.", 1,
-            new DenseLocalOnHeapMatrix(1, 2).rowSize());
-
-        assertEquals("Expected number of rows, double[][] parameter.", 1,
-            new DenseLocalOnHeapMatrix(new double[][] {new double[2]}).rowSize());
-
-        assertEquals("Expected number of cols, int parameters.", 1,
-            new DenseLocalOnHeapMatrix(2, 1).columnSize());
-
-        assertEquals("Expected number of cols, double[][] parameter.", 1,
-            new DenseLocalOnHeapMatrix(new double[][] {new double[1], new double[1]}).columnSize());
-    }
-
-    /** */
-    static void verifyAssertionError(Supplier<Matrix> ctor, String desc) {
-        try {
-            assertNotNull("Unexpected null matrix in " + desc, ctor.get());
-        }
-        catch (AssertionError ae) {
-            return;
-        }
-
-        fail("Expected error not caught in " + desc);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/DiagonalMatrixTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/DiagonalMatrixTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/DiagonalMatrixTest.java
deleted file mode 100644
index c0c2af7..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/DiagonalMatrixTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.math.ExternalizeTest;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Tests for {@link DiagonalMatrix}.
- */
-public class DiagonalMatrixTest extends ExternalizeTest<DiagonalMatrix> {
-    /** */
-    public static final String UNEXPECTED_VALUE = "Unexpected value";
-
-    /** */
-    private DiagonalMatrix testMatrix;
-
-    /** */
-    @Before
-    public void setup() {
-        DenseLocalOnHeapMatrix parent = new DenseLocalOnHeapMatrix(MathTestConstants.STORAGE_SIZE, MathTestConstants.STORAGE_SIZE);
-        fillMatrix(parent);
-        testMatrix = new DiagonalMatrix(parent);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void externalizeTest() {
-        externalizeTest(testMatrix);
-    }
-
-    /** */
-    @Test
-    public void testSetGetBasic() {
-        double testVal = 42;
-        for (int i = 0; i < MathTestConstants.STORAGE_SIZE; i++) {
-            testMatrix.set(i, i, testVal);
-
-            assertEquals(UNEXPECTED_VALUE + " at (" + i + "," + i + ")", testMatrix.get(i, i), testVal, 0d);
-        }
-
-        //noinspection EqualsWithItself
-        assertTrue("Matrix is expected to be equal to self.", testMatrix.equals(testMatrix));
-        //noinspection ObjectEqualsNull
-        assertFalse("Matrix is expected to be not equal to null.", testMatrix.equals(null));
-    }
-
-    /** */
-    @Test
-    public void testSetGet() {
-        verifyDiagonal(testMatrix);
-
-        final int size = MathTestConstants.STORAGE_SIZE;
-
-        for (Matrix m : new Matrix[] {
-            new DenseLocalOnHeapMatrix(size + 1, size),
-            new DenseLocalOnHeapMatrix(size, size + 1)}) {
-            fillMatrix(m);
-
-            verifyDiagonal(new DiagonalMatrix(m));
-        }
-
-        final double[] data = new double[size];
-
-        for (int i = 0; i < size; i++)
-            data[i] = 1 + i;
-
-        final Matrix m = new DiagonalMatrix(new DenseLocalOnHeapVector(data));
-
-        assertEquals("Rows in matrix constructed from vector", size, m.rowSize());
-        assertEquals("Cols in matrix constructed from vector", size, m.columnSize());
-
-        for (int i = 0; i < size; i++)
-            assertEquals(UNEXPECTED_VALUE + " at vector index " + i, data[i], m.get(i, i), 0d);
-
-        verifyDiagonal(m);
-
-        final Matrix m1 = new DiagonalMatrix(data);
-
-        assertEquals("Rows in matrix constructed from array", size, m1.rowSize());
-        assertEquals("Cols in matrix constructed from array", size, m1.columnSize());
-
-        for (int i = 0; i < size; i++)
-            assertEquals(UNEXPECTED_VALUE + " at array index " + i, data[i], m1.get(i, i), 0d);
-
-        verifyDiagonal(m1);
-    }
-
-    /** */
-    @Test
-    public void testConstant() {
-        final int size = MathTestConstants.STORAGE_SIZE;
-
-        for (double val : new double[] {-1.0, 0.0, 1.0}) {
-            Matrix m = new DiagonalMatrix(size, val);
-
-            assertEquals("Rows in matrix", size, m.rowSize());
-            assertEquals("Cols in matrix", size, m.columnSize());
-
-            for (int i = 0; i < size; i++)
-                assertEquals(UNEXPECTED_VALUE + " at index " + i, val, m.get(i, i), 0d);
-
-            verifyDiagonal(m, true);
-        }
-    }
-
-    /** */
-    @Test
-    public void testAttributes() {
-        assertTrue(UNEXPECTED_VALUE, testMatrix.rowSize() == MathTestConstants.STORAGE_SIZE);
-        assertTrue(UNEXPECTED_VALUE, testMatrix.columnSize() == MathTestConstants.STORAGE_SIZE);
-
-        assertFalse(UNEXPECTED_VALUE, testMatrix.isArrayBased());
-        assertTrue(UNEXPECTED_VALUE, testMatrix.isDense());
-        assertFalse(UNEXPECTED_VALUE, testMatrix.isDistributed());
-
-        assertEquals(UNEXPECTED_VALUE, testMatrix.isRandomAccess(), !testMatrix.isSequentialAccess());
-        assertTrue(UNEXPECTED_VALUE, testMatrix.isRandomAccess());
-    }
-
-    /** */
-    @Test
-    public void testNullParams() {
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DiagonalMatrix((Matrix)null), "Null Matrix parameter");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DiagonalMatrix((Vector)null), "Null Vector parameter");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DiagonalMatrix((double[])null), "Null double[] parameter");
-    }
-
-    /** */
-    private void verifyDiagonal(Matrix m, boolean readonly) {
-        final int rows = m.rowSize(), cols = m.columnSize();
-
-        final String sizeDetails = "rows" + "X" + "cols " + rows + "X" + cols;
-
-        for (int i = 0; i < rows; i++)
-            for (int j = 0; j < cols; j++) {
-                final String details = " at (" + i + "," + j + "), " + sizeDetails;
-
-                final boolean diagonal = i == j;
-
-                final double old = m.get(i, j);
-
-                if (!diagonal)
-                    assertEquals(UNEXPECTED_VALUE + details, 0, old, 0d);
-
-                final double exp = diagonal && !readonly ? old + 1 : old;
-
-                boolean expECaught = false;
-
-                try {
-                    m.set(i, j, exp);
-                }
-                catch (UnsupportedOperationException uoe) {
-                    if (diagonal && !readonly)
-                        throw uoe;
-
-                    expECaught = true;
-                }
-
-                if ((!diagonal || readonly) && !expECaught)
-                    fail("Expected exception was not caught " + details);
-
-                assertEquals(UNEXPECTED_VALUE + details, exp, m.get(i, j), 0d);
-            }
-    }
-
-    /** */
-    private void verifyDiagonal(Matrix m) {
-        verifyDiagonal(m, false);
-    }
-
-    /** */
-    private void fillMatrix(Matrix m) {
-        final int rows = m.rowSize(), cols = m.columnSize();
-
-        boolean negative = false;
-
-        for (int i = 0; i < rows; i++)
-            for (int j = 0; j < cols; j++)
-                m.set(i, j, (negative = !negative) ? -(i * cols + j + 1) : i * cols + j + 1);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/FunctionMatrixConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/FunctionMatrixConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/FunctionMatrixConstructorTest.java
deleted file mode 100644
index a5ac84a..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/FunctionMatrixConstructorTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/** */
-public class FunctionMatrixConstructorTest {
-    /** */
-    @Test
-    public void invalidArgsTest() {
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new FunctionMatrix(0, 1, (i, j) -> 0.0),
-            "Invalid row parameter.");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new FunctionMatrix(1, 0, (i, j) -> 0.0),
-            "Invalid col parameter.");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new FunctionMatrix(1, 1, null),
-            "Invalid func parameter.");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new FunctionMatrix(0, 1, (i, j) -> 0.0, null),
-            "Invalid row parameter, with setter func.");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new FunctionMatrix(1, 0, (i, j) -> 0.0, null),
-            "Invalid col parameter, with setter func.");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new FunctionMatrix(1, 1, null, null),
-            "Invalid func parameter, with setter func.");
-    }
-
-    /** */
-    @Test
-    public void basicTest() {
-        for (int rows : new int[] {1, 2, 3})
-            for (int cols : new int[] {1, 2, 3})
-                basicTest(rows, cols);
-
-        Matrix m = new FunctionMatrix(1, 1, (i, j) -> 1d);
-        //noinspection EqualsWithItself
-        assertTrue("Matrix is expected to be equal to self.", m.equals(m));
-        //noinspection ObjectEqualsNull
-        assertFalse("Matrix is expected to be not equal to null.", m.equals(null));
-    }
-
-    /** */
-    private void basicTest(int rows, int cols) {
-        double[][] data = new double[rows][cols];
-
-        for (int row = 0; row < rows; row++)
-            for (int col = 0; col < cols; col++)
-                data[row][col] = row * cols + row;
-
-        Matrix mReadOnly = new FunctionMatrix(rows, cols, (i, j) -> data[i][j]);
-
-        assertEquals("Rows in matrix.", rows, mReadOnly.rowSize());
-        assertEquals("Cols in matrix.", cols, mReadOnly.columnSize());
-
-        for (int row = 0; row < rows; row++)
-            for (int col = 0; col < cols; col++) {
-                assertEquals("Unexpected value at " + row + "x" + col, data[row][col], mReadOnly.get(row, col), 0d);
-
-                boolean expECaught = false;
-
-                try {
-                    mReadOnly.set(row, col, 0.0);
-                }
-                catch (UnsupportedOperationException uoe) {
-                    expECaught = true;
-                }
-
-                assertTrue("Expected exception wasn't thrown at " + row + "x" + col, expECaught);
-            }
-
-        Matrix m = new FunctionMatrix(rows, cols, (i, j) -> data[i][j], (i, j, val) -> data[i][j] = val);
-
-        assertEquals("Rows in matrix, with setter function.", rows, m.rowSize());
-        assertEquals("Cols in matrix, with setter function.", cols, m.columnSize());
-
-        for (int row = 0; row < rows; row++)
-            for (int col = 0; col < cols; col++) {
-                assertEquals("Unexpected value at " + row + "x" + col, data[row][col], m.get(row, col), 0d);
-
-                m.set(row, col, -data[row][col]);
-            }
-
-        for (int row = 0; row < rows; row++)
-            for (int col = 0; col < cols; col++)
-                assertEquals("Unexpected value set at " + row + "x" + col, -(row * cols + row), m.get(row, col), 0d);
-
-        assertTrue("Incorrect copy for empty matrix.", m.copy().equals(m));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixAttributeTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixAttributeTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixAttributeTest.java
deleted file mode 100644
index c9fb390..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixAttributeTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.function.Function;
-import org.apache.ignite.math.Matrix;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Attribute tests for matrices.
- *
- * TODO: WIP
- */
-public class MatrixAttributeTest {
-    /** */
-    private final List<MatrixAttributeTest.AttrCfg> attrCfgs = Arrays.asList(
-        new AttrCfg("isDense", Matrix::isDense,
-            DenseLocalOnHeapMatrix.class, DenseLocalOffHeapMatrix.class, RandomMatrix.class, DiagonalMatrix.class),
-        new AttrCfg("isArrayBased", Matrix::isArrayBased, DenseLocalOnHeapMatrix.class),
-        new AttrCfg("isDistributed", Matrix::isDistributed),
-        new AttrCfg("isRandomAccess", Matrix::isRandomAccess, DenseLocalOnHeapMatrix.class, DenseLocalOffHeapMatrix.class, RandomMatrix.class, DiagonalMatrix.class, SparseLocalOnHeapMatrix.class),
-        new AttrCfg("isSequentialAccess", Matrix::isSequentialAccess, DiagonalMatrix.class)
-    );
-
-    /** */
-    private final List<MatrixAttributeTest.Specification> specFixture = Arrays.asList(
-        new Specification(new DenseLocalOnHeapMatrix(1, 1)),
-        new Specification(new DenseLocalOffHeapMatrix(1, 1)),
-        new Specification(new RandomMatrix(1, 1)),
-        new Specification(new DiagonalMatrix(new double[] {1.0})),
-        new Specification(new FunctionMatrix(1, 1, (x, y) -> 1.0)),
-        new Specification(new SparseLocalOnHeapMatrix(1, 1))
-    );
-
-    /** */
-    @Test
-    public void isDenseTest() {
-        assertAttribute("isDense");
-    }
-
-    /** */
-    @Test
-    public void isArrayBasedTest() {
-        assertAttribute("isArrayBased");
-    }
-
-    /** */
-    @Test
-    public void isSequentialAccessTest() {
-        assertAttribute("isSequentialAccess");
-    }
-
-    /** */
-    @Test
-    public void isRandomAccessTest() {
-        assertAttribute("isRandomAccess");
-    }
-
-    /** */
-    @Test
-    public void isDistributedTest() {
-        assertAttribute("isDistributed");
-    }
-
-    /** */
-    private void assertAttribute(String name) {
-        final MatrixAttributeTest.AttrCfg attr = attrCfg(name);
-
-        for (MatrixAttributeTest.Specification spec : specFixture)
-            spec.verify(attr);
-    }
-
-    /** */
-    private MatrixAttributeTest.AttrCfg attrCfg(String name) {
-        for (MatrixAttributeTest.AttrCfg attr : attrCfgs)
-            if (attr.name.equals(name))
-                return attr;
-
-        throw new IllegalArgumentException("Undefined attribute " + name);
-    }
-
-    /** See http://en.wikipedia.org/wiki/Specification_pattern */
-    private static class Specification {
-        /** */
-        private final Matrix m;
-        /** */
-        private final Class<? extends Matrix> underlyingType;
-        /** */
-        private final List<String> attrsFromUnderlying;
-        /** */
-        final String desc;
-
-        /** */
-        Specification(Matrix m, Class<? extends Matrix> underlyingType, String... attrsFromUnderlying) {
-            this.m = m;
-            this.underlyingType = underlyingType;
-            this.attrsFromUnderlying = Arrays.asList(attrsFromUnderlying);
-            final Class<? extends Matrix> clazz = m.getClass();
-            desc = clazz.getSimpleName() + (clazz.equals(underlyingType)
-                ? "" : " (underlying type " + underlyingType.getSimpleName() + ")");
-        }
-
-        /** */
-        Specification(Matrix m) {
-            this(m, m.getClass());
-        }
-
-        /** */
-        void verify(MatrixAttributeTest.AttrCfg attr) {
-            final boolean obtained = attr.obtain.apply(m);
-
-            final Class<? extends Matrix> typeToCheck
-                = attrsFromUnderlying.contains(attr.name) ? underlyingType : m.getClass();
-
-            final boolean exp = attr.trueInTypes.contains(typeToCheck);
-
-            assertEquals("Unexpected " + attr.name + " value for " + desc, exp, obtained);
-        }
-    }
-
-    /** */
-    private static class AttrCfg {
-        /** */
-        final String name;
-        /** */
-        final Function<Matrix, Boolean> obtain;
-        /** */
-        final List<Class> trueInTypes;
-
-        /** */
-        AttrCfg(String name, Function<Matrix, Boolean> obtain, Class... trueInTypes) {
-            this.name = name;
-            this.obtain = obtain;
-            this.trueInTypes = Arrays.asList(trueInTypes);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixImplementationFixtures.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixImplementationFixtures.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixImplementationFixtures.java
deleted file mode 100644
index 88aa4fe..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixImplementationFixtures.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.function.BiConsumer;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import java.util.function.Supplier;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.impls.storage.matrix.FunctionMatrixStorage;
-import org.jetbrains.annotations.NotNull;
-
-/** */
-class MatrixImplementationFixtures {
-    /** */
-    private static final List<Supplier<Iterable<Matrix>>> suppliers = Arrays.asList(
-        (Supplier<Iterable<Matrix>>)DenseLocalOnHeapMatrixFixture::new,
-        (Supplier<Iterable<Matrix>>)DenseLocalOffHeapMatrixFixture::new,
-        (Supplier<Iterable<Matrix>>)RandomMatrixFixture::new,
-        (Supplier<Iterable<Matrix>>)SparseLocalOnHeapMatrixFixture::new,
-        (Supplier<Iterable<Matrix>>)PivotedMatrixViewFixture::new,
-        (Supplier<Iterable<Matrix>>)MatrixViewFixture::new,
-        (Supplier<Iterable<Matrix>>)FunctionMatrixFixture::new,
-        (Supplier<Iterable<Matrix>>)DiagonalMatrixFixture::new,
-        (Supplier<Iterable<Matrix>>)TransposedMatrixViewFixture::new
-    );
-
-    /** */
-    void consumeSampleMatrix(BiConsumer<Matrix, String> consumer) {
-        for (Supplier<Iterable<Matrix>> fixtureSupplier : suppliers) {
-            final Iterable<Matrix> fixture = fixtureSupplier.get();
-
-            for (Matrix matrix : fixture) {
-                consumer.accept(matrix, fixture.toString());
-
-                matrix.destroy();
-            }
-        }
-    }
-
-    /** */
-    private static class DenseLocalOnHeapMatrixFixture extends MatrixSizeIterator {
-        /** */
-        DenseLocalOnHeapMatrixFixture() {
-            super(DenseLocalOnHeapMatrix::new, "DenseLocalOnHeapMatrix");
-        }
-    }
-
-    /** */
-    private static class DenseLocalOffHeapMatrixFixture extends MatrixSizeIterator {
-        /** */
-        DenseLocalOffHeapMatrixFixture() {
-            super(DenseLocalOffHeapMatrix::new, "DenseLocalOffHeapMatrix");
-        }
-    }
-
-    /** */
-    private static class RandomMatrixFixture extends MatrixSizeIterator {
-        /** */
-        RandomMatrixFixture() {
-            super(RandomMatrix::new, "RandomMatrix");
-        }
-    }
-
-    /** */
-    private static class SparseLocalOnHeapMatrixFixture extends MatrixSizeIterator {
-        /** */
-        SparseLocalOnHeapMatrixFixture() {
-            super(SparseLocalOnHeapMatrix::new, "SparseLocalOnHeapMatrix");
-        }
-    }
-
-    /** */
-    private static class PivotedMatrixViewFixture extends WrapperMatrixIterator {
-        /** */
-        PivotedMatrixViewFixture() {
-            super(PivotedMatrixView::new, "PivotedMatrixView over DenseLocalOnHeapMatrix");
-        }
-    }
-
-    /** */
-    private static class MatrixViewFixture extends WrapperMatrixIterator {
-        /** */
-        MatrixViewFixture() {
-            super((matrix) -> new MatrixView(matrix, 0, 0, matrix.rowSize(), matrix.columnSize()),
-                "MatrixView over DenseLocalOnHeapMatrix");
-        }
-    }
-
-    /** */
-    private static class FunctionMatrixFixture extends WrapperMatrixIterator {
-        /** */
-        FunctionMatrixFixture() {
-            super(FunctionMatrixForTest::new, "FunctionMatrix wrapping DenseLocalOnHeapMatrix");
-        }
-    }
-
-    /** */
-    private static class DiagonalMatrixFixture extends DiagonalIterator {
-        /** */
-        DiagonalMatrixFixture() {
-            super(DenseLocalOnHeapMatrix::new, "DiagonalMatrix over DenseLocalOnHeapMatrix");
-        }
-
-        /** {@inheritDoc} */
-        @NotNull
-        @Override public Iterator<Matrix> iterator() {
-            return new Iterator<Matrix>() {
-                /** {@inheritDoc} */
-                @Override public boolean hasNext() {
-                    return hasNextSize(getSizeIdx());
-                }
-
-                /** {@inheritDoc} */
-                @Override public Matrix next() {
-                    assert getSize(getSizeIdx()) == 1 : "Only size 1 allowed for diagonal matrix fixture.";
-
-                    Matrix matrix = getConstructor().apply(getSize(getSizeIdx()), getSize(getSizeIdx()));
-
-                    nextIdx();
-
-                    return new DiagonalMatrix(matrix);
-                }
-            };
-        }
-    }
-
-    /** */
-    private static class TransposedMatrixViewFixture extends WrapperMatrixIterator {
-        /** */
-        TransposedMatrixViewFixture() {
-            super(TransposedMatrixView::new, "TransposedMatrixView over DenseLocalOnHeapMatrix");
-        }
-    }
-
-    /** */
-    private static abstract class DiagonalIterator implements Iterable<Matrix> {
-        /** */
-        private final Integer[] sizes = new Integer[] {1, null};
-        /** */
-        private int sizeIdx = 0;
-
-        /** */
-        private BiFunction<Integer, Integer, ? extends Matrix> constructor;
-        /** */
-        private String desc;
-
-        /** */
-        DiagonalIterator(BiFunction<Integer, Integer, ? extends Matrix> constructor, String desc) {
-            this.constructor = constructor;
-            this.desc = desc;
-        }
-
-        /** */
-        public BiFunction<Integer, Integer, ? extends Matrix> getConstructor() {
-            return constructor;
-        }
-
-        /** */
-        int getSizeIdx() {
-            return sizeIdx;
-        }
-
-        /** */
-        @Override public String toString() {
-            return desc + "{rows=" + sizes[sizeIdx] + ", cols=" + sizes[sizeIdx] + "}";
-        }
-
-        /** */
-        boolean hasNextSize(int idx) {
-            return sizes[idx] != null;
-        }
-
-        /** */
-        Integer getSize(int idx) {
-            return sizes[idx];
-        }
-
-        /** */
-        void nextIdx() {
-            sizeIdx++;
-        }
-    }
-
-    /** */
-    private static class WrapperMatrixIterator extends MatrixSizeIterator {
-        /** */
-        private final Function<Matrix, Matrix> wrapperCtor;
-
-        /** */
-        WrapperMatrixIterator(Function<Matrix, Matrix> wrapperCtor, String desc) {
-            super(DenseLocalOnHeapMatrix::new, desc);
-
-            this.wrapperCtor = wrapperCtor;
-        }
-
-        /** {@inheritDoc} */
-        @NotNull
-        @Override public Iterator<Matrix> iterator() {
-            return new Iterator<Matrix>() {
-                /** {@inheritDoc} */
-                @Override public boolean hasNext() {
-                    return hasNextCol(getSizeIdx()) && hasNextRow(getSizeIdx());
-                }
-
-                /** {@inheritDoc} */
-                @Override public Matrix next() {
-                    Matrix matrix = getConstructor().apply(getRow(getSizeIdx()), getCol(getSizeIdx()));
-
-                    nextIdx();
-
-                    return wrapperCtor.apply(matrix);
-                }
-            };
-        }
-    }
-
-    /** */
-    private static class MatrixSizeIterator implements Iterable<Matrix> {
-        /** */
-        private final Integer[] rows = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 512, 1024, null};
-        /** */
-        private final Integer[] cols = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1024, 512, null};
-        /** */
-        private int sizeIdx = 0;
-
-        /** */
-        private BiFunction<Integer, Integer, ? extends Matrix> constructor;
-        /** */
-        private String desc;
-
-        /** */
-        MatrixSizeIterator(BiFunction<Integer, Integer, ? extends Matrix> constructor, String desc) {
-            this.constructor = constructor;
-            this.desc = desc;
-        }
-
-        /** */
-        public BiFunction<Integer, Integer, ? extends Matrix> getConstructor() {
-            return constructor;
-        }
-
-        /** */
-        int getSizeIdx() {
-            return sizeIdx;
-        }
-
-        /** */
-        @Override public String toString() {
-            return desc + "{rows=" + rows[sizeIdx] + ", cols=" + cols[sizeIdx] + "}";
-        }
-
-        /** */
-        boolean hasNextRow(int idx) {
-            return rows[idx] != null;
-        }
-
-        /** */
-        boolean hasNextCol(int idx) {
-            return cols[idx] != null;
-        }
-
-        /** */
-        Integer getRow(int idx) {
-            return rows[idx];
-        }
-
-        /** */
-        int getCol(int idx) {
-            return cols[idx];
-        }
-
-        /** {@inheritDoc} */
-        @NotNull
-        @Override public Iterator<Matrix> iterator() {
-            return new Iterator<Matrix>() {
-                /** {@inheritDoc} */
-                @Override public boolean hasNext() {
-                    return hasNextCol(sizeIdx) && hasNextRow(sizeIdx);
-                }
-
-                /** {@inheritDoc} */
-                @Override public Matrix next() {
-                    Matrix matrix = constructor.apply(rows[sizeIdx], cols[sizeIdx]);
-
-                    nextIdx();
-
-                    return matrix;
-                }
-            };
-        }
-
-        /** */
-        void nextIdx() {
-            sizeIdx++;
-        }
-    }
-
-    /** Subclass tweaked for serialization */
-    private static class FunctionMatrixForTest extends FunctionMatrix {
-        /** */
-        Matrix underlying;
-
-        /** */
-        public FunctionMatrixForTest() {
-            // No-op.
-        }
-
-        /** */
-        FunctionMatrixForTest(Matrix underlying) {
-            super(underlying.rowSize(), underlying.columnSize(), underlying::get, underlying::set);
-
-            this.underlying = underlying;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Matrix copy() {
-            return new FunctionMatrixForTest(underlying);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws IOException {
-            super.writeExternal(out);
-
-            out.writeObject(underlying);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-            super.readExternal(in);
-
-            underlying = (Matrix)in.readObject();
-
-            setStorage(new FunctionMatrixStorage(underlying.rowSize(), underlying.columnSize(),
-                underlying::get, underlying::set));
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            int res = 1;
-
-            res = res * 37 + underlying.hashCode();
-
-            return res;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object o) {
-            if (this == o)
-                return true;
-
-            if (o == null || getClass() != o.getClass())
-                return false;
-
-            FunctionMatrixForTest that = (FunctionMatrixForTest)o;
-
-            return underlying != null ? underlying.equals(that.underlying) : that.underlying == null;
-        }
-    }
-}


[65/65] [abbrv] ignite git commit: IGNITE-5024 - Fixing tests

Posted by ag...@apache.org.
IGNITE-5024 - Fixing tests


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

Branch: refs/heads/ignite-5024
Commit: 777bd7763fe534ba88a9834c87f0c297832093c4
Parents: df7da50
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Apr 24 11:21:59 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Apr 24 11:21:59 2017 +0300

----------------------------------------------------------------------
 .../processors/platform/utils/PlatformConfigurationUtils.java | 4 ++--
 .../internal/processors/database/BPlusTreeSelfTest.java       | 7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/777bd776/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index 4186eb9..5fdcc6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -1343,7 +1343,7 @@ public class PlatformConfigurationUtils {
                 MemoryPolicyConfiguration cfg = new MemoryPolicyConfiguration();
 
                 cfg.setName(in.readString())
-                        .setSize(in.readLong())
+                        .setMaxSize(in.readLong())
                         .setSwapFilePath(in.readString())
                         .setPageEvictionMode(DataPageEvictionMode.values()[in.readInt()])
                         .setEvictionThreshold(in.readDouble())
@@ -1384,7 +1384,7 @@ public class PlatformConfigurationUtils {
 
             for (MemoryPolicyConfiguration plc : plcs) {
                 w.writeString(plc.getName());
-                w.writeLong(plc.getSize());
+                w.writeLong(plc.getMaxSize());
                 w.writeString(plc.getSwapFilePath());
                 w.writeInt(plc.getPageEvictionMode().ordinal());
                 w.writeDouble(plc.getEvictionThreshold());

http://git-wip-us.apache.org/repos/asf/ignite/blob/777bd776/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
index bf25349..5f9a3c9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
@@ -31,6 +31,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicLongArray;
 import java.util.concurrent.locks.Lock;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider;
 import org.apache.ignite.internal.pagemem.FullPageId;
@@ -629,7 +630,7 @@ public class BPlusTreeSelfTest extends GridCommonAbstractTest {
 
         Map<Long,Long> map = new HashMap<>();
 
-        int loops = reuseList == null ? 100_000 : 300_000;
+        int loops = reuseList == null ? 20_000 : 60_000;
 
         for (int i = 0 ; i < loops; i++) {
             final Long x = (long)BPlusTree.randomInt(CNT);
@@ -1232,7 +1233,7 @@ public class BPlusTreeSelfTest extends GridCommonAbstractTest {
 
         final Map<Long,Long> map = new ConcurrentHashMap8<>();
 
-        final int loops = reuseList == null ? 100_000 : 200_000;
+        final int loops = reuseList == null ? 20_000 : 60_000;
 
         final GridStripedLock lock = new GridStripedLock(256);
 
@@ -1707,7 +1708,7 @@ public class BPlusTreeSelfTest extends GridCommonAbstractTest {
             new UnsafeMemoryProvider(log),
             null,
             PAGE_SIZE,
-            null,
+            new MemoryPolicyConfiguration().setMaxSize(5 * 1024 * MB),
             new MemoryMetricsImpl(null), true);
 
         pageMem.start();


[35/65] [abbrv] ignite git commit: IGNITE-5043 .NET: CacheConfiguration.WriteBehindCoalescing

Posted by ag...@apache.org.
IGNITE-5043 .NET: CacheConfiguration.WriteBehindCoalescing


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

Branch: refs/heads/ignite-5024
Commit: 217c6be2650fa77e8ba295a682f6549a1e3c2be0
Parents: 800fb87
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Thu Apr 20 19:39:45 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Thu Apr 20 19:39:45 2017 +0300

----------------------------------------------------------------------
 .../platform/utils/PlatformConfigurationUtils.java    |  2 ++
 .../Cache/CacheConfigurationTest.cs                   |  3 +++
 .../IgniteConfigurationSerializerTest.cs              |  4 +++-
 .../Cache/Configuration/CacheConfiguration.cs         | 14 ++++++++++++++
 .../Apache.Ignite.Core/IgniteConfigurationSection.xsd |  7 +++++++
 5 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/217c6be2/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index b79ab4b..0fe537f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -167,6 +167,7 @@ public class PlatformConfigurationUtils {
         ccfg.setWriteBehindFlushFrequency(in.readLong());
         ccfg.setWriteBehindFlushSize(in.readInt());
         ccfg.setWriteBehindFlushThreadCount(in.readInt());
+        ccfg.setWriteBehindCoalescing(in.readBoolean());
         ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.fromOrdinal(in.readInt()));
         ccfg.setReadThrough(in.readBoolean());
         ccfg.setWriteThrough(in.readBoolean());
@@ -794,6 +795,7 @@ public class PlatformConfigurationUtils {
         writer.writeLong(ccfg.getWriteBehindFlushFrequency());
         writer.writeInt(ccfg.getWriteBehindFlushSize());
         writer.writeInt(ccfg.getWriteBehindFlushThreadCount());
+        writer.writeBoolean(ccfg.getWriteBehindCoalescing());
         writeEnumInt(writer, ccfg.getWriteSynchronizationMode());
         writer.writeBoolean(ccfg.isReadThrough());
         writer.writeBoolean(ccfg.isWriteThrough());

http://git-wip-us.apache.org/repos/asf/ignite/blob/217c6be2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
index 6406d32..25ba43e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
@@ -213,6 +213,8 @@ namespace Apache.Ignite.Core.Tests.Cache
             Assert.AreEqual(CacheConfiguration.DefaultWriteBehindEnabled, cfg.WriteBehindEnabled);
             Assert.AreEqual(CacheConfiguration.DefaultWriteBehindFlushFrequency, cfg.WriteBehindFlushFrequency);
             Assert.AreEqual(CacheConfiguration.DefaultWriteBehindFlushSize, cfg.WriteBehindFlushSize);
+            Assert.AreEqual(CacheConfiguration.DefaultWriteBehindFlushThreadCount, cfg.WriteBehindFlushThreadCount);
+            Assert.AreEqual(CacheConfiguration.DefaultWriteBehindCoalescing, cfg.WriteBehindCoalescing);
         }
 
         /// <summary>
@@ -511,6 +513,7 @@ namespace Apache.Ignite.Core.Tests.Cache
                 CacheStoreFactory = new CacheStoreFactoryTest(),
                 ReadThrough = true,
                 WriteThrough = true,
+                WriteBehindCoalescing = false,
                 QueryEntities = new[]
                 {
                     new QueryEntity

http://git-wip-us.apache.org/repos/asf/ignite/blob/217c6be2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index 2d8cc20..6b94079 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -90,7 +90,7 @@ namespace Apache.Ignite.Core.Tests
                                 <iLifecycleHandler type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+LifecycleBean' foo='15' />
                             </lifecycleHandlers>
                             <cacheConfiguration>
-                                <cacheConfiguration cacheMode='Replicated' readThrough='true' writeThrough='true' enableStatistics='true'>
+                                <cacheConfiguration cacheMode='Replicated' readThrough='true' writeThrough='true' enableStatistics='true' writeBehindCoalescing='false'>
                                     <queryEntities>    
                                         <queryEntity keyType='System.Int32' valueType='System.String' tableName='myTable'>    
                                             <fields>
@@ -174,6 +174,7 @@ namespace Apache.Ignite.Core.Tests
             Assert.IsTrue(cacheCfg.WriteThrough);
             Assert.IsInstanceOf<MyPolicyFactory>(cacheCfg.ExpiryPolicyFactory);
             Assert.IsTrue(cacheCfg.EnableStatistics);
+            Assert.IsFalse(cacheCfg.WriteBehindCoalescing);
 
             var queryEntity = cacheCfg.QueryEntities.Single();
             Assert.AreEqual(typeof(int), queryEntity.KeyType);
@@ -675,6 +676,7 @@ namespace Apache.Ignite.Core.Tests
                         WriteBehindFlushFrequency = TimeSpan.FromSeconds(55),
                         WriteBehindFlushSize = 66,
                         WriteBehindFlushThreadCount = 2,
+                        WriteBehindCoalescing = false,
                         WriteSynchronizationMode = CacheWriteSynchronizationMode.FullAsync,
                         NearConfiguration = new NearCacheConfiguration
                         {

http://git-wip-us.apache.org/repos/asf/ignite/blob/217c6be2/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
index 3586989..87ee255 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
@@ -126,6 +126,9 @@ namespace Apache.Ignite.Core.Cache.Configuration
         /// <summary> Default value for write-through behavior. </summary>
         public const bool DefaultWriteThrough = false;
 
+        /// <summary> Default value for <see cref="WriteBehindCoalescing"/>. </summary>
+        public const bool DefaultWriteBehindCoalescing = true;
+
         /// <summary>
         /// Gets or sets the cache name.
         /// </summary>
@@ -169,6 +172,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
             WriteBehindFlushFrequency = DefaultWriteBehindFlushFrequency;
             WriteBehindFlushSize = DefaultWriteBehindFlushSize;
             WriteBehindFlushThreadCount= DefaultWriteBehindFlushThreadCount;
+            WriteBehindCoalescing = DefaultWriteBehindCoalescing;
         }
 
         /// <summary>
@@ -229,6 +233,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
             WriteBehindFlushFrequency = reader.ReadLongAsTimespan();
             WriteBehindFlushSize = reader.ReadInt();
             WriteBehindFlushThreadCount = reader.ReadInt();
+            WriteBehindCoalescing = reader.ReadBoolean();
             WriteSynchronizationMode = (CacheWriteSynchronizationMode) reader.ReadInt();
             ReadThrough = reader.ReadBoolean();
             WriteThrough = reader.ReadBoolean();
@@ -285,6 +290,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
             writer.WriteLong((long) WriteBehindFlushFrequency.TotalMilliseconds);
             writer.WriteInt(WriteBehindFlushSize);
             writer.WriteInt(WriteBehindFlushThreadCount);
+            writer.WriteBoolean(WriteBehindCoalescing);
             writer.WriteInt((int) WriteSynchronizationMode);
             writer.WriteBoolean(ReadThrough);
             writer.WriteBoolean(WriteThrough);
@@ -631,5 +637,13 @@ namespace Apache.Ignite.Core.Cache.Configuration
         /// See <see cref="IgniteConfiguration.MemoryConfiguration"/>.
         /// </summary>
         public string MemoryPolicyName { get; set; }
+
+        /// <summary>
+        /// Gets or sets write coalescing flag for write-behind cache store operations.
+        /// Store operations (get or remove) with the same key are combined or coalesced to single,
+        /// resulting operation to reduce pressure to underlying cache store.
+        /// </summary>
+        [DefaultValue(DefaultWriteBehindCoalescing)]
+        public bool WriteBehindCoalescing { get; set; }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/217c6be2/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
index ba2f756..8b07147 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -621,6 +621,13 @@
                                             </xs:documentation>
                                         </xs:annotation>
                                     </xs:attribute>
+                                    <xs:attribute name="writeBehindCoalescing" type="xs:boolean">
+                                        <xs:annotation>
+                                            <xs:documentation>
+                                                Coalescing flag for write-behind cache store operations. Store operations (get or remove) with the same key are combined or coalesced to single, resulting operation to reduce pressure to underlying cache store.
+                                            </xs:documentation>
+                                        </xs:annotation>
+                                    </xs:attribute>
                                     <xs:attribute name="writeBehindBatchSize" type="xs:int">
                                         <xs:annotation>
                                             <xs:documentation>


[18/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/CacheVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/CacheVector.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/CacheVector.java
deleted file mode 100644
index 0e9b26f..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/CacheVector.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.ValueMapper;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.VectorKeyMapper;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.IgniteBiFunction;
-import org.apache.ignite.math.functions.IgniteDoubleFunction;
-import org.apache.ignite.math.functions.IgniteFunction;
-import org.apache.ignite.math.impls.CacheUtils;
-import org.apache.ignite.math.impls.storage.vector.CacheVectorStorage;
-
-/**
- * Vector based on existing cache and index and value mapping functions.
- */
-public class CacheVector<K, V> extends AbstractVector {
-    /**
-     *
-     */
-    public CacheVector() {
-        // No-op.
-    }
-
-    /**
-     * Creates new vector over existing cache.
-     *
-     * @param size
-     * @param cache
-     * @param keyFunc
-     * @param valMapper
-     */
-    public CacheVector(
-        int size,
-        IgniteCache<K, V> cache,
-        VectorKeyMapper<K> keyFunc,
-        ValueMapper<V> valMapper) {
-        setStorage(new CacheVectorStorage<>(size, cache, keyFunc, valMapper));
-    }
-
-    /**
-     * @param mapper
-     */
-    private Vector mapOverCache(IgniteFunction<Double, Double> mapper) {
-        CacheVectorStorage<K, V> sto = storage();
-
-        CacheUtils.map(sto.cache().getName(), sto.keyMapper(), sto.valueMapper(), mapper);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double minValue() {
-        CacheVectorStorage<K, V> sto = storage();
-
-        return CacheUtils.min(sto.cache().getName(), sto.keyMapper(), sto.valueMapper());
-    }
-
-    /** {@inheritDoc} */
-    @Override public double maxValue() {
-        CacheVectorStorage<K, V> sto = storage();
-
-        return CacheUtils.max(sto.cache().getName(), sto.keyMapper(), sto.valueMapper());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector map(IgniteDoubleFunction<Double> fun) {
-        return mapOverCache(fun::apply);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector map(IgniteBiFunction<Double, Double, Double> fun, double y) {
-        // TODO: provide cache-optimized implementation.
-        return super.map(fun, y); // TODO
-    }
-
-    /** {@inheritDoc} */
-    @Override public double sum() {
-        CacheVectorStorage<K, V> sto = storage();
-
-        return CacheUtils.sum(sto.cache().getName(), sto.keyMapper(), sto.valueMapper());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector assign(double val) {
-        return mapOverCache((Double d) -> val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector plus(double x) {
-        return mapOverCache((Double d) -> d + x);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector divide(double x) {
-        return mapOverCache((Double d) -> d / x);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector times(double x) {
-        return mapOverCache((Double d) -> d * x);
-    }
-
-    /**
-     *
-     *
-     */
-    @SuppressWarnings({"unchecked"})
-    private CacheVectorStorage<K, V> storage() {
-        return (CacheVectorStorage<K, V>)getStorage();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector like(int crd) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        throw new UnsupportedOperationException();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/ConstantVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/ConstantVector.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/ConstantVector.java
deleted file mode 100644
index 0fddfd6..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/ConstantVector.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.storage.vector.ConstantVectorStorage;
-
-/**
- * Constant value, read-only vector.
- */
-public class ConstantVector extends AbstractReadOnlyVector {
-    /**
-     *
-     */
-    public ConstantVector() {
-        // No-op.
-    }
-
-    /**
-     * @param size
-     * @param val
-     */
-    public ConstantVector(int size, double val) {
-        super(new ConstantVectorStorage(size, val));
-    }
-
-    /**
-     *
-     *
-     */
-    private ConstantVectorStorage storage() {
-        return (ConstantVectorStorage)getStorage();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector copy() {
-        ConstantVectorStorage sto = storage();
-
-        return new ConstantVector(sto.size(), sto.constant());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector like(int crd) {
-        return new ConstantVector(crd, storage().constant());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        ConstantVector that = (ConstantVector)o;
-
-        VectorStorage sto = getStorage();
-
-        return (sto != null ? sto.equals(that.getStorage()) : that.getStorage() == null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/DelegatingVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/DelegatingVector.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/DelegatingVector.java
deleted file mode 100644
index a10fa45..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/DelegatingVector.java
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Spliterator;
-import java.util.function.IntToDoubleFunction;
-import org.apache.ignite.lang.IgniteUuid;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.functions.IgniteBiFunction;
-import org.apache.ignite.math.functions.IgniteDoubleFunction;
-
-/**
- * Convenient class that can be used to add decorations to an existing vector. Subclasses
- * can add weights, indices, etc. while maintaining full vector functionality.
- */
-public class DelegatingVector implements Vector {
-    /** Delegating vector. */
-    private Vector dlg;
-
-    /** Meta attribute storage. */
-    private Map<String, Object> meta = new HashMap<>();
-
-    /** GUID. */
-    private IgniteUuid guid = IgniteUuid.randomUuid();
-
-    /** */
-    public DelegatingVector() {
-        // No-op.
-    }
-
-    /**
-     * @param dlg
-     */
-    public DelegatingVector(Vector dlg) {
-        assert dlg != null;
-
-        this.dlg = dlg;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(dlg);
-        out.writeObject(meta);
-        out.writeObject(guid);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        dlg = (Vector)in.readObject();
-        meta = (Map<String, Object>)in.readObject();
-        guid = (IgniteUuid)in.readObject();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Map<String, Object> getMetaStorage() {
-        return meta;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        return dlg.likeMatrix(rows, cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix toMatrix(boolean rowLike) {
-        return dlg.toMatrix(rowLike);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix toMatrixPlusOne(boolean rowLike, double zeroVal) {
-        return dlg.toMatrixPlusOne(rowLike, zeroVal);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return dlg.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return dlg.isDense();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double minValue() {
-        return dlg.minValue();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double maxValue() {
-        return dlg.maxValue();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return dlg.isSequentialAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return dlg.isArrayBased();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector copy() {
-        return new DelegatingVector(dlg);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Iterable<Element> all() {
-        return dlg.all();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Iterable<Element> nonZeroes() {
-        return dlg.nonZeroes();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector sort() {
-        return dlg.sort();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Spliterator<Double> allSpliterator() {
-        return dlg.allSpliterator();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Spliterator<Double> nonZeroSpliterator() {
-        return dlg.nonZeroSpliterator();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Element getElement(int idx) {
-        return dlg.getElement(idx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector assign(double val) {
-        return dlg.assign(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector assign(double[] vals) {
-        return dlg.assign(vals);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector assign(Vector vec) {
-        return dlg.assign(vec);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector assign(IntToDoubleFunction fun) {
-        return dlg.assign(fun);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector map(IgniteDoubleFunction<Double> fun) {
-        return dlg.map(fun);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector map(Vector vec, IgniteBiFunction<Double, Double, Double> fun) {
-        return dlg.map(vec, fun);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector map(IgniteBiFunction<Double, Double, Double> fun, double y) {
-        return dlg.map(fun, y);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector divide(double x) {
-        return dlg.divide(x);
-    }
-
-    /** {@inheritDoc} */
-    @Override public double dot(Vector vec) {
-        return dlg.dot(vec);
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int idx) {
-        return dlg.get(idx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public double getX(int idx) {
-        return dlg.getX(idx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector like(int crd) {
-        return dlg.like(crd);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector minus(Vector vec) {
-        return dlg.minus(vec);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector normalize() {
-        return dlg.normalize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector normalize(double power) {
-        return dlg.normalize(power);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector logNormalize() {
-        return dlg.logNormalize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector logNormalize(double power) {
-        return dlg.logNormalize(power);
-    }
-
-    /** {@inheritDoc} */
-    @Override public double kNorm(double power) {
-        return dlg.kNorm(power);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Element minElement() {
-        return dlg.minElement();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Element maxElement() {
-        return dlg.maxElement();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector plus(double x) {
-        return dlg.plus(x);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector plus(Vector vec) {
-        return dlg.plus(vec);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector set(int idx, double val) {
-        return dlg.set(idx, val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector setX(int idx, double val) {
-        return dlg.setX(idx, val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector incrementX(int idx, double val) {
-        return dlg.incrementX(idx, val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector increment(int idx, double val) {
-        return dlg.increment(idx, val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int nonZeroElements() {
-        return dlg.nonZeroElements();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector times(double x) {
-        return dlg.times(x);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector times(Vector vec) {
-        return dlg.times(vec);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector viewPart(int off, int len) {
-        return dlg.viewPart(off, len);
-    }
-
-    /** {@inheritDoc} */
-    @Override public VectorStorage getStorage() {
-        return dlg.getStorage();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double sum() {
-        return dlg.sum();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix cross(Vector vec) {
-        return dlg.cross(vec);
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> T foldMap(IgniteBiFunction<T, Double, T> foldFun, IgniteDoubleFunction<Double> mapFun,
-        T zeroVal) {
-        return dlg.foldMap(foldFun, mapFun, zeroVal);
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> T foldMap(Vector vec, IgniteBiFunction<T, Double, T> foldFun,
-        IgniteBiFunction<Double, Double, Double> combFun, T zeroVal) {
-        return dlg.foldMap(vec, foldFun, combFun, zeroVal);
-    }
-
-    /** {@inheritDoc} */
-    @Override public double getLengthSquared() {
-        return dlg.getLengthSquared();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double getDistanceSquared(Vector vec) {
-        return dlg.getDistanceSquared(vec);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return dlg.isRandomAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return dlg.isDistributed();
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteUuid guid() {
-        return guid;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void destroy() {
-        dlg.destroy();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + meta.hashCode();
-        res = res * 37 + dlg.hashCode();
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        DelegatingVector that = (DelegatingVector)o;
-
-        return meta.equals(that.meta) && dlg.equals(that.dlg);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/DenseLocalOffHeapVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/DenseLocalOffHeapVector.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/DenseLocalOffHeapVector.java
deleted file mode 100644
index 4e7eb21..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/DenseLocalOffHeapVector.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.stream.IntStream;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.matrix.DenseLocalOffHeapMatrix;
-import org.apache.ignite.math.impls.storage.vector.DenseLocalOffHeapVectorStorage;
-
-/**
- * Implementation for {@link Vector} assuming dense logic and local offheap JVM storage.
- * It is suitable for data sets where local, non-distributed execution is satisfactory and on-heap JVM storage
- * is not enough to keep the entire data set.
- */
-public class DenseLocalOffHeapVector extends AbstractVector {
-    /** */
-    public DenseLocalOffHeapVector() {
-        // No-op.
-    }
-
-    /** */
-    private void makeOffheapStorage(int size) {
-        setStorage(new DenseLocalOffHeapVectorStorage(size));
-    }
-
-    /**
-     * @param arr Array to copy to offheap storage.
-     */
-    public DenseLocalOffHeapVector(double[] arr) {
-        makeOffheapStorage(arr.length);
-
-        assign(arr);
-    }
-
-    /**
-     * @param size Vector cardinality.
-     */
-    public DenseLocalOffHeapVector(int size) {
-        makeOffheapStorage(size);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector assign(Vector vec) {
-        checkCardinality(vec);
-
-        IntStream.range(0, size()).parallel().forEach(idx -> set(idx, vec.get(idx)));
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector times(double x) {
-        if (x == 0.0)
-            return like(size()).assign(0);
-        else
-            return super.times(x);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector like(int crd) {
-        return new DenseLocalOffHeapVector(crd);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        return new DenseLocalOffHeapMatrix(rows, cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        return o != null && getClass().equals(o.getClass()) && (getStorage().equals(((Vector)o).getStorage()));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/DenseLocalOnHeapVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/DenseLocalOnHeapVector.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/DenseLocalOnHeapVector.java
deleted file mode 100644
index 5827998..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/DenseLocalOnHeapVector.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.Map;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.math.impls.storage.vector.ArrayVectorStorage;
-
-/**
- * Basic implementation for vector.
- * <p>
- * This is a trivial implementation for vector assuming dense logic, local on-heap JVM storage
- * based on {@code double[]} array. It is only suitable for data sets where
- * local, non-distributed execution is satisfactory and on-heap JVM storage is enough
- * to keep the entire data set.
- */
-public class DenseLocalOnHeapVector extends AbstractVector {
-    /**
-     * @param size Vector cardinality.
-     */
-    private VectorStorage mkStorage(int size) {
-        return new ArrayVectorStorage(size);
-    }
-
-    /**
-     * @param arr Source array.
-     * @param cp {@code true} to clone array, reuse it otherwise.
-     */
-    private VectorStorage mkStorage(double[] arr, boolean cp) {
-        assert arr != null;
-
-        return new ArrayVectorStorage(cp ? arr.clone() : arr);
-    }
-
-    /**
-     * @param args Parameters for new Vector.
-     */
-    public DenseLocalOnHeapVector(Map<String, Object> args) {
-        assert args != null;
-
-        if (args.containsKey("size"))
-            setStorage(mkStorage((int)args.get("size")));
-        else if (args.containsKey("arr") && args.containsKey("copy"))
-            setStorage(mkStorage((double[])args.get("arr"), (boolean)args.get("copy")));
-        else
-            throw new UnsupportedOperationException("Invalid constructor argument(s).");
-    }
-
-    /** */
-    public DenseLocalOnHeapVector() {
-        // No-op.
-    }
-
-    /**
-     * @param size Vector cardinality.
-     */
-    public DenseLocalOnHeapVector(int size) {
-        setStorage(mkStorage(size));
-    }
-
-    /**
-     * @param arr Source array.
-     * @param shallowCp {@code true} to use shallow copy.
-     */
-    public DenseLocalOnHeapVector(double[] arr, boolean shallowCp) {
-        setStorage(mkStorage(arr, shallowCp));
-    }
-
-    /**
-     * @param arr Source array.
-     */
-    public DenseLocalOnHeapVector(double[] arr) {
-        this(arr, false);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        return new DenseLocalOnHeapMatrix(rows, cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector like(int crd) {
-        return new DenseLocalOnHeapVector(crd);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/FunctionVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/FunctionVector.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/FunctionVector.java
deleted file mode 100644
index 0e7cfad..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/FunctionVector.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.Map;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.IgniteFunction;
-import org.apache.ignite.math.functions.IntDoubleToVoidFunction;
-import org.apache.ignite.math.impls.storage.vector.FunctionVectorStorage;
-
-/**
- * Implementation of {@link Vector} that maps vector element index to {@link java.util.function} interfaces.
- */
-public class FunctionVector extends AbstractVector {
-    /**
-     *
-     */
-    public FunctionVector() {
-        // No-op.
-    }
-
-    /**
-     * Creates read-write or read-only function vector.
-     *
-     * @param size Vector size.
-     * @param getFunc Function that returns value corresponding to given element index.
-     * @param setFunc Set function. If {@code null} - this will be a read-only vector.
-     */
-    public FunctionVector(int size, IgniteFunction<Integer, Double> getFunc, IntDoubleToVoidFunction setFunc) {
-        setStorage(new FunctionVectorStorage(size, getFunc, setFunc));
-    }
-
-    /**
-     * Creates read-only function vector.
-     *
-     * @param size Vector size.
-     * @param getFunc Function that returns value corresponding to given element index.
-     */
-    public FunctionVector(int size, IgniteFunction<Integer, Double> getFunc) {
-        setStorage(new FunctionVectorStorage(size, getFunc));
-    }
-
-    /**
-     * @param args Arguments for vector constructor.
-     */
-    public FunctionVector(Map<String, Object> args) {
-        assert args != null;
-
-        if (args.containsKey("size") && args.containsKey("getFunc") && args.containsKey("setFunc")) {
-            @SuppressWarnings("unchecked")
-            IgniteFunction<Integer, Double> getFunc = (IgniteFunction<Integer, Double>)args.get("getFunc");
-            IntDoubleToVoidFunction setFunc = (IntDoubleToVoidFunction)args.get("setFunc");
-            int size = (int)args.get("size");
-
-            setStorage(new FunctionVectorStorage(size, getFunc, setFunc));
-        }
-        else if (args.containsKey("size") && args.containsKey("getFunc")) {
-            @SuppressWarnings("unchecked")
-            IgniteFunction<Integer, Double> getFunc = (IgniteFunction<Integer, Double>)args.get("getFunc");
-            int size = (int)args.get("size");
-
-            setStorage(new FunctionVectorStorage(size, getFunc));
-        }
-        else
-            throw new UnsupportedOperationException("Invalid constructor argument(s).");
-    }
-
-    /**
-     *
-     *
-     */
-    private FunctionVectorStorage storage() {
-        return (FunctionVectorStorage)getStorage();
-    }
-
-    /** {@inheritDoc} */
-    @Override public org.apache.ignite.math.Vector like(int crd) {
-        FunctionVectorStorage sto = storage();
-
-        return new FunctionVector(crd, sto.getFunction(), sto.setFunction());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector times(double x) {
-        if (x == 0.0)
-            return like(size()).assign(0);
-        else
-            return super.times(x);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/MatrixVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/MatrixVectorView.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/MatrixVectorView.java
deleted file mode 100644
index 8f32a89..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/MatrixVectorView.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.IndexException;
-import org.apache.ignite.math.impls.storage.vector.MatrixVectorStorage;
-
-/**
- * Row or column vector view off the matrix.
- */
-public class MatrixVectorView extends AbstractVector {
-    /** */ private Matrix parent;
-
-    /** */ private int row;
-    /** */ private int col;
-    
-    /** */ private int rowStride;
-    /** */ private int colStride;
-
-    /**
-     *
-     */
-    public MatrixVectorView() {
-        // No-op.
-    }
-
-    /**
-     * @param parent
-     * @param row
-     * @param col
-     * @param rowStride
-     * @param colStride
-     */
-    public MatrixVectorView(Matrix parent, int row, int col, int rowStride, int colStride) {
-        assert parent != null;
-
-        if (row < 0 || row >= parent.rowSize())
-            throw new IndexException(row);
-        if (col < 0 || col >= parent.columnSize())
-            throw new IndexException(col);
-
-        this.parent = parent;
-
-        this.row = row;
-        this.col = col;
-
-        this.rowStride = rowStride;
-        this.colStride = colStride;
-
-        setStorage(new MatrixVectorStorage(parent, row, col, rowStride, colStride));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector copy() {
-        return new MatrixVectorView(parent, row, col, rowStride, colStride);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector like(int crd) {
-        return parent.likeVector(crd);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        return parent.like(rows, cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        super.writeExternal(out);
-
-        out.writeObject(parent);
-        out.writeInt(row);
-        out.writeInt(col);
-        out.writeInt(rowStride);
-        out.writeInt(colStride);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        super.readExternal(in);
-
-        parent = (Matrix)in.readObject();
-        row = in.readInt();
-        col = in.readInt();
-        rowStride = in.readInt();
-        colStride = in.readInt();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + (parent == null ? 0 : parent.hashCode());
-        res = res * 37 + row;
-        res = res * 37 + col;
-        res = res * 37 + rowStride;
-        res = res * 37 + colStride;
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        MatrixVectorView that = (MatrixVectorView)o;
-
-        return (parent != null ? parent.equals(that.parent) : that.parent == null) &&
-            row == that.row &&
-            col == that.col &&
-            rowStride == that.rowStride &&
-            colStride == that.colStride;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/PivotedVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/PivotedVectorView.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/PivotedVectorView.java
deleted file mode 100644
index cc9e835..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/PivotedVectorView.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.Functions;
-import org.apache.ignite.math.impls.storage.vector.PivotedVectorStorage;
-
-/**
- * Pivoted (index mapped) view over another vector.
- */
-public class PivotedVectorView extends AbstractVector {
-    /** */ private Vector vec;
-
-    /**
-     * @param vec
-     * @param pivot Mapping from external index to internal.
-     * @param unpivot Mapping from internal index to external.
-     */
-    public PivotedVectorView(Vector vec, int[] pivot, int[] unpivot) {
-        setStorage(new PivotedVectorStorage(vec.getStorage(), pivot, unpivot));
-
-        checkCardinality(pivot);
-        checkCardinality(unpivot);
-
-        this.vec = vec;
-    }
-
-    /**
-     * @param vec
-     * @param pivot
-     */
-    public PivotedVectorView(Vector vec, int[] pivot) {
-        setStorage(new PivotedVectorStorage(vec.getStorage(), pivot));
-
-        checkCardinality(pivot);
-
-        this.vec = vec;
-    }
-
-    /**
-     *
-     *
-     */
-    private PivotedVectorStorage storage() {
-        return (PivotedVectorStorage)getStorage();
-    }
-
-    /**
-     *
-     */
-    public PivotedVectorView() {
-        // No-op.
-    }
-
-    /**
-     *
-     *
-     */
-    public Vector getBaseVector() {
-        return vec;
-    }
-
-    /**
-     * @param i
-     */
-    public int pivot(int i) {
-        return storage().pivot()[i];
-    }
-
-    /**
-     * @param i
-     */
-    public int unpivot(int i) {
-        return storage().unpivot()[i];
-    }
-
-    /**
-     * @param idx
-     */
-    protected Vector.Element makeElement(int idx) {
-        checkIndex(idx);
-
-        // External index.
-        int exIdx = storage().pivot()[idx];
-
-        return new Vector.Element() {
-            /** {@inheritDoc */
-            @Override public double get() {
-                return storageGet(idx);
-            }
-
-            /** {@inheritDoc */
-            @Override public int index() {
-                return exIdx;
-            }
-
-            /** {@inheritDoc */
-            @Override public void set(double val) {
-                storageSet(idx, val);
-            }
-        };
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector copy() {
-        PivotedVectorStorage sto = storage();
-
-        return new PivotedVectorView(vec, sto.pivot(), sto.unpivot());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector like(int crd) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        return vec.likeMatrix(rows, cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector times(double x) {
-        if (x == 0.0)
-            return copy().map(Functions.mult(x));
-        else
-            return super.times(x);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        super.writeExternal(out);
-
-        out.writeObject(vec);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        super.readExternal(in);
-
-        vec = (Vector)in.readObject();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/RandomVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/RandomVector.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/RandomVector.java
deleted file mode 100644
index c9121c9..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/RandomVector.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Map;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.matrix.RandomMatrix;
-import org.apache.ignite.math.impls.storage.vector.RandomVectorStorage;
-
-/**
- * Random vector. Each value is taken from {-1,0,1} with roughly equal probability. Note
- * that by default, the value is determined by a relatively simple hash of the index.
- */
-public class RandomVector extends AbstractReadOnlyVector {
-    /** */ private boolean fastHash;
-
-    /**
-     * @param size Vector cardinality.
-     * @param fastHash
-     */
-    private VectorStorage mkStorage(int size, boolean fastHash) {
-        this.fastHash = fastHash;
-
-        return new RandomVectorStorage(size, fastHash);
-    }
-
-    /**
-     * @param size
-     * @param fastHash
-     */
-    public RandomVector(int size, boolean fastHash) {
-        setStorage(mkStorage(size, fastHash));
-    }
-
-    /**
-     * @param size
-     */
-    public RandomVector(int size) {
-        this(size, true);
-    }
-
-    /**
-     * @param args
-     */
-    public RandomVector(Map<String, Object> args) {
-        assert args != null;
-
-        if (args.containsKey("size") && args.containsKey("fastHash"))
-            setStorage(mkStorage((int)args.get("size"), (boolean)args.get("fastHash")));
-        else if (args.containsKey("size"))
-            setStorage(mkStorage((int)args.get("size"), true));
-        else
-            throw new UnsupportedOperationException("Invalid constructor argument(s).");
-    }
-
-    /** */
-    public RandomVector() {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public org.apache.ignite.math.Vector like(int crd) {
-        return new RandomVector(crd, fastHash);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        return new RandomMatrix(rows, cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        super.writeExternal(out);
-
-        out.writeBoolean(fastHash);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        super.readExternal(in);
-
-        fastHash = in.readBoolean();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + Boolean.hashCode(fastHash);
-        res = res * 37 + getStorage().hashCode();
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        RandomVector that = (RandomVector)o;
-        VectorStorage sto = getStorage();
-
-        return fastHash == that.fastHash && (sto != null ? sto.equals(that.getStorage()) : that.getStorage() == null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SingleElementVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SingleElementVector.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SingleElementVector.java
deleted file mode 100644
index 8d19ee0..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SingleElementVector.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.Map;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.storage.vector.SingleElementVectorStorage;
-
-/**
- * Read-write vector holding a single non-zero value at some index.
- */
-public class SingleElementVector extends AbstractVector {
-    /**
-     *
-     */
-    public SingleElementVector() {
-        // No-op
-    }
-
-    /**
-     * @param size
-     * @param idx
-     * @param val
-     */
-    public SingleElementVector(int size, int idx, double val) {
-        super(new SingleElementVectorStorage(size, idx, val));
-    }
-
-    /**
-     * @param args
-     */
-    public SingleElementVector(Map<String, Object> args) {
-        assert args != null;
-
-        if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
-            int size = (int)args.get("size");
-            int idx = (int)args.get("index");
-            double val = (double)args.get("value");
-
-            setStorage(new SingleElementVectorStorage(size, idx, val));
-        }
-        else
-            throw new UnsupportedOperationException("Invalid constructor argument(s).");
-    }
-
-    /**
-     *
-     *
-     */
-    private SingleElementVectorStorage storage() {
-        return (SingleElementVectorStorage)getStorage();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Element minElement() {
-        return makeElement(storage().index());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Element maxElement() {
-        return makeElement(storage().index());
-    }
-
-    /** {@inheritDoc} */
-    @Override public double sum() {
-        return getX(storage().index());
-    }
-
-    /** {@inheritDoc} */
-    @Override public int nonZeroElements() {
-        return isZero(get(storage().index())) ? 0 : 1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector like(int crd) {
-        int idx = storage().index();
-
-        return new SingleElementVector(crd, idx, getX(idx));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        throw new UnsupportedOperationException();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SingleElementVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SingleElementVectorView.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SingleElementVectorView.java
deleted file mode 100644
index 76a1c0a..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SingleElementVectorView.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.Functions;
-import org.apache.ignite.math.impls.storage.vector.SingleElementVectorDelegateStorage;
-
-/**
- * Single value vector view over another vector.
- */
-public class SingleElementVectorView extends AbstractVector {
-    /**
-     *
-     */
-    public SingleElementVectorView() {
-        // No-op.
-    }
-
-    /**
-     * @param vec
-     * @param idx
-     */
-    public SingleElementVectorView(Vector vec, int idx) {
-        super(new SingleElementVectorDelegateStorage(vec, idx));
-    }
-
-    /**
-     *
-     *
-     */
-    private SingleElementVectorDelegateStorage storage() {
-        return (SingleElementVectorDelegateStorage)getStorage();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector.Element minElement() {
-        return makeElement(storage().index());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector.Element maxElement() {
-        return makeElement(storage().index());
-    }
-
-    /** {@inheritDoc} */
-    @Override public double sum() {
-        return getX(storage().index());
-    }
-
-    /** {@inheritDoc} */
-    @Override public int nonZeroElements() {
-        return isZero(getX(storage().index())) ? 0 : 1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector copy() {
-        SingleElementVectorDelegateStorage sto = storage();
-
-        return new SingleElementVectorView(sto.delegate(), sto.index());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector times(double x) {
-        if (x == 0.0)
-            return copy().map(Functions.mult(x));
-        else
-            return super.times(x);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector like(int crd) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        throw new UnsupportedOperationException();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SparseLocalOffHeapVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SparseLocalOffHeapVector.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SparseLocalOffHeapVector.java
deleted file mode 100644
index 2fd1c57..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SparseLocalOffHeapVector.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.storage.vector.SparseLocalOffHeapVectorStorage;
-
-/**
- * Implementation for {@link Vector} assuming sparse logic and local offheap JVM storage.
- * It is suitable for data sets where local, non-distributed execution is satisfactory and on-heap JVM storage
- * is not enough to keep the entire data set.
- * <p>See also: <a href="https://en.wikipedia.org/wiki/Sparse_array">Wikipedia article</a>.</p>
- */
-public class SparseLocalOffHeapVector extends AbstractVector {
-    /**
-     * @param crd Vector cardinality.
-     */
-    public SparseLocalOffHeapVector(int crd) {
-        setStorage(new SparseLocalOffHeapVectorStorage(crd));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector like(int crd) {
-        return new SparseLocalOffHeapVector(crd);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SparseLocalVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SparseLocalVector.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SparseLocalVector.java
deleted file mode 100644
index ebb6731..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/SparseLocalVector.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.StorageConstants;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.matrix.SparseLocalOnHeapMatrix;
-import org.apache.ignite.math.impls.storage.vector.SparseLocalOnHeapVectorStorage;
-
-/**
- * Local on-heap sparse vector based on hash map storage.
- */
-public class SparseLocalVector extends AbstractVector implements StorageConstants {
-    /**
-     *
-     */
-    public SparseLocalVector() {
-        // No-op.
-    }
-
-    /**
-     * @param size
-     * @param acsMode
-     */
-    public SparseLocalVector(int size, int acsMode) {
-        assertAccessMode(acsMode);
-
-        setStorage(new SparseLocalOnHeapVectorStorage(size, acsMode));
-    }
-
-    /** */
-    private SparseLocalOnHeapVectorStorage storage() {
-        return (SparseLocalOnHeapVectorStorage)getStorage();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector like(int crd) {
-        SparseLocalOnHeapVectorStorage sto = storage();
-
-        return new SparseLocalVector(crd, sto.getAccessMode());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        return new SparseLocalOnHeapMatrix(rows, cols);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector times(double x) {
-        if (x == 0.0)
-            return assign(0);
-        else
-            return super.times(x);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/VectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/VectorView.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/VectorView.java
deleted file mode 100644
index ce51a45..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/VectorView.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.io.Externalizable;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.storage.vector.DelegateVectorStorage;
-
-/**
- * Implements the partial view into the parent {@link Vector}.
- */
-public class VectorView extends AbstractVector {
-    /**
-     * Constructor for {@link Externalizable} interface.
-     */
-    public VectorView() {
-        // No-op.
-    }
-
-    /**
-     * @param parent Backing parent {@link Vector}.
-     * @param off Offset to parent vector.
-     * @param len Size of the view.
-     */
-    public VectorView(Vector parent, int off, int len) {
-        super(new DelegateVectorStorage(parent.getStorage(), off, len));
-    }
-
-    /**
-     * @param sto Backing parent {@link VectorStorage}.
-     * @param off Offset to parent vector.
-     * @param len Size of the view.
-     */
-    public VectorView(VectorStorage sto, int off, int len) {
-        super(new DelegateVectorStorage(sto, off, len));
-    }
-
-    /** */
-    private DelegateVectorStorage storage() {
-        return (DelegateVectorStorage)getStorage();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector copy() {
-        DelegateVectorStorage sto = storage();
-
-        return new VectorView(sto.delegate(), sto.offset(), sto.length());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector like(int crd) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        return this == o ||
-            ((o != null)
-                && o.getClass() == getClass()
-                && (getStorage().equals(((VectorView)o).getStorage())));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/package-info.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/package-info.java
deleted file mode 100644
index d6ca1f3..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Contains specific implementations for vectors.
- */
-package org.apache.ignite.math.impls.vector;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/package-info.java b/modules/ml/src/main/java/org/apache/ignite/math/package-info.java
deleted file mode 100644
index 05ce651..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Contains main APIs for distributed code algebra.
- */
-package org.apache.ignite.math;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
new file mode 100644
index 0000000..a31503f
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
@@ -0,0 +1,571 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+Copyright 1999 CERN - European Organization for Nuclear Research.
+Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
+is hereby granted without fee, provided that the above copyright notice appear in all copies and
+that both that copyright notice and this permission notice appear in supporting documentation.
+CERN makes no representations about the suitability of this software for any purpose.
+It is provided "as is" without expressed or implied warranty.
+*/
+
+package org.apache.ignite.ml.math;
+
+/**
+ * Miscellaneous arithmetic and algebra functions.
+ * Lifted from Apache Mahout.
+ */
+public class Algebra extends Constants {
+    /** */ private static final double[] STIRLING_CORRECTION = {
+        0.0,
+        8.106146679532726e-02, 4.134069595540929e-02,
+        2.767792568499834e-02, 2.079067210376509e-02,
+        1.664469118982119e-02, 1.387612882307075e-02,
+        1.189670994589177e-02, 1.041126526197209e-02,
+        9.255462182712733e-03, 8.330563433362871e-03,
+        7.573675487951841e-03, 6.942840107209530e-03,
+        6.408994188004207e-03, 5.951370112758848e-03,
+        5.554733551962801e-03, 5.207655919609640e-03,
+        4.901395948434738e-03, 4.629153749334029e-03,
+        4.385560249232324e-03, 4.166319691996922e-03,
+        3.967954218640860e-03, 3.787618068444430e-03,
+        3.622960224683090e-03, 3.472021382978770e-03,
+        3.333155636728090e-03, 3.204970228055040e-03,
+        3.086278682608780e-03, 2.976063983550410e-03,
+        2.873449362352470e-03, 2.777674929752690e-03,
+    };
+
+    /** */ private static final double[] LOG_FACTORIALS = {
+        0.00000000000000000, 0.00000000000000000, 0.69314718055994531,
+        1.79175946922805500, 3.17805383034794562, 4.78749174278204599,
+        6.57925121201010100, 8.52516136106541430, 10.60460290274525023,
+        12.80182748008146961, 15.10441257307551530, 17.50230784587388584,
+        19.98721449566188615, 22.55216385312342289, 25.19122118273868150,
+        27.89927138384089157, 30.67186010608067280, 33.50507345013688888,
+        36.39544520803305358, 39.33988418719949404, 42.33561646075348503,
+        45.38013889847690803, 48.47118135183522388, 51.60667556776437357,
+        54.78472939811231919, 58.00360522298051994, 61.26170176100200198,
+        64.55753862700633106, 67.88974313718153498, 71.25703896716800901
+    };
+
+    /** */ private static final long[] LONG_FACTORIALS = {
+        1L,
+        1L,
+        2L,
+        6L,
+        24L,
+        120L,
+        720L,
+        5040L,
+        40320L,
+        362880L,
+        3628800L,
+        39916800L,
+        479001600L,
+        6227020800L,
+        87178291200L,
+        1307674368000L,
+        20922789888000L,
+        355687428096000L,
+        6402373705728000L,
+        121645100408832000L,
+        2432902008176640000L
+    };
+
+    /** */ private static final double[] DOUBLE_FACTORIALS = {
+        5.109094217170944E19,
+        1.1240007277776077E21,
+        2.585201673888498E22,
+        6.204484017332394E23,
+        1.5511210043330984E25,
+        4.032914611266057E26,
+        1.0888869450418352E28,
+        3.048883446117138E29,
+        8.841761993739701E30,
+        2.652528598121911E32,
+        8.222838654177924E33,
+        2.6313083693369355E35,
+        8.68331761881189E36,
+        2.952327990396041E38,
+        1.0333147966386144E40,
+        3.719933267899013E41,
+        1.3763753091226346E43,
+        5.23022617466601E44,
+        2.0397882081197447E46,
+        8.15915283247898E47,
+        3.34525266131638E49,
+        1.4050061177528801E51,
+        6.041526306337384E52,
+        2.6582715747884495E54,
+        1.196222208654802E56,
+        5.502622159812089E57,
+        2.5862324151116827E59,
+        1.2413915592536068E61,
+        6.082818640342679E62,
+        3.0414093201713376E64,
+        1.5511187532873816E66,
+        8.06581751709439E67,
+        4.274883284060024E69,
+        2.308436973392413E71,
+        1.2696403353658264E73,
+        7.109985878048632E74,
+        4.052691950487723E76,
+        2.350561331282879E78,
+        1.386831185456898E80,
+        8.32098711274139E81,
+        5.075802138772246E83,
+        3.146997326038794E85,
+        1.9826083154044396E87,
+        1.2688693218588414E89,
+        8.247650592082472E90,
+        5.443449390774432E92,
+        3.6471110918188705E94,
+        2.48003554243683E96,
+        1.7112245242814127E98,
+        1.1978571669969892E100,
+        8.504785885678624E101,
+        6.123445837688612E103,
+        4.470115461512686E105,
+        3.307885441519387E107,
+        2.4809140811395404E109,
+        1.8854947016660506E111,
+        1.451830920282859E113,
+        1.1324281178206295E115,
+        8.94618213078298E116,
+        7.15694570462638E118,
+        5.797126020747369E120,
+        4.7536433370128435E122,
+        3.94552396972066E124,
+        3.314240134565354E126,
+        2.8171041143805494E128,
+        2.4227095383672744E130,
+        2.107757298379527E132,
+        1.854826422573984E134,
+        1.6507955160908465E136,
+        1.4857159644817605E138,
+        1.3520015276784033E140,
+        1.2438414054641305E142,
+        1.156772507081641E144,
+        1.0873661566567426E146,
+        1.0329978488239061E148,
+        9.916779348709491E149,
+        9.619275968248216E151,
+        9.426890448883248E153,
+        9.332621544394415E155,
+        9.332621544394418E157,
+        9.42594775983836E159,
+        9.614466715035125E161,
+        9.902900716486178E163,
+        1.0299016745145631E166,
+        1.0813967582402912E168,
+        1.1462805637347086E170,
+        1.2265202031961373E172,
+        1.324641819451829E174,
+        1.4438595832024942E176,
+        1.5882455415227423E178,
+        1.7629525510902457E180,
+        1.974506857221075E182,
+        2.2311927486598138E184,
+        2.543559733472186E186,
+        2.925093693493014E188,
+        3.393108684451899E190,
+        3.96993716080872E192,
+        4.6845258497542896E194,
+        5.574585761207606E196,
+        6.689502913449135E198,
+        8.094298525273444E200,
+        9.875044200833601E202,
+        1.2146304367025332E205,
+        1.506141741511141E207,
+        1.882677176888926E209,
+        2.3721732428800483E211,
+        3.0126600184576624E213,
+        3.856204823625808E215,
+        4.974504222477287E217,
+        6.466855489220473E219,
+        8.471580690878813E221,
+        1.1182486511960037E224,
+        1.4872707060906847E226,
+        1.99294274616152E228,
+        2.690472707318049E230,
+        3.6590428819525483E232,
+        5.0128887482749884E234,
+        6.917786472619482E236,
+        9.615723196941089E238,
+        1.3462012475717523E241,
+        1.8981437590761713E243,
+        2.6953641378881633E245,
+        3.8543707171800694E247,
+        5.550293832739308E249,
+        8.047926057471989E251,
+        1.1749972043909107E254,
+        1.72724589045464E256,
+        2.5563239178728637E258,
+        3.8089226376305687E260,
+        5.7133839564458575E262,
+        8.627209774233244E264,
+        1.3113358856834527E267,
+        2.0063439050956838E269,
+        3.0897696138473515E271,
+        4.789142901463393E273,
+        7.471062926282892E275,
+        1.1729568794264134E278,
+        1.8532718694937346E280,
+        2.946702272495036E282,
+        4.714723635992061E284,
+        7.590705053947223E286,
+        1.2296942187394494E289,
+        2.0044015765453032E291,
+        3.287218585534299E293,
+        5.423910666131583E295,
+        9.003691705778434E297,
+        1.5036165148649983E300,
+        2.5260757449731988E302,
+        4.2690680090047056E304,
+        7.257415615308004E306
+    };
+
+    /**
+     * Efficiently returns the binomial coefficient, often also referred to as
+     * "n over k" or "n choose k". The binomial coefficient is defined as
+     * {@code (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )}.
+     * <ul> <li>{@code k&lt;0}: {@code 0}.</li>
+     * <li>{@code k==0}: {@code 1}.</li>
+     * <li>{@code k==1}: {@code n}.</li>
+     * <li>else: {@code (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k)}.</li>
+     * </ul>
+     *
+     * @param n
+     * @param k
+     * @return Binomial coefficient.
+     */
+    public static double binomial(double n, long k) {
+        if (k < 0)
+            return 0;
+
+        if (k == 0)
+            return 1;
+
+        if (k == 1)
+            return n;
+
+        // binomial(n,k) = (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )
+        double a = n - k + 1;
+        double b = 1;
+        double binomial = 1;
+
+        for (long i = k; i-- > 0; )
+            binomial *= (a++) / (b++);
+
+        return binomial;
+    }
+
+    /**
+     * Efficiently returns the binomial coefficient, often also referred to as "n over k" or "n choose k".
+     * The binomial coefficient is defined as
+     * <ul> <li>{@code k&lt;0}: {@code 0}. <li>{@code k==0 || k==n}: {@code 1}. <li>{@code k==1 || k==n-1}:
+     * {@code n}. <li>else: {@code (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )}. </ul>
+     *
+     * @param n
+     * @param k
+     * @return Binomial coefficient.
+     */
+    public static double binomial(long n, long k) {
+        if (k < 0)
+            return 0;
+
+        if (k == 0 || k == n)
+            return 1;
+
+        if (k == 1 || k == n - 1)
+            return n;
+
+        if (n > k) {
+            int max = LONG_FACTORIALS.length + DOUBLE_FACTORIALS.length;
+
+            if (n < max) {
+                double nFac = factorial((int)n);
+                double kFac = factorial((int)k);
+                double nMinusKFac = factorial((int)(n - k));
+                double nk = nMinusKFac * kFac;
+
+                if (nk != Double.POSITIVE_INFINITY) // No numeric overflow?
+                    return nFac / nk;
+            }
+
+            if (k > n / 2)
+                k = n - k;
+        }
+
+        // binomial(n,k) = (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )
+        long a = n - k + 1;
+        long b = 1;
+        double binomial = 1;
+
+        for (long i = k; i-- > 0; )
+            binomial *= (double)a++ / (b++);
+
+        return binomial;
+    }
+
+    /**
+     * Returns the smallest <code>long &gt;= value</code>.
+     * <dl><dt>Examples: {@code 1.0 -> 1, 1.2 -> 2, 1.9 -> 2}. This
+     * method is safer than using (long) Math.ceil(value), because of possible rounding error.</dt></dl>
+     *
+     * @param val
+     */
+    public static long ceil(double val) {
+        return Math.round(Math.ceil(val));
+    }
+
+    /**
+     * Evaluates the series of Chebyshev polynomials Ti at argument x/2. The series is given by
+     * <pre>
+     *        N-1
+     *         - '
+     *  y  =   &gt;   coef[i] T (x/2)
+     *         -            i
+     *        i=0
+     * </pre>
+     * Coefficients are stored in reverse order, i.e. the zero order term is last in the array.  Note N is the number of
+     * coefficients, not the order. <p> If coefficients are for the interval a to b, x must have been transformed to x
+     * -&lt; 2(2x - b - a)/(b-a) before entering the routine.  This maps x from (a, b) to (-1, 1), over which the
+     * Chebyshev polynomials are defined. <p> If the coefficients are for the inverted interval, in which (a, b) is
+     * mapped to (1/b, 1/a), the transformation required is {@code x -> 2(2ab/x - b - a)/(b-a)}.  If b is infinity, this
+     * becomes {@code x -> 4a/x - 1}. <p> SPEED: <p> Taking advantage of the recurrence properties of the Chebyshev
+     * polynomials, the routine requires one more addition per loop than evaluating a nested polynomial of the same
+     * degree.
+     *
+     * @param x Argument to the polynomial.
+     * @param coef Coefficients of the polynomial.
+     * @param N Number of coefficients.
+     */
+    public static double chbevl(double x, double[] coef, int N) {
+        int p = 0;
+
+        double b0 = coef[p++];
+        double b1 = 0.0;
+        int i = N - 1;
+
+        double b2;
+
+        do {
+            b2 = b1;
+            b1 = b0;
+            b0 = x * b1 - b2 + coef[p++];
+        }
+        while (--i > 0);
+
+        return 0.5 * (b0 - b2);
+    }
+
+    /**
+     * Instantly returns the factorial {@code k!}.
+     *
+     * @param k must hold {@code k &gt;= 0}.
+     */
+    private static double factorial(int k) {
+        if (k < 0)
+            throw new IllegalArgumentException();
+
+        int len1 = LONG_FACTORIALS.length;
+
+        if (k < len1)
+            return LONG_FACTORIALS[k];
+
+        int len2 = DOUBLE_FACTORIALS.length;
+
+        return (k < len1 + len2) ? DOUBLE_FACTORIALS[k - len1] : Double.POSITIVE_INFINITY;
+    }
+
+    /**
+     * Returns the largest <code>long &lt;= value</code>.
+     * <dl><dt>Examples: {@code 1.0 -> 1, 1.2 -> 1, 1.9 -> 1 <dt> 2.0 -> 2, 2.2 -> 2, 2.9 -> 2}</dt></dl>
+     * This method is safer than using (long) Math.floor(value), because of possible rounding error.
+     */
+    public static long floor(double val) {
+        return Math.round(Math.floor(val));
+    }
+
+    /**
+     * Returns {@code log<sub>base</sub>value}.
+     */
+    public static double log(double base, double val) {
+        return Math.log(val) / Math.log(base);
+    }
+
+    /**
+     * Returns {@code log<sub>10</sub>value}.
+     */
+    public static double log10(double val) {
+        // 1.0 / Math.log(10) == 0.43429448190325176
+        return Math.log(val) * 0.43429448190325176;
+    }
+
+    /**
+     * Returns {@code log<sub>2</sub>value}.
+     */
+    public static double log2(double val) {
+        // 1.0 / Math.log(2) == 1.4426950408889634
+        return Math.log(val) * 1.4426950408889634;
+    }
+
+    /**
+     * Returns {@code log(k!)}. Tries to avoid overflows. For {@code k&lt;30} simply looks up a table in O(1).
+     * For {@code k&gt;=30} uses stirlings approximation.
+     *
+     * @param k must hold {@code k &gt;= 0}.
+     */
+    public static double logFactorial(int k) {
+        if (k >= 30) {
+            double r = 1.0 / k;
+            double rr = r * r;
+            double C7 = -5.95238095238095238e-04;
+            double C5 = 7.93650793650793651e-04;
+            double C3 = -2.77777777777777778e-03;
+            double C1 = 8.33333333333333333e-02;
+            double C0 = 9.18938533204672742e-01;
+
+            return (k + 0.5) * Math.log(k) - k + C0 + r * (C1 + rr * (C3 + rr * (C5 + rr * C7)));
+        }
+        else
+            return LOG_FACTORIALS[k];
+    }
+
+    /**
+     * Instantly returns the factorial {@code k!}.
+     *
+     * @param k must hold {@code k >= 0 && k < 21}
+     */
+    public static long longFactorial(int k) {
+        if (k < 0)
+            throw new IllegalArgumentException("Negative k");
+
+        if (k < LONG_FACTORIALS.length)
+            return LONG_FACTORIALS[k];
+
+        throw new IllegalArgumentException("Overflow");
+    }
+
+    /**
+     * Returns the StirlingCorrection.
+     *
+     * Correction term of the Stirling approximation for {@code log(k!)} (series in
+     * 1/k, or table values for small k) with int parameter k. </p> {@code  log k! = (k + 1/2)log(k + 1) - (k + 1) +
+     * (1/2)log(2Pi) + STIRLING_CORRECTION(k + 1) log k! = (k + 1/2)log(k)     -  k      + (1/2)log(2Pi) +
+     * STIRLING_CORRECTION(k) }
+     */
+    public static double stirlingCorrection(int k) {
+        if (k > 30) {
+            double r = 1.0 / k;
+            double rr = r * r;
+            double C7 = -5.95238095238095238e-04;
+            double C5 = 7.93650793650793651e-04;
+            double C3 = -2.77777777777777778e-03;
+            double C1 = 8.33333333333333333e-02;
+
+            return r * (C1 + rr * (C3 + rr * (C5 + rr * C7)));
+        }
+        else
+            return STIRLING_CORRECTION[k];
+    }
+
+    /**
+     * Evaluates the given polynomial of degree {@code N} at {@code x}, assuming coefficient of N is 1.0. Otherwise same
+     * as {@link #evalPoly(double, double[], int)}.
+     * <pre>
+     *                     2          N
+     * y  =  C  + C x + C x  +...+ C x
+     *        0    1     2          N
+     *
+     * where C  = 1 and hence is omitted from the array.
+     *        N
+     *
+     * Coefficients are stored in reverse order:
+     *
+     * coef[0] = C  , ..., coef[N-1] = C  .
+     *            N-1                   0
+     *
+     * Calling arguments are otherwise the same as {@link #evalPoly(double, double[], int)}.
+     * </pre>
+     * In the interest of speed, there are no checks for out of bounds arithmetic.
+     *
+     * @param x Argument to the polynomial.
+     * @param coef Coefficients of the polynomial.
+     * @param n Degree of the polynomial.
+     */
+    public static double evalPoly1(double x, double[] coef, int n) {
+        double res = x + coef[0];
+
+        for (int i = 1; i < n; i++)
+            res = res * x + coef[i];
+
+        return res;
+    }
+
+    /**
+     * Evaluates the given polynomial of degree {@code N} at {@code x}.
+     * <pre>
+     *                     2          N
+     * y  =  C  + C x + C x  +...+ C x
+     *        0    1     2          N
+     *
+     * Coefficients are stored in reverse order:
+     *
+     * coef[0] = C  , ..., coef[N] = C  .
+     *            N                   0
+     * </pre>
+     * In the interest of speed, there are no checks for out of bounds arithmetic.
+     *
+     * @param x Argument to the polynomial.
+     * @param coef Coefficients of the polynomial.
+     * @param n Degree of the polynomial.
+     */
+    public static double evalPoly(double x, double[] coef, int n) {
+        double res = coef[0];
+
+        for (int i = 1; i <= n; i++)
+            res = res * x + coef[i];
+
+        return res;
+    }
+
+    /**
+     * Gets <code>sqrt(a^2 + b^2)</code> without under/overflow.
+     *
+     * @param a
+     * @param b
+     */
+    public static double hypot(double a, double b) {
+        double r;
+
+        if (Math.abs(a) > Math.abs(b)) {
+            r = b / a;
+            r = Math.abs(a) * Math.sqrt(1 + r * r);
+        }
+        else if (b != 0) {
+            r = a / b;
+            r = Math.abs(b) * Math.sqrt(1 + r * r);
+        }
+        else
+            r = 0.0;
+
+        return r;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/Constants.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Constants.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Constants.java
new file mode 100644
index 0000000..e20c139
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Constants.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+Copyright 1999 CERN - European Organization for Nuclear Research.
+Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
+is hereby granted without fee, provided that the above copyright notice appear in all copies and
+that both that copyright notice and this permission notice appear in supporting documentation.
+CERN makes no representations about the suitability of this software for any purpose.
+It is provided "as is" without expressed or implied warranty.
+*/
+
+package org.apache.ignite.ml.math;
+
+/**
+ * Math constants. Lifted from Apache Mahout.
+ */
+public class Constants {
+    /** */ public static final double MACHEP = 1.11022302462515654042E-16;
+    /** */ public static final double MAXLOG = 7.09782712893383996732E2;
+    /** */ public static final double MINLOG = -7.451332191019412076235E2;
+    /** */ public static final double MAXGAM = 171.624376956302725;
+    /** */ public static final double SQTPI = 2.50662827463100050242E0;
+    /** */ public static final double SQRTH = 7.07106781186547524401E-1;
+    /** */ public static final double LOGPI = 1.14472988584940017414;
+    /** */ public static final double BIG = 4.503599627370496e15;
+    /** */ public static final double BIGINV = 2.22044604925031308085e-16;
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/Destroyable.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Destroyable.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Destroyable.java
new file mode 100644
index 0000000..8e7ce95
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Destroyable.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+/**
+ * Support for destroying objects that are managed outside of JVM.
+ */
+public interface Destroyable {
+    /**
+     * Destroys object if managed outside of JVM. It's a no-op in all other cases.
+     */
+    public default void destroy() {
+        // No-op.
+    }
+}


[03/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseDistributedMatrixStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseDistributedMatrixStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseDistributedMatrixStorageTest.java
new file mode 100644
index 0000000..7c2d415
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseDistributedMatrixStorageTest.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.matrix;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.common.GridCommonTest;
+
+/**
+ * Tests for {@link SparseDistributedMatrixStorage}.
+ */
+@GridCommonTest(group = "Distributed Models")
+public class SparseDistributedMatrixStorageTest extends GridCommonAbstractTest {
+    /** Number of nodes in grid */
+    private static final int NODE_COUNT = 3;
+    /** Cache name. */
+    private static final String CACHE_NAME = "test-cache";
+    /** */
+    private static final String UNEXPECTED_ATTRIBUTE_VALUE = "Unexpected attribute value.";
+    /** Grid instance. */
+    private Ignite ignite;
+
+    /**
+     * Default constructor.
+     */
+    public SparseDistributedMatrixStorageTest() {
+        super(false);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        for (int i = 1; i <= NODE_COUNT; i++)
+            startGrid(i);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override protected void beforeTest() throws Exception {
+        ignite = grid(NODE_COUNT);
+
+        ignite.configuration().setPeerClassLoadingEnabled(true);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        ignite.destroyCache(CACHE_NAME);
+    }
+
+    /** */
+    public void testCacheCreation() throws Exception {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        final int rows = MathTestConstants.STORAGE_SIZE;
+        final int cols = MathTestConstants.STORAGE_SIZE;
+
+        SparseDistributedMatrixStorage storage = new SparseDistributedMatrixStorage(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+        assertNotNull("SparseDistributedMatrixStorage cache is null.", storage.cache());
+    }
+
+    /** */
+    public void testSetGet() throws Exception {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        final int rows = MathTestConstants.STORAGE_SIZE;
+        final int cols = MathTestConstants.STORAGE_SIZE;
+
+        SparseDistributedMatrixStorage storage = new SparseDistributedMatrixStorage(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+        for (int i = 0; i < rows; i++) {
+            for (int j = 0; j < cols; j++) {
+                double v = Math.random();
+                storage.set(i, j, v);
+
+                assert Double.compare(v, storage.get(i, j)) == 0;
+                assert Double.compare(v, storage.get(i, j)) == 0;
+            }
+        }
+    }
+
+    /** */
+    public void testAttributes() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        final int rows = MathTestConstants.STORAGE_SIZE;
+        final int cols = MathTestConstants.STORAGE_SIZE;
+
+        SparseDistributedMatrixStorage storage = new SparseDistributedMatrixStorage(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+        assertEquals(UNEXPECTED_ATTRIBUTE_VALUE, storage.rowSize(), rows);
+        assertEquals(UNEXPECTED_ATTRIBUTE_VALUE, storage.columnSize(), cols);
+
+        assertFalse(UNEXPECTED_ATTRIBUTE_VALUE, storage.isArrayBased());
+        assertFalse(UNEXPECTED_ATTRIBUTE_VALUE, storage.isDense());
+        assertTrue(UNEXPECTED_ATTRIBUTE_VALUE, storage.isDistributed());
+
+        assertEquals(UNEXPECTED_ATTRIBUTE_VALUE, storage.isRandomAccess(), !storage.isSequentialAccess());
+        assertTrue(UNEXPECTED_ATTRIBUTE_VALUE, storage.isRandomAccess());
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/RandomAccessSparseVectorStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/RandomAccessSparseVectorStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/RandomAccessSparseVectorStorageTest.java
new file mode 100644
index 0000000..6578e14
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/RandomAccessSparseVectorStorageTest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Unit tests for {@link SparseLocalOnHeapVectorStorage}.
+ */
+public class RandomAccessSparseVectorStorageTest extends VectorBaseStorageTest<SparseLocalOnHeapVectorStorage> {
+    /** */
+    @Override public void setUp() {
+        storage = new SparseLocalOnHeapVectorStorage(MathTestConstants.STORAGE_SIZE, StorageConstants.RANDOM_ACCESS_MODE);
+    }
+
+    /** */
+    @Test
+    public void data() throws Exception {
+        assertNull(MathTestConstants.NULL_VAL, storage.data());
+    }
+
+    /** */
+    @Test
+    public void isSequentialAccess() throws Exception {
+        assertFalse(MathTestConstants.UNEXPECTED_VAL, storage.isSequentialAccess());
+    }
+
+    /** */
+    @Test
+    public void isDense() throws Exception {
+        assertFalse(MathTestConstants.UNEXPECTED_VAL, storage.isDense());
+    }
+
+    /** */
+    @Test
+    public void isArrayBased() throws Exception {
+        assertFalse(MathTestConstants.UNEXPECTED_VAL, storage.isArrayBased());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
new file mode 100644
index 0000000..7e5fc48
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import org.apache.ignite.ml.math.ExternalizeTest;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.apache.ignite.ml.math.impls.MathTestConstants.STORAGE_SIZE;
+import static org.apache.ignite.ml.math.impls.MathTestConstants.UNEXPECTED_VAL;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests for {@link SparseLocalOffHeapVectorStorage}.
+ */
+public class SparseLocalOffHeapVectorStorageTest extends ExternalizeTest<SparseLocalOffHeapVectorStorage> {
+    /** */ private SparseLocalOffHeapVectorStorage testVectorStorage;
+
+    /** */
+    @Before
+    public void setup() {
+        testVectorStorage = new SparseLocalOffHeapVectorStorage(STORAGE_SIZE);
+    }
+
+    /** */
+    @After
+    public void teardown() {
+        testVectorStorage.destroy();
+        testVectorStorage = null;
+    }
+
+    /** */
+    @Test
+    public void testBasic() {
+        for (int i = 0; i < STORAGE_SIZE; i++) {
+            double testVal = Math.random();
+            testVectorStorage.set(i, testVal);
+            assertEquals(UNEXPECTED_VAL, testVal, testVectorStorage.get(i), 0d);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Test(expected = UnsupportedOperationException.class)
+    @Override public void externalizeTest() {
+        super.externalizeTest(new SparseLocalOffHeapVectorStorage(STORAGE_SIZE));
+    }
+
+    /** */
+    @Test
+    public void testAttributes() {
+        SparseLocalOffHeapVectorStorage testVectorStorage = new SparseLocalOffHeapVectorStorage(STORAGE_SIZE);
+
+        assertTrue(UNEXPECTED_VAL, testVectorStorage.isRandomAccess());
+        assertFalse(UNEXPECTED_VAL, testVectorStorage.isSequentialAccess());
+        assertFalse(UNEXPECTED_VAL, testVectorStorage.isDense());
+        assertFalse(UNEXPECTED_VAL, testVectorStorage.isArrayBased());
+        assertFalse(UNEXPECTED_VAL, testVectorStorage.isDistributed());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/VectorArrayStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/VectorArrayStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/VectorArrayStorageTest.java
new file mode 100644
index 0000000..ce62b3e
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/VectorArrayStorageTest.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import java.util.Arrays;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Unit test for {@link ArrayVectorStorage}.
+ */
+public class VectorArrayStorageTest extends VectorBaseStorageTest<ArrayVectorStorage> {
+    /** */
+    @Override public void setUp() {
+        storage = new ArrayVectorStorage(MathTestConstants.STORAGE_SIZE);
+    }
+
+    /** */
+    @Test
+    public void isArrayBased() throws Exception {
+        assertTrue(MathTestConstants.WRONG_ATTRIBUTE_VAL, storage.isArrayBased());
+
+        assertTrue(MathTestConstants.WRONG_ATTRIBUTE_VAL, new ArrayVectorStorage().isArrayBased());
+    }
+
+    /** */
+    @Test
+    public void data() throws Exception {
+        assertNotNull(MathTestConstants.NULL_DATA_STORAGE, storage.data());
+
+        assertEquals(MathTestConstants.WRONG_DATA_SIZE, storage.data().length, MathTestConstants.STORAGE_SIZE);
+
+        assertTrue(MathTestConstants.UNEXPECTED_DATA_VAL, Arrays.equals(storage.data(), new double[MathTestConstants.STORAGE_SIZE]));
+
+        assertNull(MathTestConstants.UNEXPECTED_DATA_VAL, new ArrayVectorStorage().data());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/VectorBaseStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/VectorBaseStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/VectorBaseStorageTest.java
new file mode 100644
index 0000000..206fe85
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/VectorBaseStorageTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import org.apache.ignite.ml.math.ExternalizeTest;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Abstract class with base tests for each vector storage.
+ */
+public abstract class VectorBaseStorageTest<T extends VectorStorage> extends ExternalizeTest<T> {
+    /** */
+    protected T storage;
+
+    /** */
+    @Before
+    public abstract void setUp();
+
+    /** */
+    @After
+    public void tearDown() throws Exception {
+        storage.destroy();
+    }
+
+    /** */
+    @Test
+    public void getSet() throws Exception {
+        for (int i = 0; i < MathTestConstants.STORAGE_SIZE; i++) {
+            double random = Math.random();
+
+            storage.set(i, random);
+
+            assertEquals(MathTestConstants.WRONG_DATA_ELEMENT, storage.get(i), random, MathTestConstants.NIL_DELTA);
+        }
+    }
+
+    /** */
+    @Test
+    public void size() {
+        assertTrue(MathTestConstants.UNEXPECTED_VAL, storage.size() == MathTestConstants.STORAGE_SIZE);
+    }
+
+    /** */
+    @Override public void externalizeTest() {
+        super.externalizeTest(storage);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/VectorOffheapStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/VectorOffheapStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/VectorOffheapStorageTest.java
new file mode 100644
index 0000000..6b719d0
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/VectorOffheapStorageTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.storage.vector;
+
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Unit tests for {@link DenseLocalOffHeapVectorStorage}.
+ */
+public class VectorOffheapStorageTest extends VectorBaseStorageTest<DenseLocalOffHeapVectorStorage> {
+    /** */
+    @Before
+    public void setUp() {
+        storage = new DenseLocalOffHeapVectorStorage(MathTestConstants.STORAGE_SIZE);
+    }
+
+    /** */
+    @Test
+    public void isArrayBased() throws Exception {
+        assertFalse(MathTestConstants.UNEXPECTED_VAL, storage.isArrayBased());
+    }
+
+    /** */
+    @Test
+    public void data() throws Exception {
+        assertNull(MathTestConstants.NULL_VAL, storage.data());
+    }
+
+    /** */
+    @Test
+    public void isSequentialAccess() throws Exception {
+        assertTrue(MathTestConstants.UNEXPECTED_VAL, storage.isSequentialAccess());
+    }
+
+    /** */
+    @Test
+    public void isDense() throws Exception {
+        assertTrue(MathTestConstants.UNEXPECTED_VAL, storage.isDense());
+    }
+
+    /** */
+    @Test
+    public void equalsTest() {
+        //noinspection EqualsWithItself
+        assertTrue(MathTestConstants.VAL_NOT_EQUALS, storage.equals(storage));
+
+        //noinspection EqualsBetweenInconvertibleTypes
+        assertFalse(MathTestConstants.VALUES_SHOULD_BE_NOT_EQUALS,
+            storage.equals(new ArrayVectorStorage(MathTestConstants.STORAGE_SIZE)));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
new file mode 100644
index 0000000..fa66769
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
@@ -0,0 +1,543 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.Arrays;
+import java.util.stream.StreamSupport;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.exceptions.IndexException;
+import org.apache.ignite.ml.math.functions.Functions;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.apache.ignite.ml.math.impls.storage.vector.ArrayVectorStorage;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Unit test for {@link AbstractVector}.
+ */
+public class AbstractVectorTest {
+    /** */
+    private AbstractVector testVector;
+
+    /** */
+    @Before
+    public void setUp() {
+        testVector = getAbstractVector();
+    }
+
+    /** */
+    @Test
+    public void setStorage() {
+        testVector.setStorage(createStorage());
+
+        assertTrue(testVector.size() == MathTestConstants.STORAGE_SIZE);
+    }
+
+    /** */
+    @Test
+    public void size() {
+        testVector.setStorage(createStorage());
+        assertTrue(testVector.size() == MathTestConstants.STORAGE_SIZE);
+
+        testVector.setStorage(new ArrayVectorStorage(MathTestConstants.STORAGE_SIZE + MathTestConstants.STORAGE_SIZE));
+        assertTrue(testVector.size() == MathTestConstants.STORAGE_SIZE + MathTestConstants.STORAGE_SIZE);
+
+        testVector = getAbstractVector(createStorage());
+        assertTrue(testVector.size() == MathTestConstants.STORAGE_SIZE);
+    }
+
+    /** */
+    @Test
+    public void getPositive() {
+        testVector = getAbstractVector(createStorage());
+
+        for (int i = 0; i < MathTestConstants.STORAGE_SIZE; i++)
+            assertNotNull(MathTestConstants.NULL_VALUES, testVector.get(i));
+
+    }
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void getNegative0() {
+        testVector.get(0);
+    }
+
+    /** */
+    @Test(expected = IndexException.class)
+    public void getNegative1() {
+        testVector.setStorage(createStorage());
+
+        testVector.get(-1);
+    }
+
+    /** */
+    @Test(expected = IndexException.class)
+    public void getNegative2() {
+        testVector.setStorage(createStorage());
+
+        testVector.get(testVector.size() + 1);
+    }
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void getXNegative0() {
+        testVector.getX(0);
+    }
+
+    /** */
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void getXNegative1() {
+        testVector.setStorage(createStorage());
+
+        testVector.getX(-1);
+    }
+
+    /** */
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void getXNegative2() {
+        testVector.setStorage(createStorage());
+
+        testVector.getX(MathTestConstants.STORAGE_SIZE + 1);
+    }
+
+    /** */
+    @Test
+    public void set() {
+        double[] data = initVector();
+
+        for (int i = 0; i < MathTestConstants.STORAGE_SIZE; i++)
+            testVector.set(i, Math.exp(data[i]));
+
+        for (int i = 0; i < MathTestConstants.STORAGE_SIZE; i++)
+            assertEquals(MathTestConstants.VAL_NOT_EQUALS, testVector.get(i), Math.exp(data[i]), MathTestConstants.NIL_DELTA);
+    }
+
+    /** */
+    @Test(expected = IndexException.class)
+    public void setNegative0() {
+        testVector.set(-1, -1);
+    }
+
+    /** */
+    @Test(expected = IndexException.class)
+    public void setNegative1() {
+        initVector();
+
+        testVector.set(-1, -1);
+    }
+
+    /** */
+    @Test(expected = IndexException.class)
+    public void setNegative2() {
+        initVector();
+
+        testVector.set(MathTestConstants.STORAGE_SIZE + 1, -1);
+    }
+
+    /** */
+    @Test(expected = IndexOutOfBoundsException.class)
+    public void setXNegative0() {
+        initVector();
+
+        testVector.setX(-1, -1);
+    }
+
+    /** */
+    @Test(expected = IndexOutOfBoundsException.class)
+    public void setXNegative1() {
+        initVector();
+
+        testVector.setX(MathTestConstants.STORAGE_SIZE + 1, -1);
+    }
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void setXNegative2() {
+        testVector.setX(-1, -1);
+    }
+
+    /** */
+    @Test
+    public void isZero() {
+        assertTrue(MathTestConstants.UNEXPECTED_VAL, testVector.isZero(0d));
+
+        assertFalse(MathTestConstants.UNEXPECTED_VAL, testVector.isZero(1d));
+    }
+
+    /** */
+    @Test
+    public void guid() {
+        assertNotNull(MathTestConstants.NULL_GUID, testVector.guid());
+
+        assertEquals(MathTestConstants.UNEXPECTED_GUID_VAL, testVector.guid(), testVector.guid());
+
+        assertFalse(MathTestConstants.EMPTY_GUID, testVector.guid().toString().isEmpty());
+
+        testVector = getAbstractVector(createStorage());
+
+        assertNotNull(MathTestConstants.NULL_GUID, testVector.guid());
+
+        assertEquals(MathTestConstants.UNEXPECTED_GUID_VAL, testVector.guid(), testVector.guid());
+
+        assertFalse(MathTestConstants.EMPTY_GUID, testVector.guid().toString().isEmpty());
+    }
+
+    /** */
+    @Test
+    public void equalsTest() {
+        VectorStorage storage = createStorage();
+
+        AbstractVector testVector1 = getAbstractVector();
+
+        testVector1.setStorage(storage);
+
+        AbstractVector testVector2 = getAbstractVector();
+
+        assertEquals(MathTestConstants.VAL_NOT_EQUALS, testVector, testVector);
+
+        testVector2.setStorage(storage);
+
+        assertTrue(MathTestConstants.VAL_NOT_EQUALS, testVector1.equals(testVector2));
+
+        assertFalse(MathTestConstants.VALUES_SHOULD_BE_NOT_EQUALS, testVector1.equals(testVector));
+    }
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void all() {
+        assertNotNull(MathTestConstants.NULL_VAL, testVector.all());
+
+        assertNotNull(MathTestConstants.NULL_VAL, getAbstractVector(createStorage()).all());
+
+        getAbstractVector().all().iterator().next();
+    }
+
+    /** */
+    @Test
+    public void nonZeroElements() {
+        VectorStorage storage = createStorage();
+
+        double[] data = storage.data();
+
+        testVector = getAbstractVector(storage);
+
+        assertEquals(MathTestConstants.VAL_NOT_EQUALS, testVector.nonZeroElements(), Arrays.stream(data).filter(x -> x != 0d).count());
+
+        addNilValues(data);
+
+        assertEquals(MathTestConstants.VAL_NOT_EQUALS, testVector.nonZeroElements(), Arrays.stream(data).filter(x -> x != 0d).count());
+    }
+
+    /** */
+    @Test
+    public void foldMapWithSecondVector() {
+        double[] data0 = initVector();
+
+        VectorStorage storage1 = createStorage();
+
+        double[] data1 = storage1.data().clone();
+
+        AbstractVector testVector1 = getAbstractVector(storage1);
+
+        String testVal = "";
+
+        for (int i = 0; i < data0.length; i++)
+            testVal += data0[i] + data1[i];
+
+        assertEquals(MathTestConstants.VAL_NOT_EQUALS, testVector.foldMap(testVector1, (string, xi) -> string.concat(xi.toString()), Functions.PLUS, ""), testVal);
+    }
+
+    /** */
+    @Test
+    public void nonZeroes() {
+        assertNotNull(MathTestConstants.NULL_VAL, testVector.nonZeroes());
+
+        double[] data = initVector();
+
+        assertNotNull(MathTestConstants.NULL_VAL, testVector.nonZeroes());
+
+        Assert.assertEquals(MathTestConstants.VAL_NOT_EQUALS, StreamSupport.stream(testVector.nonZeroes().spliterator(), false).count(), Arrays.stream(data).filter(x -> x != 0d).count());
+
+        addNilValues(data);
+
+        Assert.assertEquals(MathTestConstants.VAL_NOT_EQUALS, StreamSupport.stream(testVector.nonZeroes().spliterator(), false).count(), Arrays.stream(data).filter(x -> x != 0d).count());
+    }
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void nonZeroesEmpty() {
+        testVector.nonZeroes().iterator().next();
+    }
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void assign() {
+        testVector.assign(MathTestConstants.TEST_VAL);
+    }
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void assignArr() {
+        testVector.assign(new double[1]);
+    }
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void assignArrEmpty() {
+        testVector.assign(new double[0]);
+    }
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void dotNegative() {
+        testVector.dot(getAbstractVector(createEmptyStorage()));
+    }
+
+    /** */
+    @Test
+    public void dotSelf() {
+        double[] data = initVector();
+
+        assertEquals(MathTestConstants.VAL_NOT_EQUALS, testVector.dotSelf(), Arrays.stream(data).reduce(0, (x, y) -> x + y * y), MathTestConstants.NIL_DELTA);
+    }
+
+    /** */
+    @Test
+    public void getStorage() {
+        assertNotNull(MathTestConstants.NULL_VAL, getAbstractVector(createEmptyStorage()));
+        assertNotNull(MathTestConstants.NULL_VAL, getAbstractVector(createStorage()));
+        testVector.setStorage(createStorage());
+        assertNotNull(MathTestConstants.NULL_VAL, testVector.getStorage());
+    }
+
+    /** */
+    @Test
+    public void getElement() {
+        double[] data = initVector();
+
+        for (int i = 0; i < data.length; i++) {
+            assertNotNull(MathTestConstants.NULL_VAL, testVector.getElement(i));
+
+            assertEquals(MathTestConstants.UNEXPECTED_VAL, testVector.getElement(i).get(), data[i], MathTestConstants.NIL_DELTA);
+
+            testVector.getElement(i).set(++data[i]);
+
+            assertEquals(MathTestConstants.UNEXPECTED_VAL, testVector.getElement(i).get(), data[i], MathTestConstants.NIL_DELTA);
+        }
+    }
+
+    /**
+     * Create {@link AbstractVector} with storage for tests.
+     *
+     * @param storage {@link VectorStorage}
+     * @return AbstractVector.
+     */
+    private AbstractVector getAbstractVector(VectorStorage storage) {
+        return new AbstractVector(storage) { // TODO: find out how to fix warning about missing constructor
+            /** */
+            @Override public boolean isDense() {
+                return false;
+            }
+
+            /** */
+            @Override public boolean isSequentialAccess() {
+                return false;
+            }
+
+            /** */
+            @Override public Matrix likeMatrix(int rows, int cols) {
+                return null;
+            }
+
+            /** */
+            @Override public Vector copy() {
+                return getAbstractVector(this.getStorage());
+            }
+
+            /** */
+            @Override public Vector like(int crd) {
+                return null;
+            }
+
+            /** */
+            @Override public Vector normalize() {
+                return null;
+            }
+
+            /** */
+            @Override public Vector normalize(double power) {
+                return null;
+            }
+
+            /** */
+            @Override public Vector logNormalize() {
+                return null;
+            }
+
+            /** */
+            @Override public Vector logNormalize(double power) {
+                return null;
+            }
+
+            /** */
+            @Override public Vector viewPart(int off, int len) {
+                return null;
+            }
+
+            /** {@inheritDoc} */
+            @Override public boolean isRandomAccess() {
+                return true;
+            }
+
+            /** {@inheritDoc} */
+            @Override public boolean isDistributed() {
+                return false;
+            }
+        };
+    }
+
+    /**
+     * Create empty {@link AbstractVector} for tests.
+     *
+     * @return AbstractVector.
+     */
+    private AbstractVector getAbstractVector() {
+        return new AbstractVector() { // TODO: find out how to fix warning about missing constructor
+            /** */
+            @Override public boolean isDense() {
+                return false;
+            }
+
+            /** */
+            @Override public Matrix likeMatrix(int rows, int cols) {
+                return null;
+            }
+
+            /** */
+            @Override public boolean isSequentialAccess() {
+                return false;
+            }
+
+            /** */
+            @Override public Vector copy() {
+                return getAbstractVector(this.getStorage());
+            }
+
+            /** */
+            @Override public Vector like(int crd) {
+                return null;
+            }
+
+            /** */
+            @Override public Vector normalize() {
+                return null;
+            }
+
+            /** */
+            @Override public Vector normalize(double power) {
+                return null;
+            }
+
+            /** */
+            @Override public Vector logNormalize() {
+                return null;
+            }
+
+            /** */
+            @Override public Vector logNormalize(double power) {
+                return null;
+            }
+
+            /** */
+            @Override public Vector viewPart(int off, int len) {
+                return null;
+            }
+
+            /** {@inheritDoc} */
+            @Override public boolean isRandomAccess() {
+                return true;
+            }
+
+            /** {@inheritDoc} */
+            @Override public boolean isDistributed() {
+                return false;
+            }
+        };
+    }
+
+    /**
+     * Create {@link VectorStorage} for tests.
+     *
+     * @return VectorStorage
+     */
+    private VectorStorage createEmptyStorage() {
+        return new ArrayVectorStorage(MathTestConstants.STORAGE_SIZE);
+    }
+
+    /**
+     * Create filled {@link VectorStorage} for tests.
+     *
+     * @return VectorStorage.
+     */
+    private VectorStorage createStorage() {
+        ArrayVectorStorage storage = new ArrayVectorStorage(MathTestConstants.STORAGE_SIZE);
+
+        for (int i = 0; i < MathTestConstants.STORAGE_SIZE; i++)
+            storage.set(i, Math.random());
+
+        return storage;
+    }
+
+    /**
+     * Init vector and return initialized values.
+     *
+     * @return Initial values.
+     */
+    private double[] initVector() {
+        VectorStorage storage = createStorage();
+        double[] data = storage.data().clone();
+
+        testVector = getAbstractVector(storage);
+        return data;
+    }
+
+    /**
+     * Add some zeroes to vector elements.
+     */
+    private void addNilValues() {
+        testVector.set(10, 0);
+        testVector.set(50, 0);
+    }
+
+    /**
+     * Add some zeroes to vector elements. Also set zeroes to the same elements in reference array data
+     */
+    private void addNilValues(double[] testRef) {
+        addNilValues();
+        testRef[10] = 0;
+        testRef[50] = 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/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
new file mode 100644
index 0000000..0026e2b
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
@@ -0,0 +1,434 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.stream.IntStream;
+import junit.framework.TestCase;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.ml.math.IdentityValueMapper;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorKeyMapper;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.Functions;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.common.GridCommonTest;
+
+/**
+ * Tests for {@link CacheVector}.
+ */
+@GridCommonTest(group = "Distributed Models")
+public class CacheVectorTest extends GridCommonAbstractTest {
+    /** Number of nodes in grid */
+    private static final int NODE_COUNT = 3;
+    /** Cache name. */
+    private static final String CACHE_NAME = "test-cache";
+    /** Cache size. */
+    private static final int size = MathTestConstants.STORAGE_SIZE;
+    /** Grid instance. */
+    private Ignite ignite;
+    /** Default key mapper. */
+    private VectorKeyMapper<Integer> keyMapper = new TestKeyMapper();
+
+    /**
+     * Default constructor.
+     */
+    public CacheVectorTest() {
+        super(false);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        for (int i = 1; i <= NODE_COUNT; i++)
+            startGrid(i);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        ignite = grid(NODE_COUNT);
+
+        ignite.configuration().setPeerClassLoadingEnabled(true);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        ignite.destroyCache(CACHE_NAME);
+    }
+
+    /** */
+    public void testGetSet() throws Exception {
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        for (int i = 0; i < size; i++) {
+            double random = Math.random();
+            cacheVector.set(i, random);
+            assertEquals("Unexpected value.", random, cacheVector.get(i), 0d);
+        }
+    }
+
+    /** */
+    public void testMap() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        initVector(cacheVector);
+
+        cacheVector.map(value -> 110d);
+
+        for (int i = 0; i < size; i++)
+            assertEquals("Unexpected value.", cacheVector.get(i), 110d, 0d);
+    }
+
+    /** */
+    public void testMapBiFunc() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        initVector(cacheVector);
+
+        cacheVector.map(Functions.PLUS, 1d);
+
+        for (int i = 0; i < size; i++)
+            assertEquals("Unexpected value.", cacheVector.get(i), 1d, 0d);
+    }
+
+    /** */
+    public void testSum() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        initVector(cacheVector);
+
+        assertEquals("Unexpected value.", cacheVector.sum(), 0d, 0d);
+
+        cacheVector.assign(1d);
+
+        assertEquals("Unexpected value.", cacheVector.sum(), size, 0d);
+    }
+
+    /** */
+    public void testSumNegative() {
+        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.
+        }
+    }
+
+    /** */
+    public void testAssign() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        initVector(cacheVector);
+
+        cacheVector.assign(1d);
+
+        for (int i = 0; i < size; i++)
+            assertEquals("Unexpected value.", cacheVector.get(i), 1d, 0d);
+    }
+
+    /** */
+    public void testAssignRange() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        cacheVector.assign(IntStream.range(0, size).asDoubleStream().toArray());
+
+        for (int i = 0; i < size; i++)
+            assertEquals("Unexpected value.", cacheVector.get(i), i, 0d);
+    }
+
+    /** */
+    public void testAssignVector() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        Vector testVec = new DenseLocalOnHeapVector(IntStream.range(0, size).asDoubleStream().toArray());
+
+        cacheVector.assign(testVec);
+
+        for (int i = 0; i < size; i++)
+            assertEquals("Unexpected value.", cacheVector.get(i), testVec.get(i), 0d);
+    }
+
+    /** */
+    public void testAssignFunc() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        cacheVector.assign(idx -> idx);
+
+        for (int i = 0; i < size; i++)
+            assertEquals("Unexpected value.", cacheVector.get(i), i, 0d);
+    }
+
+    /** */
+    public void testPlus() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        initVector(cacheVector);
+
+        cacheVector.plus(1d);
+
+        for (int i = 0; i < size; i++)
+            assertEquals("Unexpected value.", cacheVector.get(i), 1d, 0d);
+    }
+
+    /** */
+    public void testPlusVec() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        Vector testVec = new DenseLocalOnHeapVector(IntStream.range(0, size).asDoubleStream().toArray());
+
+        try {
+            cacheVector.plus(testVec);
+            TestCase.fail();
+        }
+        catch (UnsupportedOperationException ignored) {
+
+        }
+    }
+
+    /** */
+    public void testDivide() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        final int size = MathTestConstants.STORAGE_SIZE;
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        initVector(cacheVector);
+        cacheVector.assign(1d);
+
+        cacheVector.divide(2d);
+
+        for (int i = 0; i < size; i++)
+            assertEquals("Unexpected value.", cacheVector.get(i), 1d / 2d, 0d);
+    }
+
+    /** */
+    public void testTimes() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        final int size = MathTestConstants.STORAGE_SIZE;
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        initVector(cacheVector);
+        cacheVector.assign(1d);
+
+        cacheVector.times(2d);
+
+        for (int i = 0; i < size; i++)
+            assertEquals("Unexpected value.", cacheVector.get(i), 2d, 0d);
+    }
+
+    /** */
+    public void testTimesVector() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        cacheVector.assign(1d);
+        Vector testVec = new DenseLocalOnHeapVector(IntStream.range(0, size).asDoubleStream().toArray());
+
+        try {
+            cacheVector.times(testVec);
+            TestCase.fail();
+        }
+        catch (UnsupportedOperationException ignored) {
+
+        }
+
+    }
+
+    /** */
+    public void testMin() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        Vector testVec = new DenseLocalOnHeapVector(IntStream.range(0, size).asDoubleStream().toArray());
+
+        cacheVector.assign(testVec);
+
+        assertEquals("Unexpected value.", cacheVector.minValue(), 0d, 0d);
+    }
+
+    /** */
+    public void testMax() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        Vector testVec = new DenseLocalOnHeapVector(IntStream.range(0, size).asDoubleStream().toArray());
+
+        cacheVector.assign(testVec);
+
+        assertEquals("Unexpected value.", cacheVector.maxValue(), testVec.get(size - 1), 0d);
+    }
+
+    /** */
+    public void testLike() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        try {
+            cacheVector.like(size);
+            TestCase.fail("Unsupported case");
+        }
+        catch (UnsupportedOperationException ignored) {
+
+        }
+    }
+
+    /** */
+    public void testLikeMatrix() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        try {
+            cacheVector.likeMatrix(size, size);
+            TestCase.fail("Unsupported case");
+        }
+        catch (UnsupportedOperationException ignored) {
+
+        }
+    }
+
+    /** */
+    public void testCopy() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        try {
+            cacheVector.copy();
+            TestCase.fail("Unsupported case");
+        }
+        catch (UnsupportedOperationException ignored) {
+
+        }
+    }
+
+    /** */
+    public void testExternalize() throws IOException, ClassNotFoundException {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        IdentityValueMapper valMapper = new IdentityValueMapper();
+        CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
+
+        cacheVector.set(1, 1.0);
+
+        ByteArrayOutputStream byteArrOutputStream = new ByteArrayOutputStream();
+        ObjectOutputStream objOutputStream = new ObjectOutputStream(byteArrOutputStream);
+
+        objOutputStream.writeObject(cacheVector);
+
+        ByteArrayInputStream byteArrInputStream = new ByteArrayInputStream(byteArrOutputStream.toByteArray());
+        ObjectInputStream objInputStream = new ObjectInputStream(byteArrInputStream);
+
+        CacheVector objRestored = (CacheVector)objInputStream.readObject();
+
+        assertTrue(MathTestConstants.VAL_NOT_EQUALS, cacheVector.equals(objRestored));
+        assertEquals(MathTestConstants.VAL_NOT_EQUALS, objRestored.get(1), 1.0, 0.0);
+    }
+
+    /** */
+    private void initVector(CacheVector cacheVector) {
+        for (int i = 0; i < cacheVector.size(); i++)
+            cacheVector.set(i, 0d);
+    }
+
+    /** */
+    private IgniteCache<Integer, Double> getCache() {
+        assert ignite != null;
+
+        CacheConfiguration cfg = new CacheConfiguration();
+        cfg.setName(CACHE_NAME);
+
+        IgniteCache<Integer, Double> cache = ignite.getOrCreateCache(CACHE_NAME);
+
+        assert cache != null;
+        return cache;
+    }
+
+    /** */ private static class TestKeyMapper implements VectorKeyMapper<Integer> {
+        /** {@inheritDoc} */
+        @Override public Integer apply(int i) {
+            return i;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean isValid(Integer i) {
+            return i < size;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/ConstantVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/ConstantVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/ConstantVectorConstructorTest.java
new file mode 100644
index 0000000..c5c0bbd
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/ConstantVectorConstructorTest.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/** */
+public class ConstantVectorConstructorTest {
+    /** */
+    private static final int IMPOSSIBLE_SIZE = -1;
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void negativeSizeTest() {
+        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
+            new ConstantVector(-1, 1).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void zeroSizeTest() {
+        assertEquals("Zero size.", IMPOSSIBLE_SIZE,
+            new ConstantVector(0, 1).size());
+    }
+
+    /** */
+    @Test
+    public void primitiveTest() {
+        assertEquals("1 size.", 1,
+            new ConstantVector(1, 1).size());
+
+        assertEquals("2 size.", 2,
+            new ConstantVector(2, 1).size());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/DelegatingVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/DelegatingVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/DelegatingVectorConstructorTest.java
new file mode 100644
index 0000000..1a9884f
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/DelegatingVectorConstructorTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import org.apache.ignite.ml.math.Vector;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/** */
+public class DelegatingVectorConstructorTest {
+    /** */
+    private static final int IMPOSSIBLE_SIZE = -1;
+
+    /** */
+    @Test
+    public void basicTest() {
+        final Vector parent = new DenseLocalOnHeapVector(new double[] {0, 1});
+
+        final Vector delegate = new DelegatingVector(parent);
+
+        final int size = parent.size();
+
+        assertEquals("Delegate size differs from expected.", size, delegate.size());
+
+        for (int idx = 0; idx < size; idx++)
+            assertDelegate(parent, delegate, idx);
+    }
+
+    /** */
+    private void assertDelegate(Vector parent, Vector delegate, int idx) {
+        assertValue(parent, delegate, idx);
+
+        parent.set(idx, parent.get(idx) + 1);
+
+        assertValue(parent, delegate, idx);
+
+        delegate.set(idx, delegate.get(idx) + 2);
+
+        assertValue(parent, delegate, idx);
+    }
+
+    /** */
+    private void assertValue(Vector parent, Vector delegate, int idx) {
+        assertEquals("Unexpected value at index " + idx, parent.get(idx), delegate.get(idx), 0d);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOffHeapVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOffHeapVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOffHeapVectorConstructorTest.java
new file mode 100644
index 0000000..1a979bd
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOffHeapVectorConstructorTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/** */
+public class DenseLocalOffHeapVectorConstructorTest {
+    /** */
+    private static final int IMPOSSIBLE_SIZE = -1;
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void negativeSizeTest() {
+        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
+            new DenseLocalOffHeapVector(-1).size());
+    }
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void nullArrayTest() {
+        assertEquals("Null array.", IMPOSSIBLE_SIZE,
+            new DenseLocalOffHeapVector(null).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void zeroSizeTest() {
+        assertEquals("0 size.", IMPOSSIBLE_SIZE,
+            new DenseLocalOffHeapVector(new double[0]).size());
+    }
+
+    /** */
+    @Test
+    public void primitiveTest() {
+        assertEquals("1 size.", 1,
+            new DenseLocalOffHeapVector(new double[1]).size());
+
+        assertEquals("2 size.", 2,
+            new DenseLocalOffHeapVector(new double[2]).size());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOnHeapVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOnHeapVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOnHeapVectorConstructorTest.java
new file mode 100644
index 0000000..df504f3
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/DenseLocalOnHeapVectorConstructorTest.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/** */
+public class DenseLocalOnHeapVectorConstructorTest {
+    /** */
+    private static final int IMPOSSIBLE_SIZE = -1;
+
+    /** */
+    @Test(expected = UnsupportedOperationException.class)
+    public void mapInvalidArgsTest() {
+        assertEquals("Expect exception due to invalid args.", IMPOSSIBLE_SIZE,
+            new DenseLocalOnHeapVector(new HashMap<String, Object>() {{
+                put("invalid", 99);
+            }}).size());
+    }
+
+    /** */
+    @Test(expected = UnsupportedOperationException.class)
+    public void mapMissingArgsTest() {
+        final Map<String, Object> test = new HashMap<String, Object>() {{
+            put("arr", new double[0]);
+            put("shallowCopyMissing", "whatever");
+        }};
+
+        assertEquals("Expect exception due to missing args.", IMPOSSIBLE_SIZE,
+            new DenseLocalOnHeapVector(test).size());
+    }
+
+    /** */
+    @Test(expected = ClassCastException.class)
+    public void mapInvalidArrTypeTest() {
+        final Map<String, Object> test = new HashMap<String, Object>() {{
+            put("size", "whatever");
+        }};
+
+        assertEquals("Expect exception due to invalid arr type.", IMPOSSIBLE_SIZE,
+            new DenseLocalOnHeapVector(test).size());
+    }
+
+    /** */
+    @Test(expected = UnsupportedOperationException.class)
+    public void mapInvalidCopyTypeTest() {
+        final Map<String, Object> test = new HashMap<String, Object>() {{
+            put("arr", new double[0]);
+            put("shallowCopy", 0);
+        }};
+
+        assertEquals("Expect exception due to invalid copy type.", IMPOSSIBLE_SIZE,
+            new DenseLocalOnHeapVector(test).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void mapNullTest() {
+        //noinspection ConstantConditions
+        assertEquals("Null map args.", IMPOSSIBLE_SIZE,
+            new DenseLocalOnHeapVector((Map<String, Object>)null).size());
+    }
+
+    /** */
+    @Test
+    public void mapTest() {
+        assertEquals("Size from args.", 99,
+            new DenseLocalOnHeapVector(new HashMap<String, Object>() {{
+                put("size", 99);
+            }}).size());
+
+        final double[] test = new double[99];
+
+        assertEquals("Size from array in args.", test.length,
+            new DenseLocalOnHeapVector(new HashMap<String, Object>() {{
+                put("arr", test);
+                put("copy", false);
+            }}).size());
+
+        assertEquals("Size from array in args, shallow copy.", test.length,
+            new DenseLocalOnHeapVector(new HashMap<String, Object>() {{
+                put("arr", test);
+                put("copy", true);
+            }}).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void negativeSizeTest() {
+        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
+            new DenseLocalOnHeapVector(-1).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void nullCopyTest() {
+        assertEquals("Null array to non-shallow copy.", IMPOSSIBLE_SIZE,
+            new DenseLocalOnHeapVector(null, false).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void nullDefaultCopyTest() {
+        assertEquals("Null array default copy.", IMPOSSIBLE_SIZE,
+            new DenseLocalOnHeapVector((double[])null).size());
+    }
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void defaultConstructorTest() {
+        assertEquals("Default constructor.", IMPOSSIBLE_SIZE,
+            new DenseLocalOnHeapVector().size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void nullArrShallowCopyTest() {
+        assertEquals("Null array shallow copy.", IMPOSSIBLE_SIZE,
+            new DenseLocalOnHeapVector(null, true).size());
+    }
+
+    /** */
+    @Test
+    public void primitiveTest() {
+        assertEquals("0 size shallow copy.", 0,
+            new DenseLocalOnHeapVector(new double[0], true).size());
+
+        assertEquals("0 size.", 0,
+            new DenseLocalOnHeapVector(new double[0], false).size());
+
+        assertEquals("1 size shallow copy.", 1,
+            new DenseLocalOnHeapVector(new double[1], true).size());
+
+        assertEquals("1 size.", 1,
+            new DenseLocalOnHeapVector(new double[1], false).size());
+
+        assertEquals("0 size default copy.", 0,
+            new DenseLocalOnHeapVector(new double[0]).size());
+
+        assertEquals("1 size default copy.", 1,
+            new DenseLocalOnHeapVector(new double[1]).size());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/FunctionVectorConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/FunctionVectorConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/FunctionVectorConstructorTest.java
new file mode 100644
index 0000000..1e99f7e
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/FunctionVectorConstructorTest.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.IntToDoubleFunction;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.functions.IgniteFunction;
+import org.apache.ignite.ml.math.functions.IntDoubleToVoidFunction;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/** */
+public class FunctionVectorConstructorTest {
+    /** */
+    private static final int IMPOSSIBLE_SIZE = -1;
+
+    /** */
+    @Test(expected = UnsupportedOperationException.class)
+    public void mapInvalidArgsTest() {
+        assertEquals("Expect exception due to invalid args.", IMPOSSIBLE_SIZE,
+            new FunctionVector(new HashMap<String, Object>() {{
+                put("invalid", 99);
+            }}).size());
+    }
+
+    /** */
+    @Test(expected = UnsupportedOperationException.class)
+    public void mapMissingArgsTest() {
+        final Map<String, Object> test = new HashMap<String, Object>() {{
+            put("size", 1);
+            put("paramMissing", "whatever");
+        }};
+
+        assertEquals("Expect exception due to missing args.",
+            -1, new FunctionVector(test).size());
+    }
+
+    /** */
+    @Test(expected = ClassCastException.class)
+    public void mapInvalidParamTypeTest() {
+        final Map<String, Object> test = new HashMap<String, Object>() {{
+            put("size", "whatever");
+
+            put("getFunc", (IntToDoubleFunction)i -> i);
+        }};
+
+        assertEquals("Expect exception due to invalid param type.", IMPOSSIBLE_SIZE,
+            new FunctionVector(test).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void mapNullTest() {
+        //noinspection ConstantConditions
+        assertEquals("Null map args.", IMPOSSIBLE_SIZE,
+            new FunctionVector(null).size());
+    }
+
+    /** */
+    @Test
+    public void mapTest() {
+        assertEquals("Size from args.", 99,
+            new FunctionVector(new HashMap<String, Object>() {{
+                put("size", 99);
+
+                put("getFunc", (IgniteFunction<Integer, Double>)i -> (double)i);
+            }}).size());
+
+        assertEquals("Size from args with setFunc.", 99,
+            new FunctionVector(new HashMap<String, Object>() {{
+                put("size", 99);
+
+                put("getFunc", (IgniteFunction<Integer, Double>)i -> (double)i);
+
+                put("setFunc", (IntDoubleToVoidFunction)(integer, aDouble) -> {
+                });
+            }}).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void negativeSizeTest() {
+        assertEquals("Negative size.", IMPOSSIBLE_SIZE,
+            new FunctionVector(-1, (i) -> (double)i).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void zeroSizeTest() {
+        assertEquals("0 size.", IMPOSSIBLE_SIZE,
+            new FunctionVector(0, (i) -> (double)i).size());
+    }
+
+    /** */
+    @Test
+    public void primitiveTest() {
+        assertEquals("1 size.", 1,
+            new FunctionVector(1, (i) -> (double)i).size());
+
+        assertEquals("2 size.", 2,
+            new FunctionVector(2, (i) -> (double)i).size());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorViewTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorViewTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorViewTest.java
new file mode 100644
index 0000000..c861a0e
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorViewTest.java
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.IndexException;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests for {@link MatrixVectorView}.
+ */
+public class MatrixVectorViewTest {
+    /** */
+    private static final String UNEXPECTED_VALUE = "Unexpected value";
+    /** */
+    private static final int SMALL_SIZE = 3;
+    /** */
+    private static final int IMPOSSIBLE_SIZE = -1;
+
+    /** */
+    private Matrix parent;
+
+    /** */
+    @Before
+    public void setup() {
+        parent = newMatrix(SMALL_SIZE, SMALL_SIZE);
+    }
+
+    /** */
+    @Test
+    public void testDiagonal() {
+        Vector vector = parent.viewDiagonal();
+
+        for (int i = 0; i < SMALL_SIZE; i++)
+            assertView(i, i, vector, i);
+    }
+
+    /** */
+    @Test
+    public void testRow() {
+        for (int i = 0; i < SMALL_SIZE; i++) {
+            Vector viewRow = parent.viewRow(i);
+
+            for (int j = 0; j < SMALL_SIZE; j++)
+                assertView(i, j, viewRow, j);
+        }
+    }
+
+    /** */
+    @Test
+    public void testCols() {
+        for (int i = 0; i < SMALL_SIZE; i++) {
+            Vector viewCol = parent.viewColumn(i);
+
+            for (int j = 0; j < SMALL_SIZE; j++)
+                assertView(j, i, viewCol, j);
+        }
+    }
+
+    /** */
+    @Test
+    public void basicTest() {
+        for (int rowSize : new int[] {1, 2, 3, 4})
+            for (int colSize : new int[] {1, 2, 3, 4})
+                for (int row = 0; row < rowSize; row++)
+                    for (int col = 0; col < colSize; col++)
+                        for (int rowStride = 0; rowStride < rowSize; rowStride++)
+                            for (int colStride = 0; colStride < colSize; colStride++)
+                                if (rowStride != 0 || colStride != 0)
+                                    assertMatrixVectorView(newMatrix(rowSize, colSize), row, col, rowStride, colStride);
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void parentNullTest() {
+        //noinspection ConstantConditions
+        assertEquals(IMPOSSIBLE_SIZE,
+            new MatrixVectorView(null, 1, 1, 1, 1).size());
+    }
+
+    /** */
+    @Test(expected = IndexException.class)
+    public void rowNegativeTest() {
+        //noinspection ConstantConditions
+        assertEquals(IMPOSSIBLE_SIZE,
+            new MatrixVectorView(parent, -1, 1, 1, 1).size());
+    }
+
+    /** */
+    @Test(expected = IndexException.class)
+    public void colNegativeTest() {
+        //noinspection ConstantConditions
+        assertEquals(IMPOSSIBLE_SIZE,
+            new MatrixVectorView(parent, 1, -1, 1, 1).size());
+    }
+
+    /** */
+    @Test(expected = IndexException.class)
+    public void rowTooLargeTest() {
+        //noinspection ConstantConditions
+        assertEquals(IMPOSSIBLE_SIZE,
+            new MatrixVectorView(parent, parent.rowSize() + 1, 1, 1, 1).size());
+    }
+
+    /** */
+    @Test(expected = IndexException.class)
+    public void colTooLargeTest() {
+        //noinspection ConstantConditions
+        assertEquals(IMPOSSIBLE_SIZE,
+            new MatrixVectorView(parent, 1, parent.columnSize() + 1, 1, 1).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void rowStrideNegativeTest() {
+        //noinspection ConstantConditions
+        assertEquals(IMPOSSIBLE_SIZE,
+            new MatrixVectorView(parent, 1, 1, -1, 1).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void colStrideNegativeTest() {
+        //noinspection ConstantConditions
+        assertEquals(IMPOSSIBLE_SIZE,
+            new MatrixVectorView(parent, 1, 1, 1, -1).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void rowStrideTooLargeTest() {
+        //noinspection ConstantConditions
+        assertEquals(IMPOSSIBLE_SIZE,
+            new MatrixVectorView(parent, 1, 1, parent.rowSize() + 1, 1).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void colStrideTooLargeTest() {
+        //noinspection ConstantConditions
+        assertEquals(IMPOSSIBLE_SIZE,
+            new MatrixVectorView(parent, 1, 1, 1, parent.columnSize() + 1).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void bothStridesZeroTest() {
+        //noinspection ConstantConditions
+        assertEquals(IMPOSSIBLE_SIZE,
+            new MatrixVectorView(parent, 1, 1, 0, 0).size());
+    }
+
+    /** */
+    private void assertMatrixVectorView(Matrix parent, int row, int col, int rowStride, int colStride) {
+        MatrixVectorView view = new MatrixVectorView(parent, row, col, rowStride, colStride);
+
+        String desc = "parent [" + parent.rowSize() + "x" + parent.columnSize() + "], view ["
+            + row + "x" + col + "], strides [" + rowStride + ", " + colStride + "]";
+
+        final int size = view.size();
+
+        final int sizeByRows = rowStride == 0 ? IMPOSSIBLE_SIZE : (parent.rowSize() - row) / rowStride;
+        final int sizeByCols = colStride == 0 ? IMPOSSIBLE_SIZE : (parent.columnSize() - col) / colStride;
+
+        assertTrue("Size " + size + " differs from expected for " + desc,
+            size == sizeByRows || size == sizeByCols);
+
+        for (int idx = 0; idx < size; idx++) {
+            final int rowIdx = row + idx * rowStride;
+            final int colIdx = col + idx * colStride;
+
+            assertEquals(UNEXPECTED_VALUE + " at view index " + idx + desc,
+                parent.get(rowIdx, colIdx), view.get(idx), 0d);
+        }
+    }
+
+    /** */
+    private Matrix newMatrix(int rowSize, int colSize) {
+        Matrix res = new DenseLocalOnHeapMatrix(rowSize, colSize);
+
+        for (int i = 0; i < res.rowSize(); i++)
+            for (int j = 0; j < res.columnSize(); j++)
+                res.set(i, j, i * res.rowSize() + j);
+
+        return res;
+    }
+
+    /** */
+    private void assertView(int row, int col, Vector view, int viewIdx) {
+        assertValue(row, col, view, viewIdx);
+
+        parent.set(row, col, parent.get(row, col) + 1);
+
+        assertValue(row, col, view, viewIdx);
+
+        view.set(viewIdx, view.get(viewIdx) + 2);
+
+        assertValue(row, col, view, viewIdx);
+    }
+
+    /** */
+    private void assertValue(int row, int col, Vector view, int viewIdx) {
+        assertEquals(UNEXPECTED_VALUE + " at row " + row + " col " + col, parent.get(row, col), view.get(viewIdx), 0d);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorViewConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorViewConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorViewConstructorTest.java
new file mode 100644
index 0000000..72be324
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorViewConstructorTest.java
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.vector;
+
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.CardinalityException;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class PivotedVectorViewConstructorTest {
+    /** */
+    private static final int IMPOSSIBLE_SIZE = -1;
+
+    /** */
+    private static final SampleParams sampleParams = new SampleParams();
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void nullVecParamTest() {
+        assertEquals("Expect exception due to null vector param.", IMPOSSIBLE_SIZE,
+            new PivotedVectorView(null, sampleParams.pivot).size());
+    }
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void nullVecParam2Test() {
+        assertEquals("Expect exception due to null vector param, with unpivot.", IMPOSSIBLE_SIZE,
+            new PivotedVectorView(null, sampleParams.pivot, sampleParams.unpivot).size());
+    }
+
+    /** */
+    @Test(expected = NullPointerException.class)
+    public void nullPivotParamTest() {
+        assertEquals("Expect exception due to null pivot param.", IMPOSSIBLE_SIZE,
+            new PivotedVectorView(sampleParams.vec, null).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void nullPivotParam2Test() {
+        assertEquals("Expect exception due to null pivot param, with unpivot.", IMPOSSIBLE_SIZE,
+            new PivotedVectorView(sampleParams.vec, null, sampleParams.unpivot).size());
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void nullUnpivotParam2Test() {
+        assertEquals("Expect exception due to null unpivot param.", IMPOSSIBLE_SIZE,
+            new PivotedVectorView(sampleParams.vec, sampleParams.pivot, null).size());
+    }
+
+    /** */
+    @Test(expected = CardinalityException.class)
+    public void emptyPivotTest() {
+        assertEquals("Expect exception due to empty pivot param.", IMPOSSIBLE_SIZE,
+            new PivotedVectorView(sampleParams.vec, new int[] {}).size());
+    }
+
+    /** */
+    @Test(expected = CardinalityException.class)
+    public void emptyPivot2Test() {
+        assertEquals("Expect exception due to empty pivot param, with unpivot.", IMPOSSIBLE_SIZE,
+            new PivotedVectorView(sampleParams.vec, new int[] {}, sampleParams.unpivot).size());
+    }
+
+    /** */
+    @Test(expected = CardinalityException.class)
+    public void wrongPivotTest() {
+        assertEquals("Expect exception due to wrong pivot param.", IMPOSSIBLE_SIZE,
+            new PivotedVectorView(sampleParams.vec, new int[] {0}).size());
+    }
+
+    /** */
+    @Test(expected = CardinalityException.class)
+    public void wrongPivot2Test() {
+        assertEquals("Expect exception due to wrong pivot param, with unpivot.", IMPOSSIBLE_SIZE,
+            new PivotedVectorView(sampleParams.vec, new int[] {0}, sampleParams.unpivot).size());
+    }
+
+    /** */
+    @Test(expected = CardinalityException.class)
+    public void emptyUnpivotTest() {
+        assertEquals("Expect exception due to empty unpivot param.", IMPOSSIBLE_SIZE,
+            new PivotedVectorView(sampleParams.vec, sampleParams.pivot, new int[] {}).size());
+    }
+
+    /** */
+    @Test(expected = CardinalityException.class)
+    public void wrongUnpivotTest() {
+        assertEquals("Expect exception due to wrong unpivot param, with unpivot.", IMPOSSIBLE_SIZE,
+            new PivotedVectorView(sampleParams.vec, sampleParams.pivot, new int[] {0}).size());
+    }
+
+    /** */
+    @Test
+    public void basicPivotTest() {
+        final PivotedVectorView pvv = new PivotedVectorView(sampleParams.vec, sampleParams.pivot);
+
+        final int size = sampleParams.vec.size();
+
+        assertEquals("View size differs from expected.", size, pvv.size());
+
+        assertSame("Base vector differs from expected.", sampleParams.vec, pvv.getBaseVector());
+
+        for (int idx = 0; idx < size; idx++) {
+            assertEquals("Sample pivot and unpivot differ from expected",
+                idx, sampleParams.unpivot[sampleParams.pivot[idx]]);
+
+            assertEquals("Pivot differs from expected at index " + idx,
+                sampleParams.pivot[idx], pvv.pivot(idx));
+
+            assertEquals("Default unpivot differs from expected at index " + idx,
+                sampleParams.unpivot[idx], pvv.unpivot(idx));
+
+            final Metric metric = new Metric(sampleParams.vec.get(idx), pvv.get(pvv.pivot(idx)));
+
+            assertTrue("Not close enough at index " + idx + ", " + metric, metric.closeEnough());
+        }
+
+        for (int idx = 0; idx < size; idx++) {
+            sampleParams.vec.set(idx, sampleParams.vec.get(idx) + idx + 1);
+
+            final Metric metric = new Metric(sampleParams.vec.get(idx), pvv.get(pvv.pivot(idx)));
+
+            assertTrue("Modified value not close enough at index " + idx + ", " + metric, metric.closeEnough());
+        }
+    }
+
+    /** */
+    @Test
+    public void basicUnpivotTest() {
+        final PivotedVectorView pvv = new PivotedVectorView(sampleParams.vec, sampleParams.pivot, sampleParams.unpivot);
+
+        final int size = sampleParams.vec.size();
+
+        assertEquals("View size differs from expected.", size, pvv.size());
+
+        for (int idx = 0; idx < size; idx++) {
+            assertEquals("Unpivot differs from expected at index " + idx,
+                sampleParams.unpivot[idx], pvv.unpivot(idx));
+
+            final Metric metric = new Metric(sampleParams.vec.get(idx), pvv.get(pvv.unpivot(idx)));
+
+            assertTrue("Not close enough at index " + idx + ", " + metric, metric.closeEnough());
+        }
+    }
+
+    /** */
+    private static class SampleParams {
+        /** */
+        final double[] data = new double[] {0, 1};
+        /** */
+        final Vector vec = new DenseLocalOnHeapVector(data);
+        /** */
+        final int[] pivot = new int[] {1, 0};
+        /** */
+        final int[] unpivot = new int[] {1, 0};
+    }
+
+    /** */
+    private static class Metric { // todo consider if softer tolerance (like say 0.1 or 0.01) would make sense here
+        /** */
+        private final double exp;
+
+        /** */
+        private final double obtained;
+
+        /** **/
+        Metric(double exp, double obtained) {
+            this.exp = exp;
+            this.obtained = obtained;
+        }
+
+        /** */
+        boolean closeEnough() {
+            return new Double(exp).equals(obtained) || closeEnoughToZero();
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return "Metric{" + "expected=" + exp +
+                ", obtained=" + obtained +
+                '}';
+        }
+
+        /** */
+        private boolean closeEnoughToZero() {
+            return (new Double(exp).equals(0.0) && new Double(obtained).equals(-0.0))
+                || (new Double(exp).equals(-0.0) && new Double(obtained).equals(0.0));
+        }
+    }
+}


[43/65] [abbrv] ignite git commit: IGNITE-4699: Added custom executors for compute tasls. This closes #1718.

Posted by ag...@apache.org.
IGNITE-4699: Added custom executors for compute tasls. This closes #1718.


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

Branch: refs/heads/ignite-5024
Commit: f871b0d77084f4ebf7993eccc9cf59767835a41d
Parents: 3eb52a8
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Fri Apr 21 14:40:22 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Fri Apr 21 14:40:22 2017 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/IgniteCompute.java   |  14 ++
 .../configuration/ExecutorConfiguration.java    | 115 +++++++++
 .../configuration/IgniteConfiguration.java      |  30 +++
 .../ignite/internal/ExecutorAwareMessage.java   |  31 +++
 .../ignite/internal/GridJobExecuteRequest.java  |  32 ++-
 .../ignite/internal/GridKernalContext.java      |   8 +
 .../ignite/internal/GridKernalContextImpl.java  |  12 +
 .../ignite/internal/GridTaskSessionImpl.java    |  15 +-
 .../ignite/internal/IgniteComputeImpl.java      |  71 ++++--
 .../apache/ignite/internal/IgniteKernal.java    |   3 +
 .../org/apache/ignite/internal/IgnitionEx.java  |  66 +++++
 .../managers/communication/GridIoManager.java   |  23 +-
 .../managers/communication/GridIoMessage.java   |  13 +
 .../closure/GridClosureProcessor.java           | 154 +++++++-----
 .../processors/job/GridJobProcessor.java        |  23 +-
 .../internal/processors/job/GridJobWorker.java  |  15 +-
 .../internal/processors/pool/PoolProcessor.java |  25 ++
 .../session/GridTaskSessionProcessor.java       |  10 +-
 .../processors/task/GridTaskProcessor.java      |  69 +++++-
 .../processors/task/GridTaskWorker.java         |   3 +-
 ...puteCustomExecutorConfigurationSelfTest.java |  85 +++++++
 .../IgniteComputeCustomExecutorSelfTest.java    | 245 +++++++++++++++++++
 .../junits/GridTestKernalContext.java           |   5 +-
 .../testsuites/IgniteComputeGridTestSuite.java  |   5 +
 24 files changed, 970 insertions(+), 102 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java b/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
index ad675c0..f0e6039 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
@@ -24,6 +24,8 @@ import org.apache.ignite.compute.ComputeTask;
 import org.apache.ignite.compute.ComputeTaskFuture;
 import org.apache.ignite.compute.ComputeTaskName;
 import org.apache.ignite.compute.ComputeTaskSpis;
+import org.apache.ignite.configuration.ExecutorConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.lang.IgniteAsyncSupport;
 import org.apache.ignite.lang.IgniteAsyncSupported;
 import org.apache.ignite.lang.IgniteCallable;
@@ -751,4 +753,16 @@ public interface IgniteCompute extends IgniteAsyncSupport {
     /** {@inheritDoc} */
     @Deprecated
     @Override public IgniteCompute withAsync();
+
+    /**
+     * Gets instance of the compute API associated with custom executor. All tasks and closures submitted to returned
+     * instance will be processed by this executor on both remote and local nodes. If executor with the given name
+     * doesn't exist, task will be processed in default ("public") pool.
+     * <p>
+     * Executor should be defined in {@link IgniteConfiguration#setExecutorConfiguration(ExecutorConfiguration...)}.
+     *
+     * @param name Custom executor name.
+     * @return Instance of compute API associated with custom executor.
+     */
+    public IgniteCompute withExecutor(@NotNull String name);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/configuration/ExecutorConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/ExecutorConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/ExecutorConfiguration.java
new file mode 100644
index 0000000..8ff7932
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/ExecutorConfiguration.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.configuration;
+
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_PUBLIC_THREAD_CNT;
+
+/**
+ * \u0421ustom thread pool configuration for compute tasks. See {@link IgniteCompute#withAsync()} for more information.
+ */
+public class ExecutorConfiguration {
+    /** Thread pool name. */
+    private String name;
+
+    /** Thread pool size. */
+    private int size = DFLT_PUBLIC_THREAD_CNT;
+
+    /**
+     * Default constructor.
+     */
+    public ExecutorConfiguration() {
+        // No-op.
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param name Thread pool name.
+     */
+    public ExecutorConfiguration(String name) {
+        this.name = name;
+    }
+
+    /**
+     * Copying constructor.
+     *
+     * @param other Instance to copy.
+     */
+    public ExecutorConfiguration(ExecutorConfiguration other) {
+        assert other != null;
+
+        name = other.name;
+        size = other.size;
+    }
+
+    /**
+     * Get thread pool name.
+     * <p>
+     * See {@link #setName(String)} for more information.
+     *
+     * @return Executor name.
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Set thread pool name. Name cannot be {@code null} and should be unique with respect to other custom executors.
+     *
+     * @param name Executor name.
+     * @return {@code this} for chaining.
+     */
+    public ExecutorConfiguration setName(String name) {
+        this.name = name;
+
+        return this;
+    }
+
+    /**
+     * Get thread pool size.
+     * <p>
+     * See {@link #setSize(int)} for more information.
+     *
+     * @return Thread pool size.
+     */
+    public int getSize() {
+        return size;
+    }
+
+    /**
+     * Set thread pool size.
+     * <p>
+     * Defaults to {@link IgniteConfiguration#DFLT_PUBLIC_THREAD_CNT}.
+     *
+     * @param size Thread pool size.
+     * @return {@code this} for chaining.
+     */
+    public ExecutorConfiguration setSize(int size) {
+        this.size = size;
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(ExecutorConfiguration.class, this);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index fe08ddf..17927b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -28,6 +28,7 @@ import javax.cache.integration.CacheLoader;
 import javax.cache.processor.EntryProcessor;
 import javax.management.MBeanServer;
 import javax.net.ssl.SSLContext;
+import org.apache.ignite.IgniteCompute;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.Ignition;
@@ -437,6 +438,9 @@ public class IgniteConfiguration {
     /** */
     private BinaryConfiguration binaryCfg;
 
+    /** Custom executor configurations. */
+    private ExecutorConfiguration[] execCfgs;
+
     /** */
     private boolean lateAffAssignment = DFLT_LATE_AFF_ASSIGNMENT;
 
@@ -494,6 +498,7 @@ public class IgniteConfiguration {
         dataStreamerPoolSize = cfg.getDataStreamerThreadPoolSize();
         deployMode = cfg.getDeploymentMode();
         discoStartupDelay = cfg.getDiscoveryStartupDelay();
+        execCfgs = cfg.getExecutorConfiguration();
         failureDetectionTimeout = cfg.getFailureDetectionTimeout();
         hadoopCfg = cfg.getHadoopConfiguration();
         igfsCfg = cfg.getFileSystemConfiguration();
@@ -2658,6 +2663,31 @@ public class IgniteConfiguration {
         return this;
     }
 
+    /**
+     * Gets custom executors for user compute tasks.
+     * <p>
+     * See {@link #setExecutorConfiguration(ExecutorConfiguration...)} for more information.
+     *
+     * @return Executor configurations.
+     */
+    public ExecutorConfiguration[] getExecutorConfiguration() {
+        return execCfgs;
+    }
+
+    /**
+     * Sets custom executors for user compute tasks.
+     * <p>
+     * See {@link IgniteCompute#withExecutor(String)} for more information.
+     *
+     * @param execCfgs Executor configurations.
+     * @return {@code this} for chaining.
+     */
+    public IgniteConfiguration setExecutorConfiguration(ExecutorConfiguration... execCfgs) {
+        this.execCfgs = execCfgs;
+
+        return this;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgniteConfiguration.class, this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/ExecutorAwareMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/ExecutorAwareMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/ExecutorAwareMessage.java
new file mode 100644
index 0000000..a8a3b1a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/ExecutorAwareMessage.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Message with specified custom executor must be processed in the appropriate thread pool.
+ */
+public interface ExecutorAwareMessage extends Message {
+    /**
+     * @return Custom executor name. {@code null} In case the custom executor is not provided.
+     */
+    @Nullable public String executorName();
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java
index a7e8309..fe2d6d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java
@@ -32,7 +32,6 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteUuid;
-import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -41,7 +40,7 @@ import org.jetbrains.annotations.Nullable;
 /**
  * Job execution request.
  */
-public class GridJobExecuteRequest implements Message {
+public class GridJobExecuteRequest implements ExecutorAwareMessage {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -146,6 +145,9 @@ public class GridJobExecuteRequest implements Message {
     /** */
     private AffinityTopologyVersion topVer;
 
+    /** */
+    private String execName;
+
     /**
      * No-op constructor to support {@link Externalizable} interface.
      */
@@ -182,6 +184,7 @@ public class GridJobExecuteRequest implements Message {
      * @param cacheIds Caches' identifiers to reserve partition.
      * @param part Partition to lock.
      * @param topVer Affinity topology version of job mapping.
+     * @param execName The name of the custom named executor.
      */
     public GridJobExecuteRequest(
             IgniteUuid sesId,
@@ -211,7 +214,8 @@ public class GridJobExecuteRequest implements Message {
             UUID subjId,
             @Nullable int[] cacheIds,
             int part,
-            @Nullable AffinityTopologyVersion topVer) {
+            @Nullable AffinityTopologyVersion topVer,
+            @Nullable String execName) {
         this.top = top;
         assert sesId != null;
         assert jobId != null;
@@ -251,6 +255,7 @@ public class GridJobExecuteRequest implements Message {
         this.idsOfCaches = cacheIds;
         this.part = part;
         this.topVer = topVer;
+        this.execName = execName;
 
         this.cpSpi = cpSpi == null || cpSpi.isEmpty() ? null : cpSpi;
     }
@@ -454,6 +459,11 @@ public class GridJobExecuteRequest implements Message {
         return part;
     }
 
+    /** {@inheritDoc} */
+    @Override public String executorName() {
+        return execName;
+    }
+
     /**
      * @return Affinity version which was used to map job
      */
@@ -622,6 +632,12 @@ public class GridJobExecuteRequest implements Message {
 
                 writer.incrementState();
 
+            case 24:
+                if (!writer.writeString("executorName", execName))
+                    return false;
+
+                writer.incrementState();
+
         }
 
         return true;
@@ -831,6 +847,14 @@ public class GridJobExecuteRequest implements Message {
 
                 reader.incrementState();
 
+            case 24:
+                execName = reader.readString("executorName");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
         }
 
         return reader.afterMessageRead(GridJobExecuteRequest.class);
@@ -843,7 +867,7 @@ public class GridJobExecuteRequest implements Message {
 
     /** {@inheritDoc} */
     @Override public byte fieldsCount() {
-        return 24;
+        return 25;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
index 8462e5f..010bd21 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
@@ -563,6 +563,14 @@ public interface GridKernalContext extends Iterable<GridComponent> {
      */
     public ExecutorService getQueryExecutorService();
 
+
+    /**
+     * Executor services that is in charge of processing user compute task.
+     *
+     * @return Map of custom thread pool executors.
+     */
+    @Nullable public Map<String, ? extends ExecutorService> customExecutors();
+
     /**
      * Executor service that is in charge of processing schema change messages.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index 213cf86..bbc9846 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@ -344,6 +344,10 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
 
     /** */
     @GridToStringExclude
+    Map<String, ? extends ExecutorService> customExecSvcs;
+
+    /** */
+    @GridToStringExclude
     private Map<String, Object> attrs = new HashMap<>();
 
     /** */
@@ -401,6 +405,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
      * @param callbackExecSvc Callback executor service.
      * @param qryExecSvc Query executor service.
      * @param schemaExecSvc Schema executor service.
+     * @param customExecSvcs Custom named executors.
      * @param plugins Plugin providers.
      */
     @SuppressWarnings("TypeMayBeWeakened")
@@ -424,6 +429,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
         IgniteStripedThreadPoolExecutor callbackExecSvc,
         ExecutorService qryExecSvc,
         ExecutorService schemaExecSvc,
+        @Nullable Map<String, ? extends ExecutorService> customExecSvcs,
         List<PluginProvider> plugins
     ) {
         assert grid != null;
@@ -448,6 +454,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
         this.callbackExecSvc = callbackExecSvc;
         this.qryExecSvc = qryExecSvc;
         this.schemaExecSvc = schemaExecSvc;
+        this.customExecSvcs = customExecSvcs;
 
         marshCtx = new MarshallerContextImpl(plugins);
 
@@ -998,6 +1005,11 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
     }
 
     /** {@inheritDoc} */
+    public Map<String, ? extends ExecutorService> customExecutors() {
+        return customExecSvcs;
+    }
+
+    /** {@inheritDoc} */
     @Override public IgniteExceptionRegistry exceptionRegistry() {
         return IgniteExceptionRegistry.get();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionImpl.java
index dd1caa1..458ad36 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionImpl.java
@@ -114,6 +114,9 @@ public class GridTaskSessionImpl implements GridTaskSessionInternal {
     /** */
     private final IgniteFutureImpl mapFut;
 
+    /** */
+    private final String execName;
+
     /**
      * @param taskNodeId Task node ID.
      * @param taskName Task name.
@@ -129,6 +132,7 @@ public class GridTaskSessionImpl implements GridTaskSessionInternal {
      * @param fullSup Session full support enabled flag.
      * @param internal Internal task flag.
      * @param subjId Subject ID.
+     * @param execName Custom executor name.
      */
     public GridTaskSessionImpl(
         UUID taskNodeId,
@@ -144,7 +148,8 @@ public class GridTaskSessionImpl implements GridTaskSessionInternal {
         GridKernalContext ctx,
         boolean fullSup,
         boolean internal,
-        UUID subjId) {
+        UUID subjId,
+        @Nullable String execName) {
         assert taskNodeId != null;
         assert taskName != null;
         assert sesId != null;
@@ -173,6 +178,7 @@ public class GridTaskSessionImpl implements GridTaskSessionInternal {
         this.fullSup = fullSup;
         this.internal = internal;
         this.subjId = subjId;
+        this.execName = execName;
 
         mapFut = new IgniteFutureImpl(new GridFutureAdapter());
     }
@@ -873,6 +879,13 @@ public class GridTaskSessionImpl implements GridTaskSessionInternal {
         return internal;
     }
 
+    /**
+     * @return Custom executor name.
+     */
+    @Nullable public String executorName() {
+        return execName;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridTaskSessionImpl.class, this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java
index 7499a5d..7ddd4ad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java
@@ -73,6 +73,9 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
     /** */
     private UUID subjId;
 
+    /** Custom executor name. */
+    private String execName;
+
     /**
      * Required by {@link Externalizable}.
      */
@@ -103,6 +106,25 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         this.subjId = subjId;
     }
 
+    /**
+     * Constructor.
+     *
+     * @param ctx Kernal context.
+     * @param prj Projection.
+     * @param subjId Subject ID.
+     * @param async Async support flag.
+     * @param execName Custom executor name.
+     */
+    private IgniteComputeImpl(GridKernalContext ctx, ClusterGroupAdapter prj, UUID subjId, boolean async,
+        String execName) {
+        super(async);
+
+        this.ctx = ctx;
+        this.prj = prj;
+        this.subjId = subjId;
+        this.execName = execName;
+    }
+
     /** {@inheritDoc} */
     @Override protected IgniteCompute createAsyncInstance() {
         return new IgniteComputeImpl(ctx, prj, subjId, true);
@@ -152,7 +174,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
                 throw new IgniteCheckedException("Failed map key to partition: [cache=" + cacheName + " key="
                     + affKey + ']');
 
-            return ctx.closure().affinityRun(Collections.singletonList(cacheName), partId, job, prj.nodes());
+            return ctx.closure().affinityRun(Collections.singletonList(cacheName), partId, job, prj.nodes(), execName);
         }
         catch (IgniteCheckedException e) {
             throw U.convertException(e);
@@ -205,7 +227,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
                 throw new IgniteCheckedException("Failed map key to partition: [cache=" + cacheName + " key="
                     + affKey + ']');
 
-            return ctx.closure().affinityRun(cacheNames, partId, job, prj.nodes());
+            return ctx.closure().affinityRun(cacheNames, partId, job, prj.nodes(), execName);
         }
         catch (IgniteCheckedException e) {
             throw U.convertException(e);
@@ -248,7 +270,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         guard();
 
         try {
-            return ctx.closure().affinityRun(cacheNames, partId, job, prj.nodes());
+            return ctx.closure().affinityRun(cacheNames, partId, job, prj.nodes(), execName);
         }
         catch (IgniteCheckedException e) {
             throw U.convertException(e);
@@ -298,7 +320,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
                 throw new IgniteCheckedException("Failed map key to partition: [cache=" + cacheName + " key="
                     + affKey + ']');
 
-            return ctx.closure().affinityCall(Collections.singletonList(cacheName), partId, job, prj.nodes());
+            return ctx.closure().affinityCall(Collections.singletonList(cacheName), partId, job, prj.nodes(), execName);
         }
         catch (IgniteCheckedException e) {
             throw U.convertException(e);
@@ -351,7 +373,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
                 throw new IgniteCheckedException("Failed map key to partition: [cache=" + cacheName + " key="
                     + affKey + ']');
 
-            return ctx.closure().affinityCall(cacheNames, partId, job, prj.nodes());
+            return ctx.closure().affinityCall(cacheNames, partId, job, prj.nodes(), execName);
         }
         catch (IgniteCheckedException e) {
             throw U.convertException(e);
@@ -394,7 +416,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         guard();
 
         try {
-            return ctx.closure().affinityCall(cacheNames, partId, job, prj.nodes());
+            return ctx.closure().affinityCall(cacheNames, partId, job, prj.nodes(), execName);
         }
         catch (IgniteCheckedException e) {
             throw U.convertException(e);
@@ -437,7 +459,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
             ctx.task().setThreadContextIfNotNull(TC_SUBGRID, prj.nodes());
             ctx.task().setThreadContextIfNotNull(TC_SUBJ_ID, subjId);
 
-            return ctx.task().execute(taskName, arg);
+            return ctx.task().execute(taskName, arg, execName);
         }
         finally {
             unguard();
@@ -477,7 +499,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
             ctx.task().setThreadContextIfNotNull(TC_SUBGRID, prj.nodes());
             ctx.task().setThreadContextIfNotNull(TC_SUBJ_ID, subjId);
 
-            return ctx.task().execute(taskCls, arg);
+            return ctx.task().execute(taskCls, arg, execName);
         }
         finally {
             unguard();
@@ -516,7 +538,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
             ctx.task().setThreadContextIfNotNull(TC_SUBGRID, prj.nodes());
             ctx.task().setThreadContextIfNotNull(TC_SUBJ_ID, subjId);
 
-            return ctx.task().execute(task, arg);
+            return ctx.task().execute(task, arg, execName);
         }
         finally {
             unguard();
@@ -550,7 +572,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         guard();
 
         try {
-            return ctx.closure().runAsync(BROADCAST, job, prj.nodes());
+            return ctx.closure().runAsync(BROADCAST, job, prj.nodes(), execName);
         }
         finally {
             unguard();
@@ -584,7 +606,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         guard();
 
         try {
-            return ctx.closure().callAsync(BROADCAST, Collections.singletonList(job), prj.nodes());
+            return ctx.closure().callAsync(BROADCAST, Collections.singletonList(job), prj.nodes(), execName);
         }
         finally {
             unguard();
@@ -620,7 +642,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         guard();
 
         try {
-            return ctx.closure().broadcast(job, arg, prj.nodes());
+            return ctx.closure().broadcast(job, arg, prj.nodes(), execName);
         }
         finally {
             unguard();
@@ -654,7 +676,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         guard();
 
         try {
-            return ctx.closure().runAsync(BALANCE, job, prj.nodes());
+            return ctx.closure().runAsync(BALANCE, job, prj.nodes(), execName);
         }
         finally {
             unguard();
@@ -689,7 +711,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         guard();
 
         try {
-            return ctx.closure().runAsync(BALANCE, jobs, prj.nodes());
+            return ctx.closure().runAsync(BALANCE, jobs, prj.nodes(), execName);
         }
         finally {
             unguard();
@@ -725,7 +747,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         guard();
 
         try {
-            return ctx.closure().callAsync(job, arg, prj.nodes());
+            return ctx.closure().callAsync(job, arg, prj.nodes(), execName);
         }
         finally {
             unguard();
@@ -759,7 +781,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         guard();
 
         try {
-            return ctx.closure().callAsync(BALANCE, job, prj.nodes());
+            return ctx.closure().callAsync(BALANCE, job, prj.nodes(), execName);
         }
         finally {
             unguard();
@@ -794,7 +816,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         guard();
 
         try {
-            return ctx.closure().callAsync(BALANCE, (Collection<? extends Callable<R>>)jobs, prj.nodes());
+            return ctx.closure().callAsync(BALANCE, (Collection<? extends Callable<R>>)jobs, prj.nodes(), execName);
         }
         finally {
             unguard();
@@ -832,7 +854,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         guard();
 
         try {
-            return ctx.closure().callAsync(job, args, prj.nodes());
+            return ctx.closure().callAsync(job, args, prj.nodes(), execName);
         }
         finally {
             unguard();
@@ -870,7 +892,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         guard();
 
         try {
-            return ctx.closure().forkjoinAsync(BALANCE, jobs, rdc, prj.nodes());
+            return ctx.closure().forkjoinAsync(BALANCE, jobs, rdc, prj.nodes(), execName);
         }
         finally {
             unguard();
@@ -911,7 +933,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
         guard();
 
         try {
-            return ctx.closure().callAsync(job, args, rdc, prj.nodes());
+            return ctx.closure().callAsync(job, args, rdc, prj.nodes(), execName);
         }
         finally {
             unguard();
@@ -1040,11 +1062,13 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
     /** {@inheritDoc} */
     @Override public void writeExternal(ObjectOutput out) throws IOException {
         out.writeObject(prj);
+        out.writeObject(execName);
     }
 
     /** {@inheritDoc} */
     @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         prj = (ClusterGroupAdapter)in.readObject();
+        execName = (String)in.readObject();
     }
 
     /**
@@ -1054,7 +1078,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
      * @throws ObjectStreamException Thrown in case of unmarshalling error.
      */
     protected Object readResolve() throws ObjectStreamException {
-        return prj.compute();
+        return prj.compute().withExecutor(execName);
     }
 
     /** {@inheritDoc} */
@@ -1068,4 +1092,9 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
     @Override public <R> ComputeTaskFuture<R> future() {
         return (ComputeTaskFuture<R>)super.future();
     }
+
+    /** {@inheritDoc} */
+    @Override public IgniteCompute withExecutor(@NotNull String name) {
+        return new IgniteComputeImpl(ctx, prj, subjId, isAsync(), name);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 50f39fa..12a7af6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -699,6 +699,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
      * @param callbackExecSvc Callback executor service.
      * @param qryExecSvc Query executor service.
      * @param schemaExecSvc Schema executor service.
+     * @param customExecSvcs Custom named executors.
      * @param errHnd Error handler to use for notification about startup problems.
      * @throws IgniteCheckedException Thrown in case of any errors.
      */
@@ -720,6 +721,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         IgniteStripedThreadPoolExecutor callbackExecSvc,
         ExecutorService qryExecSvc,
         ExecutorService schemaExecSvc,
+        Map<String, ? extends ExecutorService> customExecSvcs,
         GridAbsClosure errHnd
     )
         throws IgniteCheckedException
@@ -835,6 +837,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
                 callbackExecSvc,
                 qryExecSvc,
                 schemaExecSvc,
+                customExecSvcs,
                 plugins
             );
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 2eda01c..4b34891 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -33,6 +33,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CountDownLatch;
@@ -59,6 +60,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.ConnectorConfiguration;
 import org.apache.ignite.configuration.MemoryConfiguration;
 import org.apache.ignite.configuration.DeploymentMode;
+import org.apache.ignite.configuration.ExecutorConfiguration;
 import org.apache.ignite.configuration.FileSystemConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.TransactionConfiguration;
@@ -1530,6 +1532,9 @@ public class IgnitionEx {
         /** Query executor service. */
         private ThreadPoolExecutor schemaExecSvc;
 
+        /** Executor service. */
+        private Map<String, ThreadPoolExecutor> customExecSvcs;
+
         /** Grid state. */
         private volatile IgniteState state = STOPPED;
 
@@ -1858,6 +1863,24 @@ public class IgnitionEx {
 
             schemaExecSvc.allowCoreThreadTimeOut(true);
 
+            if (!F.isEmpty(cfg.getExecutorConfiguration())) {
+                validateCustomExecutorsConfiguration(cfg.getExecutorConfiguration());
+
+                customExecSvcs = new HashMap<>();
+
+                for(ExecutorConfiguration execCfg : cfg.getExecutorConfiguration()) {
+                    ThreadPoolExecutor exec = new IgniteThreadPoolExecutor(
+                        execCfg.getName(),
+                        cfg.getIgniteInstanceName(),
+                        execCfg.getSize(),
+                        execCfg.getSize(),
+                        DFLT_THREAD_KEEP_ALIVE_TIME,
+                        new LinkedBlockingQueue<Runnable>());
+
+                    customExecSvcs.put(execCfg.getName(), exec);
+                }
+            }
+
             // Register Ignite MBean for current grid instance.
             registerFactoryMbean(myCfg.getMBeanServer());
 
@@ -1886,6 +1909,7 @@ public class IgnitionEx {
                     callbackExecSvc,
                     qryExecSvc,
                     schemaExecSvc,
+                    customExecSvcs,
                     new CA() {
                         @Override public void apply() {
                             startLatch.countDown();
@@ -1962,6 +1986,30 @@ public class IgnitionEx {
         }
 
         /**
+         * @param cfgs Array of the executors configurations.
+         * @throws IgniteCheckedException If configuration is wrong.
+         */
+        private static void validateCustomExecutorsConfiguration(ExecutorConfiguration[] cfgs)
+            throws IgniteCheckedException {
+            if (cfgs == null)
+                return;
+
+            Set<String> names = new HashSet<>(cfgs.length);
+
+            for (ExecutorConfiguration cfg : cfgs) {
+                if (F.isEmpty(cfg.getName()))
+                    throw new IgniteCheckedException("Custom executor name cannot be null or empty.");
+
+                if (!names.add(cfg.getName()))
+                    throw new IgniteCheckedException("Duplicate custom executor name: " + cfg.getName());
+
+                if (cfg.getSize() <= 0)
+                    throw new IgniteCheckedException("Custom executor size must be positive [name=" + cfg.getName() +
+                        ", size=" + cfg.getSize() + ']');
+            }
+        }
+
+        /**
          * @param cfg Ignite configuration copy to.
          * @return New ignite configuration.
          * @throws IgniteCheckedException If failed.
@@ -2116,6 +2164,17 @@ public class IgnitionEx {
 
             initializeDefaultCacheConfiguration(myCfg);
 
+            ExecutorConfiguration[] execCfgs = myCfg.getExecutorConfiguration();
+
+            if (execCfgs != null) {
+                ExecutorConfiguration[] clone = execCfgs.clone();
+
+                for (int i = 0; i < execCfgs.length; i++)
+                    clone[i] = new ExecutorConfiguration(execCfgs[i]);
+
+                myCfg.setExecutorConfiguration(clone);
+            }
+
             if (!myCfg.isClientMode() && myCfg.getMemoryConfiguration() == null) {
                 MemoryConfiguration memCfg = new MemoryConfiguration();
 
@@ -2522,6 +2581,13 @@ public class IgnitionEx {
             U.shutdownNow(getClass(), callbackExecSvc, log);
 
             callbackExecSvc = null;
+
+            if (!F.isEmpty(customExecSvcs)) {
+                for (ThreadPoolExecutor exec : customExecSvcs.values())
+                    U.shutdownNow(getClass(), exec, log);
+
+                customExecSvcs = null;
+            }
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index 83fc3b5..c4f7519 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedDeque;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.Executor;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -65,6 +66,7 @@ import org.apache.ignite.internal.util.lang.GridTuple3;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.LT;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiPredicate;
@@ -839,12 +841,27 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
         }
 
         try {
+            String execName = msg.executorName();
+
+            if (execName != null) {
+                Executor exec = pools.customExecutor(execName);
+
+                if (exec != null) {
+                    exec.execute(c);
+
+                    return;
+                }
+                else {
+                    LT.warn(log, "Custom executor doesn't exist (message will be processed in default " +
+                        "thread pool): " + execName);
+                }
+            }
+
             pools.poolForPolicy(plc).execute(c);
         }
         catch (RejectedExecutionException e) {
-            U.error(log, "Failed to process regular message due to execution rejection. Increase the upper bound " +
-                "on 'ExecutorService' provided by 'IgniteConfiguration.getPublicThreadPoolSize()'. " +
-                "Will attempt to process message in the listener thread instead.", e);
+            U.error(log, "Failed to process regular message due to execution rejection. Will attempt to process " +
+                "message in the listener thread instead.", e);
 
             c.run();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
index 2ad4a0b..16eae26 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
@@ -19,6 +19,8 @@ package org.apache.ignite.internal.managers.communication;
 
 import java.io.Externalizable;
 import java.nio.ByteBuffer;
+
+import org.apache.ignite.internal.ExecutorAwareMessage;
 import org.apache.ignite.internal.GridDirectTransient;
 import org.apache.ignite.internal.processors.cache.GridCacheMessage;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
@@ -26,6 +28,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Wrapper for all grid messages.
@@ -334,6 +337,16 @@ public class GridIoMessage implements Message {
             return Integer.MIN_VALUE;
     }
 
+    /**
+     * @return Executor name (if available).
+     */
+    @Nullable public String executorName() {
+        if (msg instanceof ExecutorAwareMessage)
+            return ((ExecutorAwareMessage)msg).executorName();
+
+        return null;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridIoMessage.class, this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
index f91ee34..1051807 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
@@ -146,11 +146,12 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param mode Distribution mode.
      * @param jobs Closures to execute.
      * @param nodes Grid nodes.
+     * @param execName Custom executor name.
      * @return Task execution future.
      */
     public ComputeTaskInternalFuture<?> runAsync(GridClosureCallMode mode, @Nullable Collection<? extends Runnable> jobs,
-        @Nullable Collection<ClusterNode> nodes) {
-        return runAsync(mode, jobs, nodes, false);
+        @Nullable Collection<ClusterNode> nodes, @Nullable String execName) {
+        return runAsync(mode, jobs, nodes, false, execName);
     }
 
     /**
@@ -158,12 +159,14 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param jobs Closures to execute.
      * @param nodes Grid nodes.
      * @param sys If {@code true}, then system pool will be used.
+     * @param execName Custom executor name.
      * @return Task execution future.
      */
     public ComputeTaskInternalFuture<?> runAsync(GridClosureCallMode mode,
         Collection<? extends Runnable> jobs,
         @Nullable Collection<ClusterNode> nodes,
-        boolean sys)
+        boolean sys,
+        @Nullable String execName)
     {
         assert mode != null;
         assert !F.isEmpty(jobs) : jobs;
@@ -181,7 +184,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
             ctx.task().setThreadContext(TC_SUBGRID, nodes);
 
-            return ctx.task().execute(new T1(mode, jobs), null, sys);
+            return ctx.task().execute(new T1(mode, jobs), null, sys, execName);
         }
         finally {
             busyLock.readUnlock();
@@ -196,7 +199,19 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      */
     public ComputeTaskInternalFuture<?> runAsync(GridClosureCallMode mode, Runnable job,
         @Nullable Collection<ClusterNode> nodes) {
-        return runAsync(mode, job, nodes, false);
+        return runAsync(mode, job, nodes, null);
+    }
+
+    /**
+     * @param mode Distribution mode.
+     * @param job Closure to execute.
+     * @param nodes Grid nodes.
+     * @param execName Custom executor name.
+     * @return Task execution future.
+     */
+    public ComputeTaskInternalFuture<?> runAsync(GridClosureCallMode mode, Runnable job,
+        @Nullable Collection<ClusterNode> nodes, @Nullable String execName) {
+        return runAsync(mode, job, nodes, false, execName);
     }
 
     /**
@@ -204,12 +219,14 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param job Closure to execute.
      * @param nodes Grid nodes.
      * @param sys If {@code true}, then system pool will be used.
+     * @param execName Custom executor name.
      * @return Task execution future.
      */
     public ComputeTaskInternalFuture<?> runAsync(GridClosureCallMode mode,
         Runnable job,
         @Nullable Collection<ClusterNode> nodes,
-        boolean sys)
+        boolean sys,
+        @Nullable String execName)
     {
         assert mode != null;
         assert job != null;
@@ -222,7 +239,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
             ctx.task().setThreadContext(TC_SUBGRID, nodes);
 
-            return ctx.task().execute(new T2(mode, job), null, sys);
+            return ctx.task().execute(new T2(mode, job), null, sys, execName);
         }
         finally {
             busyLock.readUnlock();
@@ -341,6 +358,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param jobs Closures to execute.
      * @param rdc Reducer.
      * @param nodes Grid nodes.
+     * @param execName Custom executor name.
      * @param <R1> Type.
      * @param <R2> Type.
      * @return Reduced result.
@@ -348,7 +366,8 @@ public class GridClosureProcessor extends GridProcessorAdapter {
     public <R1, R2> ComputeTaskInternalFuture<R2> forkjoinAsync(GridClosureCallMode mode,
         Collection<? extends Callable<R1>> jobs,
         IgniteReducer<R1, R2> rdc,
-        @Nullable Collection<ClusterNode> nodes)
+        @Nullable Collection<ClusterNode> nodes,
+        @Nullable String execName)
     {
         assert mode != null;
         assert rdc != null;
@@ -362,7 +381,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
             ctx.task().setThreadContext(TC_SUBGRID, nodes);
 
-            return ctx.task().execute(new T3<>(mode, jobs, rdc), null);
+            return ctx.task().execute(new T3<>(mode, jobs, rdc), null, execName);
         }
         finally {
             busyLock.readUnlock();
@@ -380,7 +399,23 @@ public class GridClosureProcessor extends GridProcessorAdapter {
         GridClosureCallMode mode,
         @Nullable Collection<? extends Callable<R>> jobs,
         @Nullable Collection<ClusterNode> nodes) {
-        return callAsync(mode, jobs, nodes, false);
+        return callAsync(mode, jobs, nodes, null);
+    }
+
+    /**
+     * @param mode Distribution mode.
+     * @param jobs Closures to execute.
+     * @param nodes Grid nodes.
+     * @param execName Custom executor name.
+     * @param <R> Type.
+     * @return Grid future for collection of closure results.
+     */
+    public <R> ComputeTaskInternalFuture<Collection<R>> callAsync(
+        GridClosureCallMode mode,
+        @Nullable Collection<? extends Callable<R>> jobs,
+        @Nullable Collection<ClusterNode> nodes,
+        @Nullable String execName) {
+        return callAsync(mode, jobs, nodes, false, execName);
     }
 
     /**
@@ -388,13 +423,15 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param jobs Closures to execute.
      * @param nodes Grid nodes.
      * @param sys If {@code true}, then system pool will be used.
+     * @param execName Custom executor name.
      * @param <R> Type.
      * @return Grid future for collection of closure results.
      */
     public <R> ComputeTaskInternalFuture<Collection<R>> callAsync(GridClosureCallMode mode,
         Collection<? extends Callable<R>> jobs,
         @Nullable Collection<ClusterNode> nodes,
-        boolean sys)
+        boolean sys,
+        @Nullable String execName)
     {
         assert mode != null;
         assert !F.isEmpty(jobs);
@@ -407,7 +444,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
             ctx.task().setThreadContext(TC_SUBGRID, nodes);
 
-            return ctx.task().execute(new T6<>(mode, jobs), null, sys);
+            return ctx.task().execute(new T6<>(mode, jobs), null, sys, execName);
         }
         finally {
             busyLock.readUnlock();
@@ -415,7 +452,6 @@ public class GridClosureProcessor extends GridProcessorAdapter {
     }
 
     /**
-     *
      * @param mode Distribution mode.
      * @param job Closure to execute.
      * @param nodes Grid nodes.
@@ -424,7 +460,21 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      */
     public <R> ComputeTaskInternalFuture<R> callAsync(GridClosureCallMode mode,
         @Nullable Callable<R> job, @Nullable Collection<ClusterNode> nodes) {
-        return callAsync(mode, job, nodes, false);
+        return callAsync(mode, job, nodes, null);
+    }
+
+    /**
+     * @param mode Distribution mode.
+     * @param job Closure to execute.
+     * @param nodes Grid nodes.
+     * @param execName Custom executor name.
+     * @param <R> Type.
+     * @return Grid future for collection of closure results.
+     */
+    public <R> ComputeTaskInternalFuture<R> callAsync(GridClosureCallMode mode,
+        @Nullable Callable<R> job, @Nullable Collection<ClusterNode> nodes,
+        @Nullable String execName) {
+        return callAsync(mode, job, nodes, false, execName);
     }
 
     /**
@@ -432,13 +482,15 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param partId Partition.
      * @param job Closure to execute.
      * @param nodes Grid nodes.
+     * @param execName Custom executor name.
      * @return Grid future for collection of closure results.
      * @throws IgniteCheckedException If failed.
      */
     public <R> ComputeTaskInternalFuture<R> affinityCall(@NotNull Collection<String> cacheNames,
         int partId,
         Callable<R> job,
-        @Nullable Collection<ClusterNode> nodes) throws IgniteCheckedException {
+        @Nullable Collection<ClusterNode> nodes,
+        @Nullable String execName) throws IgniteCheckedException {
         assert partId >= 0 : partId;
 
         busyLock.readLock();
@@ -457,7 +509,8 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
             ctx.task().setThreadContext(TC_SUBGRID, nodes);
 
-            return ctx.task().execute(new T5(node, job, cacheNames, partId, mapTopVer), null, false);
+            return ctx.task().execute(new T5(node, job, cacheNames, partId, mapTopVer), null,
+                false, execName);
         }
         finally {
             busyLock.readUnlock();
@@ -469,13 +522,15 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param partId Partition.
      * @param job Job.
      * @param nodes Grid nodes.
+     * @param execName Custom executor name.
      * @return Job future.
      * @throws IgniteCheckedException If failed.
      */
     public ComputeTaskInternalFuture<?> affinityRun(@NotNull Collection<String> cacheNames,
         int partId,
         Runnable job,
-        @Nullable Collection<ClusterNode> nodes) throws IgniteCheckedException {
+        @Nullable Collection<ClusterNode> nodes,
+        @Nullable String execName) throws IgniteCheckedException {
         assert partId >= 0 : partId;
 
         busyLock.readLock();
@@ -494,7 +549,8 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
             ctx.task().setThreadContext(TC_SUBGRID, nodes);
 
-            return ctx.task().execute(new T4(node, job, cacheNames, partId, mapTopVer), null, false);
+            return ctx.task().execute(new T4(node, job, cacheNames, partId, mapTopVer), null,
+                false, execName);
         }
         finally {
             busyLock.readUnlock();
@@ -588,13 +644,15 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param job Closure to execute.
      * @param nodes Grid nodes.
      * @param sys If {@code true}, then system pool will be used.
+     * @param execName Custom executor name.
      * @param <R> Type.
      * @return Grid future for collection of closure results.
      */
     public <R> ComputeTaskInternalFuture<R> callAsync(GridClosureCallMode mode,
         Callable<R> job,
         @Nullable Collection<ClusterNode> nodes,
-        boolean sys)
+        boolean sys,
+        @Nullable String execName)
     {
         assert mode != null;
         assert job != null;
@@ -607,7 +665,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
             ctx.task().setThreadContext(TC_SUBGRID, nodes);
 
-            return ctx.task().execute(new T7<>(mode, job), null, sys);
+            return ctx.task().execute(new T7<>(mode, job), null, sys, execName);
         }
         finally {
             busyLock.readUnlock();
@@ -618,10 +676,11 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param job Job closure.
      * @param arg Optional job argument.
      * @param nodes Grid nodes.
+     * @param execName Custom executor name.
      * @return Grid future for execution result.
      */
     public <T, R> ComputeTaskInternalFuture<R> callAsync(IgniteClosure<T, R> job, @Nullable T arg,
-        @Nullable Collection<ClusterNode> nodes) {
+        @Nullable Collection<ClusterNode> nodes, @Nullable String execName) {
         busyLock.readLock();
 
         try {
@@ -630,7 +689,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
             ctx.task().setThreadContext(TC_SUBGRID, nodes);
 
-            return ctx.task().execute(new T8(job, arg), null, false);
+            return ctx.task().execute(new T8(job, arg), null, false, execName);
         }
         finally {
             busyLock.readUnlock();
@@ -641,33 +700,11 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param job Job closure.
      * @param arg Optional job argument.
      * @param nodes Grid nodes.
+     * @param execName Custom executor name.
      * @return Grid future for execution result.
      */
     public <T, R> IgniteInternalFuture<Collection<R>> broadcast(IgniteClosure<T, R> job, @Nullable T arg,
-        @Nullable Collection<ClusterNode> nodes) {
-        busyLock.readLock();
-
-        try {
-            if (F.isEmpty(nodes))
-                return new GridFinishedFuture<>(U.emptyTopologyException());
-
-            ctx.task().setThreadContext(TC_SUBGRID, nodes);
-
-            return ctx.task().execute(new T11<>(job), arg, false);
-        }
-        finally {
-            busyLock.readUnlock();
-        }
-    }
-
-    /**
-     * @param job Job closure.
-     * @param arg Optional job argument.
-     * @param nodes Grid nodes.
-     * @return Grid future for execution result.
-     */
-    public <T, R> IgniteInternalFuture<Collection<R>> broadcastNoFailover(IgniteClosure<T, R> job, @Nullable T arg,
-        @Nullable Collection<ClusterNode> nodes) {
+        @Nullable Collection<ClusterNode> nodes, @Nullable String execName) {
         busyLock.readLock();
 
         try {
@@ -675,9 +712,8 @@ public class GridClosureProcessor extends GridProcessorAdapter {
                 return new GridFinishedFuture<>(U.emptyTopologyException());
 
             ctx.task().setThreadContext(TC_SUBGRID, nodes);
-            ctx.task().setThreadContext(TC_NO_FAILOVER, true);
 
-            return ctx.task().execute(new T11<>(job), arg, false);
+            return ctx.task().execute(new T11<>(job), arg, false, execName);
         }
         finally {
             busyLock.readUnlock();
@@ -688,11 +724,13 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param job Job closure.
      * @param args Job arguments.
      * @param nodes Grid nodes.
+     * @param execName Custom executor name.
      * @return Grid future for execution result.
      */
     public <T, R> ComputeTaskInternalFuture<Collection<R>> callAsync(IgniteClosure<T, R> job,
         @Nullable Collection<? extends T> args,
-        @Nullable Collection<ClusterNode> nodes)
+        @Nullable Collection<ClusterNode> nodes,
+        @Nullable String execName)
     {
         busyLock.readLock();
 
@@ -702,7 +740,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
             ctx.task().setThreadContext(TC_SUBGRID, nodes);
 
-            return ctx.task().execute(new T9<>(job, args), null, false);
+            return ctx.task().execute(new T9<>(job, args), null, false, execName);
         }
         finally {
             busyLock.readUnlock();
@@ -714,10 +752,12 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param args Job arguments.
      * @param rdc Reducer.
      * @param nodes Grid nodes.
+     * @param execName Custom executor name.
      * @return Grid future for execution result.
      */
     public <T, R1, R2> ComputeTaskInternalFuture<R2> callAsync(IgniteClosure<T, R1> job,
-        Collection<? extends T> args, IgniteReducer<R1, R2> rdc, @Nullable Collection<ClusterNode> nodes) {
+        Collection<? extends T> args, IgniteReducer<R1, R2> rdc, @Nullable Collection<ClusterNode> nodes,
+        @Nullable String execName) {
         busyLock.readLock();
 
         try {
@@ -726,7 +766,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
             ctx.task().setThreadContext(TC_SUBGRID, nodes);
 
-            return ctx.task().execute(new T10<>(job, args, rdc), null, false);
+            return ctx.task().execute(new T10<>(job, args, rdc), null, false, execName);
         }
         finally {
             busyLock.readUnlock();
@@ -1122,7 +1162,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
     /**
      * Task that is free of dragged in enclosing context for the method
-     * {@link GridClosureProcessor#runAsync(GridClosureCallMode, Collection, Collection)}.
+     * {@link GridClosureProcessor#runAsync(GridClosureCallMode, Collection, Collection,String)}.
      */
     private class T1 extends TaskNoReduceAdapter<Void> implements GridNoImplicitInjection {
         /** */
@@ -1156,7 +1196,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
     /**
      * Task that is free of dragged in enclosing context for the method
-     * {@link GridClosureProcessor#runAsync(GridClosureCallMode, Runnable, Collection)}.
+     * {@link GridClosureProcessor#runAsync(GridClosureCallMode, Runnable, Collection, String)}.
      */
     private class T2 extends TaskNoReduceAdapter<Void> implements GridNoImplicitInjection {
         /** */
@@ -1187,7 +1227,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
     /**
      * Task that is free of dragged in enclosing context for the method
-     * {@link GridClosureProcessor#forkjoinAsync(GridClosureCallMode, Collection, org.apache.ignite.lang.IgniteReducer, Collection)}
+     * {@link GridClosureProcessor#forkjoinAsync(GridClosureCallMode, Collection, org.apache.ignite.lang.IgniteReducer, Collection, String)}
      */
     private class T3<R1, R2> extends GridPeerDeployAwareTaskAdapter<Void, R2> implements GridNoImplicitInjection {
         /** */
@@ -1378,7 +1418,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
     /**
      * Task that is free of dragged in enclosing context for the method
-     * {@link GridClosureProcessor#callAsync(GridClosureCallMode, Collection, Collection)}
+     * {@link GridClosureProcessor#callAsync(GridClosureCallMode, Collection, Collection, String)}
      */
     private class T6<R> extends GridPeerDeployAwareTaskAdapter<Void, Collection<R>> implements GridNoImplicitInjection {
         /** */
@@ -1421,7 +1461,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
     /**
      * Task that is free of dragged in enclosing context for the method
-     * {@link GridClosureProcessor#callAsync(GridClosureCallMode, Callable, Collection)}
+     * {@link GridClosureProcessor#callAsync(GridClosureCallMode, Callable, Collection, String)}
      */
     private class T7<R> extends GridPeerDeployAwareTaskAdapter<Void, R> implements GridNoImplicitInjection {
         /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
index 91ec8a9..369ca22 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.Executor;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.Condition;
@@ -73,6 +74,7 @@ import org.apache.ignite.internal.util.GridSpinReadWriteLock;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.P1;
 import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.LT;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiTuple;
@@ -1058,7 +1060,8 @@ public class GridJobProcessor extends GridProcessorAdapter {
                             sesAttrs,
                             req.isSessionFullSupport(),
                             req.isInternal(),
-                            req.getSubjectId());
+                            req.getSubjectId(),
+                            req.executorName());
 
                         taskSes.setCheckpointSpi(req.getCheckpointSpi());
                         taskSes.setClassLoader(dep.classLoader());
@@ -1098,7 +1101,8 @@ public class GridJobProcessor extends GridProcessorAdapter {
                         evtLsnr,
                         holdLsnr,
                         partsReservation,
-                        req.getTopVer());
+                        req.getTopVer(),
+                        req.executorName());
 
                     jobCtx.job(job);
 
@@ -1274,7 +1278,20 @@ public class GridJobProcessor extends GridProcessorAdapter {
      */
     private boolean executeAsync(GridJobWorker jobWorker) {
         try {
-            ctx.getExecutorService().execute(jobWorker);
+            if (jobWorker.executorName() != null) {
+                Executor customExec = ctx.pools().customExecutor(jobWorker.executorName());
+
+                if (customExec != null)
+                    customExec.execute(jobWorker);
+                else {
+                    LT.warn(log, "Custom executor doesn't exist (local job will be processed in default " +
+                        "thread pool): " + jobWorker.executorName());
+
+                    ctx.getExecutorService().execute(jobWorker);
+                }
+            }
+            else
+                ctx.getExecutorService().execute(jobWorker);
 
             if (metricsUpdateFreq > -1L)
                 startedJobsCnt.increment();

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
index 5c9b9e2..c9129c1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
@@ -168,6 +168,9 @@ public class GridJobWorker extends GridWorker implements GridTimeoutObject {
     /** Request topology version. */
     private final AffinityTopologyVersion reqTopVer;
 
+    /** Request topology version. */
+    private final String execName;
+
     /**
      * @param ctx Kernal context.
      * @param dep Grid deployment.
@@ -182,6 +185,7 @@ public class GridJobWorker extends GridWorker implements GridTimeoutObject {
      * @param holdLsnr Hold listener.
      * @param partsReservation Reserved partitions (must be released at the job finish).
      * @param reqTopVer Affinity topology version of the job request.
+     * @param execName Custom executor name.
      */
     GridJobWorker(
         GridKernalContext ctx,
@@ -196,7 +200,8 @@ public class GridJobWorker extends GridWorker implements GridTimeoutObject {
         GridJobEventListener evtLsnr,
         GridJobHoldListener holdLsnr,
         GridReservable partsReservation,
-        AffinityTopologyVersion reqTopVer) {
+        AffinityTopologyVersion reqTopVer,
+        String execName) {
         super(ctx.igniteInstanceName(), "grid-job-worker", ctx.log(GridJobWorker.class));
 
         assert ctx != null;
@@ -219,6 +224,7 @@ public class GridJobWorker extends GridWorker implements GridTimeoutObject {
         this.holdLsnr = holdLsnr;
         this.partsReservation = partsReservation;
         this.reqTopVer = reqTopVer;
+        this.execName = execName;
 
         if (job != null)
             this.job = job;
@@ -727,6 +733,13 @@ public class GridJobWorker extends GridWorker implements GridTimeoutObject {
     }
 
     /**
+     * @return Custom executor name.
+     */
+    public String executorName() {
+        return execName;
+    }
+
+    /**
      * @param evtType Event type.
      * @param msg Message.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java
index 37bbb54..221c7bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java
@@ -18,7 +18,9 @@
 package org.apache.ignite.internal.processors.pool;
 
 import java.util.Arrays;
+import java.util.Map;
 import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.internal.GridKernalContext;
@@ -26,6 +28,7 @@ import org.apache.ignite.internal.managers.communication.GridIoPolicy;
 import org.apache.ignite.internal.processors.GridProcessorAdapter;
 import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
 import org.apache.ignite.plugin.extensions.communication.IoPool;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Processor which abstracts out thread pool management.
@@ -34,6 +37,9 @@ public class PoolProcessor extends GridProcessorAdapter {
     /** Map of {@link IoPool}-s injected by Ignite plugins. */
     private final IoPool[] extPools = new IoPool[128];
 
+    /** Custom named pools. */
+    private final Map<String, ? extends ExecutorService> customExecs;
+
     /**
      * Constructor.
      *
@@ -72,6 +78,8 @@ public class PoolProcessor extends GridProcessorAdapter {
                 }
             }
         }
+
+        customExecs = ctx.customExecutors();
     }
 
     /** {@inheritDoc} */
@@ -165,4 +173,21 @@ public class PoolProcessor extends GridProcessorAdapter {
             }
         }
     }
+
+    /**
+     * Gets executor service for custom policy by executor name.
+     *
+     * @param name Executor name.
+     * @return Executor service.
+     */
+    @Nullable public Executor customExecutor(String name) {
+        assert name != null;
+
+        Executor exec = null;
+
+        if (customExecs != null)
+            exec = customExecs.get(name);
+
+        return exec;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/processors/session/GridTaskSessionProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/session/GridTaskSessionProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/session/GridTaskSessionProcessor.java
index 9af038a..f9937a6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/session/GridTaskSessionProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/session/GridTaskSessionProcessor.java
@@ -76,6 +76,7 @@ public class GridTaskSessionProcessor extends GridProcessorAdapter {
      * @param fullSup {@code True} to enable distributed session attributes and checkpoints.
      * @param internal {@code True} in case of internal task.
      * @param subjId Subject ID.
+     * @param execName Custom executor name.
      * @return New session if one did not exist, or existing one.
      */
     public GridTaskSessionImpl createTaskSession(
@@ -91,7 +92,8 @@ public class GridTaskSessionProcessor extends GridProcessorAdapter {
         Map<Object, Object> attrs,
         boolean fullSup,
         boolean internal,
-        UUID subjId) {
+        UUID subjId,
+        @Nullable String execName) {
         if (!fullSup) {
             return new GridTaskSessionImpl(
                 taskNodeId,
@@ -107,7 +109,8 @@ public class GridTaskSessionProcessor extends GridProcessorAdapter {
                 ctx,
                 false,
                 internal,
-                subjId);
+                subjId,
+                execName);
         }
 
         while (true) {
@@ -130,7 +133,8 @@ public class GridTaskSessionProcessor extends GridProcessorAdapter {
                         ctx,
                         true,
                         internal,
-                        subjId));
+                        subjId,
+                        execName));
 
                 if (old != null)
                     ses = old;

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
index d34f297..22d5716 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
@@ -359,6 +359,19 @@ public class GridTaskProcessor extends GridProcessorAdapter {
      * @param <R> Task return value type.
      */
     public <T, R> ComputeTaskInternalFuture<R> execute(Class<? extends ComputeTask<T, R>> taskCls, @Nullable T arg) {
+        return execute(taskCls, arg, null);
+    }
+
+    /**
+     * @param taskCls Task class.
+     * @param arg Optional execution argument.
+     * @param execName Name of the custom executor.
+     * @return Task future.
+     * @param <T> Task argument type.
+     * @param <R> Task return value type.
+     */
+    public <T, R> ComputeTaskInternalFuture<R> execute(Class<? extends ComputeTask<T, R>> taskCls, @Nullable T arg,
+        @Nullable String execName) {
         assert taskCls != null;
 
         lock.readLock();
@@ -367,7 +380,8 @@ public class GridTaskProcessor extends GridProcessorAdapter {
             if (stopping)
                 throw new IllegalStateException("Failed to execute task due to grid shutdown: " + taskCls);
 
-            return startTask(null, taskCls, null, IgniteUuid.fromUuid(ctx.localNodeId()), arg, false);
+            return startTask(null, taskCls, null, IgniteUuid.fromUuid(ctx.localNodeId()), arg,
+                false, execName);
         }
         finally {
             lock.readUnlock();
@@ -382,7 +396,19 @@ public class GridTaskProcessor extends GridProcessorAdapter {
      * @param <R> Task return value type.
      */
     public <T, R> ComputeTaskInternalFuture<R> execute(ComputeTask<T, R> task, @Nullable T arg) {
-        return execute(task, arg, false);
+        return execute(task, arg, false, null);
+    }
+
+    /**
+     * @param task Actual task.
+     * @param arg Optional task argument.
+     * @param execName Name of the custom executor.
+     * @return Task future.
+     * @param <T> Task argument type.
+     * @param <R> Task return value type.
+     */
+    public <T, R> ComputeTaskInternalFuture<R> execute(ComputeTask<T, R> task, @Nullable T arg, String execName) {
+        return execute(task, arg, false, execName);
     }
 
     /**
@@ -394,13 +420,28 @@ public class GridTaskProcessor extends GridProcessorAdapter {
      * @param <R> Task return value type.
      */
     public <T, R> ComputeTaskInternalFuture<R> execute(ComputeTask<T, R> task, @Nullable T arg, boolean sys) {
+        return execute(task, arg, sys, null);
+    }
+
+    /**
+     * @param task Actual task.
+     * @param arg Optional task argument.
+     * @param sys If {@code true}, then system pool will be used.
+     * @param execName Name of the custom executor.
+     * @return Task future.
+     * @param <T> Task argument type.
+     * @param <R> Task return value type.
+     */
+    public <T, R> ComputeTaskInternalFuture<R> execute(ComputeTask<T, R> task, @Nullable T arg, boolean sys,
+        @Nullable String execName) {
         lock.readLock();
 
         try {
             if (stopping)
                 throw new IllegalStateException("Failed to execute task due to grid shutdown: " + task);
 
-            return startTask(null, null, task, IgniteUuid.fromUuid(ctx.localNodeId()), arg, sys);
+            return startTask(null, null, task, IgniteUuid.fromUuid(ctx.localNodeId()), arg,
+                sys, execName);
         }
         finally {
             lock.readUnlock();
@@ -436,6 +477,18 @@ public class GridTaskProcessor extends GridProcessorAdapter {
      * @param <R> Task return value type.
      */
     public <T, R> ComputeTaskInternalFuture<R> execute(String taskName, @Nullable T arg) {
+        return execute(taskName, arg, null);
+    }
+
+    /**
+     * @param taskName Task name.
+     * @param arg Optional execution argument.
+     * @param execName Name of the custom executor.
+     * @return Task future.
+     * @param <T> Task argument type.
+     * @param <R> Task return value type.
+     */
+    public <T, R> ComputeTaskInternalFuture<R> execute(String taskName, @Nullable T arg, @Nullable String execName) {
         assert taskName != null;
 
         lock.readLock();
@@ -444,7 +497,8 @@ public class GridTaskProcessor extends GridProcessorAdapter {
             if (stopping)
                 throw new IllegalStateException("Failed to execute task due to grid shutdown: " + taskName);
 
-            return startTask(taskName, null, null, IgniteUuid.fromUuid(ctx.localNodeId()), arg, false);
+            return startTask(taskName, null, null, IgniteUuid.fromUuid(ctx.localNodeId()), arg,
+                false, execName);
         }
         finally {
             lock.readUnlock();
@@ -458,6 +512,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
      * @param sesId Task session ID.
      * @param arg Optional task argument.
      * @param sys If {@code true}, then system pool will be used.
+     * @param execName Name of the custom executor.
      * @return Task future.
      */
     @SuppressWarnings("unchecked")
@@ -467,7 +522,8 @@ public class GridTaskProcessor extends GridProcessorAdapter {
         @Nullable ComputeTask<T, R> task,
         IgniteUuid sesId,
         @Nullable T arg,
-        boolean sys) {
+        boolean sys,
+        @Nullable String execName) {
         assert sesId != null;
 
         String taskClsName;
@@ -629,7 +685,8 @@ public class GridTaskProcessor extends GridProcessorAdapter {
             Collections.emptyMap(),
             fullSup,
             internal,
-            subjId);
+            subjId,
+            execName);
 
         ComputeTaskInternalFuture<R> fut = new ComputeTaskInternalFuture<>(ses, ctx);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
index cb5aabe..62224f0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
@@ -1372,7 +1372,8 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
                         subjId,
                         affCacheIds,
                         affPartId,
-                        mapTopVer);
+                        mapTopVer,
+                        ses.executorName());
 
                     if (loc)
                         ctx.job().processJobExecuteRequest(ctx.discovery().localNode(), req);

http://git-wip-us.apache.org/repos/asf/ignite/blob/f871b0d7/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorConfigurationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorConfigurationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorConfigurationSelfTest.java
new file mode 100644
index 0000000..2277100
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorConfigurationSelfTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.compute;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.ExecutorConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Tests custom executor configuration.
+ */
+public class IgniteComputeCustomExecutorConfigurationSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(disco);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testConfigurations() throws Exception {
+        try {
+            checkStartWithInvalidConfiguration(getConfiguration("node0")
+                .setExecutorConfiguration(new ExecutorConfiguration()));
+
+            checkStartWithInvalidConfiguration(getConfiguration("node0")
+                .setExecutorConfiguration(new ExecutorConfiguration("")));
+
+            checkStartWithInvalidConfiguration(getConfiguration("node0")
+                .setExecutorConfiguration(new ExecutorConfiguration("exec").setSize(-1)));
+
+            checkStartWithInvalidConfiguration(getConfiguration("node0")
+                .setExecutorConfiguration(new ExecutorConfiguration("exec").setSize(0)));
+        }
+        finally {
+            Ignition.stopAll(true);
+        }
+    }
+
+    /**
+     * @param cfg Ignite configuration.
+     * @throws Exception If failed.
+     */
+    private void checkStartWithInvalidConfiguration(IgniteConfiguration cfg) throws Exception {
+        try {
+            Ignition.start(cfg);
+
+            fail("Node start must fail.");
+        }
+        catch (IgniteException e) {
+            // No-op.
+        }
+    }
+}


[63/65] [abbrv] ignite git commit: Merge branch ignite-5024 of https://github.com/gridgain/apache-ignite into ignite-5024

Posted by ag...@apache.org.
Merge branch ignite-5024 of https://github.com/gridgain/apache-ignite into ignite-5024


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

Branch: refs/heads/ignite-5024
Commit: 14c52e2fcac45bc51ca6e8588a7d250a0e285a1b
Parents: 67ba03b 83d913c
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Apr 24 11:02:13 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Apr 24 11:02:13 2017 +0300

----------------------------------------------------------------------
 examples/pom.xml                                |  5 +-
 modules/aop/pom.xml                             |  2 +-
 modules/apache-license-gen/pom.xml              |  2 +-
 modules/aws/pom.xml                             |  2 +-
 modules/benchmarks/pom.xml                      |  2 +-
 modules/camel/pom.xml                           |  2 +-
 modules/cassandra/pom.xml                       |  2 +-
 modules/cassandra/serializers/pom.xml           |  4 +-
 modules/cassandra/store/pom.xml                 |  4 +-
 modules/clients/pom.xml                         |  2 +-
 modules/cloud/pom.xml                           |  2 +-
 modules/codegen/pom.xml                         |  2 +-
 modules/core/pom.xml                            |  2 +-
 .../configuration/MemoryConfiguration.java      | 40 +++++++++-
 .../IgniteCacheDatabaseSharedManager.java       | 37 ++++++++--
 .../ignite/internal/util/IgniteUtils.java       | 26 ++++++-
 .../core/src/main/resources/ignite.properties   |  2 +-
 .../cache/MemoryPolicyConfigValidationTest.java | 77 +++++++++++++++++++-
 .../GridServiceProcessorMultiNodeSelfTest.java  |  6 +-
 modules/extdata/p2p/pom.xml                     |  2 +-
 .../extdata/uri/modules/uri-dependency/pom.xml  |  2 +-
 modules/extdata/uri/pom.xml                     |  2 +-
 modules/flink/pom.xml                           |  2 +-
 modules/flume/pom.xml                           |  2 +-
 modules/gce/pom.xml                             |  2 +-
 modules/geospatial/pom.xml                      |  2 +-
 modules/hadoop/pom.xml                          |  2 +-
 modules/hibernate/pom.xml                       |  2 +-
 modules/hibernate5/pom.xml                      |  2 +-
 modules/indexing/pom.xml                        |  2 +-
 ...teCacheJoinPartitionedAndReplicatedTest.java | 57 ++++++++++++---
 modules/jcl/pom.xml                             |  2 +-
 modules/jms11/pom.xml                           |  2 +-
 modules/jta/pom.xml                             |  2 +-
 modules/kafka/pom.xml                           |  2 +-
 modules/kubernetes/pom.xml                      |  2 +-
 modules/log4j/pom.xml                           |  2 +-
 modules/log4j2/pom.xml                          |  2 +-
 modules/mesos/pom.xml                           |  2 +-
 modules/ml/pom.xml                              |  6 +-
 modules/mqtt/pom.xml                            |  2 +-
 modules/osgi-karaf/pom.xml                      |  2 +-
 modules/osgi-paxlogging/pom.xml                 |  2 +-
 modules/osgi/pom.xml                            |  2 +-
 modules/platforms/cpp/common/configure.ac       |  2 +-
 modules/platforms/cpp/configure.ac              |  2 +-
 modules/platforms/cpp/configure.acrel           |  2 +-
 modules/platforms/cpp/core-test/configure.ac    |  2 +-
 modules/platforms/cpp/core/configure.ac         |  2 +-
 modules/platforms/cpp/examples/configure.ac     |  2 +-
 modules/platforms/cpp/ignite/configure.ac       |  2 +-
 .../cpp/odbc/install/ignite-odbc-amd64.wxs      |  2 +-
 .../cpp/odbc/install/ignite-odbc-x86.wxs        |  2 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 .../Apache.Ignite/Properties/AssemblyInfo.cs    |  6 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 .../Properties/AssemblyInfo.cs                  |  6 +-
 modules/rest-http/pom.xml                       |  2 +-
 modules/scalar-2.10/pom.xml                     |  2 +-
 modules/scalar/pom.xml                          |  2 +-
 modules/schedule/pom.xml                        |  2 +-
 modules/slf4j/pom.xml                           |  2 +-
 modules/spark-2.10/pom.xml                      |  2 +-
 modules/spark/pom.xml                           |  2 +-
 modules/spring-data/pom.xml                     |  5 +-
 modules/spring/pom.xml                          |  2 +-
 modules/ssh/pom.xml                             |  2 +-
 modules/storm/pom.xml                           |  2 +-
 modules/tools/pom.xml                           |  2 +-
 modules/twitter/pom.xml                         |  2 +-
 modules/urideploy/pom.xml                       |  2 +-
 modules/visor-console-2.10/pom.xml              |  2 +-
 modules/visor-console/pom.xml                   |  2 +-
 modules/visor-plugins/pom.xml                   |  2 +-
 modules/web-console/pom.xml                     |  2 +-
 modules/web-console/web-agent/pom.xml           |  2 +-
 modules/web/ignite-appserver-test/pom.xml       |  2 +-
 modules/web/ignite-websphere-test/pom.xml       |  2 +-
 modules/web/pom.xml                             |  2 +-
 modules/yardstick/pom.xml                       |  2 +-
 modules/yarn/pom.xml                            |  2 +-
 modules/zeromq/pom.xml                          |  2 +-
 modules/zookeeper/pom.xml                       |  2 +-
 pom.xml                                         | 43 +++++------
 95 files changed, 355 insertions(+), 181 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/14c52e2f/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
index a353eef,3cccb42..97f10b3
--- a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
@@@ -62,11 -62,11 +62,14 @@@ public class MemoryConfiguration implem
      /** */
      private static final long serialVersionUID = 0L;
  
 +    /** Default memory policy start size (256 MB). */
 +    public static final long DFLT_MEMORY_POLICY_INITIAL_SIZE = 256 * 1024 * 1024;
 +
-     /** Default memory policy's size (1 GB). */
-     public static final long DFLT_MEMORY_POLICY_MAX_SIZE = 1024 * 1024 * 1024;
+     /** Fraction of available memory to allocate for default MemoryPolicy. */
+     private static final double DFLT_MEMORY_POLICY_FRACTION = 0.8;
+ 
+     /** Default memory policy's size is 80% of physical memory available on current machine. */
 -    public static final long DFLT_MEMORY_POLICY_SIZE = (long) DFLT_MEMORY_POLICY_FRACTION * U.getTotalMemoryAvailable();
++    public static final long DFLT_MEMORY_POLICY_MAX_SIZE = (long)DFLT_MEMORY_POLICY_FRACTION * U.getTotalMemoryAvailable();
  
      /** Default size of a memory chunk for the system cache (100 MB). */
      public static final long DFLT_SYS_CACHE_MEM_SIZE = 100 * 1024 * 1024;
@@@ -167,8 -170,10 +173,10 @@@
      public MemoryPolicyConfiguration createDefaultPolicyConfig() {
          MemoryPolicyConfiguration memPlc = new MemoryPolicyConfiguration();
  
 -        long size = (dfltMemPlcSize != null) ? dfltMemPlcSize : DFLT_MEMORY_POLICY_SIZE;
++        long maxSize = (dfltMemPlcSize != null) ? dfltMemPlcSize : DFLT_MEMORY_POLICY_MAX_SIZE;
+ 
          memPlc.setName(null);
-         memPlc.setMaxSize(DFLT_MEMORY_POLICY_MAX_SIZE);
 -        memPlc.setSize(size);
++        memPlc.setMaxSize(maxSize);
  
          return memPlc;
      }
@@@ -195,9 -197,35 +203,35 @@@
      }
  
      /**
+      * Gets a size for default memory policy overridden by user.
+      *
+      * @return default memory policy size overridden by user or -1 if nothing was specified.
+      */
+     public long getDefaultMemoryPolicySize() {
+         return (dfltMemPlcSize != null) ? dfltMemPlcSize : -1;
+     }
+ 
+     /**
+      * Overrides size of default memory policy which is created automatically.
+      *
+      * If user doesn't specify any memory policy configuration, a default one with default size
+      * (80% of available RAM) is created by Ignite.
+      *
+      * This property allows user to specify desired size of default memory policy
+      * without having to use more verbose syntax of MemoryPolicyConfiguration elements.
+      *
+      * @param dfltMemPlcSize Size of default memory policy overridden by user.
+      */
+     public MemoryConfiguration setDefaultMemoryPolicySize(long dfltMemPlcSize) {
+         this.dfltMemPlcSize = dfltMemPlcSize;
+ 
+         return this;
+     }
+ 
+     /**
       * Gets a name of default memory policy.
       *
 -     * @return A name of a custom memory policy configured with {@link MemoryConfiguration} or {@code null} of the
 +     * @return A name of a custom memory policy configured with {@code MemoryConfiguration} or {@code null} of the
       *         default policy is used.
       */
      public String getDefaultMemoryPolicyName() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/14c52e2f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
index d7e1e17,de882da..d6c7faa
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
@@@ -305,14 -308,28 +309,30 @@@ public class IgniteCacheDatabaseSharedM
       * @param plcNames All MemoryPolicy names.
       * @throws IgniteCheckedException In case of validation violation.
       */
-     private static void checkDefaultPolicyConfiguration(String dfltPlcName, Collection<String> plcNames)
-         throws IgniteCheckedException {
 -    private static void checkDefaultPolicyConfiguration(String dfltPlcName,
 -                                                        long dfltPlcSize,
 -                                                        Set<String> plcNames) throws IgniteCheckedException {
++    private static void checkDefaultPolicyConfiguration(
++        String dfltPlcName,
++        long dfltPlcSize,
++        Collection<String> plcNames
++    ) throws IgniteCheckedException {
+         if (dfltPlcSize != -1) {
+             if (dfltPlcName != null)
+                 throw new IgniteCheckedException("User-defined MemoryPolicy configuration " +
 -                        "and defaultMemoryPolicySize properties are set at the same time. " +
 -                        "Delete either MemoryConfiguration.defaultMemoryPolicySize property " +
 -                        "or configuration of user-defined default MemoryPolicy");
 -
++                    "and defaultMemoryPolicySize properties are set at the same time. " +
++                    "Delete either MemoryConfiguration.defaultMemoryPolicySize property " +
++                    "or user-defined default MemoryPolicy configuration");
+ 
+             if (dfltPlcSize < MIN_PAGE_MEMORY_SIZE)
+                 throw new IgniteCheckedException("User-defined default MemoryPolicy size is less than 1MB. " +
+                         "Use MemoryConfiguration.defaultMemoryPolicySize property to set correct size.");
+         }
+ 
          if (dfltPlcName != null) {
              if (dfltPlcName.isEmpty())
                  throw new IgniteCheckedException("User-defined default MemoryPolicy name must be non-empty");
++
              if (!plcNames.contains(dfltPlcName))
-                 throw new IgniteCheckedException("User-defined default MemoryPolicy name must be presented " +
-                     "among configured MemoryPolices: " + dfltPlcName);
+                 throw new IgniteCheckedException("User-defined default MemoryPolicy name " +
 -                        "must be presented among configured MemoryPolices: " + dfltPlcName);
++                    "must be presented among configured MemoryPolices: " + dfltPlcName);
          }
      }
  
@@@ -321,12 -338,13 +341,15 @@@
       * @throws IgniteCheckedException If config is invalid.
       */
      private static void checkPolicySize(MemoryPolicyConfiguration plcCfg) throws IgniteCheckedException {
-         if (plcCfg.getMaxSize() < MIN_PAGE_MEMORY_SIZE)
-             throw new IgniteCheckedException("MemoryPolicy must have size more than 1MB: " + plcCfg.getName());
 -        if (plcCfg.getSize() < MIN_PAGE_MEMORY_SIZE)
 -            throw new IgniteCheckedException("MemoryPolicy must have size more than 1MB: MemoryPolicy[name=" +
 -                    plcCfg.getName() +
 -                    "; size=" +
 -                    plcCfg.getSize() +
 -                    "]. Use MemoryPolicyConfiguration.size property to set correct size (in bytes)."
++        if (plcCfg.getInitialSize() < MIN_PAGE_MEMORY_SIZE)
++            throw new IgniteCheckedException("MemoryPolicy must have size more than 1MB (use " +
++                "MemoryPolicyConfiguration.size property to set correct size in bytes) " +
++                "[name=" + plcCfg.getName() + ", size=" + U.readableSize(plcCfg.getInitialSize(), true) + "]"
+             );
 +
 +        if (plcCfg.getMaxSize() > plcCfg.getInitialSize())
 +            throw new IgniteCheckedException("MemoryPolicy maxSize must not be smaller than " +
 +                "initialSize: " + plcCfg.getName());
      }
  
      /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/14c52e2f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/14c52e2f/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java
index df7ddf1,32d1462..aa247fd
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java
@@@ -299,13 -299,13 +299,15 @@@ public class GridServiceProcessorMultiN
  
          checkCount(name, g.services().serviceDescriptors(), nodeCount());
  
-         latch = new CountDownLatch(1);
 -        int extraNodes = 2;
+ 
 -        latch = new CountDownLatch(1);
++
++            latch = new CountDownLatch(1);
  
          DummyService.exeLatch(name, latch);
  
-         int extraNodes = 2;
 -        startExtraNodes(2);
++            int extraNodes =2;
 +
 +        startExtraNodes(extraNodes);
  
          try {
              latch.await();

http://git-wip-us.apache.org/repos/asf/ignite/blob/14c52e2f/pom.xml
----------------------------------------------------------------------


[53/65] [abbrv] ignite git commit: Merge remote-tracking branch 'origin/ignite-2.0' into ignite-2.0

Posted by ag...@apache.org.
Merge remote-tracking branch 'origin/ignite-2.0' into ignite-2.0


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

Branch: refs/heads/ignite-5024
Commit: 6e2c51d340e9d28f0bed05cfb571fe4b32733fd9
Parents: a900dc6 ad7e4a0
Author: sboikov <sb...@gridgain.com>
Authored: Fri Apr 21 17:30:39 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Apr 21 17:30:39 2017 +0300

----------------------------------------------------------------------
 .../platform/cache/PlatformCache.java           |  24 +-
 .../platform/cluster/PlatformClusterGroup.java  |  17 ++
 .../utils/PlatformConfigurationUtils.java       |   4 +
 .../query/h2/opt/GridH2SpatialIndex.java        |   8 +-
 .../query/h2/database/H2PkHashIndex.java        |   6 +-
 .../query/h2/database/H2TreeIndex.java          |   6 +-
 .../query/h2/database/InlineIndexHelper.java    |  14 -
 .../query/h2/opt/GridH2IndexBase.java           |   4 +-
 .../query/h2/opt/GridH2MetaTable.java           |   8 +-
 .../query/h2/opt/GridH2PrimaryScanIndex.java    |   7 +-
 .../processors/query/h2/opt/GridH2Row.java      |   2 +-
 .../query/h2/opt/GridH2ScanIndex.java           |   4 +-
 .../processors/query/h2/opt/GridH2Table.java    |   7 +-
 .../query/h2/opt/GridH2TreeIndex.java           |   7 +-
 .../processors/query/h2/sql/DmlAstUtils.java    |   3 -
 .../processors/query/h2/sql/GridSqlAlias.java   |  20 +-
 .../query/h2/sql/GridSqlQueryParser.java        |   4 +
 .../processors/query/h2/sql/GridSqlTable.java   |  46 ++++
 .../query/h2/twostep/GridMergeIndex.java        |   1 +
 .../query/h2/twostep/GridMergeIndexSorted.java  |   6 +-
 .../h2/twostep/GridMergeIndexUnsorted.java      |   6 +-
 .../query/h2/twostep/GridMergeTable.java        |  12 +-
 .../query/h2/twostep/GridThreadLocalTable.java  |   9 +-
 .../query/IgniteSqlSplitterSelfTest.java        |  34 ++-
 .../h2/database/InlineIndexHelperTest.java      |   8 -
 .../query/h2/sql/GridQueryParsingTest.java      |  29 ++-
 .../ExpiryCacheHolderTest.cs                    |  10 +
 .../Apache.Ignite.Core.Tests.csproj             |   1 +
 .../Cache/Affinity/AffinityFunctionTest.cs      |   2 +-
 .../Cache/CacheConfigurationTest.cs             |   3 +
 .../Cache/CacheTestAsyncWrapper.cs              |  16 +-
 .../Cache/PartitionLossTest.cs                  | 260 +++++++++++++++++++
 .../IgniteConfigurationSerializerTest.cs        |   7 +-
 .../Apache.Ignite.Core.Tests/TestUtils.cs       |   5 +-
 .../Apache.Ignite.Core.csproj                   |   1 +
 .../Cache/Configuration/CacheConfiguration.cs   |  13 +
 .../Cache/Configuration/PartitionLossPolicy.cs  |  68 +++++
 .../dotnet/Apache.Ignite.Core/Cache/ICache.cs   |  15 ++
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |  12 +
 .../IgniteConfigurationSection.xsd              |  15 ++
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |  48 +++-
 .../Apache.Ignite.Core/Impl/Cache/CacheOp.cs    |   5 +-
 .../Impl/Cluster/ClusterGroupImpl.cs            |  27 ++
 .../Impl/Common/DelegateConverter.cs            |   1 +
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |  16 +-
 modules/spring-data/pom.xml                     |   2 +-
 .../support/IgniteRepositoryFactoryBean.java    |   7 +
 parent/pom.xml                                  |   6 +-
 48 files changed, 745 insertions(+), 91 deletions(-)
----------------------------------------------------------------------



[33/65] [abbrv] ignite git commit: Merge remote-tracking branch 'origin/ignite-2.0' into ignite-2.0

Posted by ag...@apache.org.
Merge remote-tracking branch 'origin/ignite-2.0' into ignite-2.0


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

Branch: refs/heads/ignite-5024
Commit: 6cc43cae9af09bcb938c94a7f9df376ee90d780f
Parents: d1f637f d20f458
Author: sboikov <sb...@gridgain.com>
Authored: Thu Apr 20 18:35:54 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Apr 20 18:35:54 2017 +0300

----------------------------------------------------------------------
 .../src/main/java/org/apache/ignite/Ignite.java |  1 -
 .../datastructures/DataStructuresProcessor.java |  3 +-
 .../datastructures/GridCacheLockImpl.java       | 17 +----
 .../internal/GridCacheRecreateLockTest.java     | 78 --------------------
 .../testsuites/IgniteComputeGridTestSuite.java  |  2 -
 5 files changed, 3 insertions(+), 98 deletions(-)
----------------------------------------------------------------------



[16/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/DecompositionSupport.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/DecompositionSupport.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/DecompositionSupport.java
new file mode 100644
index 0000000..20d6e79
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/DecompositionSupport.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.decompositions;
+
+import org.apache.ignite.ml.math.Destroyable;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.matrix.CacheMatrix;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.impls.matrix.PivotedMatrixView;
+import org.apache.ignite.ml.math.impls.matrix.RandomMatrix;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+
+/**
+ * Helper methods to support decomposition of matrix types having some functionality limited.
+ */
+public abstract class DecompositionSupport implements Destroyable {
+    /**
+     * Create the like matrix with read-only matrices support.
+     *
+     * @param matrix Matrix for like.
+     * @return Like matrix.
+     */
+    protected Matrix like(Matrix matrix) {
+        if (isCopyLikeSupport(matrix))
+            return new DenseLocalOnHeapMatrix(matrix.rowSize(), matrix.columnSize());
+        else
+            return matrix.like(matrix.rowSize(), matrix.columnSize());
+    }
+
+    /**
+     * Create the like matrix with specified size with read-only matrices support.
+     *
+     * @param matrix Matrix for like.
+     * @return Like matrix.
+     */
+    protected Matrix like(Matrix matrix, int rows, int cols) {
+        if (isCopyLikeSupport(matrix))
+            return new DenseLocalOnHeapMatrix(rows, cols);
+        else
+            return matrix.like(rows, cols);
+    }
+
+    /**
+     * Create the like vector with read-only matrices support.
+     *
+     * @param matrix Matrix for like.
+     * @param crd Cardinality of the vector.
+     * @return Like vector.
+     */
+    protected Vector likeVector(Matrix matrix, int crd) {
+        if (isCopyLikeSupport(matrix))
+            return new DenseLocalOnHeapVector(crd);
+        else
+            return matrix.likeVector(crd);
+    }
+
+    /**
+     * Create the like vector with read-only matrices support.
+     *
+     * @param matrix Matrix for like.
+     * @return Like vector.
+     */
+    protected Vector likeVector(Matrix matrix) {
+        return likeVector(matrix, matrix.rowSize());
+    }
+
+    /**
+     * Create the copy of matrix with read-only matrices support.
+     *
+     * @param matrix Matrix for copy.
+     * @return Copy.
+     */
+    protected Matrix copy(Matrix matrix) {
+        if (isCopyLikeSupport(matrix)) {
+            DenseLocalOnHeapMatrix cp = new DenseLocalOnHeapMatrix(matrix.rowSize(), matrix.columnSize());
+
+            cp.assign(matrix);
+
+            return cp;
+        }
+        else
+            return matrix.copy();
+    }
+
+    /** */
+    private boolean isCopyLikeSupport(Matrix matrix) {
+        return matrix instanceof RandomMatrix || matrix instanceof PivotedMatrixView || matrix instanceof CacheMatrix;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
new file mode 100644
index 0000000..01af989
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
@@ -0,0 +1,923 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.decompositions;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.functions.Functions;
+
+/**
+ * This class provides EigenDecomposition of given matrix. The class is based on
+ * class with similar name from <a href="http://mahout.apache.org/">Apache Mahout</a> library.
+ *
+ * @see <a href=http://mathworld.wolfram.com/EigenDecomposition.html>MathWorld</a>
+ */
+public class EigenDecomposition extends DecompositionSupport {
+    /** Row and column dimension (square matrix). */
+    private final int n;
+
+    /** Array for internal storage of eigen vectors. */
+    private final Matrix v;
+
+    /** Array for internal storage of eigenvalues. */
+    private final Vector d;
+    /** Array for internal storage of eigenvalues. */
+    private final Vector e;
+
+    /** */
+    public EigenDecomposition(Matrix matrix) {
+        this(matrix, isSymmetric(matrix));
+    }
+
+    /** */
+    public EigenDecomposition(Matrix matrix, boolean isSymmetric) {
+        n = matrix.columnSize();
+
+        d = likeVector(matrix);
+        e = likeVector(matrix);
+        v = like(matrix);
+
+        if (isSymmetric) {
+            v.assign(matrix);
+
+            // Tridiagonalize.
+            tred2();
+
+            // Diagonalize.
+            tql2();
+
+        }
+        else
+            // Reduce to Hessenberg form.
+            // Reduce Hessenberg to real Schur form.
+            hqr2(orthes(matrix));
+    }
+
+    /**
+     * Return the eigen vector matrix
+     *
+     * @return V
+     */
+    public Matrix getV() {
+        return like(v).assign(v);
+    }
+
+    /**
+     * Return the real parts of the eigenvalues
+     */
+    public Vector getRealEigenValues() {
+        return d;
+    }
+
+    /**
+     * Return the imaginary parts of the eigenvalues
+     */
+    public Vector getImagEigenvalues() {
+        return e;
+    }
+
+    /**
+     * Return the block diagonal eigenvalue matrix
+     *
+     * @return D
+     */
+    public Matrix getD() {
+        Matrix res = like(v, d.size(), d.size());
+        res.assign(0);
+        res.viewDiagonal().assign(d);
+        for (int i = 0; i < n; i++) {
+            double v = e.getX(i);
+            if (v > 0)
+                res.setX(i, i + 1, v);
+            else if (v < 0)
+                res.setX(i, i - 1, v);
+        }
+        return res;
+    }
+
+    /**
+     * Destroys decomposition components and other internal components of decomposition.
+     */
+    @Override public void destroy() {
+        e.destroy();
+        v.destroy();
+        d.destroy();
+    }
+
+    /** */
+    private void tred2() {
+        //  This is derived from the Algol procedures tred2 by
+        //  Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
+        //  Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
+        //  Fortran subroutine in EISPACK.
+
+        d.assign(v.viewColumn(n - 1));
+
+        // Householder reduction to tridiagonal form.
+
+        for (int i = n - 1; i > 0; i--) {
+
+            // Scale to avoid under/overflow.
+            double scale = d.viewPart(0, i).kNorm(1);
+            double h = 0.0;
+
+            if (scale == 0.0) {
+                e.setX(i, d.getX(i - 1));
+                for (int j = 0; j < i; j++) {
+                    d.setX(j, v.getX(i - 1, j));
+                    v.setX(i, j, 0.0);
+                    v.setX(j, i, 0.0);
+                }
+            }
+            else {
+
+                // Generate Householder vector.
+
+                for (int k = 0; k < i; k++) {
+                    d.setX(k, d.getX(k) / scale);
+                    h += d.getX(k) * d.getX(k);
+                }
+
+                double f = d.getX(i - 1);
+                double g = Math.sqrt(h);
+
+                if (f > 0)
+                    g = -g;
+
+                e.setX(i, scale * g);
+                h -= f * g;
+                d.setX(i - 1, f - g);
+
+                for (int j = 0; j < i; j++)
+                    e.setX(j, 0.0);
+
+                // Apply similarity transformation to remaining columns.
+
+                for (int j = 0; j < i; j++) {
+                    f = d.getX(j);
+                    v.setX(j, i, f);
+                    g = e.getX(j) + v.getX(j, j) * f;
+
+                    for (int k = j + 1; k <= i - 1; k++) {
+                        g += v.getX(k, j) * d.getX(k);
+                        e.setX(k, e.getX(k) + v.getX(k, j) * f);
+                    }
+
+                    e.setX(j, g);
+                }
+
+                f = 0.0;
+
+                for (int j = 0; j < i; j++) {
+                    e.setX(j, e.getX(j) / h);
+                    f += e.getX(j) * d.getX(j);
+                }
+
+                double hh = f / (h + h);
+
+                for (int j = 0; j < i; j++)
+                    e.setX(j, e.getX(j) - hh * d.getX(j));
+
+                for (int j = 0; j < i; j++) {
+                    f = d.getX(j);
+                    g = e.getX(j);
+
+                    for (int k = j; k <= i - 1; k++)
+                        v.setX(k, j, v.getX(k, j) - (f * e.getX(k) + g * d.getX(k)));
+
+                    d.setX(j, v.getX(i - 1, j));
+                    v.setX(i, j, 0.0);
+                }
+            }
+
+            d.setX(i, h);
+        }
+    }
+
+    /** */
+    private Matrix orthes(Matrix matrix) {
+        // Working storage for nonsymmetric algorithm.
+        Vector ort = likeVector(matrix);
+        Matrix hessenBerg = like(matrix).assign(matrix);
+
+        //  This is derived from the Algol procedures orthes and ortran,
+        //  by Martin and Wilkinson, Handbook for Auto. Comp.,
+        //  Vol.ii-Linear Algebra, and the corresponding
+        //  Fortran subroutines in EISPACK.
+
+        int low = 0;
+        int high = n - 1;
+
+        for (int m = low + 1; m <= high - 1; m++) {
+
+            // Scale column.
+
+            Vector hCol = hessenBerg.viewColumn(m - 1).viewPart(m, high - m + 1);
+            double scale = hCol.kNorm(1);
+
+            if (scale != 0.0) {
+                // Compute Householder transformation.
+                ort.viewPart(m, high - m + 1).map(hCol, Functions.plusMult(1 / scale));
+                double h = ort.viewPart(m, high - m + 1).getLengthSquared();
+
+                double g = Math.sqrt(h);
+
+                if (ort.getX(m) > 0)
+                    g = -g;
+
+                h -= ort.getX(m) * g;
+                ort.setX(m, ort.getX(m) - g);
+
+                // Apply Householder similarity transformation
+                // H = (I-u*u'/h)*H*(I-u*u')/h)
+
+                Vector ortPiece = ort.viewPart(m, high - m + 1);
+
+                for (int j = m; j < n; j++) {
+                    double f = ortPiece.dot(hessenBerg.viewColumn(j).viewPart(m, high - m + 1)) / h;
+                    hessenBerg.viewColumn(j).viewPart(m, high - m + 1).map(ortPiece, Functions.plusMult(-f));
+                }
+
+                for (int i = 0; i <= high; i++) {
+                    double f = ortPiece.dot(hessenBerg.viewRow(i).viewPart(m, high - m + 1)) / h;
+                    hessenBerg.viewRow(i).viewPart(m, high - m + 1).map(ortPiece, Functions.plusMult(-f));
+                }
+
+                ort.setX(m, scale * ort.getX(m));
+                hessenBerg.setX(m, m - 1, scale * g);
+            }
+        }
+
+        // Accumulate transformations (Algol's ortran).
+
+        v.assign(0);
+        v.viewDiagonal().assign(1);
+
+        for (int m = high - 1; m >= low + 1; m--) {
+            if (hessenBerg.getX(m, m - 1) != 0.0) {
+                ort.viewPart(m + 1, high - m).assign(hessenBerg.viewColumn(m - 1).viewPart(m + 1, high - m));
+
+                for (int j = m; j <= high; j++) {
+                    double g = ort.viewPart(m, high - m + 1).dot(v.viewColumn(j).viewPart(m, high - m + 1));
+
+                    // Double division avoids possible underflow
+                    g = g / ort.getX(m) / hessenBerg.getX(m, m - 1);
+                    v.viewColumn(j).viewPart(m, high - m + 1).map(ort.viewPart(m, high - m + 1), Functions.plusMult(g));
+                }
+            }
+        }
+
+        return hessenBerg;
+    }
+
+    /** Symmetric tridiagonal QL algorithm. */
+    private void tql2() {
+        //  This is derived from the Algol procedures tql2, by
+        //  Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
+        //  Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
+        //  Fortran subroutine in EISPACK.
+
+        e.viewPart(0, n - 1).assign(e.viewPart(1, n - 1));
+        e.setX(n - 1, 0.0);
+
+        double f = 0.0;
+        double tst1 = 0.0;
+        double eps = Math.pow(2.0, -52.0);
+
+        for (int l = 0; l < n; l++) {
+            // Find small subdiagonal element.
+
+            tst1 = Math.max(tst1, Math.abs(d.getX(l)) + Math.abs(e.getX(l)));
+            int m = l;
+
+            while (m < n) {
+                if (Math.abs(e.getX(m)) <= eps * tst1)
+                    break;
+
+                m++;
+            }
+
+            // If m == l, d.getX(l) is an eigenvalue,
+            // otherwise, iterate.
+
+            if (m > l) {
+                do {
+                    // Compute implicit shift
+
+                    double g = d.getX(l);
+                    double p = (d.getX(l + 1) - g) / (2.0 * e.getX(l));
+                    double r = Math.hypot(p, 1.0);
+
+                    if (p < 0)
+                        r = -r;
+
+                    d.setX(l, e.getX(l) / (p + r));
+                    d.setX(l + 1, e.getX(l) * (p + r));
+                    double dl1 = d.getX(l + 1);
+                    double h = g - d.getX(l);
+
+                    for (int i = l + 2; i < n; i++)
+                        d.setX(i, d.getX(i) - h);
+
+                    f += h;
+
+                    // Implicit QL transformation.
+
+                    p = d.getX(m);
+                    double c = 1.0;
+                    double c2 = c;
+                    double c3 = c;
+                    double el1 = e.getX(l + 1);
+                    double s = 0.0;
+                    double s2 = 0.0;
+
+                    for (int i = m - 1; i >= l; i--) {
+                        c3 = c2;
+                        c2 = c;
+                        s2 = s;
+                        g = c * e.getX(i);
+                        h = c * p;
+                        r = Math.hypot(p, e.getX(i));
+                        e.setX(i + 1, s * r);
+                        s = e.getX(i) / r;
+                        c = p / r;
+                        p = c * d.getX(i) - s * g;
+                        d.setX(i + 1, h + s * (c * g + s * d.getX(i)));
+
+                        // Accumulate transformation.
+
+                        for (int k = 0; k < n; k++) {
+                            h = v.getX(k, i + 1);
+                            v.setX(k, i + 1, s * v.getX(k, i) + c * h);
+                            v.setX(k, i, c * v.getX(k, i) - s * h);
+                        }
+                    }
+
+                    p = -s * s2 * c3 * el1 * e.getX(l) / dl1;
+                    e.setX(l, s * p);
+                    d.setX(l, c * p);
+
+                    // Check for convergence.
+
+                }
+                while (Math.abs(e.getX(l)) > eps * tst1);
+            }
+
+            d.setX(l, d.getX(l) + f);
+            e.setX(l, 0.0);
+        }
+
+        // Sort eigenvalues and corresponding vectors.
+
+        for (int i = 0; i < n - 1; i++) {
+            int k = i;
+            double p = d.getX(i);
+
+            for (int j = i + 1; j < n; j++)
+                if (d.getX(j) > p) {
+                    k = j;
+                    p = d.getX(j);
+                }
+
+            if (k != i) {
+                d.setX(k, d.getX(i));
+                d.setX(i, p);
+
+                for (int j = 0; j < n; j++) {
+                    p = v.getX(j, i);
+                    v.setX(j, i, v.getX(j, k));
+                    v.setX(j, k, p);
+                }
+            }
+        }
+    }
+
+    /** */
+    private void hqr2(Matrix h) {
+        //  This is derived from the Algol procedure hqr2,
+        //  by Martin and Wilkinson, Handbook for Auto. Comp.,
+        //  Vol.ii-Linear Algebra, and the corresponding
+        //  Fortran subroutine in EISPACK.
+
+        // Initialize
+
+        int nn = this.n;
+        int n = nn - 1;
+        int low = 0;
+        int high = nn - 1;
+        double eps = Math.pow(2.0, -52.0);
+        double exshift = 0.0;
+        double p = 0;
+        double q = 0;
+        double r = 0;
+        double s = 0;
+        double z = 0;
+        double w;
+        double x;
+        double y;
+
+        // Store roots isolated by balanc and compute matrix norm
+
+        double norm = h.foldMap(Functions.PLUS, Functions.ABS, 0.0);
+
+        // Outer loop over eigenvalue index
+
+        int iter = 0;
+        while (n >= low) {
+            // Look for single small sub-diagonal element
+            int l = n;
+
+            while (l > low) {
+                s = Math.abs(h.getX(l - 1, l - 1)) + Math.abs(h.getX(l, l));
+
+                if (s == 0.0)
+                    s = norm;
+
+                if (Math.abs(h.getX(l, l - 1)) < eps * s)
+                    break;
+
+                l--;
+            }
+
+            // Check for convergence
+
+            if (l == n) {
+                // One root found
+                h.setX(n, n, h.getX(n, n) + exshift);
+                d.setX(n, h.getX(n, n));
+                e.setX(n, 0.0);
+                n--;
+                iter = 0;
+            }
+            else if (l == n - 1) {
+                // Two roots found
+                w = h.getX(n, n - 1) * h.getX(n - 1, n);
+                p = (h.getX(n - 1, n - 1) - h.getX(n, n)) / 2.0;
+                q = p * p + w;
+                z = Math.sqrt(Math.abs(q));
+                h.setX(n, n, h.getX(n, n) + exshift);
+                h.setX(n - 1, n - 1, h.getX(n - 1, n - 1) + exshift);
+                x = h.getX(n, n);
+
+                // Real pair
+                if (q >= 0) {
+                    if (p >= 0)
+                        z = p + z;
+                    else
+                        z = p - z;
+
+                    d.setX(n - 1, x + z);
+                    d.setX(n, d.getX(n - 1));
+
+                    if (z != 0.0)
+                        d.setX(n, x - w / z);
+
+                    e.setX(n - 1, 0.0);
+                    e.setX(n, 0.0);
+                    x = h.getX(n, n - 1);
+                    s = Math.abs(x) + Math.abs(z);
+                    p = x / s;
+                    q = z / s;
+                    r = Math.sqrt(p * p + q * q);
+                    p /= r;
+                    q /= r;
+
+                    // Row modification
+
+                    for (int j = n - 1; j < nn; j++) {
+                        z = h.getX(n - 1, j);
+                        h.setX(n - 1, j, q * z + p * h.getX(n, j));
+                        h.setX(n, j, q * h.getX(n, j) - p * z);
+                    }
+
+                    // Column modification
+
+                    for (int i = 0; i <= n; i++) {
+                        z = h.getX(i, n - 1);
+                        h.setX(i, n - 1, q * z + p * h.getX(i, n));
+                        h.setX(i, n, q * h.getX(i, n) - p * z);
+                    }
+
+                    // Accumulate transformations
+
+                    for (int i = low; i <= high; i++) {
+                        z = v.getX(i, n - 1);
+                        v.setX(i, n - 1, q * z + p * v.getX(i, n));
+                        v.setX(i, n, q * v.getX(i, n) - p * z);
+                    }
+
+                    // Complex pair
+
+                }
+                else {
+                    d.setX(n - 1, x + p);
+                    d.setX(n, x + p);
+                    e.setX(n - 1, z);
+                    e.setX(n, -z);
+                }
+
+                n -= 2;
+                iter = 0;
+
+                // No convergence yet
+
+            }
+            else {
+                // Form shift
+                x = h.getX(n, n);
+                y = 0.0;
+                w = 0.0;
+
+                if (l < n) {
+                    y = h.getX(n - 1, n - 1);
+                    w = h.getX(n, n - 1) * h.getX(n - 1, n);
+                }
+
+                // Wilkinson's original ad hoc shift
+
+                if (iter == 10) {
+                    exshift += x;
+
+                    for (int i = low; i <= n; i++)
+                        h.setX(i, i, x);
+
+                    s = Math.abs(h.getX(n, n - 1)) + Math.abs(h.getX(n - 1, n - 2));
+                    x = y = 0.75 * s;
+                    w = -0.4375 * s * s;
+                }
+
+                // MATLAB's new ad hoc shift
+
+                if (iter == 30) {
+                    s = (y - x) / 2.0;
+                    s = s * s + w;
+
+                    if (s > 0) {
+                        s = Math.sqrt(s);
+
+                        if (y < x)
+                            s = -s;
+
+                        s = x - w / ((y - x) / 2.0 + s);
+
+                        for (int i = low; i <= n; i++)
+                            h.setX(i, i, h.getX(i, i) - s);
+
+                        exshift += s;
+                        x = y = w = 0.964;
+                    }
+                }
+
+                iter++;   // (Could check iteration count here.)
+
+                // Look for two consecutive small sub-diagonal elements
+
+                int m = n - 2;
+
+                while (m >= l) {
+                    z = h.getX(m, m);
+                    r = x - z;
+                    s = y - z;
+                    p = (r * s - w) / h.getX(m + 1, m) + h.getX(m, m + 1);
+                    q = h.getX(m + 1, m + 1) - z - r - s;
+                    r = h.getX(m + 2, m + 1);
+                    s = Math.abs(p) + Math.abs(q) + Math.abs(r);
+                    p /= s;
+                    q /= s;
+                    r /= s;
+
+                    if (m == l)
+                        break;
+
+                    double hmag = Math.abs(h.getX(m - 1, m - 1)) + Math.abs(h.getX(m + 1, m + 1));
+                    double threshold = eps * Math.abs(p) * (Math.abs(z) + hmag);
+
+                    if (Math.abs(h.getX(m, m - 1)) * (Math.abs(q) + Math.abs(r)) < threshold)
+                        break;
+
+                    m--;
+                }
+
+                for (int i = m + 2; i <= n; i++) {
+                    h.setX(i, i - 2, 0.0);
+
+                    if (i > m + 2)
+                        h.setX(i, i - 3, 0.0);
+                }
+
+                // Double QR step involving rows l:n and columns m:n
+
+                for (int k = m; k <= n - 1; k++) {
+                    boolean notlast = k != n - 1;
+
+                    if (k != m) {
+                        p = h.getX(k, k - 1);
+                        q = h.getX(k + 1, k - 1);
+                        r = notlast ? h.getX(k + 2, k - 1) : 0.0;
+                        x = Math.abs(p) + Math.abs(q) + Math.abs(r);
+                        if (x != 0.0) {
+                            p /= x;
+                            q /= x;
+                            r /= x;
+                        }
+                    }
+
+                    if (x == 0.0)
+                        break;
+
+                    s = Math.sqrt(p * p + q * q + r * r);
+
+                    if (p < 0)
+                        s = -s;
+
+                    if (s != 0) {
+                        if (k != m)
+                            h.setX(k, k - 1, -s * x);
+                        else if (l != m)
+                            h.setX(k, k - 1, -h.getX(k, k - 1));
+
+                        p += s;
+                        x = p / s;
+                        y = q / s;
+                        z = r / s;
+                        q /= p;
+                        r /= p;
+
+                        // Row modification
+
+                        for (int j = k; j < nn; j++) {
+                            p = h.getX(k, j) + q * h.getX(k + 1, j);
+
+                            if (notlast) {
+                                p += r * h.getX(k + 2, j);
+                                h.setX(k + 2, j, h.getX(k + 2, j) - p * z);
+                            }
+
+                            h.setX(k, j, h.getX(k, j) - p * x);
+                            h.setX(k + 1, j, h.getX(k + 1, j) - p * y);
+                        }
+
+                        // Column modification
+
+                        for (int i = 0; i <= Math.min(n, k + 3); i++) {
+                            p = x * h.getX(i, k) + y * h.getX(i, k + 1);
+
+                            if (notlast) {
+                                p += z * h.getX(i, k + 2);
+                                h.setX(i, k + 2, h.getX(i, k + 2) - p * r);
+                            }
+
+                            h.setX(i, k, h.getX(i, k) - p);
+                            h.setX(i, k + 1, h.getX(i, k + 1) - p * q);
+                        }
+
+                        // Accumulate transformations
+
+                        for (int i = low; i <= high; i++) {
+                            p = x * v.getX(i, k) + y * v.getX(i, k + 1);
+
+                            if (notlast) {
+                                p += z * v.getX(i, k + 2);
+                                v.setX(i, k + 2, v.getX(i, k + 2) - p * r);
+                            }
+
+                            v.setX(i, k, v.getX(i, k) - p);
+                            v.setX(i, k + 1, v.getX(i, k + 1) - p * q);
+                        }
+                    }  // (s != 0)
+                }  // k loop
+            }  // check convergence
+        }  // while (n >= low)
+
+        // Back substitute to find vectors of upper triangular form
+
+        if (norm == 0.0)
+            return;
+
+        for (n = nn - 1; n >= 0; n--) {
+            p = d.getX(n);
+            q = e.getX(n);
+
+            // Real vector
+
+            double t;
+
+            if (q == 0) {
+                int l = n;
+                h.setX(n, n, 1.0);
+
+                for (int i = n - 1; i >= 0; i--) {
+                    w = h.getX(i, i) - p;
+                    r = 0.0;
+
+                    for (int j = l; j <= n; j++)
+                        r += h.getX(i, j) * h.getX(j, n);
+
+                    if (e.getX(i) < 0.0) {
+                        z = w;
+                        s = r;
+                    }
+                    else {
+                        l = i;
+
+                        if (e.getX(i) == 0.0) {
+                            if (w == 0.0)
+                                h.setX(i, n, -r / (eps * norm));
+                            else
+                                h.setX(i, n, -r / w);
+
+                            // Solve real equations
+
+                        }
+                        else {
+                            x = h.getX(i, i + 1);
+                            y = h.getX(i + 1, i);
+                            q = (d.getX(i) - p) * (d.getX(i) - p) + e.getX(i) * e.getX(i);
+                            t = (x * s - z * r) / q;
+                            h.setX(i, n, t);
+
+                            if (Math.abs(x) > Math.abs(z))
+                                h.setX(i + 1, n, (-r - w * t) / x);
+                            else
+                                h.setX(i + 1, n, (-s - y * t) / z);
+                        }
+
+                        // Overflow control
+
+                        t = Math.abs(h.getX(i, n));
+
+                        if (eps * t * t > 1) {
+                            for (int j = i; j <= n; j++)
+                                h.setX(j, n, h.getX(j, n) / t);
+                        }
+                    }
+                }
+
+                // Complex vector
+
+            }
+            else if (q < 0) {
+                int l = n - 1;
+
+                // Last vector component imaginary so matrix is triangular
+
+                if (Math.abs(h.getX(n, n - 1)) > Math.abs(h.getX(n - 1, n))) {
+                    h.setX(n - 1, n - 1, q / h.getX(n, n - 1));
+                    h.setX(n - 1, n, -(h.getX(n, n) - p) / h.getX(n, n - 1));
+                }
+                else {
+                    cdiv(0.0, -h.getX(n - 1, n), h.getX(n - 1, n - 1) - p, q);
+                    h.setX(n - 1, n - 1, cdivr);
+                    h.setX(n - 1, n, cdivi);
+                }
+
+                h.setX(n, n - 1, 0.0);
+                h.setX(n, n, 1.0);
+
+                for (int i = n - 2; i >= 0; i--) {
+                    double ra = 0.0;
+                    double sa = 0.0;
+
+                    for (int j = l; j <= n; j++) {
+                        ra += h.getX(i, j) * h.getX(j, n - 1);
+                        sa += h.getX(i, j) * h.getX(j, n);
+                    }
+
+                    w = h.getX(i, i) - p;
+
+                    if (e.getX(i) < 0.0) {
+                        z = w;
+                        r = ra;
+                        s = sa;
+                    }
+                    else {
+                        l = i;
+
+                        if (e.getX(i) == 0) {
+                            cdiv(-ra, -sa, w, q);
+                            h.setX(i, n - 1, cdivr);
+                            h.setX(i, n, cdivi);
+                        }
+                        else {
+
+                            // Solve complex equations
+
+                            x = h.getX(i, i + 1);
+                            y = h.getX(i + 1, i);
+
+                            double vr = (d.getX(i) - p) * (d.getX(i) - p) + e.getX(i) * e.getX(i) - q * q;
+                            double vi = (d.getX(i) - p) * 2.0 * q;
+
+                            if (vr == 0.0 && vi == 0.0) {
+                                double hmag = Math.abs(x) + Math.abs(y);
+                                vr = eps * norm * (Math.abs(w) + Math.abs(q) + hmag + Math.abs(z));
+                            }
+
+                            cdiv(x * r - z * ra + q * sa, x * s - z * sa - q * ra, vr, vi);
+
+                            h.setX(i, n - 1, cdivr);
+                            h.setX(i, n, cdivi);
+
+                            if (Math.abs(x) > (Math.abs(z) + Math.abs(q))) {
+                                h.setX(i + 1, n - 1, (-ra - w * h.getX(i, n - 1) + q * h.getX(i, n)) / x);
+                                h.setX(i + 1, n, (-sa - w * h.getX(i, n) - q * h.getX(i, n - 1)) / x);
+                            }
+                            else {
+                                cdiv(-r - y * h.getX(i, n - 1), -s - y * h.getX(i, n), z, q);
+
+                                h.setX(i + 1, n - 1, cdivr);
+                                h.setX(i + 1, n, cdivi);
+                            }
+                        }
+
+                        // Overflow control
+
+                        t = Math.max(Math.abs(h.getX(i, n - 1)), Math.abs(h.getX(i, n)));
+
+                        if (eps * t * t > 1)
+                            for (int j = i; j <= n; j++) {
+                                h.setX(j, n - 1, h.getX(j, n - 1) / t);
+                                h.setX(j, n, h.getX(j, n) / t);
+                            }
+                    }
+                }
+            }
+        }
+
+        // Vectors of isolated roots
+
+        for (int i = 0; i < nn; i++)
+            if (i < low || i > high) {
+                for (int j = i; j < nn; j++)
+                    v.setX(i, j, h.getX(i, j));
+            }
+
+        // Back transformation to get eigen vectors of original matrix
+
+        for (int j = nn - 1; j >= low; j--)
+            for (int i = low; i <= high; i++) {
+                z = 0.0;
+
+                for (int k = low; k <= Math.min(j, high); k++)
+                    z += v.getX(i, k) * h.getX(k, j);
+
+                v.setX(i, j, z);
+            }
+    }
+
+    /** */
+    private static boolean isSymmetric(Matrix matrix) {
+        int cols = matrix.columnSize();
+        int rows = matrix.rowSize();
+
+        if (cols != rows)
+            return false;
+
+        for (int i = 0; i < cols; i++)
+            for (int j = 0; j < rows; j++) {
+                if (matrix.getX(i, j) != matrix.get(j, i))
+                    return false;
+            }
+
+        return true;
+    }
+
+    /** Complex scalar division - real part. */
+    private double cdivr;
+    /** Complex scalar division - imaginary part. */
+    private double cdivi;
+
+    /** */
+    private void cdiv(double xr, double xi, double yr, double yi) {
+        double r;
+        double d;
+
+        if (Math.abs(yr) > Math.abs(yi)) {
+            r = yi / yr;
+            d = yr + r * yi;
+            cdivr = (xr + r * xi) / d;
+            cdivi = (xi - r * xr) / d;
+        }
+        else {
+            r = yr / yi;
+            d = yi + r * yr;
+            cdivr = (r * xr + xi) / d;
+            cdivi = (r * xi - xr) / d;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
new file mode 100644
index 0000000..b1efc09
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
@@ -0,0 +1,366 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.decompositions;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.CardinalityException;
+import org.apache.ignite.ml.math.exceptions.SingularMatrixException;
+
+/**
+ * Calculates the LU-decomposition of a square matrix.
+ *
+ * This class inspired by class from Apache Common Math with similar name.
+ *
+ * @see <a href="http://mathworld.wolfram.com/LUDecomposition.html">MathWorld</a>
+ * @see <a href="http://en.wikipedia.org/wiki/LU_decomposition">Wikipedia</a>
+ */
+public class LUDecomposition extends DecompositionSupport {
+    /** Default bound to determine effective singularity in LU decomposition. */
+    private static final double DEFAULT_TOO_SMALL = 1e-11;
+
+    /** Pivot permutation associated with LU decomposition. */
+    private final Vector pivot;
+    /** Parity of the permutation associated with the LU decomposition. */
+    private boolean even;
+    /** Singularity indicator. */
+    private boolean singular;
+    /** Cached value of L. */
+    private Matrix cachedL;
+    /** Cached value of U. */
+    private Matrix cachedU;
+    /** Cached value of P. */
+    private Matrix cachedP;
+    /** Original matrix. */
+    private Matrix matrix;
+    /** Entries of LU decomposition. */
+    private Matrix lu;
+
+    /**
+     * Calculates the LU-decomposition of the given matrix.
+     * This constructor uses 1e-11 as default value for the singularity
+     * threshold.
+     *
+     * @param matrix Matrix to decompose.
+     * @throws CardinalityException if matrix is not square.
+     */
+    public LUDecomposition(Matrix matrix) {
+        this(matrix, DEFAULT_TOO_SMALL);
+    }
+
+    /**
+     * Calculates the LUP-decomposition of the given matrix.
+     *
+     * @param matrix Matrix to decompose.
+     * @param singularityThreshold threshold (based on partial row norm).
+     * @throws CardinalityException if matrix is not square.
+     */
+    public LUDecomposition(Matrix matrix, double singularityThreshold) {
+        assert matrix != null;
+
+        int rows = matrix.rowSize();
+        int cols = matrix.columnSize();
+
+        if (rows != cols)
+            throw new CardinalityException(rows, cols);
+
+        this.matrix = matrix;
+
+        lu = copy(matrix);
+
+        pivot = likeVector(matrix);
+
+        for (int i = 0; i < pivot.size(); i++)
+            pivot.setX(i, i);
+
+        even = true;
+        singular = false;
+
+        cachedL = null;
+        cachedU = null;
+        cachedP = null;
+
+        for (int col = 0; col < cols; col++) {
+
+            //upper
+            for (int row = 0; row < col; row++) {
+                Vector luRow = lu.viewRow(row);
+                double sum = luRow.get(col);
+
+                for (int i = 0; i < row; i++)
+                    sum -= luRow.getX(i) * lu.getX(i, col);
+
+                luRow.setX(col, sum);
+            }
+
+            // permutation row
+            int max = col;
+
+            double largest = Double.NEGATIVE_INFINITY;
+
+            // lower
+            for (int row = col; row < rows; row++) {
+                Vector luRow = lu.viewRow(row);
+                double sum = luRow.getX(col);
+
+                for (int i = 0; i < col; i++)
+                    sum -= luRow.getX(i) * lu.getX(i, col);
+
+                luRow.setX(col, sum);
+
+                if (Math.abs(sum) > largest) {
+                    largest = Math.abs(sum);
+                    max = row;
+                }
+            }
+
+            // Singularity check
+            if (Math.abs(lu.getX(max, col)) < singularityThreshold) {
+                singular = true;
+                return;
+            }
+
+            // Pivot if necessary
+            if (max != col) {
+                double tmp;
+                Vector luMax = lu.viewRow(max);
+                Vector luCol = lu.viewRow(col);
+
+                for (int i = 0; i < cols; i++) {
+                    tmp = luMax.getX(i);
+                    luMax.setX(i, luCol.getX(i));
+                    luCol.setX(i, tmp);
+                }
+
+                int temp = (int)pivot.getX(max);
+                pivot.setX(max, pivot.getX(col));
+                pivot.setX(col, temp);
+
+                even = !even;
+            }
+
+            // Divide the lower elements by the "winning" diagonal elt.
+            final double luDiag = lu.getX(col, col);
+
+            for (int row = col + 1; row < cols; row++) {
+                double val = lu.getX(row, col) / luDiag;
+                lu.setX(row, col, val);
+            }
+        }
+    }
+
+    /**
+     * Destroys decomposition components and other internal components of decomposition.
+     */
+    @Override public void destroy() {
+        if (cachedL != null)
+            cachedL.destroy();
+        if (cachedU != null)
+            cachedU.destroy();
+        if (cachedP != null)
+            cachedP.destroy();
+        lu.destroy();
+    }
+
+    /**
+     * Returns the matrix L of the decomposition.
+     * <p>L is a lower-triangular matrix</p>
+     *
+     * @return the L matrix (or null if decomposed matrix is singular).
+     */
+    public Matrix getL() {
+        if ((cachedL == null) && !singular) {
+            final int m = pivot.size();
+
+            cachedL = like(matrix);
+            cachedL.assign(0.0);
+
+            for (int i = 0; i < m; ++i) {
+                for (int j = 0; j < i; ++j)
+                    cachedL.setX(i, j, lu.getX(i, j));
+
+                cachedL.setX(i, i, 1.0);
+            }
+        }
+
+        return cachedL;
+    }
+
+    /**
+     * Returns the matrix U of the decomposition.
+     * <p>U is an upper-triangular matrix</p>
+     *
+     * @return the U matrix (or null if decomposed matrix is singular).
+     */
+    public Matrix getU() {
+        if ((cachedU == null) && !singular) {
+            final int m = pivot.size();
+
+            cachedU = like(matrix);
+            cachedU.assign(0.0);
+
+            for (int i = 0; i < m; ++i)
+                for (int j = i; j < m; ++j)
+                    cachedU.setX(i, j, lu.getX(i, j));
+        }
+
+        return cachedU;
+    }
+
+    /**
+     * Returns the P rows permutation matrix.
+     * <p>P is a sparse matrix with exactly one element set to 1.0 in
+     * each row and each column, all other elements being set to 0.0.</p>
+     * <p>The positions of the 1 elements are given by the {@link #getPivot()
+     * pivot permutation vector}.</p>
+     *
+     * @return the P rows permutation matrix (or null if decomposed matrix is singular).
+     * @see #getPivot()
+     */
+    public Matrix getP() {
+        if ((cachedP == null) && !singular) {
+            final int m = pivot.size();
+
+            cachedP = like(matrix);
+            cachedP.assign(0.0);
+
+            for (int i = 0; i < m; ++i)
+                cachedP.setX(i, (int)pivot.get(i), 1.0);
+        }
+
+        return cachedP;
+    }
+
+    /**
+     * Returns the pivot permutation vector.
+     *
+     * @return the pivot permutation vector.
+     * @see #getP()
+     */
+    public Vector getPivot() {
+        return pivot.copy();
+    }
+
+    /**
+     * Return the determinant of the matrix.
+     *
+     * @return determinant of the matrix.
+     */
+    public double determinant() {
+        if (singular)
+            return 0;
+
+        final int m = pivot.size();
+        double determinant = even ? 1 : -1;
+
+        for (int i = 0; i < m; i++)
+            determinant *= lu.getX(i, i);
+
+        return determinant;
+    }
+
+    /** */
+    public Vector solve(Vector b) {
+        final int m = pivot.size();
+
+        if (b.size() != m)
+            throw new CardinalityException(b.size(), m);
+
+        if (singular)
+            throw new SingularMatrixException();
+
+        final double[] bp = new double[m];
+
+        // Apply permutations to b
+        for (int row = 0; row < m; row++)
+            bp[row] = b.get((int)pivot.get(row));
+
+        // Solve LY = b
+        for (int col = 0; col < m; col++) {
+            final double bpCol = bp[col];
+
+            for (int i = col + 1; i < m; i++)
+                bp[i] -= bpCol * lu.get(i, col);
+        }
+
+        // Solve UX = Y
+        for (int col = m - 1; col >= 0; col--) {
+            bp[col] /= lu.get(col, col);
+            final double bpCol = bp[col];
+
+            for (int i = 0; i < col; i++)
+                bp[i] -= bpCol * lu.get(i, col);
+        }
+
+        return b.like(m).assign(bp);
+    }
+
+    /** */
+    public Matrix solve(Matrix b) {
+        final int m = pivot.size();
+
+        if (b.rowSize() != m)
+            throw new CardinalityException(b.rowSize(), m);
+
+        if (singular)
+            throw new SingularMatrixException();
+
+        final int nColB = b.columnSize();
+
+        // Apply permutations to b
+        final double[][] bp = new double[m][nColB];
+        for (int row = 0; row < m; row++) {
+            final double[] bpRow = bp[row];
+            final int pRow = (int)pivot.get(row);
+
+            for (int col = 0; col < nColB; col++)
+                bpRow[col] = b.get(pRow, col);
+        }
+
+        // Solve LY = b
+        for (int col = 0; col < m; col++) {
+            final double[] bpCol = bp[col];
+            for (int i = col + 1; i < m; i++) {
+                final double[] bpI = bp[i];
+                final double luICol = lu.get(i, col);
+
+                for (int j = 0; j < nColB; j++)
+                    bpI[j] -= bpCol[j] * luICol;
+            }
+        }
+
+        // Solve UX = Y
+        for (int col = m - 1; col >= 0; col--) {
+            final double[] bpCol = bp[col];
+            final double luDiag = lu.getX(col, col);
+
+            for (int j = 0; j < nColB; j++)
+                bpCol[j] /= luDiag;
+
+            for (int i = 0; i < col; i++) {
+                final double[] bpI = bp[i];
+                final double luICol = lu.get(i, col);
+
+                for (int j = 0; j < nColB; j++)
+                    bpI[j] -= bpCol[j] * luICol;
+            }
+        }
+
+        return b.like(b.rowSize(), b.columnSize()).assign(bp);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/QRDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/QRDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/QRDecomposition.java
new file mode 100644
index 0000000..39215e8
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/QRDecomposition.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.decompositions;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.functions.Functions;
+
+/**
+ * For an {@code m x n} matrix {@code A} with {@code m >= n}, the QR decomposition
+ * is an {@code m x n} orthogonal matrix {@code Q} and an {@code n x n} upper
+ * triangular matrix {@code R} so that {@code A = Q*R}.
+ */
+public class QRDecomposition extends DecompositionSupport {
+    /** */
+    private final Matrix q;
+    /** */
+    private final Matrix r;
+
+    /** */
+    private final Matrix mType;
+    /** */
+    private final boolean fullRank;
+
+    /** */
+    private final int rows;
+    /** */
+    private final int cols;
+
+    /**
+     * @param v Value to be checked for being an ordinary double.
+     */
+    private void checkDouble(double v) {
+        if (Double.isInfinite(v) || Double.isNaN(v))
+            throw new ArithmeticException("Invalid intermediate result");
+    }
+
+    /**
+     * Constructs a new QR decomposition object computed by Householder reflections.
+     *
+     * @param mtx A rectangular matrix.
+     */
+    public QRDecomposition(Matrix mtx) {
+        assert mtx != null;
+
+        rows = mtx.rowSize();
+
+        int min = Math.min(mtx.rowSize(), mtx.columnSize());
+
+        cols = mtx.columnSize();
+
+        mType = like(mtx, 1, 1);
+
+        Matrix qTmp = copy(mtx);
+
+        boolean fullRank = true;
+
+        r = like(mtx, min, cols);
+
+        for (int i = 0; i < min; i++) {
+            Vector qi = qTmp.viewColumn(i);
+
+            double alpha = qi.kNorm(2);
+
+            if (Math.abs(alpha) > Double.MIN_VALUE)
+                qi.map(Functions.div(alpha));
+            else {
+                checkDouble(alpha);
+
+                fullRank = false;
+            }
+
+            r.set(i, i, alpha);
+
+            for (int j = i + 1; j < cols; j++) {
+                Vector qj = qTmp.viewColumn(j);
+
+                double norm = qj.kNorm(2);
+
+                if (Math.abs(norm) > Double.MIN_VALUE) {
+                    double beta = qi.dot(qj);
+
+                    r.set(i, j, beta);
+
+                    if (j < min)
+                        qj.map(qi, Functions.plusMult(-beta));
+                }
+                else
+                    checkDouble(norm);
+            }
+        }
+
+        if (cols > min)
+            q = qTmp.viewPart(0, rows, 0, min).copy();
+        else
+            q = qTmp;
+
+        this.fullRank = fullRank;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void destroy() {
+        q.destroy();
+        r.destroy();
+        mType.destroy();
+    }
+
+    /**
+     * Gets orthogonal factor {@code Q}.
+     */
+    public Matrix getQ() {
+        return q;
+    }
+
+    /**
+     * Gets triangular factor {@code R}.
+     */
+    public Matrix getR() {
+        return r;
+    }
+
+    /**
+     * Returns whether the matrix {@code A} has full rank.
+     *
+     * @return true if {@code R}, and hence {@code A} , has full rank.
+     */
+    public boolean hasFullRank() {
+        return fullRank;
+    }
+
+    /**
+     * Least squares solution of {@code A*X = B}; {@code returns X}.
+     *
+     * @param mtx A matrix with as many rows as {@code A} and any number of cols.
+     * @return {@code X<} that minimizes the two norm of {@code Q*R*X - B}.
+     * @throws IllegalArgumentException if {@code B.rows() != A.rows()}.
+     */
+    public Matrix solve(Matrix mtx) {
+        if (mtx.rowSize() != rows)
+            throw new IllegalArgumentException("Matrix row dimensions must agree.");
+
+        int cols = mtx.columnSize();
+
+        Matrix x = like(mType, this.cols, cols);
+
+        Matrix qt = getQ().transpose();
+        Matrix y = qt.times(mtx);
+
+        Matrix r = getR();
+
+        for (int k = Math.min(this.cols, rows) - 1; k > 0; k--) {
+            // X[k,] = Y[k,] / R[k,k], note that X[k,] starts with 0 so += is same as =
+            x.viewRow(k).map(y.viewRow(k), Functions.plusMult(1 / r.get(k, k)));
+
+            // Y[0:(k-1),] -= R[0:(k-1),k] * X[k,]
+            Vector rCol = r.viewColumn(k).viewPart(0, k);
+
+            for (int c = 0; c < cols; c++)
+                y.viewColumn(c).viewPart(0, k).map(rCol, Functions.plusMult(-x.get(k, c)));
+        }
+
+        return x;
+    }
+
+    /**
+     * Returns a rough string rendition of a QR.
+     */
+    @Override public String toString() {
+        return String.format("QR(%d x %d, fullRank=%s)", rows, cols, hasFullRank());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/SingularValueDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/SingularValueDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/SingularValueDecomposition.java
new file mode 100644
index 0000000..1b04e4f
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/SingularValueDecomposition.java
@@ -0,0 +1,620 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.decompositions;
+
+import org.apache.ignite.ml.math.Algebra;
+import org.apache.ignite.ml.math.Matrix;
+
+/**
+ * Compute a singular value decomposition (SVD) of {@code (l x k)} matrix {@code m}.
+ * <p>This decomposition can be thought
+ * as an extension of {@link EigenDecomposition} to rectangular matrices. The factorization we get is following:</p>
+ * <p>{@code m = u * s * v^{*}}, where</p>
+ * <ul><li>{@code u} is a real or complex unitary matrix.</li>
+ * <li>{@code s} is a rectangular diagonal matrix with non-negative real numbers on diagonal
+ * (these numbers are singular values of {@code m}).</li>
+ * <li>{@code v} is a real or complex unitary matrix.</li></ul>
+ * <p>If {@code m} is real then {@code u} and {@code v} are also real.</p>
+ * <p>See also: <a href="https://en.wikipedia.org/wiki/Singular_value_decomposition">Wikipedia article on SVD</a>.</p>
+ * <p>Note: complex case is currently not supported.</p>
+ */
+public class SingularValueDecomposition extends DecompositionSupport {
+    // U and V.
+    /** */
+    private final double[][] u;
+    /** */
+    private final double[][] v;
+
+    /** Singular values. */
+    private final double[] s;
+
+    /** Row dimension. */
+    private final int m;
+    /** Column dimension. */
+    private final int n;
+
+    /** */
+    private Matrix arg;
+
+    /** */
+    private boolean transpositionNeeded;
+
+    /**
+     * Singular value decomposition object.
+     *
+     * @param arg A rectangular matrix.
+     */
+    public SingularValueDecomposition(Matrix arg) {
+        assert arg != null;
+
+        this.arg = arg;
+
+        if (arg.rowSize() < arg.columnSize())
+            transpositionNeeded = true;
+
+        double[][] a;
+
+        if (transpositionNeeded) {
+            // Use the transpose matrix.
+            m = arg.columnSize();
+            n = arg.rowSize();
+
+            a = new double[m][n];
+
+            for (int i = 0; i < m; i++)
+                for (int j = 0; j < n; j++)
+                    a[i][j] = arg.get(j, i);
+        }
+        else {
+            m = arg.rowSize();
+            n = arg.columnSize();
+
+            a = new double[m][n];
+
+            for (int i = 0; i < m; i++)
+                for (int j = 0; j < n; j++)
+                    a[i][j] = arg.get(i, j);
+        }
+
+        int nu = Math.min(m, n);
+
+        s = new double[Math.min(m + 1, n)];
+        u = new double[m][nu];
+        v = new double[n][n];
+
+        double[] e = new double[n];
+        double[] work = new double[m];
+
+        int nct = Math.min(m - 1, n);
+        int nrt = Math.max(0, Math.min(n - 2, m));
+
+        for (int k = 0; k < Math.max(nct, nrt); k++) {
+            if (k < nct) {
+                // Compute the transformation for the k-th column and
+                // place the k-th diagonal in s[k]. Compute 2-norm of k-th
+                // column without under/overflow.
+                s[k] = 0;
+
+                for (int i = k; i < m; i++)
+                    s[k] = Algebra.hypot(s[k], a[i][k]);
+
+                if (s[k] != 0.0) {
+                    if (a[k][k] < 0.0)
+                        s[k] = -s[k];
+
+                    for (int i = k; i < m; i++)
+                        a[i][k] /= s[k];
+
+                    a[k][k] += 1.0;
+                }
+
+                s[k] = -s[k];
+            }
+
+            for (int j = k + 1; j < n; j++) {
+                if (k < nct && s[k] != 0.0) {
+                    // Apply the transformation.
+                    double t = 0;
+
+                    for (int i = k; i < m; i++)
+                        t += a[i][k] * a[i][j];
+
+                    t = -t / a[k][k];
+
+                    for (int i = k; i < m; i++)
+                        a[i][j] += t * a[i][k];
+                }
+
+                // Place the k-th row of A into e for the
+                // subsequent calculation of the row transformation.
+                e[j] = a[k][j];
+            }
+
+            if (k < nct)
+                // Place the transformation in U for subsequent back
+                // multiplication.
+                for (int i = k; i < m; i++)
+                    u[i][k] = a[i][k];
+
+            if (k < nrt) {
+                // Compute the k-th row transformation and place the
+                // k-th super-diagonal in e[k].
+                // Compute 2-norm without under/overflow.
+                e[k] = 0;
+
+                for (int i = k + 1; i < n; i++)
+                    e[k] = Algebra.hypot(e[k], e[i]);
+
+                if (e[k] != 0.0) {
+                    if (e[k + 1] < 0.0)
+                        e[k] = -e[k];
+
+                    for (int i = k + 1; i < n; i++)
+                        e[i] /= e[k];
+
+                    e[k + 1] += 1.0;
+                }
+
+                e[k] = -e[k];
+
+                if (k + 1 < m && e[k] != 0.0) {
+                    // Apply the transformation.
+                    for (int i = k + 1; i < m; i++)
+                        work[i] = 0.0;
+
+                    for (int j = k + 1; j < n; j++)
+                        for (int i = k + 1; i < m; i++)
+                            work[i] += e[j] * a[i][j];
+
+                    for (int j = k + 1; j < n; j++) {
+                        double t = -e[j] / e[k + 1];
+
+                        for (int i = k + 1; i < m; i++)
+                            a[i][j] += t * work[i];
+                    }
+                }
+
+                // Place the transformation in V for subsequent
+                // back multiplication.
+                for (int i = k + 1; i < n; i++)
+                    v[i][k] = e[i];
+            }
+        }
+
+        // Set up the final bi-diagonal matrix or order p.
+        int p = Math.min(n, m + 1);
+
+        if (nct < n)
+            s[nct] = a[nct][nct];
+
+        if (m < p)
+            s[p - 1] = 0.0;
+
+        if (nrt + 1 < p)
+            e[nrt] = a[nrt][p - 1];
+
+        e[p - 1] = 0.0;
+
+        // Generate U.
+        for (int j = nct; j < nu; j++) {
+            for (int i = 0; i < m; i++)
+                u[i][j] = 0.0;
+
+            u[j][j] = 1.0;
+        }
+
+        for (int k = nct - 1; k >= 0; k--) {
+            if (s[k] != 0.0) {
+                for (int j = k + 1; j < nu; j++) {
+                    double t = 0;
+
+                    for (int i = k; i < m; i++)
+                        t += u[i][k] * u[i][j];
+
+                    t = -t / u[k][k];
+
+                    for (int i = k; i < m; i++)
+                        u[i][j] += t * u[i][k];
+                }
+
+                for (int i = k; i < m; i++)
+                    u[i][k] = -u[i][k];
+
+                u[k][k] = 1.0 + u[k][k];
+
+                for (int i = 0; i < k - 1; i++)
+                    u[i][k] = 0.0;
+            }
+            else {
+                for (int i = 0; i < m; i++)
+                    u[i][k] = 0.0;
+
+                u[k][k] = 1.0;
+            }
+        }
+
+        // Generate V.
+        for (int k = n - 1; k >= 0; k--) {
+            if (k < nrt && e[k] != 0.0) {
+                for (int j = k + 1; j < nu; j++) {
+                    double t = 0;
+
+                    for (int i = k + 1; i < n; i++)
+                        t += v[i][k] * v[i][j];
+
+                    t = -t / v[k + 1][k];
+
+                    for (int i = k + 1; i < n; i++)
+                        v[i][j] += t * v[i][k];
+                }
+            }
+
+            for (int i = 0; i < n; i++)
+                v[i][k] = 0.0;
+
+            v[k][k] = 1.0;
+        }
+
+        // Main iteration loop for the singular values.
+        int pp = p - 1;
+        int iter = 0;
+
+        double eps = Math.pow(2.0, -52.0);
+        double tiny = Math.pow(2.0, -966.0);
+
+        while (p > 0) {
+            int k;
+
+            for (k = p - 2; k >= -1; k--) {
+                if (k == -1)
+                    break;
+
+                if (Math.abs(e[k]) <= tiny + eps * (Math.abs(s[k]) + Math.abs(s[k + 1]))) {
+                    e[k] = 0.0;
+
+                    break;
+                }
+            }
+
+            int kase;
+
+            if (k == p - 2)
+                kase = 4;
+            else {
+                int ks;
+
+                for (ks = p - 1; ks >= k; ks--) {
+                    if (ks == k)
+                        break;
+
+                    double t =
+                        (ks != p ? Math.abs(e[ks]) : 0.) +
+                            (ks != k + 1 ? Math.abs(e[ks - 1]) : 0.);
+
+                    if (Math.abs(s[ks]) <= tiny + eps * t) {
+                        s[ks] = 0.0;
+
+                        break;
+                    }
+                }
+
+                if (ks == k)
+                    kase = 3;
+                else if (ks == p - 1)
+                    kase = 1;
+                else {
+                    kase = 2;
+
+                    k = ks;
+                }
+            }
+
+            k++;
+
+            // Perform the task indicated by kase.
+            switch (kase) {
+                // Deflate negligible s(p).
+                case 1: {
+                    double f = e[p - 2];
+
+                    e[p - 2] = 0.0;
+
+                    for (int j = p - 2; j >= k; j--) {
+                        double t = Algebra.hypot(s[j], f);
+                        double cs = s[j] / t;
+                        double sn = f / t;
+
+                        s[j] = t;
+
+                        if (j != k) {
+                            f = -sn * e[j - 1];
+                            e[j - 1] = cs * e[j - 1];
+                        }
+
+                        for (int i = 0; i < n; i++) {
+                            t = cs * v[i][j] + sn * v[i][p - 1];
+
+                            v[i][p - 1] = -sn * v[i][j] + cs * v[i][p - 1];
+                            v[i][j] = t;
+                        }
+                    }
+                }
+
+                break;
+
+                // Split at negligible s(k).
+                case 2: {
+                    double f = e[k - 1];
+                    e[k - 1] = 0.0;
+
+                    for (int j = k; j < p; j++) {
+                        double t = Algebra.hypot(s[j], f);
+                        double cs = s[j] / t;
+                        double sn = f / t;
+
+                        s[j] = t;
+                        f = -sn * e[j];
+                        e[j] = cs * e[j];
+
+                        for (int i = 0; i < m; i++) {
+                            t = cs * u[i][j] + sn * u[i][k - 1];
+
+                            u[i][k - 1] = -sn * u[i][j] + cs * u[i][k - 1];
+                            u[i][j] = t;
+                        }
+                    }
+                }
+
+                break;
+
+                // Perform one qr step.
+                case 3: {
+                    // Calculate the shift.
+                    double scale = Math.max(Math.max(Math.max(Math.max(
+                        Math.abs(s[p - 1]), Math.abs(s[p - 2])), Math.abs(e[p - 2])),
+                        Math.abs(s[k])), Math.abs(e[k]));
+
+                    double sp = s[p - 1] / scale;
+                    double spm1 = s[p - 2] / scale;
+                    double epm1 = e[p - 2] / scale;
+                    double sk = s[k] / scale;
+                    double ek = e[k] / scale;
+                    double b = ((spm1 + sp) * (spm1 - sp) + epm1 * epm1) / 2.0;
+                    double c = sp * epm1 * sp * epm1;
+                    double shift = 0.0;
+
+                    if (b != 0.0 || c != 0.0) {
+                        shift = Math.sqrt(b * b + c);
+
+                        if (b < 0.0)
+                            shift = -shift;
+
+                        shift = c / (b + shift);
+                    }
+
+                    double f = (sk + sp) * (sk - sp) + shift;
+                    double g = sk * ek;
+
+                    // Chase zeros.
+                    for (int j = k; j < p - 1; j++) {
+                        double t = Algebra.hypot(f, g);
+                        double cs = f / t;
+                        double sn = g / t;
+
+                        if (j != k)
+                            e[j - 1] = t;
+
+                        f = cs * s[j] + sn * e[j];
+                        e[j] = cs * e[j] - sn * s[j];
+                        g = sn * s[j + 1];
+                        s[j + 1] = cs * s[j + 1];
+
+                        for (int i = 0; i < n; i++) {
+                            t = cs * v[i][j] + sn * v[i][j + 1];
+
+                            v[i][j + 1] = -sn * v[i][j] + cs * v[i][j + 1];
+                            v[i][j] = t;
+                        }
+
+                        t = Algebra.hypot(f, g);
+                        cs = f / t;
+                        sn = g / t;
+                        s[j] = t;
+                        f = cs * e[j] + sn * s[j + 1];
+                        s[j + 1] = -sn * e[j] + cs * s[j + 1];
+                        g = sn * e[j + 1];
+                        e[j + 1] = cs * e[j + 1];
+
+                        if (j < m - 1)
+                            for (int i = 0; i < m; i++) {
+                                t = cs * u[i][j] + sn * u[i][j + 1];
+
+                                u[i][j + 1] = -sn * u[i][j] + cs * u[i][j + 1];
+                                u[i][j] = t;
+                            }
+                    }
+
+                    e[p - 2] = f;
+                    iter = iter + 1;
+                }
+
+                break;
+
+                // Convergence.
+                case 4: {
+                    // Make the singular values positive.
+                    if (s[k] <= 0.0) {
+                        s[k] = s[k] < 0.0 ? -s[k] : 0.0;
+
+                        for (int i = 0; i <= pp; i++)
+                            v[i][k] = -v[i][k];
+                    }
+
+                    // Order the singular values.
+                    while (k < pp) {
+                        if (s[k] >= s[k + 1])
+                            break;
+
+                        double t = s[k];
+
+                        s[k] = s[k + 1];
+                        s[k + 1] = t;
+
+                        if (k < n - 1)
+                            for (int i = 0; i < n; i++) {
+                                t = v[i][k + 1];
+
+                                v[i][k + 1] = v[i][k];
+                                v[i][k] = t;
+                            }
+
+                        if (k < m - 1)
+                            for (int i = 0; i < m; i++) {
+                                t = u[i][k + 1];
+
+                                u[i][k + 1] = u[i][k];
+                                u[i][k] = t;
+                            }
+
+                        k++;
+                    }
+
+                    iter = 0;
+                    p--;
+                }
+
+                break;
+
+                default:
+                    throw new IllegalStateException();
+            }
+        }
+    }
+
+    /**
+     * Gets the two norm condition number, which is {@code max(S) / min(S)} .
+     */
+    public double cond() {
+        return s[0] / s[Math.min(m, n) - 1];
+    }
+
+    /**
+     * @return the diagonal matrix of singular values.
+     */
+    public Matrix getS() {
+        double[][] s = new double[n][n];
+
+        for (int i = 0; i < n; i++) {
+            for (int j = 0; j < n; j++)
+                s[i][j] = 0.0;
+
+            s[i][i] = this.s[i];
+        }
+
+        return like(arg, n, n).assign(s);
+    }
+
+    /**
+     * Gets the diagonal of {@code S}, which is a one-dimensional array of
+     * singular values.
+     *
+     * @return diagonal of {@code S}.
+     */
+    public double[] getSingularValues() {
+        return s;
+    }
+
+    /**
+     * Gets the left singular vectors {@code U}.
+     *
+     * @return {@code U}
+     */
+    public Matrix getU() {
+        if (transpositionNeeded)
+            return like(arg, v.length, v.length).assign(v);
+        else {
+            int numCols = Math.min(m + 1, n);
+
+            Matrix r = like(arg, m, numCols);
+
+            for (int i = 0; i < m; i++)
+                for (int j = 0; j < numCols; j++)
+                    r.set(i, j, u[i][j]);
+
+            return r;
+        }
+    }
+
+    /**
+     * Gets the right singular vectors {@code V}.
+     *
+     * @return {@code V}
+     */
+    public Matrix getV() {
+        if (transpositionNeeded) {
+            int numCols = Math.min(m + 1, n);
+
+            Matrix r = like(arg, m, numCols);
+
+            for (int i = 0; i < m; i++)
+                for (int j = 0; j < numCols; j++)
+                    r.set(i, j, u[i][j]);
+
+            return r;
+        }
+        else
+            return like(arg, v.length, v.length).assign(v);
+    }
+
+    /**
+     * Gets the two norm, which is {@code max(S)}.
+     */
+    public double norm2() {
+        return s[0];
+    }
+
+    /**
+     * Gets effective numerical matrix rank.
+     */
+    public int rank() {
+        double eps = Math.pow(2.0, -52.0);
+        double tol = Math.max(m, n) * s[0] * eps;
+        int r = 0;
+
+        for (double value : s)
+            if (value > tol)
+                r++;
+
+        return r;
+    }
+
+    /**
+     * Gets [n � n] covariance matrix.
+     *
+     * @param minSingularVal Value below which singular values are ignored.
+     */
+    Matrix getCovariance(double minSingularVal) {
+        Matrix j = like(arg, s.length, s.length);
+        Matrix vMat = like(arg, v.length, v.length).assign(v);
+
+        for (int i = 0; i < s.length; i++)
+            j.set(i, i, s[i] >= minSingularVal ? 1 / (s[i] * s[i]) : 0.0);
+
+        return vMat.times(j).times(vMat.transpose());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/package-info.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/package-info.java
new file mode 100644
index 0000000..d317ccd
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Contains matrix decompositions for distributed code algebra.
+ */
+package org.apache.ignite.ml.math.decompositions;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/CardinalityException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/CardinalityException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/CardinalityException.java
new file mode 100644
index 0000000..f03e5d8
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/CardinalityException.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.exceptions;
+
+import org.apache.ignite.IgniteException;
+
+/**
+ * Indicates a cardinality mismatch in matrix or vector operations.
+ */
+public class CardinalityException extends IgniteException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /**
+     * Creates new cardinality violation exception.
+     *
+     * @param exp Expected cardinality.
+     * @param act Actual cardinality.
+     */
+    public CardinalityException(int exp, int act) {
+        super("Cardinality violation [expected=" + exp + ", actual=" + act + "]");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/ColumnIndexException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/ColumnIndexException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/ColumnIndexException.java
new file mode 100644
index 0000000..08a67b5
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/ColumnIndexException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.exceptions;
+
+import org.apache.ignite.IgniteException;
+
+/**
+ * This exception is used to indicate any error condition accessing matrix elements by invalid column index.
+ */
+public class ColumnIndexException extends IgniteException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /**
+     * @param idx Index value that caused this exception.
+     */
+    public ColumnIndexException(int idx) {
+        super("Invalid (out of bound) column index: " + idx);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/IndexException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/IndexException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/IndexException.java
new file mode 100644
index 0000000..93ca11e
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/IndexException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.exceptions;
+
+import org.apache.ignite.IgniteException;
+
+/**
+ * Indicates an invalid, i.e. out of bound, index on matrix or vector operations.
+ */
+public class IndexException extends IgniteException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /**
+     * @param idx Index value that caused this exception.
+     */
+    public IndexException(int idx) {
+        super("Invalid (out of bound) index: " + idx);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonPositiveDefiniteMatrixException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonPositiveDefiniteMatrixException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonPositiveDefiniteMatrixException.java
new file mode 100644
index 0000000..b0cf294
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonPositiveDefiniteMatrixException.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.exceptions;
+
+import org.apache.ignite.IgniteException;
+
+/**
+ * This exception is used to indicate error condition of matrix elements failing the positivity check.
+ */
+public class NonPositiveDefiniteMatrixException extends IgniteException {
+    /**
+     * Construct an exception.
+     *
+     * @param wrong Value that fails the positivity check.
+     * @param idx Row (and column) index.
+     * @param threshold Absolute positivity threshold.
+     */
+    public NonPositiveDefiniteMatrixException(double wrong, int idx, double threshold) {
+        super("Matrix must be positive, wrong element located on diagonal with index "
+            + idx + " and has value " + wrong + " with this threshold " + threshold);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonSymmetricMatrixException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonSymmetricMatrixException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonSymmetricMatrixException.java
new file mode 100644
index 0000000..7c563fe
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonSymmetricMatrixException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.exceptions;
+
+import org.apache.ignite.IgniteException;
+
+/**
+ * This exception is used to indicate error condition of matrix failing the symmetry check.
+ */
+public class NonSymmetricMatrixException extends IgniteException {
+    /**
+     * @param row Row.
+     * @param col Column.
+     * @param threshold Threshold.
+     */
+    public NonSymmetricMatrixException(int row, int col, double threshold) {
+        super("Symmetric matrix expected, the symmetry is broken on row "
+            + row + " and col " + col + " with this threshold " + threshold);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/RowIndexException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/RowIndexException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/RowIndexException.java
new file mode 100644
index 0000000..ebbbca3
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/RowIndexException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.exceptions;
+
+import org.apache.ignite.IgniteException;
+
+/**
+ * This exception is used to indicate any error condition accessing matrix elements by invalid row index.
+ */
+public class RowIndexException extends IgniteException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /**
+     * @param idx Index value that caused this exception.
+     */
+    public RowIndexException(int idx) {
+        super("Invalid (out of bound) row index: " + idx);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/SingularMatrixException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/SingularMatrixException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/SingularMatrixException.java
new file mode 100644
index 0000000..789b686
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/SingularMatrixException.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.exceptions;
+
+import org.apache.ignite.IgniteException;
+
+/**
+ * Exception to be thrown when a non-singular matrix is expected.
+ */
+public class SingularMatrixException extends IgniteException {
+    /** */
+    public SingularMatrixException() {
+        super("Regular (or non-singular) matrix expected.");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/UnknownProviderException.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/UnknownProviderException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/UnknownProviderException.java
new file mode 100644
index 0000000..940b9aa
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/UnknownProviderException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.exceptions;
+
+import org.apache.ignite.IgniteException;
+
+/**
+ * Indicates that no provider has been found for a given vector or matrix flavor.
+ */
+public class UnknownProviderException extends IgniteException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /**
+     * @param flv Flavor (a.k.a. operation performance hints) that has no registered provider for.
+     */
+    public UnknownProviderException(String flv) {
+        super("No provider has been found for the flavor: " + flv);
+    }
+}


[27/65] [abbrv] ignite git commit: 2.1.0-SNAPSHOT

Posted by ag...@apache.org.
2.1.0-SNAPSHOT


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

Branch: refs/heads/ignite-5024
Commit: 27fd74eeeef1ebd0cb89a99be69c5c74829307e3
Parents: 0da51d4
Author: Ignite Teamcity <ig...@apache.org>
Authored: Tue Apr 18 19:43:28 2017 +0300
Committer: Ignite Teamcity <ig...@apache.org>
Committed: Tue Apr 18 19:43:28 2017 +0300

----------------------------------------------------------------------
 examples/pom.xml                                |  5 +--
 modules/aop/pom.xml                             |  2 +-
 modules/apache-license-gen/pom.xml              |  2 +-
 modules/aws/pom.xml                             |  2 +-
 modules/benchmarks/pom.xml                      |  2 +-
 modules/camel/pom.xml                           |  2 +-
 modules/cassandra/pom.xml                       |  2 +-
 modules/cassandra/serializers/pom.xml           |  4 +-
 modules/cassandra/store/pom.xml                 |  4 +-
 modules/clients/pom.xml                         |  2 +-
 modules/cloud/pom.xml                           |  2 +-
 modules/codegen/pom.xml                         |  2 +-
 modules/core/pom.xml                            |  2 +-
 .../core/src/main/resources/ignite.properties   |  2 +-
 modules/extdata/p2p/pom.xml                     |  2 +-
 .../extdata/uri/modules/uri-dependency/pom.xml  |  2 +-
 modules/extdata/uri/pom.xml                     |  2 +-
 modules/flink/pom.xml                           |  2 +-
 modules/flume/pom.xml                           |  2 +-
 modules/gce/pom.xml                             |  2 +-
 modules/geospatial/pom.xml                      |  2 +-
 modules/hadoop/pom.xml                          |  2 +-
 modules/hibernate/pom.xml                       |  2 +-
 modules/hibernate5/pom.xml                      |  2 +-
 modules/indexing/pom.xml                        |  2 +-
 modules/jcl/pom.xml                             |  2 +-
 modules/jms11/pom.xml                           |  2 +-
 modules/jta/pom.xml                             |  2 +-
 modules/kafka/pom.xml                           |  2 +-
 modules/kubernetes/pom.xml                      |  2 +-
 modules/log4j/pom.xml                           |  2 +-
 modules/log4j2/pom.xml                          |  2 +-
 modules/mesos/pom.xml                           |  2 +-
 modules/ml/pom.xml                              |  6 +--
 modules/mqtt/pom.xml                            |  2 +-
 modules/osgi-karaf/pom.xml                      |  2 +-
 modules/osgi-paxlogging/pom.xml                 |  2 +-
 modules/osgi/pom.xml                            |  2 +-
 modules/platforms/cpp/common/configure.ac       |  2 +-
 modules/platforms/cpp/configure.ac              |  2 +-
 modules/platforms/cpp/configure.acrel           |  2 +-
 modules/platforms/cpp/core-test/configure.ac    |  2 +-
 modules/platforms/cpp/core/configure.ac         |  2 +-
 modules/platforms/cpp/examples/configure.ac     |  2 +-
 modules/platforms/cpp/ignite/configure.ac       |  2 +-
 .../cpp/odbc/install/ignite-odbc-amd64.wxs      |  2 +-
 .../cpp/odbc/install/ignite-odbc-x86.wxs        |  2 +-
 .../Properties/AssemblyInfo.cs                  |  6 +--
 .../Properties/AssemblyInfo.cs                  |  6 +--
 .../Properties/AssemblyInfo.cs                  |  6 +--
 .../Properties/AssemblyInfo.cs                  |  6 +--
 .../Properties/AssemblyInfo.cs                  |  6 +--
 .../Properties/AssemblyInfo.cs                  |  6 +--
 .../Properties/AssemblyInfo.cs                  |  6 +--
 .../Properties/AssemblyInfo.cs                  |  6 +--
 .../Properties/AssemblyInfo.cs                  |  6 +--
 .../Properties/AssemblyInfo.cs                  |  6 +--
 .../Properties/AssemblyInfo.cs                  |  6 +--
 .../Properties/AssemblyInfo.cs                  |  6 +--
 .../Apache.Ignite/Properties/AssemblyInfo.cs    |  6 +--
 .../Properties/AssemblyInfo.cs                  |  6 +--
 .../Properties/AssemblyInfo.cs                  |  6 +--
 modules/rest-http/pom.xml                       |  2 +-
 modules/scalar-2.10/pom.xml                     |  2 +-
 modules/scalar/pom.xml                          |  2 +-
 modules/schedule/pom.xml                        |  2 +-
 modules/slf4j/pom.xml                           |  2 +-
 modules/spark-2.10/pom.xml                      |  2 +-
 modules/spark/pom.xml                           |  2 +-
 modules/spring-data/pom.xml                     |  5 +--
 modules/spring/pom.xml                          |  2 +-
 modules/ssh/pom.xml                             |  2 +-
 modules/storm/pom.xml                           |  2 +-
 modules/tools/pom.xml                           |  2 +-
 modules/twitter/pom.xml                         |  2 +-
 modules/urideploy/pom.xml                       |  2 +-
 modules/visor-console-2.10/pom.xml              |  2 +-
 modules/visor-console/pom.xml                   |  2 +-
 modules/visor-plugins/pom.xml                   |  2 +-
 modules/web-console/pom.xml                     |  2 +-
 modules/web-console/web-agent/pom.xml           |  2 +-
 modules/web/ignite-appserver-test/pom.xml       |  2 +-
 modules/web/ignite-websphere-test/pom.xml       |  2 +-
 modules/web/pom.xml                             |  2 +-
 modules/yardstick/pom.xml                       |  2 +-
 modules/yarn/pom.xml                            |  2 +-
 modules/zeromq/pom.xml                          |  2 +-
 modules/zookeeper/pom.xml                       |  2 +-
 pom.xml                                         | 43 +++++++++-----------
 89 files changed, 143 insertions(+), 150 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 895519b..0a55627 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -17,8 +17,7 @@
   limitations under the License.
 -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
@@ -29,7 +28,7 @@
     </parent>
 
     <artifactId>ignite-examples</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/aop/pom.xml
----------------------------------------------------------------------
diff --git a/modules/aop/pom.xml b/modules/aop/pom.xml
index e548db2..3d56599 100644
--- a/modules/aop/pom.xml
+++ b/modules/aop/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-aop</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/apache-license-gen/pom.xml
----------------------------------------------------------------------
diff --git a/modules/apache-license-gen/pom.xml b/modules/apache-license-gen/pom.xml
index 825d55b..0edff09 100644
--- a/modules/apache-license-gen/pom.xml
+++ b/modules/apache-license-gen/pom.xml
@@ -31,7 +31,7 @@
 
     <groupId>org.apache.ignite</groupId>
     <artifactId>ignite-apache-license-gen</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <build>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/aws/pom.xml
----------------------------------------------------------------------
diff --git a/modules/aws/pom.xml b/modules/aws/pom.xml
index a9cfcca..a23843e 100644
--- a/modules/aws/pom.xml
+++ b/modules/aws/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-aws</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/benchmarks/pom.xml
----------------------------------------------------------------------
diff --git a/modules/benchmarks/pom.xml b/modules/benchmarks/pom.xml
index caa3cd2..b33931c 100644
--- a/modules/benchmarks/pom.xml
+++ b/modules/benchmarks/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-benchmarks</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/camel/pom.xml
----------------------------------------------------------------------
diff --git a/modules/camel/pom.xml b/modules/camel/pom.xml
index 66c7ae6..975c391 100644
--- a/modules/camel/pom.xml
+++ b/modules/camel/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-camel</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/pom.xml b/modules/cassandra/pom.xml
index a4f947a..83e1ce4 100644
--- a/modules/cassandra/pom.xml
+++ b/modules/cassandra/pom.xml
@@ -32,7 +32,7 @@
 
     <artifactId>ignite-cassandra</artifactId>
     <packaging>pom</packaging>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencyManagement>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/cassandra/serializers/pom.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/serializers/pom.xml b/modules/cassandra/serializers/pom.xml
index 4278eef..3ef1e53 100644
--- a/modules/cassandra/serializers/pom.xml
+++ b/modules/cassandra/serializers/pom.xml
@@ -26,12 +26,12 @@
     <parent>
         <groupId>org.apache.ignite</groupId>
         <artifactId>ignite-cassandra</artifactId>
-        <version>2.0.0-SNAPSHOT</version>
+        <version>2.1.0-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
     <artifactId>ignite-cassandra-serializers</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/cassandra/store/pom.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/pom.xml b/modules/cassandra/store/pom.xml
index eaf012a..16df518 100644
--- a/modules/cassandra/store/pom.xml
+++ b/modules/cassandra/store/pom.xml
@@ -26,12 +26,12 @@
     <parent>
         <groupId>org.apache.ignite</groupId>
         <artifactId>ignite-cassandra</artifactId>
-        <version>2.0.0-SNAPSHOT</version>
+        <version>2.1.0-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
     <artifactId>ignite-cassandra-store</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/clients/pom.xml
----------------------------------------------------------------------
diff --git a/modules/clients/pom.xml b/modules/clients/pom.xml
index 195204c..edd20ee 100644
--- a/modules/clients/pom.xml
+++ b/modules/clients/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-clients</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/cloud/pom.xml
----------------------------------------------------------------------
diff --git a/modules/cloud/pom.xml b/modules/cloud/pom.xml
index 8d806f4..6fd1248 100644
--- a/modules/cloud/pom.xml
+++ b/modules/cloud/pom.xml
@@ -29,7 +29,7 @@
     </parent>
 
     <artifactId>ignite-cloud</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/codegen/pom.xml
----------------------------------------------------------------------
diff --git a/modules/codegen/pom.xml b/modules/codegen/pom.xml
index 3cc30cd..b6400fa 100644
--- a/modules/codegen/pom.xml
+++ b/modules/codegen/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-codegen</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index cb44418..6c714d0f 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-core</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <repositories>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/core/src/main/resources/ignite.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/ignite.properties b/modules/core/src/main/resources/ignite.properties
index b599e11..9e150b9 100644
--- a/modules/core/src/main/resources/ignite.properties
+++ b/modules/core/src/main/resources/ignite.properties
@@ -15,7 +15,7 @@
 # limitations under the License.
 #
 
-ignite.version=2.0.0-SNAPSHOT
+ignite.version=2.1.0-SNAPSHOT
 ignite.build=0
 ignite.revision=DEV
 ignite.rel.date=01011970

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/extdata/p2p/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/pom.xml b/modules/extdata/p2p/pom.xml
index 4863fdd..89c6840 100644
--- a/modules/extdata/p2p/pom.xml
+++ b/modules/extdata/p2p/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-extdata-p2p</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/extdata/uri/modules/uri-dependency/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/uri/modules/uri-dependency/pom.xml b/modules/extdata/uri/modules/uri-dependency/pom.xml
index 9c6f687..a940ccb 100644
--- a/modules/extdata/uri/modules/uri-dependency/pom.xml
+++ b/modules/extdata/uri/modules/uri-dependency/pom.xml
@@ -27,7 +27,7 @@
     <artifactId>ignite-extdata-uri-dep</artifactId>
     <packaging>jar</packaging>
 
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <modelVersion>4.0.0</modelVersion>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/extdata/uri/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/uri/pom.xml b/modules/extdata/uri/pom.xml
index be4f036..09d7826 100644
--- a/modules/extdata/uri/pom.xml
+++ b/modules/extdata/uri/pom.xml
@@ -32,7 +32,7 @@
     </parent>
 
     <artifactId>ignite-extdata-uri</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/flink/pom.xml
----------------------------------------------------------------------
diff --git a/modules/flink/pom.xml b/modules/flink/pom.xml
index e0603e1..44c79e5 100644
--- a/modules/flink/pom.xml
+++ b/modules/flink/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-flink</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/flume/pom.xml
----------------------------------------------------------------------
diff --git a/modules/flume/pom.xml b/modules/flume/pom.xml
index d35c452..2e2fcbd 100644
--- a/modules/flume/pom.xml
+++ b/modules/flume/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-flume</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/gce/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gce/pom.xml b/modules/gce/pom.xml
index 89f9a8b..34c6ea3 100644
--- a/modules/gce/pom.xml
+++ b/modules/gce/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-gce</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/geospatial/pom.xml
----------------------------------------------------------------------
diff --git a/modules/geospatial/pom.xml b/modules/geospatial/pom.xml
index 6ad6d27..c715ffa 100644
--- a/modules/geospatial/pom.xml
+++ b/modules/geospatial/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-geospatial</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hadoop/pom.xml b/modules/hadoop/pom.xml
index 5432052..e7f71ec 100644
--- a/modules/hadoop/pom.xml
+++ b/modules/hadoop/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-hadoop</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/hibernate/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/pom.xml b/modules/hibernate/pom.xml
index 75dacb1..390b290 100644
--- a/modules/hibernate/pom.xml
+++ b/modules/hibernate/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-hibernate</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/hibernate5/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate5/pom.xml b/modules/hibernate5/pom.xml
index 13a0c40..a20b410 100644
--- a/modules/hibernate5/pom.xml
+++ b/modules/hibernate5/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-hibernate5</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/indexing/pom.xml
----------------------------------------------------------------------
diff --git a/modules/indexing/pom.xml b/modules/indexing/pom.xml
index 363974e..2a4cfd3 100644
--- a/modules/indexing/pom.xml
+++ b/modules/indexing/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-indexing</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/jcl/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jcl/pom.xml b/modules/jcl/pom.xml
index 27d2e7f..ce68c7f 100644
--- a/modules/jcl/pom.xml
+++ b/modules/jcl/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-jcl</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/jms11/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jms11/pom.xml b/modules/jms11/pom.xml
index 9032a93..a226043 100644
--- a/modules/jms11/pom.xml
+++ b/modules/jms11/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-jms11</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/jta/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jta/pom.xml b/modules/jta/pom.xml
index ae75f8a..254e146 100644
--- a/modules/jta/pom.xml
+++ b/modules/jta/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-jta</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/kafka/pom.xml
----------------------------------------------------------------------
diff --git a/modules/kafka/pom.xml b/modules/kafka/pom.xml
index 6f65fec..1affd57 100644
--- a/modules/kafka/pom.xml
+++ b/modules/kafka/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-kafka</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/kubernetes/pom.xml
----------------------------------------------------------------------
diff --git a/modules/kubernetes/pom.xml b/modules/kubernetes/pom.xml
index 5d4e5f0..88884d2 100644
--- a/modules/kubernetes/pom.xml
+++ b/modules/kubernetes/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-kubernetes</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/log4j/pom.xml
----------------------------------------------------------------------
diff --git a/modules/log4j/pom.xml b/modules/log4j/pom.xml
index 0dd1db6..5a41708 100644
--- a/modules/log4j/pom.xml
+++ b/modules/log4j/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-log4j</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/log4j2/pom.xml
----------------------------------------------------------------------
diff --git a/modules/log4j2/pom.xml b/modules/log4j2/pom.xml
index 5c6e7c4..9ae74aa 100644
--- a/modules/log4j2/pom.xml
+++ b/modules/log4j2/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-log4j2</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/mesos/pom.xml
----------------------------------------------------------------------
diff --git a/modules/mesos/pom.xml b/modules/mesos/pom.xml
index bd59fbd..2723334 100644
--- a/modules/mesos/pom.xml
+++ b/modules/mesos/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-mesos</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/ml/pom.xml
----------------------------------------------------------------------
diff --git a/modules/ml/pom.xml b/modules/ml/pom.xml
index e6f5acb..1df5bb6 100644
--- a/modules/ml/pom.xml
+++ b/modules/ml/pom.xml
@@ -19,9 +19,7 @@
 <!--
     POM file.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
@@ -32,7 +30,7 @@
     </parent>
 
     <artifactId>ignite-ml</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/mqtt/pom.xml
----------------------------------------------------------------------
diff --git a/modules/mqtt/pom.xml b/modules/mqtt/pom.xml
index daa196e..80fc720 100644
--- a/modules/mqtt/pom.xml
+++ b/modules/mqtt/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-mqtt</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/osgi-karaf/pom.xml
----------------------------------------------------------------------
diff --git a/modules/osgi-karaf/pom.xml b/modules/osgi-karaf/pom.xml
index 97a9048..80b9fe9 100644
--- a/modules/osgi-karaf/pom.xml
+++ b/modules/osgi-karaf/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-osgi-karaf</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <build>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/osgi-paxlogging/pom.xml
----------------------------------------------------------------------
diff --git a/modules/osgi-paxlogging/pom.xml b/modules/osgi-paxlogging/pom.xml
index 6e764a5..4852ed7 100644
--- a/modules/osgi-paxlogging/pom.xml
+++ b/modules/osgi-paxlogging/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-osgi-paxlogging</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <packaging>jar</packaging>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/osgi/pom.xml
----------------------------------------------------------------------
diff --git a/modules/osgi/pom.xml b/modules/osgi/pom.xml
index b7fd589..74a2c3d 100644
--- a/modules/osgi/pom.xml
+++ b/modules/osgi/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-osgi</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/cpp/common/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/configure.ac b/modules/platforms/cpp/common/configure.ac
index cfe098c..ab78388 100644
--- a/modules/platforms/cpp/common/configure.ac
+++ b/modules/platforms/cpp/common/configure.ac
@@ -19,7 +19,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.69])
-AC_INIT([Apache Ignite JNI bridge for C++], [1.6.1.9108], [dev@ignite.apache.org], [ignite-common], [ignite.apache.org])
+AC_INIT([Apache Ignite JNI bridge for C++], [2.1.0.19388], [dev@ignite.apache.org], [ignite-common], [ignite.apache.org])
 AC_CONFIG_SRCDIR(src)
 
 AC_CANONICAL_SYSTEM

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/cpp/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/configure.ac b/modules/platforms/cpp/configure.ac
index 3c98225..9dd52d7 100644
--- a/modules/platforms/cpp/configure.ac
+++ b/modules/platforms/cpp/configure.ac
@@ -19,7 +19,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.69])
-AC_INIT([Apache Ignite C++], [2.0.0.16694], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
+AC_INIT([Apache Ignite C++], [2.1.0.19388], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
 
 AC_CANONICAL_HOST
 AC_CONFIG_MACRO_DIR([m4])

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/cpp/configure.acrel
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/configure.acrel b/modules/platforms/cpp/configure.acrel
index f73b57c..5f8c4ed 100644
--- a/modules/platforms/cpp/configure.acrel
+++ b/modules/platforms/cpp/configure.acrel
@@ -19,7 +19,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.69])
-AC_INIT([Apache Ignite C++], [2.0.0.16694], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
+AC_INIT([Apache Ignite C++], [2.1.0.19388], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
 
 AC_CANONICAL_HOST
 AC_CONFIG_MACRO_DIR([m4])

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/cpp/core-test/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/configure.ac b/modules/platforms/cpp/core-test/configure.ac
index b23c0d1..c718055 100644
--- a/modules/platforms/cpp/core-test/configure.ac
+++ b/modules/platforms/cpp/core-test/configure.ac
@@ -19,7 +19,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.69])
-AC_INIT([Apache Ignite C++ Test], [1.6.1.9108], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
+AC_INIT([Apache Ignite C++ Test], [2.1.0.19388], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
 AC_CONFIG_SRCDIR(src)
 
 AC_CANONICAL_SYSTEM

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/cpp/core/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/configure.ac b/modules/platforms/cpp/core/configure.ac
index 5e15deb..5f1881c 100644
--- a/modules/platforms/cpp/core/configure.ac
+++ b/modules/platforms/cpp/core/configure.ac
@@ -19,7 +19,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.69])
-AC_INIT([Apache Ignite C++], [1.6.1.9108], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
+AC_INIT([Apache Ignite C++], [2.1.0.19388], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
 AC_CONFIG_SRCDIR(src)
 
 AC_CANONICAL_SYSTEM

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/cpp/examples/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/configure.ac b/modules/platforms/cpp/examples/configure.ac
index e15d186..3350d40 100644
--- a/modules/platforms/cpp/examples/configure.ac
+++ b/modules/platforms/cpp/examples/configure.ac
@@ -19,7 +19,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.69])
-AC_INIT([Apache Ignite C++ Examples], [2.0.0.16694], [dev@ignite.apache.org], [ignite-examples], [ignite.apache.org])
+AC_INIT([Apache Ignite C++ Examples], [2.1.0.19388], [dev@ignite.apache.org], [ignite-examples], [ignite.apache.org])
 
 AC_CANONICAL_HOST
 AC_CONFIG_MACRO_DIR([m4])

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/cpp/ignite/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/ignite/configure.ac b/modules/platforms/cpp/ignite/configure.ac
index f71261e..69b76e0 100644
--- a/modules/platforms/cpp/ignite/configure.ac
+++ b/modules/platforms/cpp/ignite/configure.ac
@@ -19,7 +19,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.69])
-AC_INIT([Apache Ignite C++ Runner], [1.6.1.9108], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
+AC_INIT([Apache Ignite C++ Runner], [2.1.0.19388], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
 AC_CONFIG_SRCDIR(src)
 
 AC_CANONICAL_SYSTEM

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/cpp/odbc/install/ignite-odbc-amd64.wxs
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/install/ignite-odbc-amd64.wxs b/modules/platforms/cpp/odbc/install/ignite-odbc-amd64.wxs
index eadbe88..186465c 100644
--- a/modules/platforms/cpp/odbc/install/ignite-odbc-amd64.wxs
+++ b/modules/platforms/cpp/odbc/install/ignite-odbc-amd64.wxs
@@ -21,7 +21,7 @@
 	<Product Name='Apache Ignite ODBC 64-bit Driver' Manufacturer='The Apache Software Foundation'
 		Id='F3E308E4-910C-4AF5-82DE-2ACF4D64830E' 
 		UpgradeCode='1D7AEFDF-6CD2-4FB5-88F2-811A89832D6D'
-		Language='1033' Codepage='1252' Version='2.0.0.16694'>
+		Language='1033' Codepage='1252' Version='2.1.0.19388'>
 		
 		<Package Id='*' Keywords='Installer' Description="Apache Ignite ODBC 64-bit Driver Installer"
 			Comments='Apache, Apache Ignite, the Apache feather and the Apache Ignite logo are trademarks of The Apache Software Foundation.'

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/cpp/odbc/install/ignite-odbc-x86.wxs
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/install/ignite-odbc-x86.wxs b/modules/platforms/cpp/odbc/install/ignite-odbc-x86.wxs
index b50b5a3..28a405e 100644
--- a/modules/platforms/cpp/odbc/install/ignite-odbc-x86.wxs
+++ b/modules/platforms/cpp/odbc/install/ignite-odbc-x86.wxs
@@ -21,7 +21,7 @@
 	<Product Name='Apache Ignite ODBC 32-bit Driver' Manufacturer='The Apache Software Foundation'
 		Id='D39CBABA-1E21-4701-AA5C-91EDA07B383B' 
 		UpgradeCode='743902A4-365C-424E-B226-5B2898A3941E'
-		Language='1033' Codepage='1252' Version='2.0.0.16694'>
+		Language='1033' Codepage='1252' Version='2.1.0.19388'>
 		
 		<Package Id='*' Keywords='Installer' Description="Apache Ignite ODBC 32-bit Driver Installer"
 			Comments='Apache, Apache Ignite, the Apache feather and the Apache Ignite logo are trademarks of The Apache Software Foundation.'

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Properties/AssemblyInfo.cs
index 6981500..fb582d6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Properties/AssemblyInfo.cs
@@ -35,8 +35,8 @@ using System.Runtime.InteropServices;
 
 [assembly: Guid("18ea4c71-a11d-4ab1-8042-418f7559d84f")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
 
 [assembly: CLSCompliant(true)]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs
index 1073986..3629b9c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs
@@ -33,9 +33,9 @@ using System.Runtime.InteropServices;
 
 [assembly: Guid("13ea96fc-cc83-4164-a7c0-4f30ed797460")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
 
 [assembly: CLSCompliant(true)]
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Properties/AssemblyInfo.cs
index ce82281..cc25f0b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Properties/AssemblyInfo.cs
@@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
 
 [assembly: Guid("8fae8395-7e91-411a-a78f-44d6d3fed0fc")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Properties/AssemblyInfo.cs
index d6b1699..0980324 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Properties/AssemblyInfo.cs
@@ -30,6 +30,6 @@ using System.Runtime.InteropServices;
 [assembly: ComVisible(false)]
 [assembly: Guid("134707f6-155d-47f6-9eb2-c67abbf3c009")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
index e9f93bd..e21044d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
@@ -45,6 +45,6 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
index 28f6e72..c65084d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
@@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
 
 [assembly: Guid("de8dd5cc-7c7f-4a09-80d5-7086d9416a7b")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
index cb903aa..fb07d1d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
@@ -33,9 +33,9 @@ using System.Runtime.InteropServices;
 
 [assembly: Guid("97db45a8-f922-456a-a819-7b3c6e5e03ba")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
 
 [assembly: CLSCompliant(true)]
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/Apache.Ignite.EntityFramework.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.EntityFramework.Tests/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.EntityFramework.Tests/Properties/AssemblyInfo.cs
index 8aeec58..efa6c22 100644
--- a/modules/platforms/dotnet/Apache.Ignite.EntityFramework.Tests/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.EntityFramework.Tests/Properties/AssemblyInfo.cs
@@ -32,8 +32,8 @@ using System.Runtime.InteropServices;
 
 [assembly: Guid("cda5700e-78f3-4a9e-a9b0-704cbe94651c")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
 
 [assembly: CLSCompliant(true)]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Properties/AssemblyInfo.cs
index 4d25f53..4df418b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Properties/AssemblyInfo.cs
@@ -32,9 +32,9 @@ using System.Runtime.InteropServices;
 [assembly: ComVisible(false)]
 [assembly: Guid("c558518a-c1a0-4224-aaa9-a8688474b4dc")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
 
 [assembly: CLSCompliant(true)]
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/Apache.Ignite.Linq/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Properties/AssemblyInfo.cs
index 561674a..e1b5402 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Properties/AssemblyInfo.cs
@@ -33,8 +33,8 @@ using System.Runtime.InteropServices;
 // The following GUID is for the ID of the typelib if this project is exposed to COM
 [assembly: Guid("5b571661-17f4-4f29-8c7d-0edb38ca9b55")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
 
 [assembly: CLSCompliant(true)]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/Apache.Ignite.Log4Net/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Log4Net/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Log4Net/Properties/AssemblyInfo.cs
index 09e5749..e2ab220 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Log4Net/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Log4Net/Properties/AssemblyInfo.cs
@@ -33,8 +33,8 @@ using System.Runtime.InteropServices;
 // The following GUID is for the ID of the typelib if this project is exposed to COM
 [assembly: Guid("6f82d669-382e-4435-8092-68c4440146d8")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
 
 [assembly: CLSCompliant(true)]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/Apache.Ignite.NLog/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.NLog/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.NLog/Properties/AssemblyInfo.cs
index 3f2aa71..747f440 100644
--- a/modules/platforms/dotnet/Apache.Ignite.NLog/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.NLog/Properties/AssemblyInfo.cs
@@ -33,8 +33,8 @@ using System.Runtime.InteropServices;
 // The following GUID is for the ID of the typelib if this project is exposed to COM
 [assembly: Guid("c6b58e4a-a2e9-4554-ad02-68ce6da5cfb7")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
 
 [assembly: CLSCompliant(true)]

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
index 3e0e305..73eb876 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
@@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
 
 [assembly: Guid("0f9702ec-da7d-4ce5-b4b7-73310c885355")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
index f6323e0..a87a8e0 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
@@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
 
 [assembly: Guid("41a0cb95-3435-4c78-b867-900b28e2c9ee")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
index 6d28b2b..1e9dcc8 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
@@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
 
 [assembly: Guid("ce65ec7c-d3cf-41ad-8f45-f90d5af68d77")]
 
-[assembly: AssemblyVersion("2.0.0.16694")]
-[assembly: AssemblyFileVersion("2.0.0.16694")]
-[assembly: AssemblyInformationalVersion("2.0.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("2.1.0.19388")]
+[assembly: AssemblyFileVersion("2.1.0.19388")]
+[assembly: AssemblyInformationalVersion("2.1.0")]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/rest-http/pom.xml
----------------------------------------------------------------------
diff --git a/modules/rest-http/pom.xml b/modules/rest-http/pom.xml
index 85969b3..4a29eea 100644
--- a/modules/rest-http/pom.xml
+++ b/modules/rest-http/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-rest-http</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/scalar-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/scalar-2.10/pom.xml b/modules/scalar-2.10/pom.xml
index 8d3d86d..ac3dadc 100644
--- a/modules/scalar-2.10/pom.xml
+++ b/modules/scalar-2.10/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-scalar_2.10</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/scalar/pom.xml
----------------------------------------------------------------------
diff --git a/modules/scalar/pom.xml b/modules/scalar/pom.xml
index 2bb114f..c6c3f93 100644
--- a/modules/scalar/pom.xml
+++ b/modules/scalar/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-scalar</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/schedule/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schedule/pom.xml b/modules/schedule/pom.xml
index 935f0ff..22c2571 100644
--- a/modules/schedule/pom.xml
+++ b/modules/schedule/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-schedule</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/slf4j/pom.xml
----------------------------------------------------------------------
diff --git a/modules/slf4j/pom.xml b/modules/slf4j/pom.xml
index a19b46b..96b7309 100644
--- a/modules/slf4j/pom.xml
+++ b/modules/slf4j/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-slf4j</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/spark-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spark-2.10/pom.xml b/modules/spark-2.10/pom.xml
index 58e2860..90f7d0b 100644
--- a/modules/spark-2.10/pom.xml
+++ b/modules/spark-2.10/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-spark_2.10</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/spark/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spark/pom.xml b/modules/spark/pom.xml
index 140f637..86ed9f6 100644
--- a/modules/spark/pom.xml
+++ b/modules/spark/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-spark</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/spring-data/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spring-data/pom.xml b/modules/spring-data/pom.xml
index 4d8107b..3d8bcea 100644
--- a/modules/spring-data/pom.xml
+++ b/modules/spring-data/pom.xml
@@ -20,8 +20,7 @@
 <!--
     POM file.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
@@ -32,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-spring-data</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/spring/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spring/pom.xml b/modules/spring/pom.xml
index 275243f..edaa013 100644
--- a/modules/spring/pom.xml
+++ b/modules/spring/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-spring</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/ssh/pom.xml
----------------------------------------------------------------------
diff --git a/modules/ssh/pom.xml b/modules/ssh/pom.xml
index 4b448a0..64ffabc 100644
--- a/modules/ssh/pom.xml
+++ b/modules/ssh/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-ssh</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/storm/pom.xml
----------------------------------------------------------------------
diff --git a/modules/storm/pom.xml b/modules/storm/pom.xml
index 827bcf9..444aac5 100644
--- a/modules/storm/pom.xml
+++ b/modules/storm/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-storm</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/tools/pom.xml
----------------------------------------------------------------------
diff --git a/modules/tools/pom.xml b/modules/tools/pom.xml
index 6dec29a..a5a6360 100644
--- a/modules/tools/pom.xml
+++ b/modules/tools/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-tools</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/twitter/pom.xml
----------------------------------------------------------------------
diff --git a/modules/twitter/pom.xml b/modules/twitter/pom.xml
index 126c590..b6795f3 100644
--- a/modules/twitter/pom.xml
+++ b/modules/twitter/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-twitter</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/urideploy/pom.xml
----------------------------------------------------------------------
diff --git a/modules/urideploy/pom.xml b/modules/urideploy/pom.xml
index 266dd6a..d08372f 100644
--- a/modules/urideploy/pom.xml
+++ b/modules/urideploy/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-urideploy</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/visor-console-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-console-2.10/pom.xml b/modules/visor-console-2.10/pom.xml
index bcdc8b1..2cd6864 100644
--- a/modules/visor-console-2.10/pom.xml
+++ b/modules/visor-console-2.10/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-visor-console_2.10</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/visor-console/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-console/pom.xml b/modules/visor-console/pom.xml
index 80de214..794a22f 100644
--- a/modules/visor-console/pom.xml
+++ b/modules/visor-console/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-visor-console</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/visor-plugins/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-plugins/pom.xml b/modules/visor-plugins/pom.xml
index 208dc8d..b9befad 100644
--- a/modules/visor-plugins/pom.xml
+++ b/modules/visor-plugins/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-visor-plugins</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/web-console/pom.xml
----------------------------------------------------------------------
diff --git a/modules/web-console/pom.xml b/modules/web-console/pom.xml
index 6c7959e..f1f0a14 100644
--- a/modules/web-console/pom.xml
+++ b/modules/web-console/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-web-console</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <build>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/web-console/web-agent/pom.xml
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/pom.xml b/modules/web-console/web-agent/pom.xml
index 697e58f..2bf7875 100644
--- a/modules/web-console/web-agent/pom.xml
+++ b/modules/web-console/web-agent/pom.xml
@@ -32,7 +32,7 @@
 
     <artifactId>ignite-web-agent</artifactId>
     <packaging>jar</packaging>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/web/ignite-appserver-test/pom.xml
----------------------------------------------------------------------
diff --git a/modules/web/ignite-appserver-test/pom.xml b/modules/web/ignite-appserver-test/pom.xml
index 9d0461b..6ee8d15 100644
--- a/modules/web/ignite-appserver-test/pom.xml
+++ b/modules/web/ignite-appserver-test/pom.xml
@@ -30,7 +30,7 @@
 
     <artifactId>ignite-appserver-test</artifactId>
     <packaging>jar</packaging>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/web/ignite-websphere-test/pom.xml
----------------------------------------------------------------------
diff --git a/modules/web/ignite-websphere-test/pom.xml b/modules/web/ignite-websphere-test/pom.xml
index b055b6a..8d20041 100644
--- a/modules/web/ignite-websphere-test/pom.xml
+++ b/modules/web/ignite-websphere-test/pom.xml
@@ -30,7 +30,7 @@
 
     <artifactId>ignite-websphere-test</artifactId>
     <packaging>war</packaging>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/web/pom.xml
----------------------------------------------------------------------
diff --git a/modules/web/pom.xml b/modules/web/pom.xml
index eee51eb..86d7634 100644
--- a/modules/web/pom.xml
+++ b/modules/web/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-web</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/yardstick/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml
index fbc56d2..f496e02 100644
--- a/modules/yardstick/pom.xml
+++ b/modules/yardstick/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-yardstick</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/yarn/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yarn/pom.xml b/modules/yarn/pom.xml
index a8602cf..8620ef5 100644
--- a/modules/yarn/pom.xml
+++ b/modules/yarn/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-yarn</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/zeromq/pom.xml
----------------------------------------------------------------------
diff --git a/modules/zeromq/pom.xml b/modules/zeromq/pom.xml
index c11416c..8538582 100644
--- a/modules/zeromq/pom.xml
+++ b/modules/zeromq/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-zeromq</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/modules/zookeeper/pom.xml
----------------------------------------------------------------------
diff --git a/modules/zookeeper/pom.xml b/modules/zookeeper/pom.xml
index 0e4e94e..fd7d648 100644
--- a/modules/zookeeper/pom.xml
+++ b/modules/zookeeper/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-zookeeper</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/27fd74ee/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 45d478c..c3f41f6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
 
     <groupId>org.apache.ignite</groupId>
     <artifactId>apache-ignite</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.1.0-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <properties>
@@ -516,7 +516,7 @@
                                         <mkdir dir="${basedir}/target/release-package/benchmarks" />
 
                                         <copy todir="${basedir}/target/release-package/benchmarks/">
-                                            <fileset dir="${basedir}/modules/yardstick/target/assembly/"/>
+                                            <fileset dir="${basedir}/modules/yardstick/target/assembly/" />
                                         </copy>
 
                                         <!--todo: only required jars should be exported to /benchmarks/libs during compilation-->
@@ -533,47 +533,44 @@
                                         <delete>
                                             <fileset dir="${basedir}/target/release-package/benchmarks/config/">
                                                 <include name="*.*" />
-                                                <exclude name="benchmark.properties"/>
-                                                <exclude name="benchmark-remote.properties"/>
-                                                <exclude name="benchmark-sample.properties"/>
-                                                <exclude name="benchmark-remote-sample.properties"/>
-                                                <exclude name="benchmark-multicast.properties"/>
-                                                <exclude name="ignite-base-config.xml"/>
-                                                <exclude name="ignite-localhost-config.xml"/>
-                                                <exclude name="ignite-remote-config.xml"/>
-                                                <exclude name="ignite-multicast-config.xml"/>
+                                                <exclude name="benchmark.properties" />
+                                                <exclude name="benchmark-remote.properties" />
+                                                <exclude name="benchmark-sample.properties" />
+                                                <exclude name="benchmark-remote-sample.properties" />
+                                                <exclude name="benchmark-multicast.properties" />
+                                                <exclude name="ignite-base-config.xml" />
+                                                <exclude name="ignite-localhost-config.xml" />
+                                                <exclude name="ignite-remote-config.xml" />
+                                                <exclude name="ignite-multicast-config.xml" />
                                             </fileset>
                                         </delete>
 
                                         <mkdir dir="${basedir}/target/release-package/benchmarks/sources/src" />
 
                                         <copy todir="${basedir}/target/release-package/benchmarks/sources/src/">
-                                            <fileset dir="${basedir}/modules/yardstick/src"/>
+                                            <fileset dir="${basedir}/modules/yardstick/src" />
                                         </copy>
 
                                         <mkdir dir="${basedir}/target/release-package/benchmarks/sources/config" />
 
                                         <copy todir="${basedir}/target/release-package/benchmarks/sources/config/">
-                                            <fileset dir="${basedir}/target/release-package/benchmarks/config"/>
+                                            <fileset dir="${basedir}/target/release-package/benchmarks/config" />
                                         </copy>
 
-                                        <copy file="${basedir}/modules/yardstick/pom-standalone.xml"
-                                              tofile="${basedir}/target/release-package/benchmarks/sources/pom.xml"/>
+                                        <copy file="${basedir}/modules/yardstick/pom-standalone.xml" tofile="${basedir}/target/release-package/benchmarks/sources/pom.xml" />
 
                                         <replaceregexp byline="true">
-                                            <regexp pattern="to_be_replaced_by_ignite_version"/>
-                                            <substitution expression="${project.version}"/>
-                                            <fileset dir="${basedir}/target/release-package/benchmarks/sources/" >
-                                                <include name="pom.xml"/>
+                                            <regexp pattern="to_be_replaced_by_ignite_version" />
+                                            <substitution expression="${project.version}" />
+                                            <fileset dir="${basedir}/target/release-package/benchmarks/sources/">
+                                                <include name="pom.xml" />
                                             </fileset>
                                         </replaceregexp>
 
-                                        <copy file="${basedir}/modules/yardstick/README.txt"
-                                              tofile="${basedir}/target/release-package/benchmarks/README.txt" overwrite="true">
+                                        <copy file="${basedir}/modules/yardstick/README.txt" tofile="${basedir}/target/release-package/benchmarks/README.txt" overwrite="true">
                                         </copy>
 
-                                        <copy file="${basedir}/modules/yardstick/DEVNOTES-standalone.txt"
-                                              tofile="${basedir}/target/release-package/benchmarks/sources/DEVNOTES.txt"/>
+                                        <copy file="${basedir}/modules/yardstick/DEVNOTES-standalone.txt" tofile="${basedir}/target/release-package/benchmarks/sources/DEVNOTES.txt" />
                                     </target>
                                 </configuration>
                             </execution>


[19/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/CacheVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/CacheVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/CacheVectorStorage.java
deleted file mode 100644
index 670deef..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/CacheVectorStorage.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.math.ValueMapper;
-import org.apache.ignite.math.VectorKeyMapper;
-import org.apache.ignite.math.VectorStorage;
-
-/**
- * Vector storage based on existing cache and index and value mapping functions.
- */
-public class CacheVectorStorage<K, V> implements VectorStorage {
-    /** Storage size. */
-    private int size;
-    /** Key mapper. */
-    private VectorKeyMapper<K> keyMapper;
-    /** Value mapper. */
-    private ValueMapper<V> valMapper;
-    /** Underlying ignite cache. */
-    private IgniteCache<K, V> cache;
-
-    /**
-     *
-     */
-    public CacheVectorStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param size
-     * @param cache
-     * @param keyMapper
-     * @param valMapper
-     */
-    public CacheVectorStorage(int size, IgniteCache<K, V> cache, VectorKeyMapper<K> keyMapper,
-        ValueMapper<V> valMapper) {
-        assert size > 0;
-        assert cache != null;
-        assert keyMapper != null;
-        assert valMapper != null;
-
-        this.size = size;
-        this.cache = cache;
-        this.keyMapper = keyMapper;
-        this.valMapper = valMapper;
-    }
-
-    /**
-     *
-     *
-     */
-    public IgniteCache<K, V> cache() {
-        return cache;
-    }
-
-    /**
-     *
-     *
-     */
-    public VectorKeyMapper<K> keyMapper() {
-        return keyMapper;
-    }
-
-    /**
-     *
-     *
-     */
-    public ValueMapper<V> valueMapper() {
-        return valMapper;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return size;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int i) {
-        return valMapper.toDouble(cache.get(keyMapper.apply(i)));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int i, double v) {
-        cache.put(keyMapper.apply(i), valMapper.fromDouble(v));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(size);
-        out.writeObject(keyMapper);
-        out.writeObject(valMapper);
-        out.writeUTF(cache.getName());
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        size = in.readInt();
-        keyMapper = (VectorKeyMapper<K>)in.readObject();
-        valMapper = (ValueMapper<V>)in.readObject();
-        cache = Ignition.localIgnite().getOrCreateCache(in.readUTF());
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + size();
-        res = res * 37 + keyMapper.hashCode();
-        res = res * 37 + valMapper.hashCode();
-        res = res * 37 + cache.hashCode();
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-
-        if (obj == null || getClass() != obj.getClass())
-            return false;
-
-        CacheVectorStorage that = (CacheVectorStorage)obj;
-
-        return size == that.size
-            && (keyMapper != null ? keyMapper.getClass().equals(that.keyMapper.getClass()) : that.keyMapper == null)
-            && (valMapper != null ? valMapper.getClass().equals(that.valMapper.getClass()) : that.valMapper == null)
-            && (cache != null ? cache.equals(that.cache) : that.cache == null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/ConstantVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/ConstantVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/ConstantVectorStorage.java
deleted file mode 100644
index ff5ab26..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/ConstantVectorStorage.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-
-/**
- * Constant read-only vector storage.
- */
-public class ConstantVectorStorage implements VectorStorage {
-    /** */ private int size;
-    /** */ private double val;
-
-    /**
-     *
-     */
-    public ConstantVectorStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param size Vector size.
-     * @param val Value to set for vector elements.
-     */
-    public ConstantVectorStorage(int size, double val) {
-        assert size > 0;
-
-        this.size = size;
-        this.val = val;
-    }
-
-    /**
-     *
-     *
-     */
-    public double constant() {
-        return val;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return size;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int i) {
-        return val;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int i, double v) {
-        throw new UnsupportedOperationException("Can't set value into constant vector.");
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(size);
-        out.writeDouble(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        size = in.readInt();
-        val = in.readDouble();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + size;
-        res = res * 37 + Double.hashCode(val);
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        ConstantVectorStorage that = (ConstantVectorStorage)o;
-
-        return size == that.size && val == that.val;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/DelegateVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/DelegateVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/DelegateVectorStorage.java
deleted file mode 100644
index aa6018c..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/DelegateVectorStorage.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.math.VectorStorage;
-
-/**
- * {@link VectorStorage} implementation that delegates to parent matrix.
- */
-public class DelegateVectorStorage implements VectorStorage {
-    /** Parent vector storage. */
-    private VectorStorage sto;
-
-    /** Offset in the parent vector. */
-    private int off;
-
-    /** Size of the vector. */
-    private int len;
-
-    /**
-     *
-     */
-    public DelegateVectorStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param sto Vector storage to delegate to.
-     * @param off Offset in the parent vector.
-     * @param len Size of the vector.
-     */
-    public DelegateVectorStorage(VectorStorage sto, int off, int len) {
-        assert sto != null;
-        assert off >= 0;
-        assert len > 0;
-
-        this.sto = sto;
-        this.off = off;
-        this.len = len;
-    }
-
-    /** */
-    public VectorStorage delegate() {
-        return sto;
-    }
-
-    /** */
-    public int offset() {
-        return off;
-    }
-
-    /** */
-    public int length() {
-        return len;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return len;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int i) {
-        return sto.get(off + i);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int i, double v) {
-        sto.set(off + i, v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public double[] data() {
-        return sto.data();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return sto.isSequentialAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return sto.isDense();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return sto.isRandomAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return sto.isDistributed();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return sto.isArrayBased();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(sto);
-        out.writeInt(off);
-        out.writeInt(len);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        sto = (VectorStorage)in.readObject();
-        off = in.readInt();
-        len = in.readInt();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        DelegateVectorStorage that = (DelegateVectorStorage)o;
-
-        return len == that.len && off == that.off && (sto != null ? sto.equals(that.sto) : that.sto == null);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + off;
-        res = res * 37 + len;
-        res = res * 37 + sto.hashCode();
-
-        return res;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/DenseLocalOffHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/DenseLocalOffHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/DenseLocalOffHeapVectorStorage.java
deleted file mode 100644
index 2e7cdc9..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/DenseLocalOffHeapVectorStorage.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.stream.IntStream;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.math.VectorStorage;
-
-/**
- * Local, dense off-heap vector storage.
- */
-public class DenseLocalOffHeapVectorStorage implements VectorStorage {
-    /** Vector size. */
-    private int size;
-
-    /** */
-    private transient long ptr;
-    //TODO: temp solution.
-    /** */
-    private int ptrInitHash;
-
-    /**
-     *
-     */
-    public DenseLocalOffHeapVectorStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param size Vector size.
-     */
-    public DenseLocalOffHeapVectorStorage(int size) {
-        assert size > 0;
-
-        this.size = size;
-
-        allocateMemory(size);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return size;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int i) {
-        return GridUnsafe.getDouble(pointerOffset(i));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int i, double v) {
-        GridUnsafe.putDouble(pointerOffset(i), v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double[] data() {
-        return null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(size);
-        out.writeInt(ptrInitHash);
-
-        for (int i = 0; i < size; i++)
-            out.writeDouble(get(i));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        size = in.readInt();
-
-        allocateMemory(size);
-
-        ptrInitHash = in.readInt();
-
-        for (int i = 0; i < size; i++)
-            set(i, in.readDouble());
-    }
-
-    /** {@inheritDoc} */
-    @Override public void destroy() {
-        GridUnsafe.freeMemory(ptr);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + size;
-        res = res * 37 + ptrInitHash;
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        DenseLocalOffHeapVectorStorage that = (DenseLocalOffHeapVectorStorage)o;
-
-        return size == that.size && isMemoryEquals(that);
-    }
-
-    /** */
-    private boolean isMemoryEquals(DenseLocalOffHeapVectorStorage otherStorage) {
-        return IntStream.range(0, size).parallel().noneMatch(idx -> Double.compare(get(idx), otherStorage.get(idx)) != 0);
-    }
-
-    /**
-     * Pointer offset for specific index.
-     *
-     * @param i Offset index.
-     */
-    private long pointerOffset(int i) {
-        return ptr + i * Double.BYTES;
-    }
-
-    /** */
-    private void allocateMemory(int size) {
-        ptr = GridUnsafe.allocateMemory(size * Double.BYTES);
-
-        ptrInitHash = Long.hashCode(ptr);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/FunctionVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/FunctionVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/FunctionVectorStorage.java
deleted file mode 100644
index df8fa12..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/FunctionVectorStorage.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.IgniteFunction;
-import org.apache.ignite.math.functions.IntDoubleToVoidFunction;
-
-/**
- * Read-only or read-write function-based vector storage.
- */
-public class FunctionVectorStorage implements VectorStorage {
-    /** */ private IgniteFunction<Integer, Double> getFunc;
-    /** */ private IntDoubleToVoidFunction setFunc;
-    /** */ private int size;
-
-    /**
-     *
-     */
-    public FunctionVectorStorage() {
-        // No-op.
-    }
-
-    /**
-     * Creates read-only or read-write storage.
-     *
-     * @param size Cardinality of this vector storage.
-     * @param getFunc Get function.
-     * @param setFunc Optional set function ({@code null} for read-only storage).
-     */
-    public FunctionVectorStorage(int size, IgniteFunction<Integer, Double> getFunc, IntDoubleToVoidFunction setFunc) {
-        assert size > 0;
-        assert getFunc != null; // At least get function is required.
-
-        this.size = size;
-        this.getFunc = getFunc;
-        this.setFunc = setFunc;
-    }
-
-    /**
-     *
-     *
-     */
-    public IgniteFunction<Integer, Double> getFunction() {
-        return getFunc;
-    }
-
-    /**
-     *
-     *
-     */
-    public IntDoubleToVoidFunction setFunction() {
-        return setFunc;
-    }
-
-    /**
-     * Creates read-only storage.
-     *
-     * @param size Cardinality of this vector storage.
-     * @param getFunc Get function.
-     */
-    public FunctionVectorStorage(int size, IgniteFunction<Integer, Double> getFunc) {
-        this(size, getFunc, null);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return size;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int i) {
-        return getFunc.apply(i);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int i, double v) {
-        if (setFunc != null)
-            setFunc.accept(i, v);
-        else
-            throw new UnsupportedOperationException("Cannot set into read-only vector.");
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(setFunc);
-        out.writeObject(getFunc);
-        out.writeInt(size);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        setFunc = (IntDoubleToVoidFunction)in.readObject();
-        getFunc = (IgniteFunction<Integer, Double>)in.readObject();
-        size = in.readInt();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/MatrixVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/MatrixVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/MatrixVectorStorage.java
deleted file mode 100644
index ece0003..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/MatrixVectorStorage.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.exceptions.IndexException;
-
-/**
- * Row, column or diagonal vector-based view of the matrix
- */
-public class MatrixVectorStorage implements VectorStorage {
-    /** */ private Matrix parent;
-
-    /** */ private int row;
-    /** */ private int col;
-
-    /** */ private int rowStride;
-    /** */  private int colStride;
-
-    /** */ private int size;
-
-    /**
-     *
-     */
-    public MatrixVectorStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param parent
-     * @param row
-     * @param col
-     * @param rowStride
-     * @param colStride
-     */
-    public MatrixVectorStorage(Matrix parent, int row, int col, int rowStride, int colStride) {
-        assert parent != null;
-        assert rowStride >= 0;
-        assert colStride >= 0;
-        assert rowStride > 0 || colStride > 0;
-
-        if (row < 0 || row >= parent.rowSize())
-            throw new IndexException(row);
-        if (col < 0 || col >= parent.columnSize())
-            throw new IndexException(col);
-
-        this.parent = parent;
-
-        this.row = row;
-        this.col = col;
-
-        this.rowStride = rowStride;
-        this.colStride = colStride;
-
-        this.size = getSize();
-    }
-
-    /**
-     *
-     *
-     */
-    int row() {
-        return row;
-    }
-
-    /**
-     *
-     *
-     */
-    int column() {
-        return col;
-    }
-
-    /**
-     *
-     *
-     */
-    int rowStride() {
-        return rowStride;
-    }
-
-    /**
-     *
-     *
-     */
-    int columnStride() {
-        return colStride;
-    }
-
-    /**
-     *
-     *
-     */
-    private int getSize() {
-        if (rowStride != 0 && colStride != 0) {
-            int n1 = (parent.rowSize() - row) / rowStride;
-            int n2 = (parent.columnSize() - col) / colStride;
-
-            return Math.min(n1, n2);
-        }
-        else if (rowStride > 0)
-            return (parent.rowSize() - row) / rowStride;
-        else
-            return (parent.columnSize() - col) / colStride;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return size;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int i) {
-        return parent.get(row + i * rowStride, col + i * colStride);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int i, double v) {
-        parent.set(row + i * rowStride, col + i * colStride, v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return parent.isSequentialAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return parent.isDense();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return parent.isRandomAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return parent.isDistributed();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(parent);
-        out.writeInt(row);
-        out.writeInt(col);
-        out.writeInt(rowStride);
-        out.writeInt(colStride);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        parent = (Matrix)in.readObject();
-        row = in.readInt();
-        col = in.readInt();
-        rowStride = in.readInt();
-        colStride = in.readInt();
-
-        size = getSize();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/PivotedVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/PivotedVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/PivotedVectorStorage.java
deleted file mode 100644
index f69e959..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/PivotedVectorStorage.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Arrays;
-import org.apache.ignite.math.VectorStorage;
-
-/**
- * Pivoted (index mapped) view over another vector storage implementation.
- */
-public class PivotedVectorStorage implements VectorStorage {
-    /** */ private VectorStorage sto;
-
-    /** */ private int[] pivot;
-    /** */ private int[] unpivot;
-
-    /**
-     * @param pivot Pivot array.
-     */
-    private static int[] reverse(int[] pivot) {
-        int[] res = new int[pivot.length];
-
-        for (int i = 0; i < pivot.length; i++)
-            res[pivot[i]] = i;
-
-        return res;
-    }
-
-    /**
-     *
-     *
-     */
-    public int[] pivot() {
-        return pivot;
-    }
-
-    /**
-     *
-     *
-     */
-    public int[] unpivot() {
-        return unpivot;
-    }
-
-    /**
-     * @param sto Backing vector storage.
-     * @param pivot Mapping from external index to internal.
-     * @param unpivot Mapping from internal index to external.
-     */
-    public PivotedVectorStorage(VectorStorage sto, int[] pivot, int[] unpivot) {
-        assert sto != null;
-        assert pivot != null;
-        assert unpivot != null;
-
-        this.sto = sto;
-        this.pivot = pivot;
-        this.unpivot = unpivot;
-    }
-
-    /**
-     * @param sto Backing vector storage.
-     * @param pivot Mapping from external index to internal.
-     */
-    public PivotedVectorStorage(VectorStorage sto, int[] pivot) {
-        this(sto, pivot, reverse(pivot));
-    }
-
-    /**
-     *
-     */
-    public PivotedVectorStorage() {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return sto.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int i) {
-        return sto.get(pivot[i]);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int i, double v) {
-        sto.set(pivot[i], v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(sto);
-        out.writeObject(pivot);
-        out.writeObject(unpivot);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        sto = (VectorStorage)in.readObject();
-        pivot = (int[])in.readObject();
-        unpivot = (int[])in.readObject();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return sto.isSequentialAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return sto.isDense();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return sto.isRandomAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return sto.isDistributed();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return sto.isArrayBased();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double[] data() {
-        return isArrayBased() ? sto.data() : null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        PivotedVectorStorage that = (PivotedVectorStorage)o;
-
-        return (sto != null ? sto.equals(that.sto) : that.sto == null) && Arrays.equals(pivot, that.pivot)
-            && Arrays.equals(unpivot, that.unpivot);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = sto != null ? sto.hashCode() : 0;
-
-        res = 31 * res + Arrays.hashCode(pivot);
-        res = 31 * res + Arrays.hashCode(unpivot);
-
-        return res;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/RandomVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/RandomVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/RandomVectorStorage.java
deleted file mode 100644
index 58f0fb4..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/RandomVectorStorage.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.nio.ByteBuffer;
-import java.util.Random;
-import org.apache.ignite.math.MurmurHash;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-
-/**
- * {@link VectorStorage} implementation with random values in the vector elements.
- */
-public class RandomVectorStorage implements VectorStorage {
-    /** */
-    private static final long SCALE = 1L << 32;
-    /** */
-    private static final int PRIME = 104047;
-
-    /** Random generation seed. */
-    private int seed;
-
-    /** Vector size. */
-    private int size;
-
-    /** Whether fast hash is used, in {@link #get(int)}. */
-    private boolean fastHash;
-
-    /** */
-    public RandomVectorStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param size Size of the storage.
-     * @param fastHash Whether or not to use fast hashing or Murmur hashing.
-     */
-    public RandomVectorStorage(int size, boolean fastHash) {
-        assert size > 0;
-
-        this.size = size;
-        this.fastHash = fastHash;
-
-        seed = new Random().nextInt();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return size;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int i) {
-        if (!fastHash) {
-            ByteBuffer buf = ByteBuffer.allocate(4);
-
-            buf.putInt(i);
-            buf.flip();
-
-            return (MurmurHash.hash64A(buf, seed) & (SCALE - 1)) / (double)SCALE;
-        }
-        else
-            // This isn't a fantastic random number generator, but it is just fine for random projections.
-            return (((i * PRIME) & 8) * 0.25) - 1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int i, double v) {
-        throw new UnsupportedOperationException("Random vector storage is a read-only storage.");
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(size);
-        out.writeInt(seed);
-        out.writeBoolean(fastHash);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        size = in.readInt();
-        seed = in.readInt();
-        fastHash = in.readBoolean();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-
-        res = res * 37 + Boolean.hashCode(fastHash);
-        res = res * 37 + seed;
-        res = res * 37 + size;
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        RandomVectorStorage that = (RandomVectorStorage)o;
-
-        return size == that.size && seed == that.seed && fastHash == that.fastHash;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SingleElementVectorDelegateStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
deleted file mode 100644
index c5a4350..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-
-/**
- * Single value view storage over another vector.
- */
-public class SingleElementVectorDelegateStorage implements VectorStorage {
-    /** */ private int idx;
-    /** */ private Vector vec;
-
-    /**
-     *
-     */
-    public SingleElementVectorDelegateStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param vec Parent vector.
-     * @param idx Element index.
-     */
-    public SingleElementVectorDelegateStorage(Vector vec, int idx) {
-        assert vec != null;
-        assert idx >= 0;
-
-        this.vec = vec;
-        this.idx = idx;
-    }
-
-    /**
-     *
-     *
-     */
-    public int index() {
-        return idx;
-    }
-
-    /**
-     *
-     *
-     */
-    public Vector delegate() {
-        return vec;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return vec.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int i) {
-        return i == idx ? vec.get(i) : 0.0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int i, double v) {
-        if (i == idx)
-            vec.set(i, v);
-        else
-            throw new UnsupportedOperationException("Can't set element outside of index: " + idx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(vec);
-        out.writeInt(idx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        vec = (Vector)in.readObject();
-        idx = in.readInt();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        SingleElementVectorDelegateStorage that = (SingleElementVectorDelegateStorage)o;
-
-        return idx == that.idx && (vec != null ? vec.equals(that.vec) : that.vec == null);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = idx;
-
-        res = 31 * res + (vec != null ? vec.hashCode() : 0);
-
-        return res;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SingleElementVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SingleElementVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SingleElementVectorStorage.java
deleted file mode 100644
index 3378817..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SingleElementVectorStorage.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-
-/**
- * Vector storage holding a single non-zero value at some index.
- */
-public class SingleElementVectorStorage implements VectorStorage {
-    /** */ private int idx;
-    /** */ private double val;
-    /** */ private int size;
-
-    /**
-     *
-     */
-    public SingleElementVectorStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param size Parent vector size.
-     * @param idx Element index in the parent vector.
-     * @param val Value of the element.
-     */
-    public SingleElementVectorStorage(int size, int idx, double val) {
-        assert size > 0;
-        assert idx >= 0;
-
-        this.size = size;
-        this.idx = idx;
-        this.val = val;
-    }
-
-    /**
-     *
-     * @return Index of the element in the parent vector.
-     */
-    public int index() {
-        return idx;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return size;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int i) {
-        return i == idx ? val : 0.0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int i, double v) {
-        if (i == idx)
-            val = v;
-        else
-            throw new UnsupportedOperationException("Can't set element outside of index: " + idx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(size);
-        out.writeInt(idx);
-        out.writeDouble(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        size = in.readInt();
-        idx = in.readInt();
-        val = in.readDouble();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        SingleElementVectorStorage that = (SingleElementVectorStorage)o;
-
-        return idx == that.idx && Double.compare(that.val, val) == 0 && size == that.size;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = idx;
-        long temp = Double.doubleToLongBits(val);
-
-        res = 31 * res + (int)(temp ^ (temp >>> 32));
-        res = 31 * res + size;
-
-        return res;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
deleted file mode 100644
index 9b912cb..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.nio.ByteBuffer;
-import org.apache.ignite.internal.util.offheap.GridOffHeapMap;
-import org.apache.ignite.internal.util.offheap.GridOffHeapMapFactory;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-
-/**
- * {@link VectorStorage} implementation for {@link org.apache.ignite.math.impls.vector.SparseLocalOffHeapVector}.
- */
-public class SparseLocalOffHeapVectorStorage implements VectorStorage {
-    /** Assume 10% density. */
-    private static final int INIT_DENSITY = 10;
-    /** Storage capacity. */
-    private int size;
-    /** Local off heap map. */
-    private GridOffHeapMap gridOffHeapMap;
-
-    /** */
-    public SparseLocalOffHeapVectorStorage() {
-        //No-op.
-    }
-
-    /** */
-    public SparseLocalOffHeapVectorStorage(int cap) {
-        assert cap > 0;
-
-        gridOffHeapMap = GridOffHeapMapFactory.unsafeMap(cap / INIT_DENSITY);
-        size = cap;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return size;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int i) {
-        byte[] bytes = gridOffHeapMap.get(hash(i), intToByteArray(i));
-        return bytes == null ? 0 : ByteBuffer.wrap(bytes).getDouble();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int i, double v) {
-        if (v != 0.0)
-            gridOffHeapMap.put(hash(i), intToByteArray(i), doubleToByteArray(v));
-        else if (gridOffHeapMap.contains(hash(i), intToByteArray(i)))
-            gridOffHeapMap.remove(hash(i), intToByteArray(i));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        throw new UnsupportedOperationException(); // TODO: add externalization support.
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void destroy() {
-        gridOffHeapMap.destruct();
-    }
-
-    /** */
-    private int hash(int h) {
-        // Apply base step of MurmurHash; see http://code.google.com/p/smhasher/
-        // Despite two multiplies, this is often faster than others
-        // with comparable bit-spread properties.
-        h ^= h >>> 16;
-        h *= 0x85ebca6b;
-        h ^= h >>> 13;
-        h *= 0xc2b2ae35;
-
-        return (h >>> 16) ^ h;
-    }
-
-    /** */
-    private byte[] intToByteArray(int val) {
-        return new byte[] {
-            (byte)(val >>> 24),
-            (byte)(val >>> 16),
-            (byte)(val >>> 8),
-            (byte)val};
-    }
-
-    /** */
-    private byte[] doubleToByteArray(double val) {
-        long l = Double.doubleToRawLongBits(val);
-        return new byte[] {
-            (byte)((l >> 56) & 0xff),
-            (byte)((l >> 48) & 0xff),
-            (byte)((l >> 40) & 0xff),
-            (byte)((l >> 32) & 0xff),
-            (byte)((l >> 24) & 0xff),
-            (byte)((l >> 16) & 0xff),
-            (byte)((l >> 8) & 0xff),
-            (byte)((l) & 0xff),
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
deleted file mode 100644
index b3a8a3c..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.vector;
-
-import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
-import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Map;
-import org.apache.ignite.math.StorageConstants;
-import org.apache.ignite.math.VectorStorage;
-
-/**
- * Sparse, local, on-heap vector storage.
- */
-public class SparseLocalOnHeapVectorStorage implements VectorStorage, StorageConstants {
-    /** */ private int size;
-    /** */ private int acsMode;
-
-    /** Actual map storage. */
-    private Map<Integer, Double> sto;
-
-    /**
-     *
-     */
-    public SparseLocalOnHeapVectorStorage() {
-        // No-op.
-    }
-
-    /**
-     * @param size Vector size.
-     * @param acsMode Access mode.
-     */
-    public SparseLocalOnHeapVectorStorage(int size, int acsMode) {
-        assert size > 0;
-        assertAccessMode(acsMode);
-
-        this.size = size;
-        this.acsMode = acsMode;
-
-        if (acsMode == SEQUENTIAL_ACCESS_MODE)
-            sto = new Int2DoubleRBTreeMap();
-        else
-            sto = new Int2DoubleOpenHashMap();
-    }
-
-    /**
-     *
-     *
-     */
-    public int getAccessMode() {
-        return acsMode;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return size;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int i) {
-        return sto.getOrDefault(i, 0.0);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void set(int i, double v) {
-        if (v != 0.0)
-            sto.put(i, v);
-        else if (sto.containsKey(i))
-            sto.remove(i);
-
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(size);
-        out.writeInt(acsMode);
-        out.writeObject(sto);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings({"unchecked"})
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        size = in.readInt();
-        acsMode = in.readInt();
-        sto = (Map<Integer, Double>)in.readObject();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return acsMode == SEQUENTIAL_ACCESS_MODE;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        SparseLocalOnHeapVectorStorage that = (SparseLocalOnHeapVectorStorage)o;
-
-        return size == that.size && acsMode == that.acsMode && (sto != null ? sto.equals(that.sto) : that.sto == null);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = size;
-
-        res = 31 * res + acsMode;
-        res = 31 * res + (sto != null ? sto.hashCode() : 0);
-
-        return res;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/package-info.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/package-info.java
deleted file mode 100644
index a716e6a..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/storage/vector/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Contains specific implementations for vector storage models.
- */
-package org.apache.ignite.math.impls.storage.vector;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/AbstractReadOnlyVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/AbstractReadOnlyVector.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/AbstractReadOnlyVector.java
deleted file mode 100644
index 58c583a..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/AbstractReadOnlyVector.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.apache.ignite.math.impls.vector;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.functions.IgniteBiFunction;
-import org.apache.ignite.math.functions.IgniteDoubleFunction;
-import org.apache.ignite.math.impls.matrix.FunctionMatrix;
-
-/**
- * This class provides a helper implementation of the read-only implementation of {@link Vector}
- * interface to minimize the effort required to implement it.
- * Subclasses may override some of the implemented methods if a more
- * specific or optimized implementation is desirable.
- */
-public abstract class AbstractReadOnlyVector extends AbstractVector {
-    /** */
-    public AbstractReadOnlyVector() {
-        // No-op.
-    }
-
-    /**
-     * @param sto Storage.
-     */
-    public AbstractReadOnlyVector(VectorStorage sto) {
-        super(true, sto);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix cross(Vector vec) {
-        return new FunctionMatrix(size(), vec.size(),
-            (row, col) -> vec.get(col) * get(row));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix toMatrix(boolean rowLike) {
-        return new FunctionMatrix(rowLike ? 1 : size(), rowLike ? size() : 1,
-            (row, col) -> rowLike ? get(col) : get(row));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix toMatrixPlusOne(boolean rowLike, double zeroVal) {
-        return new FunctionMatrix(rowLike ? 1 : size() + 1, rowLike ? size() + 1 : 1, (row, col) -> {
-            if (row == 0 && col == 0)
-                return zeroVal;
-
-            return rowLike ? get(col - 1) : get(row - 1);
-        });
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector copy() {
-        return this; // This exploits read-only feature of this type vector.
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector logNormalize() {
-        return logNormalize(2.0, Math.sqrt(getLengthSquared()));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector logNormalize(double power) {
-        return logNormalize(power, kNorm(power));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector map(IgniteDoubleFunction<Double> fun) {
-        return new FunctionVector(size(), (i) -> fun.apply(get(i)));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector map(Vector vec, IgniteBiFunction<Double, Double, Double> fun) {
-        checkCardinality(vec);
-
-        return new FunctionVector(size(), (i) -> fun.apply(get(i), vec.get(i)));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector map(IgniteBiFunction<Double, Double, Double> fun, double y) {
-        return new FunctionVector(size(), (i) -> fun.apply(get(i), y));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector divide(double x) {
-        if (x == 1.0)
-            return this;
-
-        return new FunctionVector(size(), (i) -> get(i) / x);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector times(double x) {
-        return x == 0 ? new ConstantVector(size(), 0) : new FunctionVector(size(), (i) -> get(i) * x);
-    }
-
-    /**
-     * @param power Power.
-     * @param normLen Normalized length.
-     * @return logNormalized value.
-     */
-    private Vector logNormalize(double power, double normLen) {
-        assert !(Double.isInfinite(power) || power <= 1.0);
-
-        double denominator = normLen * Math.log(power);
-
-        return new FunctionVector(size(), (idx) -> Math.log1p(get(idx)) / denominator);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/AbstractVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/AbstractVector.java b/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/AbstractVector.java
deleted file mode 100644
index d84c0f3..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/math/impls/vector/AbstractVector.java
+++ /dev/null
@@ -1,903 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Spliterator;
-import java.util.function.Consumer;
-import java.util.function.IntToDoubleFunction;
-import org.apache.ignite.lang.IgniteUuid;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.VectorStorage;
-import org.apache.ignite.math.exceptions.CardinalityException;
-import org.apache.ignite.math.exceptions.IndexException;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.functions.Functions;
-import org.apache.ignite.math.functions.IgniteBiFunction;
-import org.apache.ignite.math.functions.IgniteDoubleFunction;
-import org.apache.ignite.math.impls.matrix.MatrixView;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * This class provides a helper implementation of the {@link Vector}
- * interface to minimize the effort required to implement it.
- * Subclasses may override some of the implemented methods if a more
- * specific or optimized implementation is desirable.
- */
-public abstract class AbstractVector implements Vector {
-    /** Vector storage implementation. */
-    private VectorStorage sto;
-
-    /** Meta attribute storage. */
-    private Map<String, Object> meta = new HashMap<>();
-
-    /** Vector's GUID. */
-    private IgniteUuid guid = IgniteUuid.randomUuid();
-
-    /** Cached value for length squared. */
-    private double lenSq = 0.0;
-
-    /** Maximum cached element. */
-    private Element maxElm = null;
-    /** Minimum cached element. */
-    private Element minElm = null;
-
-    /** Readonly flag (false by default). */
-    private boolean readOnly = false;
-
-    /** Read-only error message. */
-    private static final String RO_MSG = "Vector is read-only.";
-
-    /**
-     *
-     */
-    private void ensureReadOnly() {
-        if (readOnly)
-            throw new UnsupportedOperationException(RO_MSG);
-    }
-
-    /**
-     * @param sto Storage.
-     */
-    public AbstractVector(VectorStorage sto) {
-        this(false, sto);
-    }
-
-    /**
-     * @param readOnly Is read only.
-     * @param sto Storage.
-     */
-    public AbstractVector(boolean readOnly, VectorStorage sto) {
-        assert sto != null;
-
-        this.readOnly = readOnly;
-        this.sto = sto;
-    }
-
-    /**
-     *
-     */
-    public AbstractVector() {
-        // No-op.
-    }
-
-    /**
-     * Set storage.
-     *
-     * @param sto Storage.
-     */
-    protected void setStorage(VectorStorage sto) {
-        this.sto = sto;
-    }
-
-    /**
-     * @param i Index.
-     * @param v Value.
-     */
-    protected void storageSet(int i, double v) {
-        ensureReadOnly();
-
-        sto.set(i, v);
-
-        // Reset cached values.
-        lenSq = 0.0;
-        maxElm = minElm = null;
-    }
-
-    /**
-     * @param i Index.
-     * @return Value.
-     */
-    protected double storageGet(int i) {
-        return sto.get(i);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return sto.size();
-    }
-
-    /**
-     * Check index bounds.
-     *
-     * @param idx Index to check.
-     */
-    protected void checkIndex(int idx) {
-        if (idx < 0 || idx >= sto.size())
-            throw new IndexException(idx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public double get(int idx) {
-        checkIndex(idx);
-
-        return storageGet(idx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public double getX(int idx) {
-        return storageGet(idx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isArrayBased() {
-        return sto.isArrayBased();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector sort() {
-        if (isArrayBased())
-            Arrays.parallelSort(sto.data());
-        else
-            throw new UnsupportedOperationException();
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector map(IgniteDoubleFunction<Double> fun) {
-        if (sto.isArrayBased()) {
-            double[] data = sto.data();
-
-            Arrays.setAll(data, (idx) -> fun.apply(data[idx]));
-        }
-        else {
-            int len = size();
-
-            for (int i = 0; i < len; i++)
-                storageSet(i, fun.apply(storageGet(i)));
-        }
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector map(Vector vec, IgniteBiFunction<Double, Double, Double> fun) {
-        checkCardinality(vec);
-
-        int len = size();
-
-        for (int i = 0; i < len; i++)
-            storageSet(i, fun.apply(storageGet(i), vec.get(i)));
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector map(IgniteBiFunction<Double, Double, Double> fun, double y) {
-        int len = size();
-
-        for (int i = 0; i < len; i++)
-            storageSet(i, fun.apply(storageGet(i), y));
-
-        return this;
-    }
-
-    /**
-     * @param idx Index.
-     * @return Value.
-     */
-    protected Element makeElement(int idx) {
-        checkIndex(idx);
-
-        return new Element() {
-            /** {@inheritDoc} */
-            @Override public double get() {
-                return storageGet(idx);
-            }
-
-            /** {@inheritDoc} */
-            @Override public int index() {
-                return idx;
-            }
-
-            /** {@inheritDoc} */
-            @Override public void set(double val) {
-                storageSet(idx, val);
-            }
-        };
-    }
-
-    /** {@inheritDoc} */
-    @Override public Element minElement() {
-        if (minElm == null) {
-            int minIdx = 0;
-            int len = size();
-
-            for (int i = 0; i < len; i++)
-                if (storageGet(i) < storageGet(minIdx))
-                    minIdx = i;
-
-            minElm = makeElement(minIdx);
-        }
-
-        return minElm;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Element maxElement() {
-        if (maxElm == null) {
-            int maxIdx = 0;
-            int len = size();
-
-            for (int i = 0; i < len; i++)
-                if (storageGet(i) > storageGet(maxIdx))
-                    maxIdx = i;
-
-            maxElm = makeElement(maxIdx);
-        }
-
-        return maxElm;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double minValue() {
-        return minElement().get();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double maxValue() {
-        return maxElement().get();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector set(int idx, double val) {
-        checkIndex(idx);
-
-        storageSet(idx, val);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector setX(int idx, double val) {
-        storageSet(idx, val);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector increment(int idx, double val) {
-        checkIndex(idx);
-
-        storageSet(idx, storageGet(idx) + val);
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector incrementX(int idx, double val) {
-        storageSet(idx, storageGet(idx) + val);
-
-        return this;
-    }
-
-    /**
-     * Tests if given value is considered a zero value.
-     *
-     * @param val Value to check.
-     */
-    protected boolean isZero(double val) {
-        return val == 0.0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double sum() {
-        double sum = 0;
-        int len = size();
-
-        for (int i = 0; i < len; i++)
-            sum += storageGet(i);
-
-        return sum;
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteUuid guid() {
-        return guid;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Iterable<Element> all() {
-        return new Iterable<Element>() {
-            private int idx = 0;
-
-            /** {@inheritDoc} */
-            @NotNull
-            @Override public Iterator<Element> iterator() {
-                return new Iterator<Element>() {
-                    /** {@inheritDoc} */
-                    @Override public boolean hasNext() {
-                        return size() > 0 && idx < size();
-                    }
-
-                    /** {@inheritDoc} */
-                    @Override public Element next() {
-                        if (hasNext())
-                            return getElement(idx++);
-
-                        throw new NoSuchElementException();
-                    }
-                };
-            }
-        };
-    }
-
-    /** {@inheritDoc} */
-    @Override public int nonZeroElements() {
-        int cnt = 0;
-
-        for (Element ignored : nonZeroes())
-            cnt++;
-
-        return cnt;
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> T foldMap(IgniteBiFunction<T, Double, T> foldFun, IgniteDoubleFunction<Double> mapFun,
-        T zeroVal) {
-        T res = zeroVal;
-        int len = size();
-
-        for (int i = 0; i < len; i++)
-            res = foldFun.apply(res, mapFun.apply(storageGet(i)));
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> T foldMap(Vector vec, IgniteBiFunction<T, Double, T> foldFun,
-        IgniteBiFunction<Double, Double, Double> combFun, T zeroVal) {
-        checkCardinality(vec);
-
-        T res = zeroVal;
-        int len = size();
-
-        for (int i = 0; i < len; i++)
-            res = foldFun.apply(res, combFun.apply(storageGet(i), vec.getX(i)));
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Iterable<Element> nonZeroes() {
-        return new Iterable<Element>() {
-            private int idx = 0;
-            private int idxNext = -1;
-
-            /** {@inheritDoc} */
-            @NotNull
-            @Override public Iterator<Element> iterator() {
-                return new Iterator<Element>() {
-                    @Override public boolean hasNext() {
-                        findNext();
-
-                        return !over();
-                    }
-
-                    @Override public Element next() {
-                        if (hasNext()) {
-                            idx = idxNext;
-
-                            return getElement(idxNext);
-                        }
-
-                        throw new NoSuchElementException();
-                    }
-
-                    private void findNext() {
-                        if (over())
-                            return;
-
-                        if (idxNextInitialized() && idx != idxNext)
-                            return;
-
-                        if (idxNextInitialized())
-                            idx = idxNext + 1;
-
-                        while (idx < size() && isZero(get(idx)))
-                            idx++;
-
-                        idxNext = idx++;
-                    }
-
-                    private boolean over() {
-                        return idxNext >= size();
-                    }
-
-                    private boolean idxNextInitialized() {
-                        return idxNext != -1;
-                    }
-                };
-            }
-        };
-    }
-
-    /** {@inheritDoc} */
-    @Override public Map<String, Object> getMetaStorage() {
-        return meta;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector assign(double val) {
-        if (sto.isArrayBased()) {
-            ensureReadOnly();
-
-            Arrays.fill(sto.data(), val);
-        }
-        else {
-            int len = size();
-
-            for (int i = 0; i < len; i++)
-                storageSet(i, val);
-        }
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector assign(double[] vals) {
-        checkCardinality(vals);
-
-        if (sto.isArrayBased()) {
-            ensureReadOnly();
-
-            System.arraycopy(vals, 0, sto.data(), 0, vals.length);
-
-            lenSq = 0.0;
-        }
-        else {
-            int len = size();
-
-            for (int i = 0; i < len; i++)
-                storageSet(i, vals[i]);
-        }
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector assign(Vector vec) {
-        checkCardinality(vec);
-
-        for (Vector.Element x : vec.all())
-            storageSet(x.index(), x.get());
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector assign(IntToDoubleFunction fun) {
-        assert fun != null;
-
-        if (sto.isArrayBased()) {
-            ensureReadOnly();
-
-            Arrays.setAll(sto.data(), fun);
-        }
-        else {
-            int len = size();
-
-            for (int i = 0; i < len; i++)
-                storageSet(i, fun.applyAsDouble(i));
-        }
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Spliterator<Double> allSpliterator() {
-        return new Spliterator<Double>() {
-            /** {@inheritDoc} */
-            @Override public boolean tryAdvance(Consumer<? super Double> act) {
-                int len = size();
-
-                for (int i = 0; i < len; i++)
-                    act.accept(storageGet(i));
-
-                return true;
-            }
-
-            /** {@inheritDoc} */
-            @Override public Spliterator<Double> trySplit() {
-                return null; // No Splitting.
-            }
-
-            /** {@inheritDoc} */
-            @Override public long estimateSize() {
-                return size();
-            }
-
-            /** {@inheritDoc} */
-            @Override public int characteristics() {
-                return ORDERED | SIZED;
-            }
-        };
-    }
-
-    /** {@inheritDoc} */
-    @Override public Spliterator<Double> nonZeroSpliterator() {
-        return new Spliterator<Double>() {
-            /** {@inheritDoc} */
-            @Override public boolean tryAdvance(Consumer<? super Double> act) {
-                int len = size();
-
-                for (int i = 0; i < len; i++) {
-                    double val = storageGet(i);
-
-                    if (!isZero(val))
-                        act.accept(val);
-                }
-
-                return true;
-            }
-
-            /** {@inheritDoc} */
-            @Override public Spliterator<Double> trySplit() {
-                return null; // No Splitting.
-            }
-
-            /** {@inheritDoc} */
-            @Override public long estimateSize() {
-                return nonZeroElements();
-            }
-
-            /** {@inheritDoc} */
-            @Override public int characteristics() {
-                return ORDERED | SIZED;
-            }
-        };
-    }
-
-    /** {@inheritDoc} */
-    @Override public double dot(Vector vec) {
-        checkCardinality(vec);
-
-        double sum = 0.0;
-        int len = size();
-
-        for (int i = 0; i < len; i++)
-            sum += storageGet(i) * vec.getX(i);
-
-        return sum;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double getLengthSquared() {
-        if (lenSq == 0.0)
-            lenSq = dotSelf();
-
-        return lenSq;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDense() {
-        return sto.isDense();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isSequentialAccess() {
-        return sto.isSequentialAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isRandomAccess() {
-        return sto.isRandomAccess();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isDistributed() {
-        return sto.isDistributed();
-    }
-
-    /** {@inheritDoc} */
-    @Override public VectorStorage getStorage() {
-        return sto;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector viewPart(int off, int len) {
-        return new VectorView(this, off, len);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix cross(Vector vec) {
-        Matrix res = likeMatrix(size(), vec.size());
-
-        if (res == null)
-            return null;
-
-        for (Element e : nonZeroes()) {
-            int row = e.index();
-
-            res.assignRow(row, vec.times(getX(row)));
-        }
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix toMatrix(boolean rowLike) {
-        Matrix res = likeMatrix(rowLike ? 1 : size(), rowLike ? size() : 1);
-
-        if (res == null)
-            return null;
-
-        if (rowLike)
-            res.assignRow(0, this);
-        else
-            res.assignColumn(0, this);
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix toMatrixPlusOne(boolean rowLike, double zeroVal) {
-        Matrix res = likeMatrix(rowLike ? 1 : size() + 1, rowLike ? size() + 1 : 1);
-
-        if (res == null)
-            return null;
-
-        res.set(0, 0, zeroVal);
-
-        if (rowLike)
-            new MatrixView(res, 0, 1, 1, size()).assignRow(0, this);
-        else
-            new MatrixView(res, 1, 0, size(), 1).assignColumn(0, this);
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double getDistanceSquared(Vector vec) {
-        checkCardinality(vec);
-
-        double thisLenSq = getLengthSquared();
-        double thatLenSq = vec.getLengthSquared();
-        double dot = dot(vec);
-        double distEst = thisLenSq + thatLenSq - 2 * dot;
-
-        if (distEst > 1.0e-3 * (thisLenSq + thatLenSq))
-            // The vectors are far enough from each other that the formula is accurate.
-            return Math.max(distEst, 0);
-        else
-            return foldMap(vec, Functions.PLUS, Functions.MINUS_SQUARED, 0d);
-    }
-
-    /** */
-    protected void checkCardinality(Vector vec) {
-        if (vec.size() != size())
-            throw new CardinalityException(size(), vec.size());
-    }
-
-    /** */
-    protected void checkCardinality(double[] vec) {
-        if (vec.length != size())
-            throw new CardinalityException(size(), vec.length);
-    }
-
-    /** */
-    protected void checkCardinality(int[] arr) {
-        if (arr.length != size())
-            throw new CardinalityException(size(), arr.length);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector minus(Vector vec) {
-        checkCardinality(vec);
-
-        Vector cp = copy();
-
-        return cp.map(vec, Functions.MINUS);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector plus(double x) {
-        Vector cp = copy();
-
-        return x != 0.0 ? cp.map(Functions.plus(x)) : cp;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector divide(double x) {
-        Vector cp = copy();
-
-        if (x != 1.0)
-            for (Element element : cp.all())
-                element.set(element.get() / x);
-
-        return cp;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector times(double x) {
-        if (x == 0.0)
-            return like(size());
-        else
-            return copy().map(Functions.mult(x));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector times(Vector vec) {
-        checkCardinality(vec);
-
-        return copy().map(vec, Functions.MULT);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector plus(Vector vec) {
-        checkCardinality(vec);
-
-        Vector cp = copy();
-
-        return cp.map(vec, Functions.PLUS);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector logNormalize() {
-        return logNormalize(2.0, Math.sqrt(getLengthSquared()));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector logNormalize(double power) {
-        return logNormalize(power, kNorm(power));
-    }
-
-    /**
-     * @param power Power.
-     * @param normLen Normalized length.
-     * @return logNormalized value.
-     */
-    private Vector logNormalize(double power, double normLen) {
-        assert !(Double.isInfinite(power) || power <= 1.0);
-
-        double denominator = normLen * Math.log(power);
-
-        Vector cp = copy();
-
-        for (Element element : cp.all())
-            element.set(Math.log1p(element.get()) / denominator);
-
-        return cp;
-    }
-
-    /** {@inheritDoc} */
-    @Override public double kNorm(double power) {
-        assert power >= 0.0;
-
-        // Special cases.
-        if (Double.isInfinite(power))
-            return foldMap(Math::max, Math::abs, 0d);
-        else if (power == 2.0)
-            return Math.sqrt(getLengthSquared());
-        else if (power == 1.0)
-            return foldMap(Functions.PLUS, Math::abs, 0d);
-        else if (power == 0.0)
-            return nonZeroElements();
-        else
-            // Default case.
-            return Math.pow(foldMap(Functions.PLUS, Functions.pow(power), 0d), 1.0 / power);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector normalize() {
-        return divide(Math.sqrt(getLengthSquared()));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector normalize(double power) {
-        return divide(kNorm(power));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector copy() {
-        return like(size()).assign(this);
-    }
-
-    /**
-     * @return Result of dot with self.
-     */
-    protected double dotSelf() {
-        double sum = 0.0;
-        int len = size();
-
-        for (int i = 0; i < len; i++) {
-            double v = storageGet(i);
-
-            sum += v * v;
-        }
-
-        return sum;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Element getElement(int idx) {
-        return makeElement(idx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(sto);
-        out.writeObject(meta);
-        out.writeObject(guid);
-        out.writeBoolean(readOnly);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        sto = (VectorStorage)in.readObject();
-        meta = (Map<String, Object>)in.readObject();
-        guid = (IgniteUuid)in.readObject();
-        readOnly = in.readBoolean();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void destroy() {
-        sto.destroy();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int res = 1;
-        res += res * 37 + guid.hashCode();
-        res += sto == null ? 0 : res * 37 + sto.hashCode();
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-
-        if (obj == null || getClass() != obj.getClass())
-            return false;
-
-        AbstractVector that = (AbstractVector)obj;
-
-        return (sto != null ? sto.equals(that.sto) : that.sto == null);
-    }
-}


[40/65] [abbrv] ignite git commit: IGNITE-4952 - Delete swap-related functionality - Fixes #1794.

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 87b0d00..8296945 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -722,53 +722,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         }
     }
 
-    /** {@inheritDoc} */
-    @Override public void onSwap(@Nullable String spaceName, KeyCacheObject key,
-        int partId) throws IgniteCheckedException {
-        Schema schema = schemas.get(schema(spaceName));
-
-        if (schema == null)
-            return;
-
-        Class<?> keyCls = getClass(objectContext(spaceName), key);
-
-        for (TableDescriptor tbl : schema.tbls.values()) {
-            if (tbl.type().keyClass().isAssignableFrom(keyCls)) {
-                try {
-                    if (tbl.tbl.onSwap(key, partId))
-                        return;
-                }
-                catch (IgniteCheckedException e) {
-                    throw new IgniteCheckedException(e);
-                }
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onUnswap(@Nullable String spaceName, KeyCacheObject key, int partId, CacheObject val)
-        throws IgniteCheckedException {
-        assert val != null;
-
-        CacheObjectContext coctx = objectContext(spaceName);
-
-        Class<?> keyCls = getClass(coctx, key);
-        Class<?> valCls = getClass(coctx, val);
-
-        for (TableDescriptor tbl : tables(schema(spaceName))) {
-            if (tbl.type().keyClass().isAssignableFrom(keyCls)
-                && tbl.type().valueClass().isAssignableFrom(valCls)) {
-                try {
-                    if (tbl.tbl.onUnswap(key, partId, val))
-                        return;
-                }
-                catch (IgniteCheckedException e) {
-                    throw new IgniteCheckedException(e);
-                }
-            }
-        }
-    }
-
     /**
      * Drops table form h2 database and clear all related indexes (h2 text, lucene).
      *
@@ -3532,9 +3485,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         private final GridUnsafeGuard guard;
 
         /** */
-        private final boolean preferSwapVal;
-
-        /** */
         private final boolean snapshotableIdx;
 
         /** */
@@ -3579,10 +3529,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
                 props[i] = p;
             }
 
-            // TODO GG-10884.
-//            preferSwapVal = schema.ccfg.getMemoryMode() == CacheMemoryMode.OFFHEAP_TIERED;
-            preferSwapVal = true;
-
             // Index is not snapshotable in db-x.
             snapshotableIdx = false;
         }
@@ -3733,14 +3679,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         }
 
         /** {@inheritDoc} */
-        @SuppressWarnings("unchecked")
-        @Override public Object readFromSwap(Object key) throws IgniteCheckedException {
-            assert false : "'readFromSwap' to be removed";
-
-            return null;
-        }
-
-        /** {@inheritDoc} */
         @Override public int valueType() {
             return valType;
         }
@@ -3799,11 +3737,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         }
 
         /** {@inheritDoc} */
-        @Override public boolean preferSwapValue() {
-            return preferSwapVal;
-        }
-
-        /** {@inheritDoc} */
         @Override public boolean snapshotableIndex() {
             return snapshotableIdx;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
index e9970af..28dd891 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
@@ -111,33 +111,6 @@ public abstract class GridH2AbstractKeyValueRow extends GridH2Row {
     }
 
     /**
-     * Should be called to remove reference on value.
-     *
-     * @throws IgniteCheckedException If failed.
-     */
-    public synchronized void onSwap() throws IgniteCheckedException {
-        setValue(VAL_COL, null);
-    }
-
-    /**
-     * Should be called when entry getting unswapped.
-     *
-     * @param val Value.
-     * @param beforeRmv If this is unswap before remove.
-     * @throws IgniteCheckedException If failed.
-     */
-    public synchronized void onUnswap(Object val, boolean beforeRmv) throws IgniteCheckedException {
-        Value val0 = peekValue(VAL_COL);
-
-        if (val0 != null && !(val0 instanceof WeakValue))
-            return;
-
-        setValue(VAL_COL, desc.wrap(val, desc.valueType()));
-
-        notifyAll();
-    }
-
-    /**
      * Atomically updates weak value.
      *
      * @param valObj New value.
@@ -209,68 +182,8 @@ public abstract class GridH2AbstractKeyValueRow extends GridH2Row {
         if (col < DEFAULT_COLUMNS_COUNT) {
             Value v;
 
-            if (col == VAL_COL) {
+            if (col == VAL_COL)
                 v = peekValue(VAL_COL);
-
-                long start = 0;
-                int attempt = 0;
-
-                while ((v = WeakValue.unwrap(v)) == null) {
-                    if (!desc.preferSwapValue()) {
-                        v = getOffheapValue(VAL_COL);
-
-                        if (v != null) {
-                            setValue(VAL_COL, v);
-
-                            if (peekValue(KEY_COL) == null)
-                                cache();
-
-                            return v;
-                        }
-                    }
-
-                    Object k = getValue(KEY_COL).getObject();
-
-                    try {
-                        Object valObj = desc.readFromSwap(k);
-
-                        if (valObj != null) {
-                            // Even if we've found valObj in swap, it is may be some new value,
-                            // while the needed value was already unswapped, so we have to recheck it.
-                            if ((v = getOffheapValue(VAL_COL)) == null)
-                                return updateWeakValue(valObj);
-                        }
-                        else {
-                            // If nothing found in swap then we should be already unswapped.
-                            if (desc.preferSwapValue()) {
-                                v = getOffheapValue(VAL_COL);
-
-                                if (v != null) {
-                                    setValue(VAL_COL, v);
-
-                                    if (peekValue(KEY_COL) == null)
-                                        cache();
-
-                                    return v;
-                                }
-                            }
-
-                            v = syncValue(attempt);
-                        }
-                    }
-                    catch (IgniteCheckedException e) {
-                        throw new IgniteException(e);
-                    }
-
-                    attempt++;
-
-                    if (start == 0)
-                        start = U.currentTimeMillis();
-                    else if (U.currentTimeMillis() - start > 60_000) // Loop for at most 60 seconds.
-                        throw new IgniteException("Failed to get value for key: " + k +
-                            ". This can happen due to a long GC pause.");
-                }
-            }
             else {
                 assert col == KEY_COL : col;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
index 78ba2e2..fd310ce 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
@@ -187,34 +187,6 @@ public class GridH2KeyValueRowOffheap extends GridH2AbstractKeyValueRow {
     }
 
     /** {@inheritDoc} */
-    @Override public synchronized void onSwap() throws IgniteCheckedException {
-        Lock l = lock(ptr);
-
-        try {
-            final long p = ptr + OFFSET_VALUE_REF;
-
-            final GridUnsafeMemory mem = desc.memory();
-
-            final long valPtr = mem.readLongVolatile(p);
-
-            if (valPtr <= 0)
-                throw new IllegalStateException("Already swapped: " + ptr);
-
-            if (!mem.casLong(p, valPtr, 0))
-                throw new IllegalStateException("Concurrent unswap: " + ptr);
-
-            desc.guard().finalizeLater(new Runnable() {
-                @Override public void run() {
-                    mem.release(valPtr, mem.readInt(valPtr) + OFFSET_VALUE);
-                }
-            });
-        }
-        finally {
-            l.unlock();
-        }
-    }
-
-    /** {@inheritDoc} */
     @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod")
     @Override protected synchronized Value updateWeakValue(Object valObj) throws IgniteCheckedException {
         Value val = peekValue(VAL_COL);
@@ -232,48 +204,6 @@ public class GridH2KeyValueRowOffheap extends GridH2AbstractKeyValueRow {
     }
 
     /** {@inheritDoc} */
-    @Override public synchronized void onUnswap(Object val, boolean beforeRmv) throws IgniteCheckedException {
-        assert val != null;
-
-        final long p = ptr;
-
-        Lock l = lock(p);
-
-        try {
-            GridUnsafeMemory mem = desc.memory();
-
-            if (mem.readLongVolatile(p + OFFSET_VALUE_REF) != 0)
-                return; // The offheap value is in its place, nothing to do here.
-
-            Value v = peekValue(VAL_COL);
-
-            if (v == null) {
-                setValue(VAL_COL, desc.wrap(val, desc.valueType()));
-
-                v = peekValue(VAL_COL);
-            }
-
-            byte[] bytes = new byte[SIZE_CALCULATOR.getValueLen(v)];
-
-            Data data = Data.create(null, bytes);
-
-            data.writeValue(v);
-
-            long valPtr = mem.allocate(bytes.length + OFFSET_VALUE);
-
-            mem.writeInt(valPtr, bytes.length);
-            mem.writeBytes(valPtr + OFFSET_VALUE, bytes);
-
-            mem.writeLongVolatile(p + OFFSET_VALUE_REF, valPtr);
-        }
-        finally {
-            l.unlock();
-        }
-
-        notifyAll();
-    }
-
-    /** {@inheritDoc} */
     @Override protected Value syncValue(long waitTime) {
         Value v = super.syncValue(waitTime);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2RowDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2RowDescriptor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2RowDescriptor.java
index f645921..61de362 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2RowDescriptor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2RowDescriptor.java
@@ -80,12 +80,6 @@ public interface GridH2RowDescriptor extends GridOffHeapSmartPointerFactory<Grid
      */
     public GridH2Row cachedRow(long link);
 
-    /**
-     * @param key Cache key.
-     * @return Value.
-     * @throws IgniteCheckedException If failed.
-     */
-    public Object readFromSwap(Object key) throws IgniteCheckedException;
 
     /**
      * @return Value type.
@@ -164,11 +158,6 @@ public interface GridH2RowDescriptor extends GridOffHeapSmartPointerFactory<Grid
     public Value wrap(Object o, int type) throws IgniteCheckedException;
 
     /**
-     * @return {@code True} if should check swap value before offheap.
-     */
-    public boolean preferSwapValue();
-
-    /**
      * @return {@code True} if index should support snapshots.
      */
     public boolean snapshotableIndex();

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
index a9c1a20..c07dce4 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
@@ -187,79 +187,6 @@ public class GridH2Table extends TableBase {
     }
 
     /**
-     * Should be called when entry is swapped.
-     *
-     * @param key Entry key.
-     * @return {@code true} If row was found.
-     * @throws IgniteCheckedException If failed.
-     */
-    public boolean onSwap(KeyCacheObject key, int partId) throws IgniteCheckedException {
-        return onSwapUnswap(key, partId, null);
-    }
-
-    /**
-     * Should be called when entry is unswapped.
-     *
-     * @param key Key.
-     * @param val Value.
-     * @return {@code true} If row was found.
-     * @throws IgniteCheckedException If failed.
-     */
-    public boolean onUnswap(KeyCacheObject key, int partId, CacheObject val) throws IgniteCheckedException {
-        assert val != null : "Key=" + key;
-
-        return onSwapUnswap(key, partId, val);
-    }
-
-    /**
-     * Swaps or unswaps row.
-     *
-     * @param key Key.
-     * @param val Value for promote or {@code null} if we have to swap.
-     * @return {@code true} if row was found and swapped/unswapped.
-     * @throws IgniteCheckedException If failed.
-     */
-    @SuppressWarnings("LockAcquiredButNotSafelyReleased")
-    private boolean onSwapUnswap(KeyCacheObject key, int partId, @Nullable CacheObject val) throws IgniteCheckedException {
-        assert key != null;
-
-        GridH2IndexBase pk = pk();
-
-        assert desc != null;
-
-        GridH2Row searchRow = desc.createRow(key, partId, null, null, 0);
-
-        GridUnsafeMemory mem = desc.memory();
-
-        lock(false);
-
-        if (mem != null)
-            desc.guard().begin();
-
-        try {
-            ensureNotDestroyed();
-
-            GridH2AbstractKeyValueRow row = (GridH2AbstractKeyValueRow)pk.findOne(searchRow);
-
-            if (row == null)
-                return false;
-
-            if (val == null)
-                row.onSwap();
-            else
-                row.onUnswap(val, false);
-
-            return true;
-        }
-        finally {
-            unlock(false);
-
-            if (mem != null)
-                desc.guard().end();
-        }
-    }
-
-    /**
      * @return Space name.
      */
     @Nullable public String spaceName() {
@@ -621,12 +548,7 @@ public class GridH2Table extends TableBase {
 
                 GridH2Row old = pk.put(row); // Put to PK.
 
-                if (old instanceof GridH2AbstractKeyValueRow) { // Unswap value on replace.
-                    GridH2AbstractKeyValueRow kvOld = (GridH2AbstractKeyValueRow)old;
-
-                    kvOld.onUnswap(kvOld.getValue(VAL_COL), true);
-                }
-                else if (old == null)
+                if (old == null)
                     size.increment();
 
                 int len = idxs.size();
@@ -648,13 +570,6 @@ public class GridH2Table extends TableBase {
                 //  index(1) is PK, get full row from there (search row here contains only key but no other columns).
                 GridH2Row old = pk.remove(row);
 
-                if (row.getColumnCount() != 1 && old instanceof GridH2AbstractKeyValueRow) { // Unswap value.
-                    Value v = row.getValue(VAL_COL);
-
-                    if (v != null)
-                        ((GridH2AbstractKeyValueRow)old).onUnswap(v.getObject(), true);
-                }
-
                 if (old != null) {
                     // Remove row from all indexes.
                     // Start from 3 because 0 - Scan (don't need to update), 1 - PK hash (already updated), 2 - PK (already updated).

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridBinaryDuplicateIndexObjectsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridBinaryDuplicateIndexObjectsAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridBinaryDuplicateIndexObjectsAbstractSelfTest.java
deleted file mode 100644
index e257378..0000000
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridBinaryDuplicateIndexObjectsAbstractSelfTest.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.QueryEntity;
-import org.apache.ignite.cache.QueryIndex;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.configuration.BinaryConfiguration;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
-import org.apache.ignite.binary.BinaryObject;
-
-/**
- * Tests that binary object is the same in cache entry and in index.
- */
-public abstract class GridBinaryDuplicateIndexObjectsAbstractSelfTest extends GridCacheAbstractSelfTest {
-    /** {@inheritDoc} */
-    @Override protected int gridCount() {
-        return 1;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
-        BinaryConfiguration bCfg = new BinaryConfiguration();
-
-        bCfg.setClassNames(Collections.singletonList(TestBinary.class.getName()));
-
-        cfg.setBinaryConfiguration(bCfg);
-
-        cfg.setMarshaller(new BinaryMarshaller());
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
-        CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);
-
-        ccfg.setCopyOnRead(false);
-
-        QueryEntity queryEntity = new QueryEntity(Integer.class.getName(), TestBinary.class.getName());
-
-        queryEntity.addQueryField("fieldOne", String.class.getName(), null);
-        queryEntity.addQueryField("fieldTwo", Integer.class.getName(), null);
-
-        queryEntity.setIndexes(Arrays.asList(
-            new QueryIndex("fieldOne", true),
-            new QueryIndex("fieldTwo", true)));
-
-        ccfg.setQueryEntities(Collections.singletonList(queryEntity));
-
-        return ccfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override public abstract CacheAtomicityMode atomicityMode();
-
-    /** {@inheritDoc} */
-    @Override public abstract CacheMode cacheMode();
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testIndexReferences() throws Exception {
-        IgniteCache<Integer, TestBinary> cache = grid(0).cache(null);
-
-        String fieldOneVal = "123";
-        int fieldTwoVal = 123;
-        int key = 0;
-
-        cache.put(key, new TestBinary(fieldOneVal, fieldTwoVal));
-
-        IgniteCache<Integer, BinaryObject> prj = grid(0).cache(null).withKeepBinary();
-
-        BinaryObject cacheVal = prj.get(key);
-
-        assertEquals(fieldOneVal, cacheVal.field("fieldOne"));
-        assertEquals(new Integer(fieldTwoVal), cacheVal.field("fieldTwo"));
-
-        List<?> row = F.first(prj.query(new SqlFieldsQuery("select _val from " +
-            "TestBinary where _key = ?").setArgs(key)).getAll());
-
-        assertEquals(1, row.size());
-
-        BinaryObject qryVal = (BinaryObject)row.get(0);
-
-        assertEquals(fieldOneVal, qryVal.field("fieldOne"));
-        assertEquals(new Integer(fieldTwoVal), qryVal.field("fieldTwo"));
-        assertSame(cacheVal, qryVal);
-    }
-
-    /**
-     * Test binary object.
-     */
-    private static class TestBinary {
-        /** */
-        private String fieldOne;
-
-        /** */
-        private int fieldTwo;
-
-        /**
-         *
-         */
-        private TestBinary() {
-            // No-op.
-        }
-
-        /**
-         * @param fieldOne Field one.
-         * @param fieldTwo Field two.
-         */
-        private TestBinary(String fieldOne, int fieldTwo) {
-            this.fieldOne = fieldOne;
-            this.fieldTwo = fieldTwo;
-        }
-
-        /**
-         * @return Field one.
-         */
-        public String fieldOne() {
-            return fieldOne;
-        }
-
-        /**
-         * @return Field two.
-         */
-        public int fieldTwo() {
-            return fieldTwo;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
index 148ce74..8d91a57 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
@@ -17,60 +17,36 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicInteger;
 import javax.cache.Cache;
-import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.cache.query.SqlQuery;
 import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.events.Event;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
 import static org.apache.ignite.configuration.DeploymentMode.SHARED;
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_FROM_OFFHEAP;
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_TO_OFFHEAP;
 
 /**
  * Test for cache swap.
  */
 public class GridCacheOffHeapSelfTest extends GridCommonAbstractTest {
-    /** Entry count. */
-    private static final int ENTRY_CNT = 1000;
-
-    /** Swap count. */
-    private final AtomicInteger swapCnt = new AtomicInteger();
-
-    /** Unswap count. */
-    private final AtomicInteger unswapCnt = new AtomicInteger();
-
     /** Saved versions. */
     private final Map<Integer, Object> versions = new HashMap<>();
 
     /** */
     private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
 
-    /** PeerClassLoadingLocalClassPathExclude enable. */
-    private boolean excluded;
-
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
@@ -93,10 +69,6 @@ public class GridCacheOffHeapSelfTest extends GridCommonAbstractTest {
 
         cfg.setDeploymentMode(SHARED);
 
-        if (excluded)
-            cfg.setPeerClassLoadingLocalClassPathExclude(GridCacheOffHeapSelfTest.class.getName(),
-                CacheValue.class.getName());
-
         return cfg;
     }
 
@@ -110,156 +82,6 @@ public class GridCacheOffHeapSelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
-    @SuppressWarnings("BusyWait")
-    public void testOffHeapDeployment() throws Exception {
-        try {
-            Ignite ignite1 = startGrid(1);
-
-            excluded = true;
-
-            Ignite ignite2 = startGrid(2);
-
-            IgniteCache<Integer, Object> cache1 = ignite1.cache(null);
-            IgniteCache<Integer, Object> cache2 = ignite2.cache(null);
-
-            Object v1 = new CacheValue(1);
-
-            cache1.put(1, v1);
-
-            info("Stored value in cache1 [v=" + v1 + ", ldr=" + v1.getClass().getClassLoader() + ']');
-
-            Object v2 = cache2.get(1);
-
-            assert v2 != null;
-
-            info("Read value from cache2 [v=" + v2 + ", ldr=" + v2.getClass().getClassLoader() + ']');
-
-            assert !v2.getClass().getClassLoader().equals(getClass().getClassLoader());
-            assert v2.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader");
-
-            SwapListener lsnr = new SwapListener();
-
-            ignite2.events().localListen(lsnr, EVT_CACHE_OBJECT_TO_OFFHEAP, EVT_CACHE_OBJECT_FROM_OFFHEAP);
-
-            cache2.localEvict(keySet(cache2));
-
-            assert lsnr.awaitSwap();
-
-            assert cache2.get(1) != null;
-
-            assert lsnr.awaitUnswap();
-
-            ignite2.events().stopLocalListen(lsnr);
-
-            lsnr = new SwapListener();
-
-            ignite2.events().localListen(lsnr, EVT_CACHE_OBJECT_TO_OFFHEAP, EVT_CACHE_OBJECT_FROM_OFFHEAP);
-
-            cache2.localEvict(keySet(cache2));
-
-            assert lsnr.awaitSwap();
-
-            stopGrid(1);
-
-            boolean success = false;
-
-            for (int i = 0; i < 6; i++) {
-                success = cache2.get(1) == null;
-
-                if (success)
-                    break;
-                else if (i < 2) {
-                    info("Sleeping to wait for cache clear.");
-
-                    Thread.sleep(500);
-                }
-            }
-
-            assert success;
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testOffHeap() throws Exception {
-        try {
-            startGrids(1);
-
-            grid(0).events().localListen(new IgnitePredicate<Event>() {
-                @Override public boolean apply(Event evt) {
-                    assert evt != null;
-
-                    switch (evt.type()) {
-                        case EVT_CACHE_OBJECT_TO_OFFHEAP:
-                            swapCnt.incrementAndGet();
-
-                            break;
-                        case EVT_CACHE_OBJECT_FROM_OFFHEAP:
-                            unswapCnt.incrementAndGet();
-
-                            break;
-                    }
-
-                    return true;
-                }
-            }, EVT_CACHE_OBJECT_TO_OFFHEAP, EVT_CACHE_OBJECT_FROM_OFFHEAP);
-
-            IgniteCache<Integer, CacheValue> cache = grid(0).cache(null);
-
-            populate(cache);
-            evictAll(cache);
-
-            int cnt = 0;
-
-            for (Cache.Entry<Integer, CacheValue> e : cache.localEntries(CachePeekMode.OFFHEAP)) {
-                assertEquals(e.getKey().intValue(), e.getValue().value());
-
-                cnt++;
-            }
-
-            assertEquals(ENTRY_CNT, cnt);
-
-            query(cache, 0, 200);        // Query swapped entries.
-            unswap(cache, 200, 400);     // Check 'promote' method.
-            unswapAll(cache, 400, 600);  // Check 'promoteAll' method.
-            get(cache, 600, 800);        // Check 'get' method.
-            peek(cache, 800, ENTRY_CNT); // Check 'peek' method in 'SWAP' mode.
-
-            // Check that all entries were unswapped.
-            for (int i = 0; i < ENTRY_CNT; i++) {
-                CacheValue val = cache.localPeek(i);
-
-                assert val != null;
-                assert val.value() == i;
-            }
-
-            // Query unswapped entries.
-            Collection<Cache.Entry<Integer, CacheValue>> res = cache.query(
-                new SqlQuery<Integer, CacheValue>(CacheValue.class, "val >= ? and val < ?").
-                setArgs(0, ENTRY_CNT)).
-                getAll();
-
-            assert res.size() == ENTRY_CNT;
-
-            for (Cache.Entry<Integer, CacheValue> entry : res) {
-                assert entry != null;
-                assert entry.getKey() != null;
-                assert entry.getValue() != null;
-                assert entry.getKey() == entry.getValue().value();
-            }
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
     public void testOffHeapIterator() throws Exception {
         try {
             startGrids(1);
@@ -272,8 +94,6 @@ public class GridCacheOffHeapSelfTest extends GridCommonAbstractTest {
                 info("Putting: " + i);
 
                 cache.put(i, i);
-
-                cache.localEvict(Collections.singleton(i));
             }
 
             int i = 0;
@@ -300,255 +120,6 @@ public class GridCacheOffHeapSelfTest extends GridCommonAbstractTest {
     }
 
     /**
-     * Populates cache.
-     *
-     * @param cache Cache.
-     * @throws Exception In case of error.
-     */
-    private void populate(IgniteCache<Integer, CacheValue> cache) throws Exception {
-        resetCounters();
-
-        for (int i = 0; i < ENTRY_CNT; i++) {
-            cache.put(i, new CacheValue(i));
-
-            CacheValue val = cache.localPeek(i);
-
-            assert val != null;
-            assert val.value() == i;
-
-            GridCacheEntryEx entry = dht(cache).peekEx(i);
-
-            assert entry != null;
-
-            versions.put(i, entry.version());
-        }
-
-        assert swapCnt.get() == 0;
-        assert unswapCnt.get() == 0;
-    }
-
-    /**
-     * Evicts all entries in cache.
-     *
-     * @param cache Cache.
-     * @throws Exception In case of error.
-     */
-    private void evictAll(IgniteCache<Integer, CacheValue> cache) throws Exception {
-        resetCounters();
-
-        assertEquals(ENTRY_CNT, cache.size());
-        assertEquals(0, cache.localSize(CachePeekMode.OFFHEAP));
-
-        for (int i = 0; i < ENTRY_CNT; i++) {
-            cache.localEvict(Collections.singleton(i));
-
-            assertEquals(ENTRY_CNT - i - 1, cache.localSize(CachePeekMode.ONHEAP));
-            assertEquals(i + 1, cache.localSize(CachePeekMode.OFFHEAP));
-        }
-        // cache.evictAll();
-
-        assertEquals(0, cache.localSize(CachePeekMode.ONHEAP));
-        assertEquals(ENTRY_CNT, cache.localSize(CachePeekMode.OFFHEAP));
-
-        for (int i = 0; i < ENTRY_CNT; i++)
-            assertNull(cache.localPeek(i, CachePeekMode.ONHEAP));
-
-        assertEquals(ENTRY_CNT, swapCnt.get());
-        assertEquals(0, unswapCnt.get());
-    }
-
-    /**
-     * Runs SQL query and checks result.
-     *
-     * @param cache Cache.
-     * @param lowerBound Lower key bound.
-     * @param upperBound Upper key bound.
-     * @throws Exception In case of error.
-     */
-    private void query(IgniteCache<Integer, CacheValue> cache, int lowerBound, int upperBound) throws Exception {
-        resetCounters();
-
-        Collection<Cache.Entry<Integer, CacheValue>> res = cache.query(new SqlQuery<Integer, CacheValue>(CacheValue.class, "val >= ? and val < ?").
-            setArgs(lowerBound, upperBound)).
-            getAll();
-
-        assertEquals(res.size(), upperBound - lowerBound);
-
-        for (Cache.Entry<Integer, CacheValue> entry : res) {
-            assert entry != null;
-            assert entry.getKey() != null;
-            assert entry.getValue() != null;
-            assert entry.getKey() == entry.getValue().value();
-        }
-
-        assertEquals(0, swapCnt.get());
-        assertEquals(0, unswapCnt.get());
-
-        checkEntries(cache, lowerBound, upperBound);
-
-        assertEquals(0, swapCnt.get());
-        assertEquals(unswapCnt.get(), upperBound - lowerBound);
-    }
-
-    /**
-     * Unswaps entries and checks result.
-     *
-     * @param cache Cache.
-     * @param lowerBound Lower key bound.
-     * @param upperBound Upper key bound.
-     * @throws Exception In case of error.
-     */
-    private void unswap(IgniteCache<Integer, CacheValue> cache, int lowerBound, int upperBound) throws Exception {
-        resetCounters();
-
-        assertEquals(0, swapCnt.get());
-        assertEquals(0, unswapCnt.get());
-
-        for (int i = lowerBound; i < upperBound; i++) {
-            assert cache.localPeek(i, CachePeekMode.ONHEAP) == null;
-
-            cache.localPromote(Collections.singleton(i));
-            CacheValue val = cache.localPeek(i);
-
-            assertNotNull(val);
-            assertEquals(i, val.value());
-
-            assertEquals(i - lowerBound + 1, unswapCnt.get());
-        }
-
-        assertEquals(0, swapCnt.get());
-        assertEquals(unswapCnt.get(), upperBound - lowerBound);
-
-        checkEntries(cache, lowerBound, upperBound);
-
-        assertEquals(0, swapCnt.get());
-        assertEquals(unswapCnt.get(), upperBound - lowerBound);
-    }
-
-    /**
-     * Unswaps entries and checks result.
-     *
-     * @param cache Cache.
-     * @param lowerBound Lower key bound.
-     * @param upperBound Upper key bound.
-     * @throws Exception In case of error.
-     */
-    private void unswapAll(IgniteCache<Integer, CacheValue> cache, int lowerBound, int upperBound) throws Exception {
-        resetCounters();
-
-        Set<Integer> keys = new HashSet<>();
-
-        for (int i = lowerBound; i < upperBound; i++) {
-            assert cache.localPeek(i, CachePeekMode.ONHEAP) == null;
-
-            keys.add(i);
-        }
-
-        cache.localPromote(keys);
-
-        assert swapCnt.get() == 0;
-        assert unswapCnt.get() == upperBound - lowerBound;
-
-        checkEntries(cache, lowerBound, upperBound);
-
-        assert swapCnt.get() == 0;
-        assert unswapCnt.get() == upperBound - lowerBound;
-    }
-
-    /**
-     * Unswaps entries via {@code get} method and checks result.
-     *
-     * @param cache Cache.
-     * @param lowerBound Lower key bound.
-     * @param upperBound Upper key bound.
-     * @throws Exception In case of error.
-     */
-    private void get(IgniteCache<Integer, CacheValue> cache, int lowerBound, int upperBound) throws Exception {
-        resetCounters();
-
-        for (int i = lowerBound; i < upperBound; i++) {
-            assert cache.localPeek(i, CachePeekMode.ONHEAP) == null;
-
-            CacheValue val = cache.get(i);
-
-            assert val != null;
-            assert val.value() == i;
-        }
-
-        assert swapCnt.get() == 0;
-        assert unswapCnt.get() == upperBound - lowerBound;
-
-        checkEntries(cache, lowerBound, upperBound);
-
-        assert swapCnt.get() == 0;
-        assert unswapCnt.get() == upperBound - lowerBound;
-    }
-
-    /**
-     * Peeks entries in {@code SWAP} mode and checks result.
-     *
-     * @param cache Cache.
-     * @param lowerBound Lower key bound.
-     * @param upperBound Upper key bound.
-     * @throws Exception In case of error.
-     */
-    private void peek(IgniteCache<Integer, CacheValue> cache, int lowerBound, int upperBound) throws Exception {
-        resetCounters();
-
-        for (int i = lowerBound; i < upperBound; i++) {
-            assert cache.localPeek(i, CachePeekMode.ONHEAP) == null;
-
-            CacheValue val = cache.localPeek(i, CachePeekMode.OFFHEAP);
-
-            assert val != null;
-            assert val.value() == i;
-        }
-
-        assert swapCnt.get() == 0;
-        assert unswapCnt.get() == 0;
-
-        checkEntries(cache, lowerBound, upperBound);
-
-        assert swapCnt.get() == 0;
-        assert unswapCnt.get() == upperBound - lowerBound;
-    }
-
-    /**
-     * Resets event counters.
-     */
-    private void resetCounters() {
-        swapCnt.set(0);
-        unswapCnt.set(0);
-    }
-
-    /**
-     * Checks that entries in cache are correct after being unswapped.
-     * If entry is still swapped, it will be unswapped in this method.
-     *
-     * @param cache Cache.
-     * @param lowerBound Lower key bound.
-     * @param upperBound Upper key bound.
-     * @throws Exception In case of error.
-     */
-    private void checkEntries(IgniteCache<Integer, CacheValue> cache, int lowerBound, int upperBound) throws Exception {
-        for (int i = lowerBound; i < upperBound; i++) {
-            cache.localPromote(Collections.singleton(i));
-
-            GridCacheEntryEx entry = dht(cache).entryEx(i);
-
-            assert entry != null;
-            assert entry.key() != null;
-
-            CacheValue val = CU.value(entry.rawGet(), entry.context(), false);
-
-            assertNotNull("Value null for key: " + i, val);
-            assertEquals(entry.key().value(entry.context().cacheObjectContext(), false), (Integer)val.value());
-
-            assertEquals(entry.version(), versions.get(i));
-        }
-    }
-
-    /**
      *
      */
     private static class CacheValue {
@@ -575,51 +146,4 @@ public class GridCacheOffHeapSelfTest extends GridCommonAbstractTest {
             return S.toString(CacheValue.class, this);
         }
     }
-
-    /**
-     *
-     */
-    private class SwapListener implements IgnitePredicate<Event> {
-        /** */
-        private final CountDownLatch swapLatch = new CountDownLatch(1);
-
-        /** */
-        private final CountDownLatch unswapLatch = new CountDownLatch(1);
-
-        /** {@inheritDoc} */
-        @Override public boolean apply(Event evt) {
-            assert evt != null;
-
-            info("Received event: " + evt);
-
-            switch (evt.type()) {
-                case EVT_CACHE_OBJECT_TO_OFFHEAP:
-                    swapLatch.countDown();
-
-                    break;
-                case EVT_CACHE_OBJECT_FROM_OFFHEAP:
-                    unswapLatch.countDown();
-
-                    break;
-            }
-
-            return true;
-        }
-
-        /**
-         * @return {@code True} if await succeeded.
-         * @throws InterruptedException If interrupted.
-         */
-        boolean awaitSwap() throws InterruptedException {
-            return swapLatch.await(5000, MILLISECONDS);
-        }
-
-        /**
-         * @return {@code True} if await succeeded.
-         * @throws InterruptedException If interrupted.
-         */
-        boolean awaitUnswap() throws InterruptedException {
-            return unswapLatch.await(5000, MILLISECONDS);
-        }
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java
index 1f2ec99..e0024fb 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java
@@ -96,8 +96,6 @@ public class IgniteCacheQueryMultiThreadedSelfTest extends GridCommonAbstractTes
 
         cfg.setCacheConfiguration(cacheConfiguration());
 
-        GridQueryProcessor.idxCls = FakeIndexing.class;
-
         return cfg;
     }
 
@@ -140,24 +138,6 @@ public class IgniteCacheQueryMultiThreadedSelfTest extends GridCommonAbstractTes
         return DURATION + 60_000;
     }
 
-    /**
-     *
-     */
-    private static class FakeIndexing extends IgniteH2Indexing {
-        @Override public void onSwap(@Nullable String spaceName, KeyCacheObject key, int partId) throws IgniteCheckedException {
-            super.onSwap(spaceName, key, partId);
-
-            idxSwapCnt.incrementAndGet();
-        }
-
-        @Override public void onUnswap(@Nullable String spaceName, KeyCacheObject key, int partId, CacheObject val)
-        throws IgniteCheckedException {
-            super.onUnswap(spaceName, key, partId, val);
-
-            idxUnswapCnt.incrementAndGet();
-        }
-    }
-
     /** @return {@code true} If evictions enabled. */
     protected boolean evictsEnabled() {
         return false;
@@ -185,11 +165,6 @@ public class IgniteCacheQueryMultiThreadedSelfTest extends GridCommonAbstractTes
     /** {@inheritDoc} */
     @Override protected void afterTestsStopped() throws Exception {
         stopAllGrids();
-
-        if (evictsEnabled()) {
-            assertTrue(idxSwapCnt.get() > 0);
-            assertTrue(idxUnswapCnt.get() > 0);
-        }
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.java
deleted file mode 100644
index d36b794..0000000
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache.distributed;
-
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.internal.processors.cache.GridBinaryDuplicateIndexObjectsAbstractSelfTest;
-
-/**
- * Test PARTITIONED ATOMIC.
- */
-public class GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest extends
-    GridBinaryDuplicateIndexObjectsAbstractSelfTest {
-    /** {@inheritDoc} */
-    @Override public CacheAtomicityMode atomicityMode() {
-        return CacheAtomicityMode.ATOMIC;
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheMode cacheMode() {
-        return CacheMode.PARTITIONED;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.java
deleted file mode 100644
index 529b556..0000000
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache.distributed;
-
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.internal.processors.cache.GridBinaryDuplicateIndexObjectsAbstractSelfTest;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-
-/**
- * Test PARTITIONED and TRANSACTIONAL.
- */
-public class GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest extends
-    GridBinaryDuplicateIndexObjectsAbstractSelfTest {
-    /** {@inheritDoc} */
-    @Override public CacheAtomicityMode atomicityMode() {
-        return TRANSACTIONAL;
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheMode cacheMode() {
-        return PARTITIONED;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java
index fe966f9..f3404fd 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java
@@ -208,15 +208,5 @@ public class IgniteQueryDedicatedPoolTest extends GridCommonAbstractTest {
         @Override public void remove(@Nullable String spaceName, Object key) {
             // No-op.
         }
-
-        /** {@inheritDoc} */
-        @Override public void onSwap(@Nullable String spaceName, Object key) {
-            // No-op.
-        }
-
-        /** {@inheritDoc} */
-        @Override public void onUnswap(@Nullable String spaceName, Object key, Object val) {
-            // No-op.
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
index e957f0f..5826b72 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
@@ -22,8 +22,6 @@ import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.processors.cache.BinarySerializationQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.BinarySerializationQueryWithReflectiveSerializerSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheBinaryObjectsScanSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest;
 import org.apache.ignite.testframework.config.GridTestProperties;
 
 /**
@@ -47,9 +45,6 @@ public class IgniteBinaryCacheQueryTestSuite extends TestSuite {
         //Should be adjusted. Not ready to be used with BinaryMarshaller.
         //suite.addTestSuite(GridCacheBinarySwapScanQuerySelfTest.class);
 
-        suite.addTestSuite(GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.class);
-        suite.addTestSuite(GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.class);
-
         //TODO: the following tests= was never tested with binary. Exclude or pass?
 //        suite.addTestSuite(IgniteSqlSchemaIndexingTest.class);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTask.java
----------------------------------------------------------------------
diff --git a/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTask.java b/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTask.java
index 2f6a728..d5f2286 100644
--- a/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTask.java
+++ b/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTask.java
@@ -333,10 +333,6 @@ public class IgniteSourceTask extends SourceTask {
         /** */
         UNLOCKED(EventType.EVT_CACHE_OBJECT_UNLOCKED),
         /** */
-        SWAPPED(EventType.EVT_CACHE_OBJECT_SWAPPED),
-        /** */
-        UNSWAPPED(EventType.EVT_CACHE_OBJECT_UNSWAPPED),
-        /** */
         EXPIRED(EventType.EVT_CACHE_OBJECT_EXPIRED);
 
         /** Internal Ignite event id. */

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
index d629331..351c25c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -1313,64 +1313,6 @@ namespace Apache.Ignite.Core.Tests.Cache
         }
 
         [Test]
-        [Ignore("IGNITE-4535")]
-        public void TestPromote()
-        {
-            var cache = Cache();
-
-            int key = GetPrimaryKeyForCache(cache);
-
-            cache.Put(key, 1);
-
-            Assert.AreEqual(1, PeekInt(cache, key));
-
-            cache.LocalEvict(new[] {key});
-
-            Assert.AreEqual(0, cache.GetLocalSize(CachePeekMode.Onheap));
-
-            Assert.AreEqual(0, PeekInt(cache, key));
-
-            cache.LocalPromote(new[] { key });
-
-            Assert.AreEqual(1, cache.GetLocalSize(CachePeekMode.Onheap));
-
-            Assert.AreEqual(1, PeekInt(cache, key));
-        }
-
-        [Test]
-        [Ignore("IGNITE-4535")]
-        public void TestPromoteAll()
-        {
-            var cache = Cache();
-
-            List<int> keys = GetPrimaryKeysForCache(cache, 3);
-
-            cache.Put(keys[0], 1);
-            cache.Put(keys[1], 2);
-            cache.Put(keys[2], 3);
-
-            Assert.AreEqual(1, PeekInt(cache, keys[0]));
-            Assert.AreEqual(2, PeekInt(cache, keys[1]));
-            Assert.AreEqual(3, PeekInt(cache, keys[2]));
-
-            cache.LocalEvict(new List<int> { -1, keys[0], keys[1] });
-
-            Assert.AreEqual(1, cache.GetLocalSize(CachePeekMode.Onheap));
-
-            Assert.AreEqual(0, PeekInt(cache, keys[0]));
-            Assert.AreEqual(0, PeekInt(cache, keys[1]));
-            Assert.AreEqual(3, PeekInt(cache, keys[2]));
-
-            cache.LocalPromote(new[] {keys[0], keys[1]});
-
-            Assert.AreEqual(3, cache.GetLocalSize(CachePeekMode.Onheap));
-
-            Assert.AreEqual(1, PeekInt(cache, keys[0]));
-            Assert.AreEqual(2, PeekInt(cache, keys[1]));
-            Assert.AreEqual(3, PeekInt(cache, keys[2]));
-        }
-
-        [Test]
         public void TestPutGetBinary()
         {
             var cache = Cache<int, BinarizablePerson>();

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
index c44a17b..6c8f0d6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -439,12 +439,6 @@ namespace Apache.Ignite.Core.Tests.Cache
         }
 
         /** <inheritDoc /> */
-        public void LocalPromote(IEnumerable<TK> keys)
-        {
-            _cache.LocalPromote(keys);
-        }
-        
-        /** <inheritDoc /> */
         public IQueryCursor<ICacheEntry<TK, TV>> Query(QueryBase qry)
         {
             return _cache.Query(qry);

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
index 5a4cdcf..b7cb0d5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
@@ -693,12 +693,6 @@ namespace Apache.Ignite.Core.Cache
         Task<int> GetSizeAsync(params CachePeekMode[] modes);
 
         /// <summary>
-        /// This method unswaps cache entries by given keys, if any, from swap storage into memory.
-        /// </summary>
-        /// <param name="keys">Keys to promote entries for.</param>
-        void LocalPromote(IEnumerable<TK> keys);
-
-        /// <summary>
         /// Queries cache.
         /// </summary>
         /// <param name="qry">Query.</param>

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index 516f91c..6009659 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -818,14 +818,6 @@ namespace Apache.Ignite.Core.Impl.Cache
             return (int) DoOutInOp((int) op, modes0);
         }
 
-        /** <inheritDoc /> */
-        public void LocalPromote(IEnumerable<TK> keys)
-        {
-            IgniteArgumentCheck.NotNull(keys, "keys");
-
-            DoOutOp(CacheOp.LocPromote, writer => WriteEnumerable(writer, keys));
-        }
-
         /** <inheritdoc /> */
         public TRes Invoke<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
         {

http://git-wip-us.apache.org/repos/asf/ignite/blob/0da8c70a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
index dc4f9aa..51fef40 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
@@ -40,7 +40,6 @@ namespace Apache.Ignite.Core.Impl.Cache
         LoadCache = 15,
         LocEvict = 16,
         LocLoadCache = 17,
-        LocPromote = 18,
         LocalClear = 20,
         LocalClearAll = 21,
         Lock = 22,


[48/65] [abbrv] ignite git commit: Spring Data version fix

Posted by ag...@apache.org.
Spring Data version fix


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

Branch: refs/heads/ignite-5024
Commit: 0781b1af0980cb52dadf0546d752e4e2f496f2b4
Parents: ca8ad03
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Apr 21 16:32:43 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Apr 21 16:32:43 2017 +0300

----------------------------------------------------------------------
 modules/spring-data/pom.xml                                      | 2 +-
 .../repository/support/IgniteRepositoryFactoryBean.java          | 4 ++++
 parent/pom.xml                                                   | 4 ++--
 3 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0781b1af/modules/spring-data/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spring-data/pom.xml b/modules/spring-data/pom.xml
index 4d8107b..9383ec4 100644
--- a/modules/spring-data/pom.xml
+++ b/modules/spring-data/pom.xml
@@ -58,7 +58,7 @@
         <dependency>
             <groupId>org.springframework.data</groupId>
             <artifactId>spring-data-commons</artifactId>
-            <version>1.12.2.RELEASE</version>
+            <version>${spring.data.version}</version>
         </dependency>
 
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/0781b1af/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactoryBean.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactoryBean.java b/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactoryBean.java
index f4131ba..dcb1d9a 100644
--- a/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactoryBean.java
+++ b/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryFactoryBean.java
@@ -49,6 +49,10 @@ public class IgniteRepositoryFactoryBean<T extends Repository<S, ID>, S, ID exte
     /** Application context. */
     private ApplicationContext ctx;
 
+    protected IgniteRepositoryFactoryBean(Class<? extends T> repositoryInterface) {
+        super(repositoryInterface);
+    }
+
     /** {@inheritDoc} */
     @Override public void setApplicationContext(ApplicationContext context) throws BeansException {
         this.ctx = context;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0781b1af/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 24ff924..74e8cf5 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -37,8 +37,8 @@
         <ignite.edition>fabric</ignite.edition>
         <hadoop.version>2.4.1</hadoop.version>
         <spark.version>2.1.0</spark.version>
-        <spring.version>4.3.7.RELEASE</spring.version>
-        <spring.data.version>1.2.1.RELEASE</spring.data.version>
+        <spring.version>4.3.7.RELEASE</spring.version> <!-- don't forget to update spring-data version -->
+        <spring.data.version>1.13.1.RELEASE</spring.data.version> <!-- don't forget to update spring version -->
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <maven.build.timestamp.format>MMMM d yyyy</maven.build.timestamp.format>
         <doxygen.exec>doxygen</doxygen.exec>


[57/65] [abbrv] ignite git commit: Fixed CacheExchangeMessageDuplicatedStateTest.

Posted by ag...@apache.org.
Fixed CacheExchangeMessageDuplicatedStateTest.


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

Branch: refs/heads/ignite-5024
Commit: a4e8296f3ccc2fa532f7ac5f4ac28ed68b1ab3e5
Parents: a4d9148
Author: sboikov <sb...@gridgain.com>
Authored: Sat Apr 22 09:42:54 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Sat Apr 22 09:42:54 2017 +0300

----------------------------------------------------------------------
 .../cache/CacheExchangeMessageDuplicatedStateTest.java       | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a4e8296f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheExchangeMessageDuplicatedStateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheExchangeMessageDuplicatedStateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheExchangeMessageDuplicatedStateTest.java
index 6c74dae..a4dd3fe 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheExchangeMessageDuplicatedStateTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheExchangeMessageDuplicatedStateTest.java
@@ -80,11 +80,9 @@ public class CacheExchangeMessageDuplicatedStateTest extends GridCommonAbstractT
 
         commSpi.record(new IgniteBiPredicate<ClusterNode, Message>() {
             @Override public boolean apply(ClusterNode node, Message msg) {
-                Message msg0 = ((GridIoMessage) msg).message();
-
-                return (msg0.getClass() == GridDhtPartitionsSingleMessage.class ||
-                    msg0.getClass() == GridDhtPartitionsFullMessage.class) &&
-                    ((GridDhtPartitionsAbstractMessage) msg0).exchangeId() != null;
+                return (msg.getClass() == GridDhtPartitionsSingleMessage.class ||
+                    msg.getClass() == GridDhtPartitionsFullMessage.class) &&
+                    ((GridDhtPartitionsAbstractMessage)msg).exchangeId() != null;
 
             }
         });


[36/65] [abbrv] ignite git commit: Minor doc fix in DataPageEvictionMOde

Posted by ag...@apache.org.
Minor doc fix in DataPageEvictionMOde


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

Branch: refs/heads/ignite-5024
Commit: e41de0cf42089c636deddaa611a38009ed5b313e
Parents: 217c6be
Author: Denis Magda <dm...@gridgain.com>
Authored: Thu Apr 20 14:32:18 2017 -0700
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Apr 20 14:32:18 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/ignite/configuration/DataPageEvictionMode.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e41de0cf/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java b/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
index 437721b..0d1b5b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
@@ -20,7 +20,7 @@ package org.apache.ignite.configuration;
 /**
  * Defines memory page eviction algorithm. A mode is set for a specific
  * {@link MemoryPolicyConfiguration}. Only data pages, that store key-value entries, are eligible for eviction. The
- * other types of pages, like index or system pages, are not evictable.
+ * other types of pages, like index or meta pages, are not evictable.
  */
 public enum DataPageEvictionMode {
     /** Eviction is disabled. */


[39/65] [abbrv] ignite git commit: IgniteCacheAtomicProtocolTest fix - Fixes #1839.

Posted by ag...@apache.org.
IgniteCacheAtomicProtocolTest fix - Fixes #1839.

Signed-off-by: Alexey Goncharuk <al...@gmail.com>


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

Branch: refs/heads/ignite-5024
Commit: 1f382afba6028bcb4463c3926e2d4e7ba6ffc590
Parents: 3eb52a8
Author: Konstantin Dudkov <kd...@ya.ru>
Authored: Fri Apr 21 11:47:31 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Apr 21 11:47:31 2017 +0300

----------------------------------------------------------------------
 .../atomic/IgniteCacheAtomicProtocolTest.java   | 175 +++++++++++++++++--
 1 file changed, 156 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1f382afb/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
index 29d67e2..5a6b1c8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
@@ -17,11 +17,14 @@
 
 package org.apache.ignite.internal.processors.cache.distributed.dht.atomic;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 import javax.cache.processor.MutableEntry;
 import org.apache.ignite.Ignite;
@@ -29,12 +32,18 @@ import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cache.affinity.AffinityFunction;
+import org.apache.ignite.cache.affinity.AffinityFunctionContext;
+import org.apache.ignite.cluster.ClusterMetrics;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.TestRecordingCommunicationSpi;
 import org.apache.ignite.internal.managers.communication.GridIoMessage;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheMessage;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
 import org.apache.ignite.internal.util.lang.GridAbsPredicate;
@@ -44,11 +53,13 @@ import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.lang.IgniteProductVersion;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
 import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC;
@@ -357,7 +368,7 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
 
         final IgniteCache<Integer, Integer> nearCache = clientNode.createCache(cacheConfiguration(1, FULL_ASYNC));
 
-        List<Integer> keys = primaryKeys(srv0.cache(TEST_CACHE), putAll ? 3 : 1);
+        List<Integer> keys = getKeysMoved(srv0, TEST_CACHE, putAll ? 3 : 1);
 
         testSpi(clientNode).blockMessages(GridNearAtomicSingleUpdateRequest.class, srv0.name());
         testSpi(clientNode).blockMessages(GridNearAtomicFullUpdateRequest.class, srv0.name());
@@ -372,30 +383,18 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
         else
             nearCache.put(keys.get(0), map.get(keys.get(0)));
 
-        int nodeIdx = 2;
-
         Affinity<Object> aff = clientNode.affinity(TEST_CACHE);
 
-        int keysMoved;
-
-        do {
-            startGrid(nodeIdx);
-
-            awaitPartitionMapExchange();
-
-            keysMoved = 0;
+        startGrid(2);
 
-            for (Integer key : keys) {
-                if (!aff.isPrimary(srv0.cluster().localNode(), key))
-                    keysMoved++;
-            }
+        awaitPartitionMapExchange();
 
-            if (keysMoved == keys.size())
-                break;
+        int keysMoved = 0;
 
-            nodeIdx++;
+        for (Integer key : keys) {
+            if (!aff.isPrimary(srv0.cluster().localNode(), key))
+                keysMoved++;
         }
-        while (nodeIdx < 10);
 
         assertEquals(keys.size(), keysMoved);
 
@@ -826,6 +825,68 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
     }
 
     /**
+     * Return list of keys that are primary for given node on given topology,
+     * but will not be primary after add one new node.
+     *
+     * @param ign Ignite.
+     * @param cacheName Cache name.
+     * @param size Number of keys.
+     * @return List of keys.
+     */
+    private List<Integer> getKeysMoved(Ignite ign, String cacheName, int size) {
+        GridCacheContext<Object, Object> cctx = ((IgniteKernal)ign).context().cache().internalCache(cacheName).context();
+
+        ArrayList<ClusterNode> nodes = new ArrayList<>(ign.cluster().nodes());
+
+        AffinityFunction func = cctx.config().getAffinity();
+
+        AffinityFunctionContext ctx = new GridAffinityFunctionContextImpl(
+            nodes,
+            null,
+            null,
+            new AffinityTopologyVersion(1, 0),
+            cctx.config().getBackups());
+
+        List<List<ClusterNode>> calcAff = func.assignPartitions(ctx);
+
+        String name = getTestIgniteInstanceName(nodes.size());
+
+        nodes.add(new FakeNode(name));
+
+        ctx = new GridAffinityFunctionContextImpl(
+            nodes,
+            null,
+            null,
+            new AffinityTopologyVersion(1, 0),
+            cctx.config().getBackups());
+
+        List<List<ClusterNode>> calcAff2 = func.assignPartitions(ctx);
+
+        Set<Integer> movedParts = new HashSet<>();
+
+        UUID localId = ign.cluster().localNode().id();
+
+        for (int i = 0; i < calcAff.size(); i++) {
+            if (calcAff.get(i).get(0).id().equals(localId) && !calcAff2.get(i).get(0).id().equals(localId))
+                movedParts.add(i);
+        }
+
+        List<Integer> keys = new ArrayList<>();
+
+        for (int i = 0; i < 10000; i++) {
+            int keyPart = func.partition(ign.affinity(cacheName).affinityKey(i));
+
+            if (movedParts.contains(keyPart))
+                keys.add(i);
+
+            if (keys.size() == size)
+                break;
+        }
+
+        return keys;
+    }
+
+    /**
      *
      */
     public static class SetValueEntryProcessor implements CacheEntryProcessor<Integer, Integer, Object> {
@@ -847,4 +908,80 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
             return null;
         }
     }
+
+    /**
+     *
+     */
+    public static class FakeNode implements ClusterNode {
+        /** */
+        private final String consistendId;
+        /** */
+        private final UUID uuid;
+
+        /** */
+        public FakeNode(String consistendId) {
+            this.consistendId = consistendId;
+            uuid = UUID.randomUUID();
+        }
+
+        /** {@inheritDoc} */
+        @Override public UUID id() {
+            return uuid;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Object consistentId() {
+            return consistendId;
+        }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public <T> T attribute(String name) {
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public ClusterMetrics metrics() {
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<String, Object> attributes() {
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Collection<String> addresses() {
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Collection<String> hostNames() {
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public long order() {
+            return 0;
+        }
+
+        /** {@inheritDoc} */
+        @Override public IgniteProductVersion version() {
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean isLocal() {
+            return false;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean isDaemon() {
+            return false;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean isClient() {
+            return false;
+        }
+    }
 }


[59/65] [abbrv] ignite git commit: IGNITE-4988 Fixed merge result.

Posted by ag...@apache.org.
IGNITE-4988 Fixed merge result.


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

Branch: refs/heads/ignite-5024
Commit: 045ae66524be8c41007a9ddf641e1ffb01046487
Parents: 3a5c6f3
Author: Alexey Kuznetsov <ak...@gridgain.com>
Authored: Sun Apr 23 09:54:43 2017 +0700
Committer: Alexey Kuznetsov <ak...@gridgain.com>
Committed: Sun Apr 23 09:54:43 2017 +0700

----------------------------------------------------------------------
 .../ignite/internal/visor/cache/VisorCachePartitionsTask.java    | 2 +-
 .../ignite/internal/visor/node/VisorNodeDataCollectorTask.java   | 4 +---
 .../internal/visor/node/VisorNodeDataCollectorTaskResult.java    | 4 ++--
 3 files changed, 4 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/045ae665/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java
index c9339b7..69188c5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java
@@ -124,7 +124,7 @@ public class VisorCachePartitionsTask extends VisorMultiNodeTask<VisorCacheParti
                     for (GridDhtLocalPartition part : locParts) {
                         int p = part.id();
 
-                        long sz = part.publicSize();
+                        long sz = part.dataStore().size();
 
                         // Pass NONE as topology version in order not to wait for topology version.
                         if (part.primary(AffinityTopologyVersion.NONE))

http://git-wip-us.apache.org/repos/asf/ignite/blob/045ae665/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTask.java
index af02e34..a317ffe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTask.java
@@ -71,9 +71,7 @@ public class VisorNodeDataCollectorTask extends VisorMultiNodeTask<VisorNodeData
             }
         }
 
-        taskRes.active(true /*ignite.active()*/);
-
-        taskRes.active(ignite.active());
+        taskRes.setActive(ignite.active());
 
         return taskRes;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/045ae665/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskResult.java
index 5018f43..669cc80 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskResult.java
@@ -109,14 +109,14 @@ public class VisorNodeDataCollectorTaskResult extends VisorDataTransferObject {
     /**
      * @return {@code True} if grid is active.
      */
-    public boolean active() {
+    public boolean isActive() {
         return active;
     }
 
     /**
      * @param active active New value of grid active flag.
      */
-    public void active(boolean active) {
+    public void setActive(boolean active) {
         this.active = active;
     }
 


[06/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorIterableTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorIterableTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorIterableTest.java
deleted file mode 100644
index 7a64c85..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorIterableTest.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Spliterator;
-import java.util.function.BiConsumer;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.junit.Test;
-
-import static java.util.Spliterator.ORDERED;
-import static java.util.Spliterator.SIZED;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/** */
-public class VectorIterableTest {
-    /** */
-    @Test
-    public void allTest() {
-        consumeSampleVectors(
-            (v, desc) -> {
-                int expIdx = 0;
-
-                for (Vector.Element e : v.all()) {
-                    int actualIdx = e.index();
-
-                    assertEquals("Unexpected index for " + desc,
-                        expIdx, actualIdx);
-
-                    expIdx++;
-                }
-
-                assertEquals("Unexpected amount of elements for " + desc,
-                    expIdx, v.size());
-            }
-        );
-    }
-
-    /** */
-    @Test
-    public void allTestBound() {
-        consumeSampleVectors(
-            (v, desc) -> iteratorTestBound(v.all().iterator(), desc)
-        );
-    }
-
-    /** */
-    @Test
-    public void nonZeroesTestBasic() {
-        final int size = 5;
-
-        final double[] nonZeroesOddData = new double[size], nonZeroesEvenData = new double[size];
-
-        for (int idx = 0; idx < size; idx++) {
-            final boolean odd = (idx & 1) == 1;
-
-            nonZeroesOddData[idx] = odd ? 1 : 0;
-
-            nonZeroesEvenData[idx] = odd ? 0 : 1;
-        }
-
-        assertTrue("Arrays failed to initialize.",
-            !isZero(nonZeroesEvenData[0])
-                && isZero(nonZeroesEvenData[1])
-                && isZero(nonZeroesOddData[0])
-                && !isZero(nonZeroesOddData[1]));
-
-        final Vector nonZeroesEvenVec = new DenseLocalOnHeapVector(nonZeroesEvenData),
-            nonZeroesOddVec = new DenseLocalOnHeapVector(nonZeroesOddData);
-
-        assertTrue("Vectors failed to initialize.",
-            !isZero(nonZeroesEvenVec.getElement(0).get())
-                && isZero(nonZeroesEvenVec.getElement(1).get())
-                && isZero(nonZeroesOddVec.getElement(0).get())
-                && !isZero(nonZeroesOddVec.getElement(1).get()));
-
-        assertTrue("Iterator(s) failed to start.",
-            nonZeroesEvenVec.nonZeroes().iterator().next() != null
-                && nonZeroesOddVec.nonZeroes().iterator().next() != null);
-
-        int nonZeroesActual = 0;
-
-        for (Vector.Element e : nonZeroesEvenVec.nonZeroes()) {
-            final int idx = e.index();
-
-            final boolean odd = (idx & 1) == 1;
-
-            final double val = e.get();
-
-            assertTrue("Not an even index " + idx + ", for value " + val, !odd);
-
-            assertTrue("Zero value " + val + " at even index " + idx, !isZero(val));
-
-            nonZeroesActual++;
-        }
-
-        final int nonZeroesOddExp = (size + 1) / 2;
-
-        assertEquals("Unexpected num of iterated odd non-zeroes.", nonZeroesOddExp, nonZeroesActual);
-
-        assertEquals("Unexpected nonZeroElements of odd.", nonZeroesOddExp, nonZeroesEvenVec.nonZeroElements());
-
-        nonZeroesActual = 0;
-
-        for (Vector.Element e : nonZeroesOddVec.nonZeroes()) {
-            final int idx = e.index();
-
-            final boolean odd = (idx & 1) == 1;
-
-            final double val = e.get();
-
-            assertTrue("Not an odd index " + idx + ", for value " + val, odd);
-
-            assertTrue("Zero value " + val + " at even index " + idx, !isZero(val));
-
-            nonZeroesActual++;
-        }
-
-        final int nonZeroesEvenExp = size / 2;
-
-        assertEquals("Unexpected num of iterated even non-zeroes", nonZeroesEvenExp, nonZeroesActual);
-
-        assertEquals("Unexpected nonZeroElements of even", nonZeroesEvenExp, nonZeroesOddVec.nonZeroElements());
-    }
-
-    /** */
-    @Test
-    public void nonZeroesTest() {
-        // todo make RandomVector constructor that accepts a function and use it here
-        //  in order to *reliably* test non-zeroes in there
-        consumeSampleVectors(
-            (v, desc) -> consumeSampleVectorsWithZeroes(v, (vec, numZeroes)
-                -> {
-                int numZeroesActual = vec.size();
-
-                for (Vector.Element e : vec.nonZeroes()) {
-                    numZeroesActual--;
-
-                    assertTrue("Unexpected zero at " + desc + ", index " + e.index(), !isZero(e.get()));
-                }
-
-                assertEquals("Unexpected num zeroes at " + desc, (int)numZeroes, numZeroesActual);
-            }));
-    }
-
-    /** */
-    @Test
-    public void nonZeroesTestBound() {
-        consumeSampleVectors(
-            (v, desc) -> consumeSampleVectorsWithZeroes(v, (vec, numZeroes)
-                -> iteratorTestBound(vec.nonZeroes().iterator(), desc)));
-    }
-
-    /** */
-    @Test
-    public void nonZeroElementsTest() {
-        consumeSampleVectors(
-            (v, desc) -> consumeSampleVectorsWithZeroes(v, (vec, numZeroes)
-                -> assertEquals("Unexpected num zeroes at " + desc,
-                (int)numZeroes, vec.size() - vec.nonZeroElements())));
-    }
-
-    /** */
-    @Test
-    public void allSpliteratorTest() {
-        consumeSampleVectors(
-            (v, desc) -> {
-                final String desc1 = " " + desc;
-
-                Spliterator<Double> spliterator = v.allSpliterator();
-
-                assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator);
-
-                assertNull(MathTestConstants.NOT_NULL_VAL + desc1, spliterator.trySplit());
-
-                assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED));
-
-                if (!readOnly(v))
-                    fillWithNonZeroes(v);
-
-                spliterator = v.allSpliterator();
-
-                assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator);
-
-                assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.estimateSize(), v.size());
-
-                assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.getExactSizeIfKnown(), v.size());
-
-                assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED));
-
-                Spliterator<Double> secondHalf = spliterator.trySplit();
-
-                assertNull(MathTestConstants.NOT_NULL_VAL + desc1, secondHalf);
-
-                spliterator.tryAdvance(x -> {
-                });
-            }
-        );
-    }
-
-    /** */
-    @Test
-    public void nonZeroSpliteratorTest() {
-        consumeSampleVectors(
-            (v, desc) -> consumeSampleVectorsWithZeroes(v, (vec, numZeroes)
-                -> {
-                final String desc1 = " Num zeroes " + numZeroes + " " + desc;
-
-                Spliterator<Double> spliterator = vec.nonZeroSpliterator();
-
-                assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator);
-
-                assertNull(MathTestConstants.NOT_NULL_VAL + desc1, spliterator.trySplit());
-
-                assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED));
-
-                spliterator = vec.nonZeroSpliterator();
-
-                assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator);
-
-                assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.estimateSize(), vec.size() - numZeroes);
-
-                assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.getExactSizeIfKnown(), vec.size() - numZeroes);
-
-                assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED));
-
-                Spliterator<Double> secondHalf = spliterator.trySplit();
-
-                assertNull(MathTestConstants.NOT_NULL_VAL + desc1, secondHalf);
-
-                double[] data = new double[vec.size()];
-
-                for (Vector.Element e : vec.all())
-                    data[e.index()] = e.get();
-
-                spliterator = vec.nonZeroSpliterator();
-
-                assertNotNull(MathTestConstants.NULL_VAL + desc1, spliterator);
-
-                assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.estimateSize(),
-                    Arrays.stream(data).filter(x -> x != 0d).count());
-
-                assertEquals(MathTestConstants.VAL_NOT_EQUALS + desc1, spliterator.getExactSizeIfKnown(),
-                    Arrays.stream(data).filter(x -> x != 0d).count());
-
-                assertTrue(MathTestConstants.UNEXPECTED_VAL + desc1, spliterator.hasCharacteristics(ORDERED | SIZED));
-
-                secondHalf = spliterator.trySplit();
-
-                assertNull(MathTestConstants.NOT_NULL_VAL + desc1, secondHalf);
-
-                if (!spliterator.tryAdvance(x -> {
-                }))
-                    fail(MathTestConstants.NO_NEXT_ELEMENT + desc1);
-            }));
-    }
-
-    /** */
-    private void iteratorTestBound(Iterator<Vector.Element> it, String desc) {
-        while (it.hasNext())
-            assertNotNull(it.next());
-
-        boolean expECaught = false;
-
-        try {
-            it.next();
-        }
-        catch (NoSuchElementException e) {
-            expECaught = true;
-        }
-
-        assertTrue("Expected exception missed for " + desc,
-            expECaught);
-    }
-
-    /** */
-    private void consumeSampleVectorsWithZeroes(Vector sample,
-        BiConsumer<Vector, Integer> consumer) {
-        if (readOnly(sample)) {
-            int numZeroes = 0;
-
-            for (Vector.Element e : sample.all())
-                if (isZero(e.get()))
-                    numZeroes++;
-
-            consumer.accept(sample, numZeroes);
-
-            return;
-        }
-
-        fillWithNonZeroes(sample);
-
-        consumer.accept(sample, 0);
-
-        final int sampleSize = sample.size();
-
-        if (sampleSize == 0)
-            return;
-
-        for (Vector.Element e : sample.all())
-            e.set(0);
-
-        consumer.accept(sample, sampleSize);
-
-        fillWithNonZeroes(sample);
-
-        for (int testIdx : new int[] {0, sampleSize / 2, sampleSize - 1}) {
-            final Vector.Element e = sample.getElement(testIdx);
-
-            final double backup = e.get();
-
-            e.set(0);
-
-            consumer.accept(sample, 1);
-
-            e.set(backup);
-        }
-
-        if (sampleSize < 3)
-            return;
-
-        sample.getElement(sampleSize / 3).set(0);
-
-        sample.getElement((2 * sampleSize) / 3).set(0);
-
-        consumer.accept(sample, 2);
-    }
-
-    /** */
-    private void fillWithNonZeroes(Vector sample) {
-        int idx = 0;
-
-        for (Vector.Element e : sample.all())
-            e.set(1 + idx++);
-
-        assertEquals("Not all filled with non-zeroes", idx, sample.size());
-    }
-
-    /** */
-    private void consumeSampleVectors(BiConsumer<Vector, String> consumer) {
-        new VectorImplementationsFixtures().consumeSampleVectors(null, consumer);
-    }
-
-    /** */
-    private boolean isZero(double val) {
-        return val == 0.0;
-    }
-
-    /** */
-    private boolean readOnly(Vector v) {
-        return v instanceof RandomVector || v instanceof ConstantVector;
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorNormTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorNormTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorNormTest.java
deleted file mode 100644
index f1c2928..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorNormTest.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.util.function.BiConsumer;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import org.apache.ignite.math.Vector;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/** */
-public class VectorNormTest {
-    /** */
-    @Test
-    public void normalizeTest() {
-        normalizeTest(2, (val, len) -> val / len, Vector::normalize);
-    }
-
-    /** */
-    @Test
-    public void normalizePowerTest() {
-        for (double pow : new double[] {0, 0.5, 1, 2, 2.5, Double.POSITIVE_INFINITY})
-            normalizeTest(pow, (val, norm) -> val / norm, (v) -> v.normalize(pow));
-    }
-
-    /** */
-    @Test
-    public void logNormalizeTest() {
-        normalizeTest(2, (val, len) -> Math.log1p(val) / (len * Math.log(2)), Vector::logNormalize);
-    }
-
-    /** */
-    @Test
-    public void logNormalizePowerTest() {
-        for (double pow : new double[] {1.1, 2, 2.5})
-            normalizeTest(pow, (val, norm) -> Math.log1p(val) / (norm * Math.log(pow)), (v) -> v.logNormalize(pow));
-    }
-
-    /** */
-    @Test
-    public void kNormTest() {
-        for (double pow : new double[] {0, 0.5, 1, 2, 2.5, Double.POSITIVE_INFINITY})
-            toDoubleTest(pow, ref -> new Norm(ref, pow).calculate(), v -> v.kNorm(pow));
-    }
-
-    /** */
-    @Test
-    public void getLengthSquaredTest() {
-        toDoubleTest(2.0, ref -> new Norm(ref, 2).sumPowers(), Vector::getLengthSquared);
-    }
-
-    /** */
-    @Test
-    public void getDistanceSquaredTest() {
-        consumeSampleVectors((v, desc) -> {
-            new VectorImplementationsTest.ElementsChecker(v, desc); // IMPL NOTE this initialises vector
-
-            final int size = v.size();
-            final Vector vOnHeap = new DenseLocalOnHeapVector(size);
-            final Vector vOffHeap = new DenseLocalOffHeapVector(size);
-
-            invertValues(v, vOnHeap);
-            invertValues(v, vOffHeap);
-
-            for (int idx = 0; idx < size; idx++) {
-                final double exp = v.get(idx);
-                final int idxMirror = size - 1 - idx;
-
-                assertTrue("On heap vector difference at " + desc + ", idx " + idx,
-                    exp - vOnHeap.get(idxMirror) == 0);
-                assertTrue("Off heap vector difference at " + desc + ", idx " + idx,
-                    exp - vOffHeap.get(idxMirror) == 0);
-            }
-
-            final double exp = vOnHeap.minus(v).getLengthSquared(); // IMPL NOTE this won't mutate vOnHeap
-            final VectorImplementationsTest.Metric metric = new VectorImplementationsTest.Metric(exp, v.getDistanceSquared(vOnHeap));
-
-            assertTrue("On heap vector not close enough at " + desc + ", " + metric,
-                metric.closeEnough());
-
-            final VectorImplementationsTest.Metric metric1 = new VectorImplementationsTest.Metric(exp, v.getDistanceSquared(vOffHeap));
-
-            assertTrue("Off heap vector not close enough at " + desc + ", " + metric1,
-                metric1.closeEnough());
-        });
-    }
-
-    /** */
-    @Test
-    public void dotTest() {
-        consumeSampleVectors((v, desc) -> {
-            new VectorImplementationsTest.ElementsChecker(v, desc); // IMPL NOTE this initialises vector
-
-            final int size = v.size();
-            final Vector v1 = new DenseLocalOnHeapVector(size);
-
-            invertValues(v, v1);
-
-            final double actual = v.dot(v1);
-
-            double exp = 0;
-
-            for (Vector.Element e : v.all())
-                exp += e.get() * v1.get(e.index());
-
-            final VectorImplementationsTest.Metric metric = new VectorImplementationsTest.Metric(exp, actual);
-
-            assertTrue("Dot product not close enough at " + desc + ", " + metric,
-                metric.closeEnough());
-        });
-    }
-
-    /** */
-    private void invertValues(Vector src, Vector dst) {
-        final int size = src.size();
-
-        for (Vector.Element e : src.all()) {
-            final int idx = size - 1 - e.index();
-            final double val = e.get();
-
-            dst.set(idx, val);
-        }
-    }
-
-    /** */
-    private void toDoubleTest(Double val, Function<double[], Double> calcRef, Function<Vector, Double> calcVec) {
-        consumeSampleVectors((v, desc) -> {
-            final int size = v.size();
-            final double[] ref = new double[size];
-
-            new VectorImplementationsTest.ElementsChecker(v, ref, desc); // IMPL NOTE this initialises vector and reference array
-
-            final double exp = calcRef.apply(ref);
-            final double obtained = calcVec.apply(v);
-            final VectorImplementationsTest.Metric metric = new VectorImplementationsTest.Metric(exp, obtained);
-
-            assertTrue("Not close enough at " + desc
-                + (val == null ? "" : ", value " + val) + ", " + metric, metric.closeEnough());
-        });
-    }
-
-    /** */
-    private void normalizeTest(double pow, BiFunction<Double, Double, Double> operation,
-        Function<Vector, Vector> vecOperation) {
-        consumeSampleVectors((v, desc) -> {
-            final int size = v.size();
-            final double[] ref = new double[size];
-            final boolean nonNegative = pow != (int)pow;
-
-            final VectorImplementationsTest.ElementsChecker checker = new VectorImplementationsTest.ElementsChecker(v, ref, desc + ", pow = " + pow, nonNegative);
-            final double norm = new Norm(ref, pow).calculate();
-
-            for (int idx = 0; idx < size; idx++)
-                ref[idx] = operation.apply(ref[idx], norm);
-
-            checker.assertCloseEnough(vecOperation.apply(v), ref);
-        });
-    }
-
-    /** */
-    private void consumeSampleVectors(BiConsumer<Vector, String> consumer) {
-        new VectorImplementationsFixtures().consumeSampleVectors(null, consumer);
-    }
-
-    /** */
-    private static class Norm {
-        /** */
-        private final double[] arr;
-
-        /** */
-        private final Double pow;
-
-        /** */
-        Norm(double[] arr, double pow) {
-            this.arr = arr;
-            this.pow = pow;
-        }
-
-        /** */
-        double calculate() {
-            if (pow.equals(0.0))
-                return countNonZeroes(); // IMPL NOTE this is beautiful if you think of it
-
-            if (pow.equals(Double.POSITIVE_INFINITY))
-                return maxAbs();
-
-            return Math.pow(sumPowers(), 1 / pow);
-        }
-
-        /** */
-        double sumPowers() {
-            if (pow.equals(0.0))
-                return countNonZeroes();
-
-            double norm = 0;
-
-            for (double val : arr)
-                norm += pow == 1 ? Math.abs(val) : Math.pow(val, pow);
-
-            return norm;
-        }
-
-        /** */
-        private int countNonZeroes() {
-            int cnt = 0;
-
-            final Double zero = 0.0;
-
-            for (double val : arr)
-                if (!zero.equals(val))
-                    cnt++;
-
-            return cnt;
-        }
-
-        /** */
-        private double maxAbs() {
-            double res = 0;
-
-            for (double val : arr) {
-                final double abs = Math.abs(val);
-
-                if (abs > res)
-                    res = abs;
-            }
-
-            return res;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorToMatrixTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorToMatrixTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorToMatrixTest.java
deleted file mode 100644
index adcb2cc..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorToMatrixTest.java
+++ /dev/null
@@ -1,291 +0,0 @@
-package org.apache.ignite.math.impls.vector;
-
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.BiConsumer;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.matrix.DenseLocalOffHeapMatrix;
-import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.math.impls.matrix.RandomMatrix;
-import org.apache.ignite.math.impls.matrix.SparseLocalOnHeapMatrix;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-/** Tests for methods of Vector that involve Matrix. */
-public class VectorToMatrixTest {
-    /** */
-    private static final Map<Class<? extends Vector>, Class<? extends Matrix>> typesMap = typesMap();
-
-    /** */
-    private static final List<Class<? extends Vector>> likeMatrixUnsupported = Arrays.asList(FunctionVector.class,
-        SingleElementVector.class, SingleElementVectorView.class, ConstantVector.class);
-
-    /** */
-    @Test
-    public void testHaveLikeMatrix() throws InstantiationException, IllegalAccessException {
-        for (Class<? extends Vector> key : typesMap.keySet()) {
-            Class<? extends Matrix> val = typesMap.get(key);
-
-            if (val == null && likeMatrixSupported(key))
-                System.out.println("Missing test for implementation of likeMatrix for " + key.getSimpleName());
-        }
-    }
-
-    /** */
-    @Test
-    public void testLikeMatrixUnsupported() throws Exception {
-        consumeSampleVectors((v, desc) -> {
-            if (likeMatrixSupported(v.getClass()))
-                return;
-
-            boolean expECaught = false;
-
-            try {
-                assertNull("Null view instead of exception in " + desc, v.likeMatrix(1, 1));
-            }
-            catch (UnsupportedOperationException uoe) {
-                expECaught = true;
-            }
-
-            assertTrue("Expected exception was not caught in " + desc, expECaught);
-        });
-    }
-
-    /** */
-    @Test
-    public void testLikeMatrix() {
-        consumeSampleVectors((v, desc) -> {
-            if (!availableForTesting(v))
-                return;
-
-            final Matrix matrix = v.likeMatrix(1, 1);
-
-            Class<? extends Vector> key = v.getClass();
-
-            Class<? extends Matrix> expMatrixType = typesMap.get(key);
-
-            assertNotNull("Expect non-null matrix for " + key.getSimpleName() + " in " + desc, matrix);
-
-            Class<? extends Matrix> actualMatrixType = matrix.getClass();
-
-            assertTrue("Expected matrix type " + expMatrixType.getSimpleName()
-                    + " should be assignable from actual type " + actualMatrixType.getSimpleName() + " in " + desc,
-                expMatrixType.isAssignableFrom(actualMatrixType));
-
-            for (int rows : new int[] {1, 2})
-                for (int cols : new int[] {1, 2}) {
-                    final Matrix actualMatrix = v.likeMatrix(rows, cols);
-
-                    String details = "rows " + rows + " cols " + cols;
-
-                    assertNotNull("Expect non-null matrix for " + details + " in " + desc,
-                        actualMatrix);
-
-                    assertEquals("Unexpected number of rows in " + desc, rows, actualMatrix.rowSize());
-
-                    assertEquals("Unexpected number of cols in " + desc, cols, actualMatrix.columnSize());
-                }
-        });
-    }
-
-    /** */
-    @Test
-    public void testToMatrix() {
-        consumeSampleVectors((v, desc) -> {
-            if (!availableForTesting(v))
-                return;
-
-            fillWithNonZeroes(v);
-
-            final Matrix matrixRow = v.toMatrix(true);
-
-            final Matrix matrixCol = v.toMatrix(false);
-
-            for (Vector.Element e : v.all())
-                assertToMatrixValue(desc, matrixRow, matrixCol, e.get(), e.index());
-        });
-    }
-
-    /** */
-    @Test
-    public void testToMatrixPlusOne() {
-        consumeSampleVectors((v, desc) -> {
-            if (!availableForTesting(v))
-                return;
-
-            fillWithNonZeroes(v);
-
-            for (double zeroVal : new double[] {-1, 0, 1, 2}) {
-                final Matrix matrixRow = v.toMatrixPlusOne(true, zeroVal);
-
-                final Matrix matrixCol = v.toMatrixPlusOne(false, zeroVal);
-
-                final Metric metricRow0 = new Metric(zeroVal, matrixRow.get(0, 0));
-
-                assertTrue("Not close enough row like " + metricRow0 + " at index 0 in " + desc,
-                    metricRow0.closeEnough());
-
-                final Metric metricCol0 = new Metric(zeroVal, matrixCol.get(0, 0));
-
-                assertTrue("Not close enough cols like " + metricCol0 + " at index 0 in " + desc,
-                    metricCol0.closeEnough());
-
-                for (Vector.Element e : v.all())
-                    assertToMatrixValue(desc, matrixRow, matrixCol, e.get(), e.index() + 1);
-            }
-        });
-    }
-
-    /** */
-    @Test
-    public void testCross() {
-        consumeSampleVectors((v, desc) -> {
-            if (!availableForTesting(v))
-                return;
-
-            fillWithNonZeroes(v);
-
-            for (int delta : new int[] {-1, 0, 1}) {
-                final int size2 = v.size() + delta;
-
-                if (size2 < 1)
-                    return;
-
-                final Vector v2 = new DenseLocalOnHeapVector(size2);
-
-                for (Vector.Element e : v2.all())
-                    e.set(size2 - e.index());
-
-                assertCross(v, v2, desc);
-            }
-        });
-    }
-
-    /** */
-    private void assertCross(Vector v1, Vector v2, String desc) {
-        assertNotNull(v1);
-        assertNotNull(v2);
-
-        final Matrix res = v1.cross(v2);
-
-        assertNotNull("Cross matrix is expected to be not null in " + desc, res);
-
-        assertEquals("Unexpected number of rows in cross Matrix in " + desc, v1.size(), res.rowSize());
-
-        assertEquals("Unexpected number of cols in cross Matrix in " + desc, v2.size(), res.columnSize());
-
-        for (int row = 0; row < v1.size(); row++)
-            for (int col = 0; col < v2.size(); col++) {
-                final Metric metric = new Metric(v1.get(row) * v2.get(col), res.get(row, col));
-
-                assertTrue("Not close enough cross " + metric + " at row " + row + " at col " + col
-                    + " in " + desc, metric.closeEnough());
-            }
-    }
-
-    /** */
-    private void assertToMatrixValue(String desc, Matrix matrixRow, Matrix matrixCol, double exp, int idx) {
-        final Metric metricRow = new Metric(exp, matrixRow.get(0, idx));
-
-        assertTrue("Not close enough row like " + metricRow + " at index " + idx + " in " + desc,
-            metricRow.closeEnough());
-
-        final Metric metricCol = new Metric(exp, matrixCol.get(idx, 0));
-
-        assertTrue("Not close enough cols like " + matrixCol + " at index " + idx + " in " + desc,
-            metricCol.closeEnough());
-    }
-
-    /** */
-    private void fillWithNonZeroes(Vector sample) {
-        if (sample instanceof RandomVector)
-            return;
-
-        for (Vector.Element e : sample.all())
-            e.set(1 + e.index());
-    }
-
-    /** */
-    private boolean availableForTesting(Vector v) {
-        assertNotNull("Error in test: vector is null", v);
-
-        if (!likeMatrixSupported(v.getClass()))
-            return false;
-
-        final boolean availableForTesting = typesMap.get(v.getClass()) != null;
-
-        final Matrix actualLikeMatrix = v.likeMatrix(1, 1);
-
-        assertTrue("Need to enable matrix testing for vector type " + v.getClass().getSimpleName(),
-            availableForTesting || actualLikeMatrix == null);
-
-        return availableForTesting;
-    }
-
-    /** Ignore test for given vector type. */
-    private boolean likeMatrixSupported(Class<? extends Vector> clazz) {
-        for (Class<? extends Vector> ignoredClass : likeMatrixUnsupported)
-            if (ignoredClass.isAssignableFrom(clazz))
-                return false;
-
-        return true;
-    }
-
-    /** */
-    private void consumeSampleVectors(BiConsumer<Vector, String> consumer) {
-        new VectorImplementationsFixtures().consumeSampleVectors(null, consumer);
-    }
-
-    /** */
-    private static Map<Class<? extends Vector>, Class<? extends Matrix>> typesMap() {
-        return new LinkedHashMap<Class<? extends Vector>, Class<? extends Matrix>>() {{
-            put(DenseLocalOnHeapVector.class, DenseLocalOnHeapMatrix.class);
-            put(DenseLocalOffHeapVector.class, DenseLocalOffHeapMatrix.class);
-            put(RandomVector.class, RandomMatrix.class);
-            put(SparseLocalVector.class, SparseLocalOnHeapMatrix.class);
-            put(SingleElementVector.class, null); // todo find out if we need SingleElementMatrix to match, or skip it
-            put(ConstantVector.class, null);
-            put(FunctionVector.class, null);
-            put(PivotedVectorView.class, DenseLocalOnHeapMatrix.class); // IMPL NOTE per fixture
-            put(SingleElementVectorView.class, null);
-            put(MatrixVectorView.class, DenseLocalOnHeapMatrix.class); // IMPL NOTE per fixture
-            put(DelegatingVector.class, DenseLocalOnHeapMatrix.class); // IMPL NOTE per fixture
-            // IMPL NOTE check for presence of all implementations here will be done in testHaveLikeMatrix via Fixture
-        }};
-    }
-
-    /** */
-    private static class Metric { // todo consider if softer tolerance (like say 0.1 or 0.01) would make sense here
-        /** */
-        private final double exp;
-
-        /** */
-        private final double obtained;
-
-        /** **/
-        Metric(double exp, double obtained) {
-            this.exp = exp;
-            this.obtained = obtained;
-        }
-
-        /** */
-        boolean closeEnough() {
-            return new Double(exp).equals(obtained);
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return "Metric{" + "expected=" + exp +
-                ", obtained=" + obtained +
-                '}';
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorViewTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorViewTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorViewTest.java
deleted file mode 100644
index 55893d0..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/vector/VectorViewTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.vector;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.function.BiConsumer;
-import java.util.stream.IntStream;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Unit tests for {@link VectorView}.
- */
-public class VectorViewTest {
-    /** */
-    private static final int OFFSET = 10;
-
-    /** */
-    private static final int VIEW_LENGTH = 80;
-
-    /** */
-    private static final String EXTERNALIZE_TEST_FILE_NAME = "externalizeTest";
-
-    /** */
-    private VectorView testVector;
-
-    /** */
-    private DenseLocalOnHeapVector parentVector;
-
-    /** */
-    private double[] parentData;
-
-    /** */
-    @Before
-    public void setup() {
-        parentVector = new DenseLocalOnHeapVector(MathTestConstants.STORAGE_SIZE);
-
-        IntStream.range(0, MathTestConstants.STORAGE_SIZE).forEach(idx -> parentVector.set(idx, Math.random()));
-
-        parentData = parentVector.getStorage().data().clone();
-
-        testVector = new VectorView(parentVector, OFFSET, VIEW_LENGTH);
-    }
-
-    /** */
-    @AfterClass
-    public static void cleanup() throws IOException {
-        Files.deleteIfExists(Paths.get(EXTERNALIZE_TEST_FILE_NAME));
-    }
-
-    /** */
-    @Test
-    public void testCopy() throws Exception {
-        Vector cp = testVector.copy();
-
-        assertTrue(MathTestConstants.VAL_NOT_EQUALS, cp.equals(testVector));
-    }
-
-    /** */
-    @Test(expected = org.apache.ignite.math.exceptions.UnsupportedOperationException.class)
-    public void testLike() throws Exception {
-        for (int card : new int[] {1, 2, 4, 8, 16, 32, 64, 128})
-            consumeSampleVectors((v, desc) -> {
-                Vector vLike = new VectorView(v, 0, 1).like(card);
-
-                Class<? extends Vector> expType = v.getClass();
-
-                assertNotNull("Expect non-null like vector for " + expType.getSimpleName() + " in " + desc, vLike);
-
-                assertEquals("Expect size equal to cardinality at " + desc, card, vLike.size());
-
-                Class<? extends Vector> actualType = vLike.getClass();
-
-                assertTrue("Expected matrix type " + expType.getSimpleName()
-                        + " should be assignable from actual type " + actualType.getSimpleName() + " in " + desc,
-                    expType.isAssignableFrom(actualType));
-
-            });
-    }
-
-    /** See also {@link VectorToMatrixTest#testLikeMatrix()}. */
-    @Test
-    public void testLikeMatrix() {
-        consumeSampleVectors((v, desc) -> {
-            boolean expECaught = false;
-
-            try {
-                assertNull("Null view instead of exception in " + desc, new VectorView(v, 0, 1).likeMatrix(1, 1));
-            }
-            catch (UnsupportedOperationException uoe) {
-                expECaught = true;
-            }
-
-            assertTrue("Expected exception was not caught in " + desc, expECaught);
-        });
-    }
-
-    /** */
-    @Test
-    public void testWriteReadExternal() throws Exception {
-        assertNotNull("Unexpected null parent data", parentData);
-
-        File f = new File(EXTERNALIZE_TEST_FILE_NAME);
-
-        try {
-            ObjectOutputStream objOutputStream = new ObjectOutputStream(new FileOutputStream(f));
-
-            objOutputStream.writeObject(testVector);
-
-            objOutputStream.close();
-
-            ObjectInputStream objInputStream = new ObjectInputStream(new FileInputStream(f));
-
-            VectorView readVector = (VectorView)objInputStream.readObject();
-
-            objInputStream.close();
-
-            assertTrue(MathTestConstants.VAL_NOT_EQUALS, testVector.equals(readVector));
-        }
-        catch (ClassNotFoundException | IOException e) {
-            fail(e.getMessage());
-        }
-    }
-
-    /** */
-    private void consumeSampleVectors(BiConsumer<Vector, String> consumer) {
-        new VectorImplementationsFixtures().consumeSampleVectors(null, consumer);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/ExternalizeTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/ExternalizeTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/ExternalizeTest.java
new file mode 100644
index 0000000..32a8ec1
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/ExternalizeTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Common test for externalization.
+ */
+public abstract class ExternalizeTest<T extends Externalizable & Destroyable> {
+    /** */
+    protected void externalizeTest(T initObj) {
+        T objRestored = null;
+
+        try {
+            ByteArrayOutputStream byteArrOutputStream = new ByteArrayOutputStream();
+            ObjectOutputStream objOutputStream = new ObjectOutputStream(byteArrOutputStream);
+
+            objOutputStream.writeObject(initObj);
+
+            ByteArrayInputStream byteArrInputStream = new ByteArrayInputStream(byteArrOutputStream.toByteArray());
+            ObjectInputStream objInputStream = new ObjectInputStream(byteArrInputStream);
+
+            objRestored = (T)objInputStream.readObject();
+
+            assertTrue(MathTestConstants.VAL_NOT_EQUALS, initObj.equals(objRestored));
+            assertTrue(MathTestConstants.VAL_NOT_EQUALS, Integer.compare(initObj.hashCode(), objRestored.hashCode()) == 0);
+        }
+        catch (ClassNotFoundException | IOException e) {
+            fail(e + " [" + e.getMessage() + "]");
+        }
+        finally {
+            if (objRestored != null)
+                objRestored.destroy();
+        }
+    }
+
+    /** */
+    @Test
+    public abstract void externalizeTest();
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplDistributedTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplDistributedTestSuite.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplDistributedTestSuite.java
new file mode 100644
index 0000000..720a090
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplDistributedTestSuite.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import org.apache.ignite.ml.math.impls.matrix.CacheMatrixTest;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrixTest;
+import org.apache.ignite.ml.math.impls.storage.matrix.SparseDistributedMatrixStorageTest;
+import org.apache.ignite.ml.math.impls.vector.CacheVectorTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite for all distributed tests located in org.apache.ignite.math.impls.* package.
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    CacheVectorTest.class,
+    CacheMatrixTest.class,
+    SparseDistributedMatrixStorageTest.class,
+    SparseDistributedMatrixTest.class,
+})
+public class MathImplDistributedTestSuite {
+    // No-op.
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplLocalTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplLocalTestSuite.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplLocalTestSuite.java
new file mode 100644
index 0000000..be9c33a
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplLocalTestSuite.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import org.apache.ignite.ml.math.decompositions.CholeskyDecompositionTest;
+import org.apache.ignite.ml.math.decompositions.EigenDecompositionTest;
+import org.apache.ignite.ml.math.decompositions.LUDecompositionTest;
+import org.apache.ignite.ml.math.decompositions.QRDecompositionTest;
+import org.apache.ignite.ml.math.decompositions.SingularValueDecompositionTest;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOffHeapMatrixConstructorTest;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrixConstructorTest;
+import org.apache.ignite.ml.math.impls.matrix.DiagonalMatrixTest;
+import org.apache.ignite.ml.math.impls.matrix.FunctionMatrixConstructorTest;
+import org.apache.ignite.ml.math.impls.matrix.MatrixAttributeTest;
+import org.apache.ignite.ml.math.impls.matrix.MatrixImplementationsTest;
+import org.apache.ignite.ml.math.impls.matrix.MatrixViewConstructorTest;
+import org.apache.ignite.ml.math.impls.matrix.PivotedMatrixViewConstructorTest;
+import org.apache.ignite.ml.math.impls.matrix.RandomMatrixConstructorTest;
+import org.apache.ignite.ml.math.impls.matrix.SparseLocalOnHeapMatrixConstructorTest;
+import org.apache.ignite.ml.math.impls.matrix.TransposedMatrixViewTest;
+import org.apache.ignite.ml.math.impls.storage.matrix.MatrixArrayStorageTest;
+import org.apache.ignite.ml.math.impls.storage.matrix.MatrixOffHeapStorageTest;
+import org.apache.ignite.ml.math.impls.storage.matrix.MatrixStorageImplementationTest;
+import org.apache.ignite.ml.math.impls.storage.vector.RandomAccessSparseVectorStorageTest;
+import org.apache.ignite.ml.math.impls.storage.vector.SparseLocalOffHeapVectorStorageTest;
+import org.apache.ignite.ml.math.impls.storage.vector.VectorArrayStorageTest;
+import org.apache.ignite.ml.math.impls.storage.vector.VectorOffheapStorageTest;
+import org.apache.ignite.ml.math.impls.vector.AbstractVectorTest;
+import org.apache.ignite.ml.math.impls.vector.ConstantVectorConstructorTest;
+import org.apache.ignite.ml.math.impls.vector.DelegatingVectorConstructorTest;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOffHeapVectorConstructorTest;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVectorConstructorTest;
+import org.apache.ignite.ml.math.impls.vector.FunctionVectorConstructorTest;
+import org.apache.ignite.ml.math.impls.vector.MatrixVectorViewTest;
+import org.apache.ignite.ml.math.impls.vector.PivotedVectorViewConstructorTest;
+import org.apache.ignite.ml.math.impls.vector.RandomVectorConstructorTest;
+import org.apache.ignite.ml.math.impls.vector.SingleElementVectorConstructorTest;
+import org.apache.ignite.ml.math.impls.vector.SingleElementVectorViewConstructorTest;
+import org.apache.ignite.ml.math.impls.vector.SparseLocalVectorConstructorTest;
+import org.apache.ignite.ml.math.impls.vector.VectorAttributesTest;
+import org.apache.ignite.ml.math.impls.vector.VectorFoldMapTest;
+import org.apache.ignite.ml.math.impls.vector.VectorImplementationsTest;
+import org.apache.ignite.ml.math.impls.vector.VectorIterableTest;
+import org.apache.ignite.ml.math.impls.vector.VectorNormTest;
+import org.apache.ignite.ml.math.impls.vector.VectorToMatrixTest;
+import org.apache.ignite.ml.math.impls.vector.VectorViewTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite for all local tests located in org.apache.ignite.math.impls.* package.
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    // Vector constructors tests.
+    DenseLocalOnHeapVectorConstructorTest.class,
+    DenseLocalOffHeapVectorConstructorTest.class,
+    SparseLocalVectorConstructorTest.class,
+    RandomVectorConstructorTest.class,
+    ConstantVectorConstructorTest.class,
+    FunctionVectorConstructorTest.class,
+    SingleElementVectorConstructorTest.class,
+    PivotedVectorViewConstructorTest.class,
+    SingleElementVectorViewConstructorTest.class,
+    DelegatingVectorConstructorTest.class,
+    // Various vectors tests.
+    AbstractVectorTest.class,
+    VectorImplementationsTest.class,
+    VectorViewTest.class,
+    MatrixVectorViewTest.class,
+    // Vector particular features tests.
+    VectorIterableTest.class,
+    VectorAttributesTest.class,
+    VectorToMatrixTest.class,
+    VectorNormTest.class,
+    VectorFoldMapTest.class,
+    // Vector storage tests
+    VectorArrayStorageTest.class,
+    VectorOffheapStorageTest.class,
+    RandomAccessSparseVectorStorageTest.class,
+    SparseLocalOffHeapVectorStorageTest.class,
+    // Matrix storage tests.
+    MatrixStorageImplementationTest.class,
+    MatrixOffHeapStorageTest.class,
+    MatrixArrayStorageTest.class,
+    // Matrix constructors tests.
+    DenseLocalOnHeapMatrixConstructorTest.class,
+    DenseLocalOffHeapMatrixConstructorTest.class,
+    RandomMatrixConstructorTest.class,
+    FunctionMatrixConstructorTest.class,
+    MatrixViewConstructorTest.class,
+    PivotedMatrixViewConstructorTest.class,
+    SparseLocalOnHeapMatrixConstructorTest.class,
+    // Matrix tests.
+    MatrixImplementationsTest.class,
+    DiagonalMatrixTest.class,
+    MatrixAttributeTest.class,
+    TransposedMatrixViewTest.class,
+    // Decomposes
+    LUDecompositionTest.class,
+    EigenDecompositionTest.class,
+    CholeskyDecompositionTest.class,
+    QRDecompositionTest.class,
+    SingularValueDecompositionTest.class
+})
+public class MathImplLocalTestSuite {
+    // No-op.
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplMainTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplMainTestSuite.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplMainTestSuite.java
new file mode 100644
index 0000000..5f41583
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplMainTestSuite.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite for local and distributed tests
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    MathImplLocalTestSuite.class,
+    MathImplDistributedTestSuite.class
+})
+public class MathImplMainTestSuite {
+    // No-op.
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
new file mode 100644
index 0000000..d7c746d
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math;
+
+import java.awt.Color;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Optional;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.junit.Test;
+
+import static java.nio.file.Files.createTempFile;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests for {@link Tracer}.
+ */
+public class TracerTest {
+    /** */ private static final String DEFAULT_FORMAT = "%.10f";
+    /** */ private static final double DEFAULT_DELTA = 0.000000001d;
+
+    /**
+     * Color mapper that maps [0, 1] range into three distinct RGB segments.
+     */
+    private static final Tracer.ColorMapper COLOR_MAPPER = new Tracer.ColorMapper() {
+        /** {@inheritDoc} */
+        @Override public Color apply(Double d) {
+            if (d <= 0.33)
+                return Color.RED;
+            else if (d <= 0.66)
+                return Color.GREEN;
+            else
+                return Color.BLUE;
+        }
+    };
+
+    /**
+     * @param size Vector size.
+     */
+    private Vector makeRandomVector(int size) {
+        DenseLocalOnHeapVector vec = new DenseLocalOnHeapVector(size);
+
+        vec.assign((idx) -> Math.random());
+
+        return vec;
+    }
+
+    /**
+     * @param rows Amount of rows in matrix.
+     * @param cols Amount of columns in matrix.
+     */
+    private Matrix makeRandomMatrix(int rows, int cols) {
+        DenseLocalOnHeapMatrix mtx = new DenseLocalOnHeapMatrix(rows, cols);
+
+        // Missing assign(f)?
+        mtx.map((d) -> Math.random());
+
+        return mtx;
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void testAsciiVectorTracer() {
+        Vector vec = makeRandomVector(20);
+
+        Tracer.showAscii(vec);
+        Tracer.showAscii(vec, "%2f");
+        Tracer.showAscii(vec, "%.3g");
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void testAsciiMatrixTracer() {
+        Matrix mtx = makeRandomMatrix(10, 10);
+
+        Tracer.showAscii(mtx);
+        Tracer.showAscii(mtx, "%2f");
+        Tracer.showAscii(mtx, "%.3g");
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void testHtmlVectorTracer() throws IOException {
+        Vector vec1 = makeRandomVector(1000);
+
+        // Default color mapping.
+        Tracer.showHtml(vec1);
+
+        // Custom color mapping.
+        Tracer.showHtml(vec1, COLOR_MAPPER);
+
+        // Default color mapping with sorted vector.
+        Tracer.showHtml(vec1.sort());
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void testHtmlMatrixTracer() throws IOException {
+        Matrix mtx1 = makeRandomMatrix(100, 100);
+
+        // Custom color mapping.
+        Tracer.showHtml(mtx1, COLOR_MAPPER);
+
+        Matrix mtx2 = new DenseLocalOnHeapMatrix(100, 100);
+
+        double MAX = (double)(mtx2.rowSize() * mtx2.columnSize());
+
+        mtx2.assign((x, y) -> (double)(x * y) / MAX);
+
+        Tracer.showHtml(mtx2);
+    }
+
+    /** */
+    @Test
+    public void testWriteVectorToCSVFile() throws IOException {
+        DenseLocalOnHeapVector vector = new DenseLocalOnHeapVector(MathTestConstants.STORAGE_SIZE);
+
+        for (int i = 0; i < vector.size(); i++)
+            vector.set(i, Math.random());
+
+        Path file = createTempFile("vector", ".csv");
+
+        Tracer.saveAsCsv(vector, DEFAULT_FORMAT, file.toString());
+
+        System.out.println("Vector exported: " + file.getFileName());
+
+        List<String> strings = Files.readAllLines(file);
+        Optional<String> reduce = strings.stream().reduce((s1, s2) -> s1 + s2);
+        String[] csvVals = reduce.get().split(",");
+
+        for (int i = 0; i < vector.size(); i++) {
+            Double csvVal = Double.valueOf(csvVals[i]);
+
+            assertEquals("Unexpected value.", csvVal, vector.get(i), DEFAULT_DELTA);
+        }
+
+        Files.deleteIfExists(file);
+    }
+
+    /** */
+    @Test
+    public void testWriteMatrixToCSVFile() throws IOException {
+        DenseLocalOnHeapMatrix matrix = new DenseLocalOnHeapMatrix(MathTestConstants.STORAGE_SIZE, MathTestConstants.STORAGE_SIZE);
+
+        for (int i = 0; i < matrix.rowSize(); i++)
+            for (int j = 0; j < matrix.columnSize(); j++)
+                matrix.set(i, j, Math.random());
+
+        Path file = createTempFile("matrix", ".csv");
+
+        Tracer.saveAsCsv(matrix, DEFAULT_FORMAT, file.toString());
+
+        System.out.println("Matrix exported: " + file.getFileName());
+
+        List<String> strings = Files.readAllLines(file);
+        Optional<String> reduce = strings.stream().reduce((s1, s2) -> s1 + s2);
+        String[] csvVals = reduce.get().split(",");
+
+        for (int i = 0; i < matrix.rowSize(); i++)
+            for (int j = 0; j < matrix.columnSize(); j++) {
+                Double csvVal = Double.valueOf(csvVals[i * matrix.rowSize() + j]);
+
+                assertEquals("Unexpected value.", csvVal, matrix.get(i, j), DEFAULT_DELTA);
+            }
+
+        Files.deleteIfExists(file);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/MathBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/MathBenchmark.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/MathBenchmark.java
new file mode 100644
index 0000000..33ccfc9
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/MathBenchmark.java
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.benchmark;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+/** Refer {@link MathBenchmarkSelfTest} for usage examples. */
+class MathBenchmark {
+    /** */
+    private final boolean outputToConsole;
+
+    /** */
+    private final String benchmarkName;
+
+    /** */
+    private final int measurementTimes;
+
+    /** */
+    private final int warmUpTimes;
+
+    /** */
+    private final String tag;
+
+    /** */
+    private final String comments;
+
+    /** Constructor strictly for use within this class. */
+    private MathBenchmark(String benchmarkName, boolean outputToConsole, int measurementTimes, int warmUpTimes,
+        String tag, String comments) {
+        this.benchmarkName = benchmarkName;
+        this.outputToConsole = outputToConsole;
+        this.measurementTimes = measurementTimes;
+        this.warmUpTimes = warmUpTimes;
+        this.tag = tag;
+        this.comments = comments;
+        validate();
+    }
+
+    /**
+     * Benchmark with specified name and default parameters, in particular, default output file.
+     *
+     * @param benchmarkName name
+     */
+    MathBenchmark(String benchmarkName) {
+        this(benchmarkName, false, 100, 1, "", "");
+    }
+
+    /**
+     * Executes the code using config of this benchmark.
+     *
+     * @param code code to execute
+     * @throws Exception if something goes wrong
+     */
+    void execute(BenchmarkCode code) throws Exception {
+        System.out.println("Started benchmark [" + benchmarkName + "].");
+
+        for (int cnt = 0; cnt < warmUpTimes; cnt++)
+            code.call();
+
+        final long start = System.currentTimeMillis();
+
+        for (int cnt = 0; cnt < measurementTimes; cnt++)
+            code.call();
+
+        final long end = System.currentTimeMillis();
+
+        writeResults(formatResults(start, end));
+
+        System.out.println("Finished benchmark [" + benchmarkName + "].");
+    }
+
+    /**
+     * Set optional output mode for using stdout.
+     *
+     * @return configured benchmark
+     */
+    MathBenchmark outputToConsole() {
+        return new MathBenchmark(benchmarkName, true, measurementTimes, warmUpTimes, tag, comments);
+    }
+
+    /**
+     * Set optional measurement times.
+     *
+     * @param param times
+     * @return configured benchmark
+     */
+    MathBenchmark measurementTimes(int param) {
+        return new MathBenchmark(benchmarkName, outputToConsole, param, warmUpTimes, tag, comments);
+    }
+
+    /**
+     * Set optional warm-up times.
+     *
+     * @param param times
+     * @return configured benchmark
+     */
+    MathBenchmark warmUpTimes(int param) {
+        return new MathBenchmark(benchmarkName, outputToConsole, measurementTimes, param, tag, comments);
+    }
+
+    /**
+     * Set optional tag to help filtering specific kind of benchmark results.
+     *
+     * @param param name
+     * @return configured benchmark
+     */
+    MathBenchmark tag(String param) {
+        return new MathBenchmark(benchmarkName, outputToConsole, measurementTimes, warmUpTimes, param, comments);
+    }
+
+    /**
+     * Set optional comments.
+     *
+     * @param param name
+     * @return configured benchmark
+     */
+    MathBenchmark comments(String param) {
+        return new MathBenchmark(benchmarkName, outputToConsole, measurementTimes, warmUpTimes, tag, param);
+    }
+
+    /** */
+    private void writeResults(String results) throws Exception {
+        if (outputToConsole) {
+            System.out.println(results);
+
+            return;
+        }
+
+        new ResultsWriter().append(results);
+    }
+
+    /** */
+    private String formatResults(long start, long end) {
+        final String delim = ",";
+
+        assert !formatDouble(1000_000_001.1).contains(delim) : "Formatted results contain [" + delim + "].";
+
+        final String ts = formatTs(start);
+
+        assert !ts.contains(delim) : "Formatted timestamp contains [" + delim + "].";
+
+        return benchmarkName +
+            delim +
+            ts + // IMPL NOTE timestamp
+            delim +
+            formatDouble((double)(end - start) / measurementTimes) +
+            delim +
+            measurementTimes +
+            delim +
+            warmUpTimes +
+            delim +
+            tag +
+            delim +
+            comments;
+    }
+
+    /** */
+    private String formatDouble(double val) {
+        return String.format(Locale.US, "%f", val);
+    }
+
+    /** */
+    private String formatTs(long ts) {
+        final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
+
+        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+
+        return sdf.format(new Date(ts));
+    }
+
+    /** */
+    private void validate() {
+        if (benchmarkName == null || benchmarkName.isEmpty())
+            throw new IllegalArgumentException("Invalid benchmark name: [" + benchmarkName + "].");
+
+        if (measurementTimes < 1)
+            throw new IllegalArgumentException("Invalid measurement times: [" + measurementTimes + "].");
+    }
+
+    /** */
+    interface BenchmarkCode {
+        // todo find out why Callable<Void> failed to work here
+
+        /** */
+        void call() throws Exception;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/MathBenchmarkSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/MathBenchmarkSelfTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/MathBenchmarkSelfTest.java
new file mode 100644
index 0000000..86b29db
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/MathBenchmarkSelfTest.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.benchmark;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class MathBenchmarkSelfTest {
+    /** */
+    @Test
+    @Ignore("Benchmark tests are intended only for manual execution")
+    public void demoTest() throws Exception {
+        for (int i = 0; i < 2; i++)
+            new MathBenchmark("demo test")
+                .outputToConsole() // IMPL NOTE this is to write output into console instead of a file
+                .tag(null) // IMPL NOTE try null for tag, expect it to be formatted reasonably
+                .comments(null) // IMPL NOTE try null for comments, expect it to be formatted reasonably
+                .execute(() -> {
+                    double seed = 1.1;
+
+                    for (int cnt = 0; cnt < 1000; cnt++) {
+                        seed = Math.pow(seed, 2);
+
+                        assertTrue(seed > 0);
+                    }
+                });
+    }
+
+    /** */
+    @Test
+    @Ignore("Benchmark tests are intended only for manual execution")
+    public void configTest() throws Exception {
+        new MathBenchmark("demo config test")
+            .outputToConsole()
+            .measurementTimes(2)
+            .warmUpTimes(0)
+            .tag("demo tag")
+            .comments("demo comments")
+            .execute(() -> System.out.println("config test"));
+    }
+
+    /** */
+    @Test(expected = IllegalArgumentException.class)
+    @Ignore("Benchmark tests are intended only for manual execution")
+    public void emptyNameTest() throws Exception {
+        new MathBenchmark("")
+            .outputToConsole()
+            .measurementTimes(1)
+            .warmUpTimes(1)
+            .tag("empty name test tag")
+            .comments("empty name test comments")
+            .execute(() -> System.out.println("empty name test"));
+    }
+
+    /** */
+    @Test(expected = IllegalArgumentException.class)
+    @Ignore("Benchmark tests are intended only for manual execution")
+    public void nullDropboxPathTest() throws Exception {
+        new ResultsWriter(null, "whatever", "whatever");
+    }
+
+    /** */
+    @Test(expected = IllegalArgumentException.class)
+    @Ignore("Benchmark tests are intended only for manual execution")
+    public void nullDropboxUrlTest() throws Exception {
+        new ResultsWriter("whatever", null, "whatever");
+    }
+
+    /** */
+    @Test(expected = IllegalArgumentException.class)
+    @Ignore("Benchmark tests are intended only for manual execution")
+    public void nullDropboxTokenTest() throws Exception {
+        new ResultsWriter("whatever", "whatever", null);
+    }
+
+    /** */
+    @Test(expected = IllegalArgumentException.class)
+    @Ignore("Benchmark tests are intended only for manual execution")
+    public void nullResultsTest() throws Exception {
+        new ResultsWriter("whatever", "whatever", "whatever").append(null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/ResultsWriter.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/ResultsWriter.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/ResultsWriter.java
new file mode 100644
index 0000000..2c37bff
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/ResultsWriter.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.benchmark;
+
+import com.dropbox.core.DbxException;
+import com.dropbox.core.DbxRequestConfig;
+import com.dropbox.core.v2.DbxClientV2;
+import com.dropbox.core.v2.files.WriteMode;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.util.UUID;
+
+/** */
+class ResultsWriter {
+    /** */
+    private static final String DROPBOX_PATH
+        = "/benchmarks/math.benchmark.results.csv";
+
+    /** */
+    private static final String DROPBOX_URL
+        = "https://www.dropbox.com/s/r7tcle31r7gaty8/math.benchmark.results.csv";
+
+    /** */
+    private static final String ACCESS_TOKEN
+        = "1MMmQjEyzGAAAAAAAAAAfDFrQ6oBPPi4NX-iU_VrgmXB2JDXqRHGa125cTkkEQ0V";
+
+    /** */
+    private final String dropboxPath;
+    /** */
+    private final String dropboxUrl;
+    /** */
+    private final String accessTok;
+
+    /** */
+    ResultsWriter(String dropboxPath, String dropboxUrl, String accessTok) {
+        this.dropboxPath = dropboxPath;
+        this.dropboxUrl = dropboxUrl;
+        this.accessTok = accessTok;
+
+        if (dropboxPath == null || dropboxUrl == null || accessTok == null)
+            throw new IllegalArgumentException("Neither of dropbox path, URL, access token can be null.");
+    }
+
+    /** **/
+    ResultsWriter() {
+        this(DROPBOX_PATH, DROPBOX_URL, ACCESS_TOKEN);
+    }
+
+    /** */
+    void append(String res) throws DbxException, IOException {
+        if (res == null)
+            throw new IllegalArgumentException("benchmark result is null");
+
+        if (dropboxPath == null) {
+            System.out.println(res);
+
+            return;
+        }
+
+        append(res, client());
+    }
+
+    /** */
+    private void append(String res, DbxClientV2 client) throws DbxException, IOException {
+        File tmp = createTmpFile();
+
+        try (FileOutputStream out = new FileOutputStream(tmp)) {
+            client.files().download(dropboxPath).download(out);
+        }
+
+        writeResults(res, tmp);
+
+        try (FileInputStream in = new FileInputStream(tmp)) {
+            client.files().uploadBuilder(dropboxPath).withMode(WriteMode.OVERWRITE).uploadAndFinish(in);
+        }
+
+        if (!tmp.delete())
+            System.out.println("Failed to delete " + tmp.getAbsolutePath());
+
+        System.out.println("Uploaded benchmark results to: " + dropboxUrl);
+    }
+
+    /** */
+    private void writeResults(String res, File tmp) throws IOException {
+        final String unixLineSeparator = "\n";
+
+        try (final PrintWriter writer = new PrintWriter(Files.newBufferedWriter(Paths.get(tmp.toURI()),
+            StandardOpenOption.APPEND, StandardOpenOption.CREATE))) {
+            writer.write(res + unixLineSeparator);
+        }
+    }
+
+    /** */
+    private File createTmpFile() throws IOException {
+        File tmp = File.createTempFile(UUID.randomUUID().toString(), ".csv");
+
+        tmp.deleteOnExit();
+
+        return tmp;
+    }
+
+    /** */
+    private DbxClientV2 client() {
+        return new DbxClientV2(DbxRequestConfig.newBuilder("dropbox/MathBenchmark").build(), accessTok);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/VectorBenchmarkTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/VectorBenchmarkTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/VectorBenchmarkTest.java
new file mode 100644
index 0000000..fd98382
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/VectorBenchmarkTest.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.benchmark;
+
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOffHeapVector;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+/** */
+public class VectorBenchmarkTest {
+    // todo add benchmarks for other methods in Vector and for other types of Vector and Matrix
+
+    /** */
+    @Test
+    @Ignore("Benchmark tests are intended only for manual execution")
+    public void testDenseLocalOnHeapVector() throws Exception {
+        benchmark("DenseLocalOnHeapVector basic mix", DenseLocalOnHeapVector::new, this::basicMix);
+
+        benchmark("DenseLocalOnHeapVector fold map", DenseLocalOnHeapVector::new, this::foldMapMix);
+    }
+
+    /** */
+    @Test
+    @Ignore("Benchmark tests are intended only for manual execution")
+    public void testDenseLocalOffHeapVector() throws Exception {
+        benchmark("DenseLocalOffHeapVector basic mix", DenseLocalOffHeapVector::new, this::basicMix);
+
+        benchmark("DenseLocalOffHeapVector fold map", DenseLocalOffHeapVector::new, this::foldMapMix);
+    }
+
+    /** */
+    private void benchmark(String namePrefix, Function<Integer, Vector> constructor,
+        BiConsumer<Integer, Function<Integer, Vector>> consumer) throws Exception {
+        assertNotNull(namePrefix);
+
+        new MathBenchmark(namePrefix + " small sizes").execute(() -> {
+            for (int size : new int[] {2, 3, 4, 5, 6, 7})
+                consumer.accept(size, constructor);
+        });
+
+        new MathBenchmark(namePrefix + " sizes powers of 2").execute(() -> {
+            for (int power : new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14})
+                consumer.accept(1 << power, constructor);
+        });
+
+        new MathBenchmark(namePrefix + " large sizes").execute(() -> {
+            for (int power : new int[] {10, 12, 14, 16})
+                for (int delta : new int[] {-1, 0, 1})
+                    consumer.accept((1 << power) + delta, constructor);
+        });
+
+        new MathBenchmark(namePrefix + " extra large sizes")
+            .measurementTimes(10)
+            .execute(() -> { // IMPL NOTE trying below with power 22 almost killed my IDEA and laptop
+                for (int power : new int[] {17, 18, 19, 20, 21})
+                    for (int delta : new int[] {-1, 0}) // IMPL NOTE delta +1 is not intended for use here
+                        consumer.accept((1 << power) + delta, constructor);
+            });
+    }
+
+    /** */
+    private void basicMix(int size, Function<Integer, Vector> constructor) {
+        final Vector v1 = constructor.apply(size), v2 = constructor.apply(size);
+
+        for (int idx = 0; idx < size; idx++) {
+            v1.set(idx, idx);
+
+            v2.set(idx, size - idx);
+        }
+
+        assertNotNull(v1.sum());
+
+        assertNotNull(v1.copy());
+
+        assertFalse(v1.getLengthSquared() < 0);
+
+        assertNotNull(v1.normalize());
+
+        assertNotNull(v1.logNormalize());
+
+        assertFalse(v1.getDistanceSquared(v2) < 0);
+
+        assertNotNull(v1.divide(2));
+
+        assertNotNull(v1.minus(v2));
+
+        assertNotNull(v1.plus(v2));
+
+        assertNotNull(v1.dot(v2));
+
+        assertNotNull(v1.assign(v2));
+
+        assertNotNull(v1.assign(1)); // IMPL NOTE this would better be last test for it sets all values the same
+    }
+
+    /** */
+    private void foldMapMix(int size, Function<Integer, Vector> constructor) {
+        final Vector v1 = constructor.apply(size), v2 = constructor.apply(size);
+
+        for (int idx = 0; idx < size; idx++) {
+            v1.set(idx, idx);
+
+            v2.set(idx, size - idx);
+        }
+
+        assertNotNull(v1.map((val) -> (val + 1)));
+
+        assertNotNull(v1.map(v2, (one, other) -> one + other / 2.0));
+
+        assertNotNull(v1.map((val, val1) -> (val + val1), 2.0));
+
+        assertNotNull(v1.foldMap((sum, val) -> (val + sum), (val) -> val, 0.0));
+
+        assertNotNull(v1.foldMap(v2, (sum, val) -> (val + sum), (val1, val2) -> val1 + val2, 0.0));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/package-info.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/package-info.java
new file mode 100644
index 0000000..f77e6e32
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/benchmark/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.benchmark;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/CholeskyDecompositionTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/CholeskyDecompositionTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/CholeskyDecompositionTest.java
new file mode 100644
index 0000000..be03cb1
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/CholeskyDecompositionTest.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.decompositions;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.CardinalityException;
+import org.apache.ignite.ml.math.exceptions.NonPositiveDefiniteMatrixException;
+import org.apache.ignite.ml.math.exceptions.NonSymmetricMatrixException;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.impls.matrix.PivotedMatrixView;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/** */
+public class CholeskyDecompositionTest {
+    /** */
+    @Test
+    public void basicTest() {
+        basicTest(new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d, 0.0d},
+            {-1.0d, 2.0d, -1.0d},
+            {0.0d, -1.0d, 2.0d}
+        }));
+    }
+
+    /**
+     * Test for {@link DecompositionSupport} features.
+     */
+    @Test
+    public void decompositionSupportTest() {
+        basicTest(new PivotedMatrixView(new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d, 0.0d},
+            {-1.0d, 2.0d, -1.0d},
+            {0.0d, -1.0d, 2.0d}
+        })));
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void nullMatrixTest() {
+        new CholeskyDecomposition(null);
+    }
+
+    /** */
+    @Test(expected = CardinalityException.class)
+    public void wrongMatrixSizeTest() {
+        new CholeskyDecomposition(new DenseLocalOnHeapMatrix(2, 3));
+    }
+
+    /** */
+    @Test(expected = NonSymmetricMatrixException.class)
+    public void nonSymmetricMatrixTest() {
+        new CholeskyDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d, 10.0d},
+            {-1.0d, 2.0d, -1.0d},
+            {-10.0d, -1.0d, 2.0d}
+        }));
+    }
+
+    /** */
+    @Test(expected = NonPositiveDefiniteMatrixException.class)
+    public void nonAbsPositiveMatrixTest() {
+        new CholeskyDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d, 0.0d},
+            {-1.0d, 0.0d, -1.0d},
+            {0.0d, -1.0d, 2.0d}
+        }));
+    }
+
+    /** */
+    @Test(expected = CardinalityException.class)
+    public void solveWrongVectorSizeTest() {
+        new CholeskyDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d, 0.0d},
+            {-1.0d, 2.0d, -1.0d},
+            {0.0d, -1.0d, 2.0d}
+        })).solve(new DenseLocalOnHeapVector(2));
+    }
+
+    /** */
+    @Test(expected = CardinalityException.class)
+    public void solveWrongMatrixSizeTest() {
+        new CholeskyDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d, 0.0d},
+            {-1.0d, 2.0d, -1.0d},
+            {0.0d, -1.0d, 2.0d}
+        })).solve(new DenseLocalOnHeapMatrix(2, 3));
+    }
+
+    /** */
+    private void basicTest(Matrix m) {
+        // This decomposition is useful when dealing with systems of linear equations of the form
+        // m x = b where m is a Hermitian matrix.
+        // For such systems Cholesky decomposition provides
+        // more effective method of solving compared to LU decomposition.
+        // Suppose we want to solve system
+        // m x = b for various bs. Then after we computed Cholesky decomposition, we can feed various bs
+        // as a matrix of the form
+        // (b1, b2, ..., bm)
+        // to the method Cholesky::solve which returns solutions in the form
+        // (sol1, sol2, ..., solm)
+        CholeskyDecomposition dec = new CholeskyDecomposition(m);
+        assertEquals("Unexpected value for decomposition determinant.",
+            4d, dec.getDeterminant(), 0d);
+
+        Matrix l = dec.getL();
+        Matrix lt = dec.getLT();
+
+        assertNotNull("Matrix l is expected to be not null.", l);
+        assertNotNull("Matrix lt is expected to be not null.", lt);
+
+        for (int row = 0; row < l.rowSize(); row++)
+            for (int col = 0; col < l.columnSize(); col++)
+                assertEquals("Unexpected value transposed matrix at (" + row + "," + col + ").",
+                    l.get(row, col), lt.get(col, row), 0d);
+
+        Matrix bs = new DenseLocalOnHeapMatrix(new double[][] {
+            {4.0, -6.0, 7.0},
+            {1.0, 1.0, 1.0}
+        }).transpose();
+        Matrix sol = dec.solve(bs);
+
+        assertNotNull("Solution matrix is expected to be not null.", sol);
+        assertEquals("Solution rows are not as expected.", bs.rowSize(), sol.rowSize());
+        assertEquals("Solution columns are not as expected.", bs.columnSize(), sol.columnSize());
+
+        for (int i = 0; i < sol.columnSize(); i++)
+            assertNotNull("Solution matrix column is expected to be not null at index " + i, sol.viewColumn(i));
+
+        Vector b = new DenseLocalOnHeapVector(new double[] {4.0, -6.0, 7.0});
+        Vector solVec = dec.solve(b);
+
+        for (int idx = 0; idx < b.size(); idx++)
+            assertEquals("Unexpected value solution vector at " + idx,
+                b.get(idx), solVec.get(idx), 0d);
+
+        dec.destroy();
+    }
+}


[05/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/EigenDecompositionTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/EigenDecompositionTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/EigenDecompositionTest.java
new file mode 100644
index 0000000..d283ce7
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/EigenDecompositionTest.java
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.decompositions;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests for {@link EigenDecomposition}
+ */
+public class EigenDecompositionTest {
+    /** */
+    private static final double EPSILON = 1e-11;
+
+    /** */
+    @Test
+    public void testMatrixWithRealEigenvalues() {
+        test(new double[][] {
+                {1.0d, 0.0d, 0.0d, 0.0d},
+                {0.0d, 1.0d, 0.0d, 0.0d},
+                {0.0d, 0.0d, 2.0d, 0.0d},
+                {1.0d, 1.0d, 0.0d, 2.0d}},
+            new double[] {1, 2, 2, 1});
+    }
+
+    /** */
+    @Test
+    public void testSymmetricMatrix() {
+        EigenDecomposition decomposition = new EigenDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
+            {1.0d, 0.0d, 0.0d, 1.0d},
+            {0.0d, 1.0d, 0.0d, 1.0d},
+            {0.0d, 0.0d, 2.0d, 0.0d},
+            {1.0d, 1.0d, 0.0d, 2.0d}}));
+
+        Matrix d = decomposition.getD();
+        Matrix v = decomposition.getV();
+
+        assertNotNull("Matrix d is expected to be not null.", d);
+        assertNotNull("Matrix v is expected to be not null.", v);
+
+        assertEquals("Unexpected rows in d matrix.", 4, d.rowSize());
+        assertEquals("Unexpected cols in d matrix.", 4, d.columnSize());
+
+        assertEquals("Unexpected rows in v matrix.", 4, v.rowSize());
+        assertEquals("Unexpected cols in v matrix.", 4, v.columnSize());
+
+        assertIsDiagonalNonZero(d);
+
+        decomposition.destroy();
+    }
+
+    /** */
+    @Test
+    public void testNonSquareMatrix() {
+        EigenDecomposition decomposition = new EigenDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
+            {1.0d, 0.0d, 0.0d},
+            {0.0d, 1.0d, 0.0d},
+            {0.0d, 0.0d, 2.0d},
+            {1.0d, 1.0d, 0.0d}}));
+        // todo find out why decomposition of 3X4 matrix throws row index exception
+
+        Matrix d = decomposition.getD();
+        Matrix v = decomposition.getV();
+
+        assertNotNull("Matrix d is expected to be not null.", d);
+        assertNotNull("Matrix v is expected to be not null.", v);
+
+        assertEquals("Unexpected rows in d matrix.", 4, d.rowSize());
+        assertEquals("Unexpected cols in d matrix.", 4, d.columnSize());
+
+        assertEquals("Unexpected rows in v matrix.", 4, v.rowSize());
+        assertEquals("Unexpected cols in v matrix.", 3, v.columnSize());
+
+        assertIsDiagonal(d, true);
+
+        decomposition.destroy();
+    }
+
+    /** */
+    private void test(double[][] mRaw, double[] expRealEigenValues) {
+        DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(mRaw);
+        EigenDecomposition decomposition = new EigenDecomposition(m);
+
+        Matrix d = decomposition.getD();
+        Matrix v = decomposition.getV();
+
+        assertIsDiagonalNonZero(d);
+
+        // check that d's diagonal consists of eigenvalues of m.
+        assertDiagonalConsistsOfEigenvalues(m, d, v);
+
+        // m = v d v^{-1} is equivalent to
+        // m v = v d
+        assertMatricesAreEqual(m.times(v), v.times(d));
+
+        assertEigenvalues(decomposition, expRealEigenValues);
+
+        decomposition.destroy();
+    }
+
+    /** */
+    private void assertEigenvalues(EigenDecomposition decomposition, double[] expRealEigenValues) {
+        Vector real = decomposition.getRealEigenValues();
+        Vector imag = decomposition.getImagEigenvalues();
+
+        assertEquals("Real values size differs from expected.", expRealEigenValues.length, real.size());
+        assertEquals("Imag values size differs from expected.", expRealEigenValues.length, imag.size());
+
+        for (int idx = 0; idx < expRealEigenValues.length; idx++) {
+            assertEquals("Real eigen value differs from expected at " + idx,
+                expRealEigenValues[idx], real.get(idx), 0d);
+
+            assertEquals("Imag eigen value differs from expected at " + idx,
+                0d, imag.get(idx), 0d);
+        }
+
+    }
+
+    /** */
+    private void assertDiagonalConsistsOfEigenvalues(DenseLocalOnHeapMatrix m, Matrix d, Matrix v) {
+        int n = m.columnSize();
+        for (int i = 0; i < n; i++) {
+            Vector eigenVector = v.viewColumn(i);
+            double eigenVal = d.getX(i, i);
+            assertVectorsAreEqual(m.times(eigenVector), eigenVector.times(eigenVal));
+        }
+
+    }
+
+    /** */
+    private void assertMatricesAreEqual(Matrix exp, Matrix actual) {
+        assertTrue("The row sizes of matrices are not equal", exp.rowSize() == actual.rowSize());
+        assertTrue("The col sizes of matrices are not equal", exp.columnSize() == actual.columnSize());
+
+        // Since matrix is square, we need only one dimension
+        int n = exp.columnSize();
+
+        for (int i = 0; i < n; i++)
+            for (int j = 0; j < n; j++)
+                assertEquals("Values should be equal", exp.getX(i, j), actual.getX(i, j), EPSILON);
+    }
+
+    /** */
+    private void assertVectorsAreEqual(Vector exp, Vector actual) {
+        assertTrue("Vectors sizes are not equal", exp.size() == actual.size());
+
+        // Since matrix is square, we need only one dimension
+        int n = exp.size();
+
+        for (int i = 0; i < n; i++)
+            assertEquals("Values should be equal", exp.getX(i), actual.getX(i), EPSILON);
+    }
+
+    /** */
+    private void assertIsDiagonalNonZero(Matrix m) {
+        assertIsDiagonal(m, false);
+    }
+
+    /** */
+    private void assertIsDiagonal(Matrix m, boolean zeroesAllowed) {
+        // Since matrix is square, we need only one dimension
+        int n = m.columnSize();
+
+        assertEquals("Diagonal matrix is not square", n, m.rowSize());
+
+        for (int i = 0; i < n; i++)
+            for (int j = 0; j < n; j++)
+                assertTrue("Matrix is not diagonal, violation at (" + i + "," + j + ")",
+                    ((i == j) && (zeroesAllowed || m.getX(i, j) != 0))
+                        || ((i != j) && m.getX(i, j) == 0));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/LUDecompositionTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/LUDecompositionTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/LUDecompositionTest.java
new file mode 100644
index 0000000..fc76c39
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/LUDecompositionTest.java
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.decompositions;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.CardinalityException;
+import org.apache.ignite.ml.math.exceptions.SingularMatrixException;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.impls.matrix.PivotedMatrixView;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests for {@link LUDecomposition}.
+ */
+public class LUDecompositionTest {
+    /** */
+    private Matrix testL;
+    /** */
+    private Matrix testU;
+    /** */
+    private Matrix testP;
+    /** */
+    private Matrix testMatrix;
+    /** */
+    private int[] rawPivot;
+
+    /** */
+    @Before
+    public void setUp() {
+        double[][] rawMatrix = new double[][] {
+            {2.0d, 1.0d, 1.0d, 0.0d},
+            {4.0d, 3.0d, 3.0d, 1.0d},
+            {8.0d, 7.0d, 9.0d, 5.0d},
+            {6.0d, 7.0d, 9.0d, 8.0d}};
+        double[][] rawL = {
+            {1.0d, 0.0d, 0.0d, 0.0d},
+            {3.0d / 4.0d, 1.0d, 0.0d, 0.0d},
+            {1.0d / 2.0d, -2.0d / 7.0d, 1.0d, 0.0d},
+            {1.0d / 4.0d, -3.0d / 7.0d, 1.0d / 3.0d, 1.0d}};
+        double[][] rawU = {
+            {8.0d, 7.0d, 9.0d, 5.0d},
+            {0.0d, 7.0d / 4.0d, 9.0d / 4.0d, 17.0d / 4.0d},
+            {0.0d, 0.0d, -6.0d / 7.0d, -2.0d / 7.0d},
+            {0.0d, 0.0d, 0.0d, 2.0d / 3.0d}};
+        double[][] rawP = new double[][] {
+            {0, 0, 1.0d, 0},
+            {0, 0, 0, 1.0d},
+            {0, 1.0d, 0, 0},
+            {1.0d, 0, 0, 0}};
+
+        rawPivot = new int[] {3, 4, 2, 1};
+
+        testMatrix = new DenseLocalOnHeapMatrix(rawMatrix);
+        testL = new DenseLocalOnHeapMatrix(rawL);
+        testU = new DenseLocalOnHeapMatrix(rawU);
+        testP = new DenseLocalOnHeapMatrix(rawP);
+    }
+
+    /** */
+    @Test
+    public void getL() throws Exception {
+        Matrix luDecompositionL = new LUDecomposition(testMatrix).getL();
+
+        assertEquals("Unexpected row size.", testL.rowSize(), luDecompositionL.rowSize());
+        assertEquals("Unexpected column size.", testL.columnSize(), luDecompositionL.columnSize());
+
+        for (int i = 0; i < testL.rowSize(); i++)
+            for (int j = 0; j < testL.columnSize(); j++)
+                assertEquals("Unexpected value at (" + i + "," + j + ").",
+                    testL.getX(i, j), luDecompositionL.getX(i, j), 0.0000001d);
+
+        luDecompositionL.destroy();
+    }
+
+    /** */
+    @Test
+    public void getU() throws Exception {
+        Matrix luDecompositionU = new LUDecomposition(testMatrix).getU();
+
+        assertEquals("Unexpected row size.", testU.rowSize(), luDecompositionU.rowSize());
+        assertEquals("Unexpected column size.", testU.columnSize(), luDecompositionU.columnSize());
+
+        for (int i = 0; i < testU.rowSize(); i++)
+            for (int j = 0; j < testU.columnSize(); j++)
+                assertEquals("Unexpected value at (" + i + "," + j + ").",
+                    testU.getX(i, j), luDecompositionU.getX(i, j), 0.0000001d);
+
+        luDecompositionU.destroy();
+    }
+
+    /** */
+    @Test
+    public void getP() throws Exception {
+        Matrix luDecompositionP = new LUDecomposition(testMatrix).getP();
+
+        assertEquals("Unexpected row size.", testP.rowSize(), luDecompositionP.rowSize());
+        assertEquals("Unexpected column size.", testP.columnSize(), luDecompositionP.columnSize());
+
+        for (int i = 0; i < testP.rowSize(); i++)
+            for (int j = 0; j < testP.columnSize(); j++)
+                assertEquals("Unexpected value at (" + i + "," + j + ").",
+                    testP.getX(i, j), luDecompositionP.getX(i, j), 0.0000001d);
+
+        luDecompositionP.destroy();
+    }
+
+    /** */
+    @Test
+    public void getPivot() throws Exception {
+        Vector pivot = new LUDecomposition(testMatrix).getPivot();
+
+        assertEquals("Unexpected pivot size.", rawPivot.length, pivot.size());
+
+        for (int i = 0; i < testU.rowSize(); i++)
+            assertEquals("Unexpected value at " + i, rawPivot[i], (int)pivot.get(i) + 1);
+    }
+
+    /**
+     * Test for {@link DecompositionSupport} features.
+     */
+    @Test
+    public void decompositionSupportTest() {
+        LUDecomposition dec = new LUDecomposition(new PivotedMatrixView(testMatrix));
+        Matrix luDecompositionL = dec.getL();
+
+        assertEquals("Unexpected L row size.", testL.rowSize(), luDecompositionL.rowSize());
+        assertEquals("Unexpected L column size.", testL.columnSize(), luDecompositionL.columnSize());
+
+        for (int i = 0; i < testL.rowSize(); i++)
+            for (int j = 0; j < testL.columnSize(); j++)
+                assertEquals("Unexpected L value at (" + i + "," + j + ").",
+                    testL.getX(i, j), luDecompositionL.getX(i, j), 0.0000001d);
+
+        Matrix luDecompositionU = dec.getU();
+
+        assertEquals("Unexpected U row size.", testU.rowSize(), luDecompositionU.rowSize());
+        assertEquals("Unexpected U column size.", testU.columnSize(), luDecompositionU.columnSize());
+
+        for (int i = 0; i < testU.rowSize(); i++)
+            for (int j = 0; j < testU.columnSize(); j++)
+                assertEquals("Unexpected U value at (" + i + "," + j + ").",
+                    testU.getX(i, j), luDecompositionU.getX(i, j), 0.0000001d);
+
+        Matrix luDecompositionP = dec.getP();
+
+        assertEquals("Unexpected P row size.", testP.rowSize(), luDecompositionP.rowSize());
+        assertEquals("Unexpected P column size.", testP.columnSize(), luDecompositionP.columnSize());
+
+        for (int i = 0; i < testP.rowSize(); i++)
+            for (int j = 0; j < testP.columnSize(); j++)
+                assertEquals("Unexpected P value at (" + i + "," + j + ").",
+                    testP.getX(i, j), luDecompositionP.getX(i, j), 0.0000001d);
+
+        dec.destroy();
+    }
+
+    /** */
+    @Test
+    public void singularDeterminant() throws Exception {
+        assertEquals("Unexpected determinant for singular matrix decomposition.",
+            0d, new LUDecomposition(new DenseLocalOnHeapMatrix(2, 2)).determinant(), 0d);
+    }
+
+    /** */
+    @Test(expected = CardinalityException.class)
+    public void solveVecWrongSize() throws Exception {
+        new LUDecomposition(testMatrix).solve(new DenseLocalOnHeapVector(testMatrix.rowSize() + 1));
+    }
+
+    /** */
+    @Test(expected = SingularMatrixException.class)
+    public void solveVecSingularMatrix() throws Exception {
+        new LUDecomposition(new DenseLocalOnHeapMatrix(testMatrix.rowSize(), testMatrix.rowSize()))
+            .solve(new DenseLocalOnHeapVector(testMatrix.rowSize()));
+    }
+
+    /** */
+    @Test
+    public void solveVec() throws Exception {
+        Vector sol = new LUDecomposition(new PivotedMatrixView(testMatrix))
+            .solve(new DenseLocalOnHeapVector(testMatrix.rowSize()));
+
+        assertEquals("Wrong solution vector size.", testMatrix.rowSize(), sol.size());
+
+        for (int i = 0; i < sol.size(); i++)
+            assertEquals("Unexpected value at index " + i, 0d, sol.getX(i), 0.0000001d);
+    }
+
+    /** */
+    @Test(expected = CardinalityException.class)
+    public void solveMtxWrongSize() throws Exception {
+        new LUDecomposition(testMatrix).solve(
+            new DenseLocalOnHeapMatrix(testMatrix.rowSize() + 1, testMatrix.rowSize()));
+    }
+
+    /** */
+    @Test(expected = SingularMatrixException.class)
+    public void solveMtxSingularMatrix() throws Exception {
+        new LUDecomposition(new DenseLocalOnHeapMatrix(testMatrix.rowSize(), testMatrix.rowSize()))
+            .solve(new DenseLocalOnHeapMatrix(testMatrix.rowSize(), testMatrix.rowSize()));
+    }
+
+    /** */
+    @Test
+    public void solveMtx() throws Exception {
+        Matrix sol = new LUDecomposition(new PivotedMatrixView(testMatrix))
+            .solve(new DenseLocalOnHeapMatrix(testMatrix.rowSize(), testMatrix.rowSize()));
+
+        assertEquals("Wrong solution matrix row size.", testMatrix.rowSize(), sol.rowSize());
+
+        assertEquals("Wrong solution matrix column size.", testMatrix.rowSize(), sol.columnSize());
+
+        for (int row = 0; row < sol.rowSize(); row++)
+            for (int col = 0; col < sol.columnSize(); col++)
+                assertEquals("Unexpected P value at (" + row + "," + col + ").",
+                    0d, sol.getX(row, col), 0.0000001d);
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void nullMatrixTest() {
+        new LUDecomposition(null);
+    }
+
+    /** */
+    @Test(expected = CardinalityException.class)
+    public void nonSquareMatrixTest() {
+        new LUDecomposition(new DenseLocalOnHeapMatrix(2, 3));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/QRDecompositionTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/QRDecompositionTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/QRDecompositionTest.java
new file mode 100644
index 0000000..589d5d1
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/QRDecompositionTest.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.decompositions;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.impls.matrix.PivotedMatrixView;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class QRDecompositionTest {
+    /** */
+    @Test
+    public void basicTest() {
+        basicTest(new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d, 0.0d},
+            {-1.0d, 2.0d, -1.0d},
+            {0.0d, -1.0d, 2.0d}
+        }));
+    }
+
+    /**
+     * Test for {@link DecompositionSupport} features.
+     */
+    @Test
+    public void decompositionSupportTest() {
+        basicTest(new PivotedMatrixView(new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d, 0.0d},
+            {-1.0d, 2.0d, -1.0d},
+            {0.0d, -1.0d, 2.0d}
+        })));
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void nullMatrixTest() {
+        new QRDecomposition(null);
+    }
+
+    /** */
+    @Test(expected = IllegalArgumentException.class)
+    public void solveWrongMatrixSizeTest() {
+        new QRDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d, 0.0d},
+            {-1.0d, 2.0d, -1.0d},
+            {0.0d, -1.0d, 2.0d}
+        })).solve(new DenseLocalOnHeapMatrix(2, 3));
+    }
+
+    /** */
+    private void basicTest(Matrix m) {
+        QRDecomposition dec = new QRDecomposition(m);
+        assertTrue("Unexpected value for full rank in decomposition " + dec, dec.hasFullRank());
+
+        Matrix q = dec.getQ();
+        Matrix r = dec.getR();
+
+        assertNotNull("Matrix q is expected to be not null.", q);
+        assertNotNull("Matrix r is expected to be not null.", r);
+
+        Matrix qSafeCp = safeCopy(q);
+
+        Matrix expIdentity = qSafeCp.times(qSafeCp.transpose());
+
+        final double delta = 0.0001;
+
+        for (int row = 0; row < expIdentity.rowSize(); row++)
+            for (int col = 0; col < expIdentity.columnSize(); col++)
+                assertEquals("Unexpected identity matrix value at (" + row + "," + col + ").",
+                    row == col ? 1d : 0d, expIdentity.get(col, row), delta);
+
+        for (int row = 0; row < r.rowSize(); row++)
+            for (int col = 0; col < row - 1; col++)
+                assertEquals("Unexpected upper triangular matrix value at (" + row + "," + col + ").",
+                    0d, r.get(row, col), delta);
+
+        Matrix recomposed = qSafeCp.times(r);
+
+        for (int row = 0; row < m.rowSize(); row++)
+            for (int col = 0; col < m.columnSize(); col++)
+                assertEquals("Unexpected recomposed matrix value at (" + row + "," + col + ").",
+                    m.get(row, col), recomposed.get(row, col), delta);
+
+        Matrix sol = dec.solve(new DenseLocalOnHeapMatrix(3, 10));
+        assertEquals("Unexpected rows in solution matrix.", 3, sol.rowSize());
+        assertEquals("Unexpected cols in solution matrix.", 10, sol.columnSize());
+
+        for (int row = 0; row < sol.rowSize(); row++)
+            for (int col = 0; col < sol.columnSize(); col++)
+                assertEquals("Unexpected solution matrix value at (" + row + "," + col + ").",
+                    0d, sol.get(row, col), delta);
+
+        dec.destroy();
+
+        QRDecomposition dec1 = new QRDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d},
+            {-1.0d, 2.0d},
+            {0.0d, -1.0d}
+        }));
+
+        assertTrue("Unexpected value for full rank in decomposition " + dec1, dec1.hasFullRank());
+
+        dec1.destroy();
+
+        QRDecomposition dec2 = new QRDecomposition(new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d, 0.0d, 0.0d},
+            {-1.0d, 2.0d, -1.0d, 0.0d},
+            {0.0d, -1.0d, 2.0d, 0.0d}
+        }));
+
+        assertTrue("Unexpected value for full rank in decomposition " + dec2, dec2.hasFullRank());
+
+        dec2.destroy();
+    }
+
+    /** */
+    private Matrix safeCopy(Matrix orig) {
+        return new DenseLocalOnHeapMatrix(orig.rowSize(), orig.columnSize()).assign(orig);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/SingularValueDecompositionTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/SingularValueDecompositionTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/SingularValueDecompositionTest.java
new file mode 100644
index 0000000..f9843ae
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/decompositions/SingularValueDecompositionTest.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.decompositions;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.impls.matrix.PivotedMatrixView;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class SingularValueDecompositionTest {
+    /** */
+    @Test
+    public void basicTest() {
+        basicTest(new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d, 0.0d},
+            {-1.0d, 2.0d, -1.0d},
+            {0.0d, -1.0d, 2.0d}
+        }));
+    }
+
+    /**
+     * Test for {@link DecompositionSupport} features.
+     */
+    @Test
+    public void decompositionSupportTest() {
+        basicTest(new PivotedMatrixView(new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d, 0.0d},
+            {-1.0d, 2.0d, -1.0d},
+            {0.0d, -1.0d, 2.0d}
+        })));
+    }
+
+    /** */
+    @Test
+    public void rowsLessThanColumnsTest() {
+        DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(new double[][] {
+            {2.0d, -1.0d, 0.0d},
+            {-1.0d, 2.0d, -1.0d}
+        });
+
+        SingularValueDecomposition dec = new SingularValueDecomposition(m);
+        assertEquals("Unexpected value for singular values size.",
+            2, dec.getSingularValues().length);
+
+        Matrix s = dec.getS();
+        Matrix u = dec.getU();
+        Matrix v = dec.getV();
+        Matrix covariance = dec.getCovariance(0.5);
+
+        assertNotNull("Matrix s is expected to be not null.", s);
+        assertNotNull("Matrix u is expected to be not null.", u);
+        assertNotNull("Matrix v is expected to be not null.", v);
+        assertNotNull("Covariance matrix is expected to be not null.", covariance);
+
+        dec.destroy();
+    }
+
+    /** */
+    @Test(expected = AssertionError.class)
+    public void nullMatrixTest() {
+        new SingularValueDecomposition(null);
+    }
+
+    /** */
+    private void basicTest(Matrix m) {
+        SingularValueDecomposition dec = new SingularValueDecomposition(m);
+        assertEquals("Unexpected value for singular values size.",
+            3, dec.getSingularValues().length);
+
+        Matrix s = dec.getS();
+        Matrix u = dec.getU();
+        Matrix v = dec.getV();
+        Matrix covariance = dec.getCovariance(0.5);
+
+        assertNotNull("Matrix s is expected to be not null.", s);
+        assertNotNull("Matrix u is expected to be not null.", u);
+        assertNotNull("Matrix v is expected to be not null.", v);
+        assertNotNull("Covariance matrix is expected to be not null.", covariance);
+
+        assertTrue("Decomposition cond is expected to be positive.", dec.cond() > 0);
+        assertTrue("Decomposition norm2 is expected to be positive.", dec.norm2() > 0);
+        assertEquals("Decomposition rank differs from expected.", 3, dec.rank());
+        assertEquals("Decomposition singular values size differs from expected.",
+            3, dec.getSingularValues().length);
+
+        Matrix recomposed = (u.times(s).times(v.transpose()));
+
+        for (int row = 0; row < m.rowSize(); row++)
+            for (int col = 0; col < m.columnSize(); col++)
+                assertEquals("Unexpected recomposed matrix value at (" + row + "," + col + ").",
+                    m.get(row, col), recomposed.get(row, col), 0.001);
+
+        for (int row = 0; row < covariance.rowSize(); row++)
+            for (int col = row + 1; col < covariance.columnSize(); col++)
+                assertEquals("Unexpected covariance matrix value at (" + row + "," + col + ").",
+                    covariance.get(row, col), covariance.get(col, row), 0.001);
+
+        dec.destroy();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/MathTestConstants.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/MathTestConstants.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/MathTestConstants.java
new file mode 100644
index 0000000..d26733e
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/MathTestConstants.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls;
+
+/**
+ * Collect constants for org.apache.ignite.math tests
+ */
+public interface MathTestConstants {
+    /** */
+    public double SECOND_ARG = 1d;
+
+    /**
+     * We assume that we will check calculation precision in other tests.
+     */
+    public double EXP_DELTA = 0.1d;
+
+    /** */
+    public String UNEXPECTED_VAL = "Unexpected value.";
+
+    /** */
+    public String NULL_GUID = "Null GUID.";
+
+    /** */
+    public String UNEXPECTED_GUID_VAL = "Unexpected GUID value.";
+
+    /** */
+    public String EMPTY_GUID = "Empty GUID.";
+
+    /** */
+    public String VALUES_SHOULD_BE_NOT_EQUALS = "Values should be not equals.";
+
+    /** */
+    public String NULL_VAL = "Null value.";
+
+    /** */
+    public String NULL_VALUES = "Null values.";
+
+    /** */
+    public String NOT_NULL_VAL = "Not null value.";
+
+    /** */
+    public double TEST_VAL = 1d;
+
+    /** */
+    public String VAL_NOT_EQUALS = "Values not equals.";
+
+    /** */
+    public String NO_NEXT_ELEMENT = "No next element.";
+
+    /** */
+    public int STORAGE_SIZE = 100;
+
+    /** */
+    public String WRONG_ATTRIBUTE_VAL = "Wrong attribute value.";
+
+    /** */
+    public String NULL_DATA_ELEMENT = "Null data element.";
+
+    /** */
+    public String WRONG_DATA_ELEMENT = "Wrong data element.";
+
+    /** */
+    public double NIL_DELTA = 0d;
+
+    /** */
+    public String NULL_DATA_STORAGE = "Null data storage.";
+
+    /** */
+    public String WRONG_DATA_SIZE = "Wrong data size.";
+
+    /** */
+    public String UNEXPECTED_DATA_VAL = "Unexpected data value.";
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
new file mode 100644
index 0000000..3d4d05e
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
@@ -0,0 +1,369 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.ml.math.ExternalizeTest;
+import org.apache.ignite.ml.math.IdentityValueMapper;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.MatrixKeyMapper;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.common.GridCommonTest;
+
+/**
+ * Tests for {@link CacheMatrix}.
+ */
+@GridCommonTest(group = "Distributed Models")
+public class CacheMatrixTest extends GridCommonAbstractTest {
+    /** Number of nodes in grid */
+    private static final int NODE_COUNT = 3;
+    /** Cache name. */
+    private static final String CACHE_NAME = "test-cache";
+    /** */
+    private static final String UNEXPECTED_ATTRIBUTE_VALUE = "Unexpected attribute value.";
+    /** Grid instance. */
+    private Ignite ignite;
+    /** Matrix rows */
+    private final int rows = MathTestConstants.STORAGE_SIZE;
+    /** Matrix cols */
+    private final int cols = MathTestConstants.STORAGE_SIZE;
+
+    /**
+     * Default constructor.
+     */
+    public CacheMatrixTest() {
+        super(false);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        for (int i = 1; i <= NODE_COUNT; i++)
+            startGrid(i);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override protected void beforeTest() throws Exception {
+        ignite = grid(NODE_COUNT);
+
+        ignite.configuration().setPeerClassLoadingEnabled(true);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        ignite.destroyCache(CACHE_NAME);
+    }
+
+    /** */
+    public void testGetSet() throws Exception {
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        for (int i = 0; i < rows; i++) {
+            for (int j = 0; j < cols; j++) {
+                double v = Math.random();
+                cacheMatrix.set(i, j, v);
+
+                assert Double.compare(v, cacheMatrix.get(i, j)) == 0;
+                assert Double.compare(v, cache.get(keyMapper.apply(i, j))) == 0;
+            }
+        }
+    }
+
+    /** */
+    public void testCopy() throws Exception {
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        fillMatrix(cacheMatrix);
+
+        try {
+            cacheMatrix.copy();
+
+            fail("UnsupportedOperationException expected");
+        }
+        catch (UnsupportedOperationException e) {
+            // No-op.
+        }
+    }
+
+    /** */
+    public void testLike() throws Exception {
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        try {
+            cacheMatrix.like(rows, cols);
+
+            fail("UnsupportedOperationException expected");
+        }
+        catch (UnsupportedOperationException e) {
+            // No-op.
+        }
+    }
+
+    /** */
+    public void testLikeVector() throws Exception {
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        try {
+            cacheMatrix.likeVector(cols);
+
+            fail("UnsupportedOperationException expected");
+        }
+        catch (UnsupportedOperationException e) {
+            // No-op.
+        }
+    }
+
+    /** */
+    public void testPlus() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        double plusVal = 2;
+
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        initMatrix(cacheMatrix);
+
+        cacheMatrix.plus(plusVal);
+
+        for (int i = 0; i < rows; i++)
+            for (int j = 0; j < cols; j++)
+                assertEquals(plusVal, cacheMatrix.get(i, j));
+    }
+
+    /** */
+    public void testDivide() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        double initVal = 1;
+        double divVal = 2;
+
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        initMatrix(cacheMatrix);
+        cacheMatrix.assign(initVal);
+        cacheMatrix.divide(divVal);
+
+        for (int i = 0; i < rows; i++)
+            for (int j = 0; j < cols; j++)
+                assertTrue(Double.compare(cacheMatrix.get(i, j), initVal / divVal) == 0);
+    }
+
+    /** */
+    public void testTimes() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        double initVal = 1;
+        double timVal = 2;
+
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        initMatrix(cacheMatrix);
+        cacheMatrix.assign(initVal);
+        cacheMatrix.times(timVal);
+
+        for (int i = 0; i < rows; i++)
+            for (int j = 0; j < cols; j++)
+                assertTrue(Double.compare(cacheMatrix.get(i, j), initVal * timVal) == 0);
+    }
+
+    /** */
+    public void testSum() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        double initVal = 1;
+
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        double sum = 0;
+
+        initMatrix(cacheMatrix);
+        sum = cacheMatrix.sum();
+
+        assertTrue(Double.compare(sum, 0d) == 0);
+
+        cacheMatrix.assign(1d);
+        sum = cacheMatrix.sum();
+
+        assertTrue(Double.compare(sum, rows * cols) == 0);
+    }
+
+    /** */
+    public void testAssignSingleValue() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        double initVal = 1;
+
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        initMatrix(cacheMatrix);
+
+        cacheMatrix.assign(initVal);
+
+        for (int i = 0; i < rows; i++)
+            for (int j = 0; j < cols; j++)
+                assertEquals(initVal, cacheMatrix.get(i, j));
+    }
+
+    /** */
+    public void testAssignArray() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        double[][] initVal = new double[rows][cols];
+
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        for (int i = 0; i < rows; i++)
+            for (int j = 0; j < cols; j++)
+                initVal[i][j] = Math.random();
+
+        cacheMatrix.assign(initVal);
+
+        for (int i = 0; i < rows; i++)
+            for (int j = 0; j < cols; j++)
+                assertEquals(initVal[i][j], cacheMatrix.get(i, j));
+    }
+
+    /** */
+    public void testAttributes() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        assertFalse(UNEXPECTED_ATTRIBUTE_VALUE, cacheMatrix.isSequentialAccess());
+        assertFalse(UNEXPECTED_ATTRIBUTE_VALUE, cacheMatrix.isDense());
+        assertFalse(UNEXPECTED_ATTRIBUTE_VALUE, cacheMatrix.isArrayBased());
+        assertTrue(UNEXPECTED_ATTRIBUTE_VALUE, cacheMatrix.isRandomAccess());
+        assertTrue(UNEXPECTED_ATTRIBUTE_VALUE, cacheMatrix.isDistributed());
+    }
+
+    /** */
+    public void testExternalization() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        final CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        ExternalizeTest<CacheMatrix<Integer, Double>> externalizeTest = new ExternalizeTest<CacheMatrix<Integer, Double>>() {
+
+            @Override public void externalizeTest() {
+                super.externalizeTest(cacheMatrix);
+            }
+        };
+
+        externalizeTest.externalizeTest();
+    }
+
+    /** */
+    public void testMinMax() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        final CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        for (int i = 0; i < rows; i++)
+            for (int j = 0; j < cols; j++)
+                cacheMatrix.set(i, j, i * rows + j);
+
+        assertEquals(0.0, cacheMatrix.minValue(), 0.0);
+        assertEquals(rows * cols - 1, cacheMatrix.maxValue(), 0.0);
+    }
+
+    /** */
+    public void testMap() {
+        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+        MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
+        IgniteCache<Integer, Double> cache = getCache();
+        final CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
+
+        initMatrix(cacheMatrix);
+
+        cacheMatrix.map(value -> value + 10);
+
+        for (int i = 0; i < rows; i++)
+            for (int j = 0; j < cols; j++)
+                assertEquals(10.0, cacheMatrix.getX(i, j), 0.0);
+    }
+
+    /** */
+    private IgniteCache<Integer, Double> getCache() {
+        assert ignite != null;
+
+        CacheConfiguration cfg = new CacheConfiguration();
+        cfg.setName(CACHE_NAME);
+
+        IgniteCache<Integer, Double> cache = ignite.getOrCreateCache(CACHE_NAME);
+
+        assert cache != null;
+        return cache;
+    }
+
+    /** */
+    private MatrixKeyMapper<Integer> getKeyMapper(final int rows, final int cols) {
+        return new MatrixKeyMapperForTests(rows, cols);
+    }
+
+    /** Init the given matrix by random values. */
+    private void fillMatrix(Matrix m) {
+        for (int i = 0; i < m.rowSize(); i++)
+            for (int j = 0; j < m.columnSize(); j++)
+                m.set(i, j, Math.random());
+    }
+
+    /** Init the given matrix by zeros. */
+    private void initMatrix(Matrix m) {
+        for (int i = 0; i < m.rowSize(); i++)
+            for (int j = 0; j < m.columnSize(); j++)
+                m.set(i, j, 0d);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOffHeapMatrixConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOffHeapMatrixConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOffHeapMatrixConstructorTest.java
new file mode 100644
index 0000000..88bf8d0
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOffHeapMatrixConstructorTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class DenseLocalOffHeapMatrixConstructorTest {
+    /** */
+    @Test
+    public void invalidArgsTest() {
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DenseLocalOffHeapMatrix(0, 1), "invalid row parameter");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DenseLocalOffHeapMatrix(1, 0), "invalid col parameter");
+
+        //noinspection ConstantConditions
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DenseLocalOffHeapMatrix(null), "null matrix parameter");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DenseLocalOffHeapMatrix(new double[][] {null, new double[1]}),
+            "null row in matrix");
+    }
+
+    /** */
+    @Test
+    public void basicTest() {
+        assertEquals("Expected number of rows, int parameters.", 1,
+            new DenseLocalOffHeapMatrix(1, 2).rowSize());
+
+        assertEquals("Expected number of rows, double[][] parameter.", 1,
+            new DenseLocalOffHeapMatrix(new double[][] {new double[2]}).rowSize());
+
+        assertEquals("Expected number of cols, int parameters.", 1,
+            new DenseLocalOffHeapMatrix(2, 1).columnSize());
+
+        assertEquals("Expected number of cols, double[][] parameter.", 1,
+            new DenseLocalOffHeapMatrix(new double[][] {new double[1], new double[1]}).columnSize());
+
+        double[][] data1 = new double[][] {{1, 2}, {3, 4}}, data2 = new double[][] {{1, 2}, {3, 5}};
+
+        assertTrue("Matrices with same values are expected to be equal",
+            new DenseLocalOffHeapMatrix(data1).equals(new DenseLocalOffHeapMatrix(data1)));
+
+        assertFalse("Matrices with same values are expected to be equal",
+            new DenseLocalOffHeapMatrix(data1).equals(new DenseLocalOffHeapMatrix(data2)));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOnHeapMatrixConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOnHeapMatrixConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOnHeapMatrixConstructorTest.java
new file mode 100644
index 0000000..1cf6464
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/DenseLocalOnHeapMatrixConstructorTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import java.util.function.Supplier;
+import org.apache.ignite.ml.math.Matrix;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+/** */
+public class DenseLocalOnHeapMatrixConstructorTest {
+    /** */
+    @Test
+    public void invalidArgsTest() {
+        verifyAssertionError(() -> new DenseLocalOnHeapMatrix(0, 1), "invalid row parameter");
+
+        verifyAssertionError(() -> new DenseLocalOnHeapMatrix(1, 0), "invalid col parameter");
+
+        //noinspection ConstantConditions
+        verifyAssertionError(() -> new DenseLocalOnHeapMatrix(null), "null matrix parameter");
+
+        verifyAssertionError(() -> new DenseLocalOnHeapMatrix(new double[][] {null, new double[1]}),
+            "null row in matrix");
+    }
+
+    /** */
+    @Test
+    public void basicTest() {
+        assertEquals("Expected number of rows, int parameters.", 1,
+            new DenseLocalOnHeapMatrix(1, 2).rowSize());
+
+        assertEquals("Expected number of rows, double[][] parameter.", 1,
+            new DenseLocalOnHeapMatrix(new double[][] {new double[2]}).rowSize());
+
+        assertEquals("Expected number of cols, int parameters.", 1,
+            new DenseLocalOnHeapMatrix(2, 1).columnSize());
+
+        assertEquals("Expected number of cols, double[][] parameter.", 1,
+            new DenseLocalOnHeapMatrix(new double[][] {new double[1], new double[1]}).columnSize());
+    }
+
+    /** */
+    static void verifyAssertionError(Supplier<Matrix> ctor, String desc) {
+        try {
+            assertNotNull("Unexpected null matrix in " + desc, ctor.get());
+        }
+        catch (AssertionError ae) {
+            return;
+        }
+
+        fail("Expected error not caught in " + desc);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/DiagonalMatrixTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/DiagonalMatrixTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/DiagonalMatrixTest.java
new file mode 100644
index 0000000..a00403f
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/DiagonalMatrixTest.java
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.ml.math.ExternalizeTest;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.MathTestConstants;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Tests for {@link DiagonalMatrix}.
+ */
+public class DiagonalMatrixTest extends ExternalizeTest<DiagonalMatrix> {
+    /** */
+    public static final String UNEXPECTED_VALUE = "Unexpected value";
+
+    /** */
+    private DiagonalMatrix testMatrix;
+
+    /** */
+    @Before
+    public void setup() {
+        DenseLocalOnHeapMatrix parent = new DenseLocalOnHeapMatrix(MathTestConstants.STORAGE_SIZE, MathTestConstants.STORAGE_SIZE);
+        fillMatrix(parent);
+        testMatrix = new DiagonalMatrix(parent);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void externalizeTest() {
+        externalizeTest(testMatrix);
+    }
+
+    /** */
+    @Test
+    public void testSetGetBasic() {
+        double testVal = 42;
+        for (int i = 0; i < MathTestConstants.STORAGE_SIZE; i++) {
+            testMatrix.set(i, i, testVal);
+
+            assertEquals(UNEXPECTED_VALUE + " at (" + i + "," + i + ")", testMatrix.get(i, i), testVal, 0d);
+        }
+
+        //noinspection EqualsWithItself
+        assertTrue("Matrix is expected to be equal to self.", testMatrix.equals(testMatrix));
+        //noinspection ObjectEqualsNull
+        assertFalse("Matrix is expected to be not equal to null.", testMatrix.equals(null));
+    }
+
+    /** */
+    @Test
+    public void testSetGet() {
+        verifyDiagonal(testMatrix);
+
+        final int size = MathTestConstants.STORAGE_SIZE;
+
+        for (Matrix m : new Matrix[] {
+            new DenseLocalOnHeapMatrix(size + 1, size),
+            new DenseLocalOnHeapMatrix(size, size + 1)}) {
+            fillMatrix(m);
+
+            verifyDiagonal(new DiagonalMatrix(m));
+        }
+
+        final double[] data = new double[size];
+
+        for (int i = 0; i < size; i++)
+            data[i] = 1 + i;
+
+        final Matrix m = new DiagonalMatrix(new DenseLocalOnHeapVector(data));
+
+        assertEquals("Rows in matrix constructed from vector", size, m.rowSize());
+        assertEquals("Cols in matrix constructed from vector", size, m.columnSize());
+
+        for (int i = 0; i < size; i++)
+            assertEquals(UNEXPECTED_VALUE + " at vector index " + i, data[i], m.get(i, i), 0d);
+
+        verifyDiagonal(m);
+
+        final Matrix m1 = new DiagonalMatrix(data);
+
+        assertEquals("Rows in matrix constructed from array", size, m1.rowSize());
+        assertEquals("Cols in matrix constructed from array", size, m1.columnSize());
+
+        for (int i = 0; i < size; i++)
+            assertEquals(UNEXPECTED_VALUE + " at array index " + i, data[i], m1.get(i, i), 0d);
+
+        verifyDiagonal(m1);
+    }
+
+    /** */
+    @Test
+    public void testConstant() {
+        final int size = MathTestConstants.STORAGE_SIZE;
+
+        for (double val : new double[] {-1.0, 0.0, 1.0}) {
+            Matrix m = new DiagonalMatrix(size, val);
+
+            assertEquals("Rows in matrix", size, m.rowSize());
+            assertEquals("Cols in matrix", size, m.columnSize());
+
+            for (int i = 0; i < size; i++)
+                assertEquals(UNEXPECTED_VALUE + " at index " + i, val, m.get(i, i), 0d);
+
+            verifyDiagonal(m, true);
+        }
+    }
+
+    /** */
+    @Test
+    public void testAttributes() {
+        assertTrue(UNEXPECTED_VALUE, testMatrix.rowSize() == MathTestConstants.STORAGE_SIZE);
+        assertTrue(UNEXPECTED_VALUE, testMatrix.columnSize() == MathTestConstants.STORAGE_SIZE);
+
+        assertFalse(UNEXPECTED_VALUE, testMatrix.isArrayBased());
+        assertTrue(UNEXPECTED_VALUE, testMatrix.isDense());
+        assertFalse(UNEXPECTED_VALUE, testMatrix.isDistributed());
+
+        assertEquals(UNEXPECTED_VALUE, testMatrix.isRandomAccess(), !testMatrix.isSequentialAccess());
+        assertTrue(UNEXPECTED_VALUE, testMatrix.isRandomAccess());
+    }
+
+    /** */
+    @Test
+    public void testNullParams() {
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DiagonalMatrix((Matrix)null), "Null Matrix parameter");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DiagonalMatrix((Vector)null), "Null Vector parameter");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new DiagonalMatrix((double[])null), "Null double[] parameter");
+    }
+
+    /** */
+    private void verifyDiagonal(Matrix m, boolean readonly) {
+        final int rows = m.rowSize(), cols = m.columnSize();
+
+        final String sizeDetails = "rows" + "X" + "cols " + rows + "X" + cols;
+
+        for (int i = 0; i < rows; i++)
+            for (int j = 0; j < cols; j++) {
+                final String details = " at (" + i + "," + j + "), " + sizeDetails;
+
+                final boolean diagonal = i == j;
+
+                final double old = m.get(i, j);
+
+                if (!diagonal)
+                    assertEquals(UNEXPECTED_VALUE + details, 0, old, 0d);
+
+                final double exp = diagonal && !readonly ? old + 1 : old;
+
+                boolean expECaught = false;
+
+                try {
+                    m.set(i, j, exp);
+                }
+                catch (UnsupportedOperationException uoe) {
+                    if (diagonal && !readonly)
+                        throw uoe;
+
+                    expECaught = true;
+                }
+
+                if ((!diagonal || readonly) && !expECaught)
+                    fail("Expected exception was not caught " + details);
+
+                assertEquals(UNEXPECTED_VALUE + details, exp, m.get(i, j), 0d);
+            }
+    }
+
+    /** */
+    private void verifyDiagonal(Matrix m) {
+        verifyDiagonal(m, false);
+    }
+
+    /** */
+    private void fillMatrix(Matrix m) {
+        final int rows = m.rowSize(), cols = m.columnSize();
+
+        boolean negative = false;
+
+        for (int i = 0; i < rows; i++)
+            for (int j = 0; j < cols; j++)
+                m.set(i, j, (negative = !negative) ? -(i * cols + j + 1) : i * cols + j + 1);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/FunctionMatrixConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/FunctionMatrixConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/FunctionMatrixConstructorTest.java
new file mode 100644
index 0000000..25de7d3
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/FunctionMatrixConstructorTest.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class FunctionMatrixConstructorTest {
+    /** */
+    @Test
+    public void invalidArgsTest() {
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new FunctionMatrix(0, 1, (i, j) -> 0.0),
+            "Invalid row parameter.");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new FunctionMatrix(1, 0, (i, j) -> 0.0),
+            "Invalid col parameter.");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new FunctionMatrix(1, 1, null),
+            "Invalid func parameter.");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new FunctionMatrix(0, 1, (i, j) -> 0.0, null),
+            "Invalid row parameter, with setter func.");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new FunctionMatrix(1, 0, (i, j) -> 0.0, null),
+            "Invalid col parameter, with setter func.");
+
+        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new FunctionMatrix(1, 1, null, null),
+            "Invalid func parameter, with setter func.");
+    }
+
+    /** */
+    @Test
+    public void basicTest() {
+        for (int rows : new int[] {1, 2, 3})
+            for (int cols : new int[] {1, 2, 3})
+                basicTest(rows, cols);
+
+        Matrix m = new FunctionMatrix(1, 1, (i, j) -> 1d);
+        //noinspection EqualsWithItself
+        assertTrue("Matrix is expected to be equal to self.", m.equals(m));
+        //noinspection ObjectEqualsNull
+        assertFalse("Matrix is expected to be not equal to null.", m.equals(null));
+    }
+
+    /** */
+    private void basicTest(int rows, int cols) {
+        double[][] data = new double[rows][cols];
+
+        for (int row = 0; row < rows; row++)
+            for (int col = 0; col < cols; col++)
+                data[row][col] = row * cols + row;
+
+        Matrix mReadOnly = new FunctionMatrix(rows, cols, (i, j) -> data[i][j]);
+
+        assertEquals("Rows in matrix.", rows, mReadOnly.rowSize());
+        assertEquals("Cols in matrix.", cols, mReadOnly.columnSize());
+
+        for (int row = 0; row < rows; row++)
+            for (int col = 0; col < cols; col++) {
+                assertEquals("Unexpected value at " + row + "x" + col, data[row][col], mReadOnly.get(row, col), 0d);
+
+                boolean expECaught = false;
+
+                try {
+                    mReadOnly.set(row, col, 0.0);
+                }
+                catch (UnsupportedOperationException uoe) {
+                    expECaught = true;
+                }
+
+                assertTrue("Expected exception wasn't thrown at " + row + "x" + col, expECaught);
+            }
+
+        Matrix m = new FunctionMatrix(rows, cols, (i, j) -> data[i][j], (i, j, val) -> data[i][j] = val);
+
+        assertEquals("Rows in matrix, with setter function.", rows, m.rowSize());
+        assertEquals("Cols in matrix, with setter function.", cols, m.columnSize());
+
+        for (int row = 0; row < rows; row++)
+            for (int col = 0; col < cols; col++) {
+                assertEquals("Unexpected value at " + row + "x" + col, data[row][col], m.get(row, col), 0d);
+
+                m.set(row, col, -data[row][col]);
+            }
+
+        for (int row = 0; row < rows; row++)
+            for (int col = 0; col < cols; col++)
+                assertEquals("Unexpected value set at " + row + "x" + col, -(row * cols + row), m.get(row, col), 0d);
+
+        assertTrue("Incorrect copy for empty matrix.", m.copy().equals(m));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixAttributeTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixAttributeTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixAttributeTest.java
new file mode 100644
index 0000000..79cb13a
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixAttributeTest.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
+import org.apache.ignite.ml.math.Matrix;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Attribute tests for matrices.
+ *
+ * TODO: WIP
+ */
+public class MatrixAttributeTest {
+    /** */
+    private final List<MatrixAttributeTest.AttrCfg> attrCfgs = Arrays.asList(
+        new AttrCfg("isDense", Matrix::isDense,
+            DenseLocalOnHeapMatrix.class, DenseLocalOffHeapMatrix.class, RandomMatrix.class, DiagonalMatrix.class),
+        new AttrCfg("isArrayBased", Matrix::isArrayBased, DenseLocalOnHeapMatrix.class),
+        new AttrCfg("isDistributed", Matrix::isDistributed),
+        new AttrCfg("isRandomAccess", Matrix::isRandomAccess, DenseLocalOnHeapMatrix.class, DenseLocalOffHeapMatrix.class, RandomMatrix.class, DiagonalMatrix.class, SparseLocalOnHeapMatrix.class),
+        new AttrCfg("isSequentialAccess", Matrix::isSequentialAccess, DiagonalMatrix.class)
+    );
+
+    /** */
+    private final List<MatrixAttributeTest.Specification> specFixture = Arrays.asList(
+        new Specification(new DenseLocalOnHeapMatrix(1, 1)),
+        new Specification(new DenseLocalOffHeapMatrix(1, 1)),
+        new Specification(new RandomMatrix(1, 1)),
+        new Specification(new DiagonalMatrix(new double[] {1.0})),
+        new Specification(new FunctionMatrix(1, 1, (x, y) -> 1.0)),
+        new Specification(new SparseLocalOnHeapMatrix(1, 1))
+    );
+
+    /** */
+    @Test
+    public void isDenseTest() {
+        assertAttribute("isDense");
+    }
+
+    /** */
+    @Test
+    public void isArrayBasedTest() {
+        assertAttribute("isArrayBased");
+    }
+
+    /** */
+    @Test
+    public void isSequentialAccessTest() {
+        assertAttribute("isSequentialAccess");
+    }
+
+    /** */
+    @Test
+    public void isRandomAccessTest() {
+        assertAttribute("isRandomAccess");
+    }
+
+    /** */
+    @Test
+    public void isDistributedTest() {
+        assertAttribute("isDistributed");
+    }
+
+    /** */
+    private void assertAttribute(String name) {
+        final MatrixAttributeTest.AttrCfg attr = attrCfg(name);
+
+        for (MatrixAttributeTest.Specification spec : specFixture)
+            spec.verify(attr);
+    }
+
+    /** */
+    private MatrixAttributeTest.AttrCfg attrCfg(String name) {
+        for (MatrixAttributeTest.AttrCfg attr : attrCfgs)
+            if (attr.name.equals(name))
+                return attr;
+
+        throw new IllegalArgumentException("Undefined attribute " + name);
+    }
+
+    /** See http://en.wikipedia.org/wiki/Specification_pattern */
+    private static class Specification {
+        /** */
+        private final Matrix m;
+        /** */
+        private final Class<? extends Matrix> underlyingType;
+        /** */
+        private final List<String> attrsFromUnderlying;
+        /** */
+        final String desc;
+
+        /** */
+        Specification(Matrix m, Class<? extends Matrix> underlyingType, String... attrsFromUnderlying) {
+            this.m = m;
+            this.underlyingType = underlyingType;
+            this.attrsFromUnderlying = Arrays.asList(attrsFromUnderlying);
+            final Class<? extends Matrix> clazz = m.getClass();
+            desc = clazz.getSimpleName() + (clazz.equals(underlyingType)
+                ? "" : " (underlying type " + underlyingType.getSimpleName() + ")");
+        }
+
+        /** */
+        Specification(Matrix m) {
+            this(m, m.getClass());
+        }
+
+        /** */
+        void verify(MatrixAttributeTest.AttrCfg attr) {
+            final boolean obtained = attr.obtain.apply(m);
+
+            final Class<? extends Matrix> typeToCheck
+                = attrsFromUnderlying.contains(attr.name) ? underlyingType : m.getClass();
+
+            final boolean exp = attr.trueInTypes.contains(typeToCheck);
+
+            assertEquals("Unexpected " + attr.name + " value for " + desc, exp, obtained);
+        }
+    }
+
+    /** */
+    private static class AttrCfg {
+        /** */
+        final String name;
+        /** */
+        final Function<Matrix, Boolean> obtain;
+        /** */
+        final List<Class> trueInTypes;
+
+        /** */
+        AttrCfg(String name, Function<Matrix, Boolean> obtain, Class... trueInTypes) {
+            this.name = name;
+            this.obtain = obtain;
+            this.trueInTypes = Arrays.asList(trueInTypes);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixImplementationFixtures.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixImplementationFixtures.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixImplementationFixtures.java
new file mode 100644
index 0000000..52a0077
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixImplementationFixtures.java
@@ -0,0 +1,381 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.math.impls.matrix;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.storage.matrix.FunctionMatrixStorage;
+import org.jetbrains.annotations.NotNull;
+
+/** */
+class MatrixImplementationFixtures {
+    /** */
+    private static final List<Supplier<Iterable<Matrix>>> suppliers = Arrays.asList(
+        (Supplier<Iterable<Matrix>>)DenseLocalOnHeapMatrixFixture::new,
+        (Supplier<Iterable<Matrix>>)DenseLocalOffHeapMatrixFixture::new,
+        (Supplier<Iterable<Matrix>>)RandomMatrixFixture::new,
+        (Supplier<Iterable<Matrix>>)SparseLocalOnHeapMatrixFixture::new,
+        (Supplier<Iterable<Matrix>>)PivotedMatrixViewFixture::new,
+        (Supplier<Iterable<Matrix>>)MatrixViewFixture::new,
+        (Supplier<Iterable<Matrix>>)FunctionMatrixFixture::new,
+        (Supplier<Iterable<Matrix>>)DiagonalMatrixFixture::new,
+        (Supplier<Iterable<Matrix>>)TransposedMatrixViewFixture::new
+    );
+
+    /** */
+    void consumeSampleMatrix(BiConsumer<Matrix, String> consumer) {
+        for (Supplier<Iterable<Matrix>> fixtureSupplier : suppliers) {
+            final Iterable<Matrix> fixture = fixtureSupplier.get();
+
+            for (Matrix matrix : fixture) {
+                consumer.accept(matrix, fixture.toString());
+
+                matrix.destroy();
+            }
+        }
+    }
+
+    /** */
+    private static class DenseLocalOnHeapMatrixFixture extends MatrixSizeIterator {
+        /** */
+        DenseLocalOnHeapMatrixFixture() {
+            super(DenseLocalOnHeapMatrix::new, "DenseLocalOnHeapMatrix");
+        }
+    }
+
+    /** */
+    private static class DenseLocalOffHeapMatrixFixture extends MatrixSizeIterator {
+        /** */
+        DenseLocalOffHeapMatrixFixture() {
+            super(DenseLocalOffHeapMatrix::new, "DenseLocalOffHeapMatrix");
+        }
+    }
+
+    /** */
+    private static class RandomMatrixFixture extends MatrixSizeIterator {
+        /** */
+        RandomMatrixFixture() {
+            super(RandomMatrix::new, "RandomMatrix");
+        }
+    }
+
+    /** */
+    private static class SparseLocalOnHeapMatrixFixture extends MatrixSizeIterator {
+        /** */
+        SparseLocalOnHeapMatrixFixture() {
+            super(SparseLocalOnHeapMatrix::new, "SparseLocalOnHeapMatrix");
+        }
+    }
+
+    /** */
+    private static class PivotedMatrixViewFixture extends WrapperMatrixIterator {
+        /** */
+        PivotedMatrixViewFixture() {
+            super(PivotedMatrixView::new, "PivotedMatrixView over DenseLocalOnHeapMatrix");
+        }
+    }
+
+    /** */
+    private static class MatrixViewFixture extends WrapperMatrixIterator {
+        /** */
+        MatrixViewFixture() {
+            super((matrix) -> new MatrixView(matrix, 0, 0, matrix.rowSize(), matrix.columnSize()),
+                "MatrixView over DenseLocalOnHeapMatrix");
+        }
+    }
+
+    /** */
+    private static class FunctionMatrixFixture extends WrapperMatrixIterator {
+        /** */
+        FunctionMatrixFixture() {
+            super(FunctionMatrixForTest::new, "FunctionMatrix wrapping DenseLocalOnHeapMatrix");
+        }
+    }
+
+    /** */
+    private static class DiagonalMatrixFixture extends DiagonalIterator {
+        /** */
+        DiagonalMatrixFixture() {
+            super(DenseLocalOnHeapMatrix::new, "DiagonalMatrix over DenseLocalOnHeapMatrix");
+        }
+
+        /** {@inheritDoc} */
+        @NotNull
+        @Override public Iterator<Matrix> iterator() {
+            return new Iterator<Matrix>() {
+                /** {@inheritDoc} */
+                @Override public boolean hasNext() {
+                    return hasNextSize(getSizeIdx());
+                }
+
+                /** {@inheritDoc} */
+                @Override public Matrix next() {
+                    assert getSize(getSizeIdx()) == 1 : "Only size 1 allowed for diagonal matrix fixture.";
+
+                    Matrix matrix = getConstructor().apply(getSize(getSizeIdx()), getSize(getSizeIdx()));
+
+                    nextIdx();
+
+                    return new DiagonalMatrix(matrix);
+                }
+            };
+        }
+    }
+
+    /** */
+    private static class TransposedMatrixViewFixture extends WrapperMatrixIterator {
+        /** */
+        TransposedMatrixViewFixture() {
+            super(TransposedMatrixView::new, "TransposedMatrixView over DenseLocalOnHeapMatrix");
+        }
+    }
+
+    /** */
+    private static abstract class DiagonalIterator implements Iterable<Matrix> {
+        /** */
+        private final Integer[] sizes = new Integer[] {1, null};
+        /** */
+        private int sizeIdx = 0;
+
+        /** */
+        private BiFunction<Integer, Integer, ? extends Matrix> constructor;
+        /** */
+        private String desc;
+
+        /** */
+        DiagonalIterator(BiFunction<Integer, Integer, ? extends Matrix> constructor, String desc) {
+            this.constructor = constructor;
+            this.desc = desc;
+        }
+
+        /** */
+        public BiFunction<Integer, Integer, ? extends Matrix> getConstructor() {
+            return constructor;
+        }
+
+        /** */
+        int getSizeIdx() {
+            return sizeIdx;
+        }
+
+        /** */
+        @Override public String toString() {
+            return desc + "{rows=" + sizes[sizeIdx] + ", cols=" + sizes[sizeIdx] + "}";
+        }
+
+        /** */
+        boolean hasNextSize(int idx) {
+            return sizes[idx] != null;
+        }
+
+        /** */
+        Integer getSize(int idx) {
+            return sizes[idx];
+        }
+
+        /** */
+        void nextIdx() {
+            sizeIdx++;
+        }
+    }
+
+    /** */
+    private static class WrapperMatrixIterator extends MatrixSizeIterator {
+        /** */
+        private final Function<Matrix, Matrix> wrapperCtor;
+
+        /** */
+        WrapperMatrixIterator(Function<Matrix, Matrix> wrapperCtor, String desc) {
+            super(DenseLocalOnHeapMatrix::new, desc);
+
+            this.wrapperCtor = wrapperCtor;
+        }
+
+        /** {@inheritDoc} */
+        @NotNull
+        @Override public Iterator<Matrix> iterator() {
+            return new Iterator<Matrix>() {
+                /** {@inheritDoc} */
+                @Override public boolean hasNext() {
+                    return hasNextCol(getSizeIdx()) && hasNextRow(getSizeIdx());
+                }
+
+                /** {@inheritDoc} */
+                @Override public Matrix next() {
+                    Matrix matrix = getConstructor().apply(getRow(getSizeIdx()), getCol(getSizeIdx()));
+
+                    nextIdx();
+
+                    return wrapperCtor.apply(matrix);
+                }
+            };
+        }
+    }
+
+    /** */
+    private static class MatrixSizeIterator implements Iterable<Matrix> {
+        /** */
+        private final Integer[] rows = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 512, 1024, null};
+        /** */
+        private final Integer[] cols = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1024, 512, null};
+        /** */
+        private int sizeIdx = 0;
+
+        /** */
+        private BiFunction<Integer, Integer, ? extends Matrix> constructor;
+        /** */
+        private String desc;
+
+        /** */
+        MatrixSizeIterator(BiFunction<Integer, Integer, ? extends Matrix> constructor, String desc) {
+            this.constructor = constructor;
+            this.desc = desc;
+        }
+
+        /** */
+        public BiFunction<Integer, Integer, ? extends Matrix> getConstructor() {
+            return constructor;
+        }
+
+        /** */
+        int getSizeIdx() {
+            return sizeIdx;
+        }
+
+        /** */
+        @Override public String toString() {
+            return desc + "{rows=" + rows[sizeIdx] + ", cols=" + cols[sizeIdx] + "}";
+        }
+
+        /** */
+        boolean hasNextRow(int idx) {
+            return rows[idx] != null;
+        }
+
+        /** */
+        boolean hasNextCol(int idx) {
+            return cols[idx] != null;
+        }
+
+        /** */
+        Integer getRow(int idx) {
+            return rows[idx];
+        }
+
+        /** */
+        int getCol(int idx) {
+            return cols[idx];
+        }
+
+        /** {@inheritDoc} */
+        @NotNull
+        @Override public Iterator<Matrix> iterator() {
+            return new Iterator<Matrix>() {
+                /** {@inheritDoc} */
+                @Override public boolean hasNext() {
+                    return hasNextCol(sizeIdx) && hasNextRow(sizeIdx);
+                }
+
+                /** {@inheritDoc} */
+                @Override public Matrix next() {
+                    Matrix matrix = constructor.apply(rows[sizeIdx], cols[sizeIdx]);
+
+                    nextIdx();
+
+                    return matrix;
+                }
+            };
+        }
+
+        /** */
+        void nextIdx() {
+            sizeIdx++;
+        }
+    }
+
+    /** Subclass tweaked for serialization */
+    private static class FunctionMatrixForTest extends FunctionMatrix {
+        /** */
+        Matrix underlying;
+
+        /** */
+        public FunctionMatrixForTest() {
+            // No-op.
+        }
+
+        /** */
+        FunctionMatrixForTest(Matrix underlying) {
+            super(underlying.rowSize(), underlying.columnSize(), underlying::get, underlying::set);
+
+            this.underlying = underlying;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Matrix copy() {
+            return new FunctionMatrixForTest(underlying);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+            super.writeExternal(out);
+
+            out.writeObject(underlying);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            super.readExternal(in);
+
+            underlying = (Matrix)in.readObject();
+
+            setStorage(new FunctionMatrixStorage(underlying.rowSize(), underlying.columnSize(),
+                underlying::get, underlying::set));
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            int res = 1;
+
+            res = res * 37 + underlying.hashCode();
+
+            return res;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            FunctionMatrixForTest that = (FunctionMatrixForTest)o;
+
+            return underlying != null ? underlying.equals(that.underlying) : that.underlying == null;
+        }
+    }
+}


[09/65] [abbrv] ignite git commit: IGNITE-5000 Rename Ignite Math module to Ignite ML module added missed licenses renamed packages fixed wrong ml profile activation (cherry picked from commit d78e071)

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixImplementationsTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixImplementationsTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixImplementationsTest.java
deleted file mode 100644
index 28abab7..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixImplementationsTest.java
+++ /dev/null
@@ -1,1113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.BiConsumer;
-import java.util.function.Supplier;
-import org.apache.ignite.math.ExternalizeTest;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.Vector;
-import org.apache.ignite.math.exceptions.CardinalityException;
-import org.apache.ignite.math.exceptions.ColumnIndexException;
-import org.apache.ignite.math.exceptions.IndexException;
-import org.apache.ignite.math.exceptions.RowIndexException;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.vector.DenseLocalOffHeapVector;
-import org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector;
-import org.apache.ignite.math.impls.vector.RandomVector;
-import org.apache.ignite.math.impls.vector.SparseLocalVector;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Tests for {@link Matrix} implementations.
- */
-public class MatrixImplementationsTest extends ExternalizeTest<Matrix> {
-    /** */
-    private static final double DEFAULT_DELTA = 0.000000001d;
-
-    /** */
-    private void consumeSampleMatrix(BiConsumer<Matrix, String> consumer) {
-        new MatrixImplementationFixtures().consumeSampleMatrix(consumer);
-    }
-
-    /** */
-    @Test
-    public void externalizeTest() {
-        consumeSampleMatrix((m, desc) -> externalizeTest(m));
-    }
-
-    /** */
-    @Test
-    public void testLike() {
-        consumeSampleMatrix((m, desc) -> {
-            Class<? extends Matrix> cls = likeMatrixType(m);
-
-            if (cls != null) {
-                Matrix like = m.like(m.rowSize(), m.columnSize());
-
-                assertEquals("Wrong \"like\" matrix for " + desc + "; Unexpected rows.", like.rowSize(), m.rowSize());
-                assertEquals("Wrong \"like\" matrix for " + desc + "; Unexpected columns.", like.columnSize(), m.columnSize());
-
-                assertEquals("Wrong \"like\" matrix for " + desc
-                        + "; Unexpected class: " + like.getClass().toString(),
-                    cls,
-                    like.getClass());
-
-                return;
-            }
-
-            boolean expECaught = false;
-
-            try {
-                m.like(1, 1);
-            }
-            catch (UnsupportedOperationException uoe) {
-                expECaught = true;
-            }
-
-            assertTrue("Expected exception was not caught for " + desc, expECaught);
-        });
-    }
-
-    /** */
-    @Test
-    public void testCopy() {
-        consumeSampleMatrix((m, desc) -> {
-            Matrix cp = m.copy();
-            assertTrue("Incorrect copy for empty matrix " + desc, cp.equals(m));
-
-            if (!readOnly(m))
-                fillMatrix(m);
-
-            cp = m.copy();
-
-            assertTrue("Incorrect copy for matrix " + desc, cp.equals(m));
-        });
-    }
-
-    /** */
-    @Test
-    public void testHaveLikeVector() throws InstantiationException, IllegalAccessException {
-        for (Class<? extends Matrix> key : likeVectorTypesMap().keySet()) {
-            Class<? extends Vector> val = likeVectorTypesMap().get(key);
-
-            if (val == null && !ignore(key))
-                System.out.println("Missing test for implementation of likeMatrix for " + key.getSimpleName());
-        }
-    }
-
-    /** */
-    @Test
-    public void testLikeVector() {
-        consumeSampleMatrix((m, desc) -> {
-            if (likeVectorTypesMap().containsKey(m.getClass())) {
-                Vector likeVector = m.likeVector(m.columnSize());
-
-                assertNotNull(likeVector);
-                assertEquals("Unexpected value for " + desc, likeVector.size(), m.columnSize());
-
-                return;
-            }
-
-            boolean expECaught = false;
-
-            try {
-                m.likeVector(1);
-            }
-            catch (UnsupportedOperationException uoe) {
-                expECaught = true;
-            }
-
-            assertTrue("Expected exception was not caught for " + desc, expECaught);
-        });
-    }
-
-    /** */
-    @Test
-    public void testAssignSingleElement() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            final double assignVal = Math.random();
-
-            m.assign(assignVal);
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
-                        assignVal, m.get(i, j), 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testAssignArray() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            double[][] data = new double[m.rowSize()][m.columnSize()];
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    data[i][j] = Math.random();
-
-            m.assign(data);
-
-            for (int i = 0; i < m.rowSize(); i++) {
-                for (int j = 0; j < m.columnSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
-                        data[i][j], m.get(i, j), 0d);
-            }
-        });
-    }
-
-    /** */
-    @Test
-    public void testAssignFunction() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            m.assign((i, j) -> (double)(i * m.columnSize() + j));
-
-            for (int i = 0; i < m.rowSize(); i++) {
-                for (int j = 0; j < m.columnSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
-                        (double)(i * m.columnSize() + j), m.get(i, j), 0d);
-            }
-        });
-    }
-
-    /** */
-    @Test
-    public void testPlus() {
-        consumeSampleMatrix((m, desc) -> {
-            if (readOnly(m))
-                return;
-
-            double[][] data = fillAndReturn(m);
-
-            double plusVal = Math.random();
-
-            Matrix plus = m.plus(plusVal);
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
-                        data[i][j] + plusVal, plus.get(i, j), 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testPlusMatrix() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            double[][] data = fillAndReturn(m);
-
-            Matrix plus = m.plus(m);
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
-                        data[i][j] * 2.0, plus.get(i, j), 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testMinusMatrix() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            fillMatrix(m);
-
-            Matrix minus = m.minus(m);
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
-                        0.0, minus.get(i, j), 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testTimes() {
-        consumeSampleMatrix((m, desc) -> {
-            if (readOnly(m))
-                return;
-
-            double[][] data = fillAndReturn(m);
-
-            double timeVal = Math.random();
-            Matrix times = m.times(timeVal);
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
-                        data[i][j] * timeVal, times.get(i, j), 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testTimesVector() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            double[][] data = fillAndReturn(m);
-
-            double[] arr = fillArray(m.columnSize());
-
-            Vector times = m.times(new DenseLocalOnHeapVector(arr));
-
-            assertEquals("Unexpected vector size for " + desc, times.size(), m.rowSize());
-
-            for (int i = 0; i < m.rowSize(); i++) {
-                double exp = 0.0;
-
-                for (int j = 0; j < m.columnSize(); j++)
-                    exp += arr[j] * data[i][j];
-
-                assertEquals("Unexpected value for " + desc + " at " + i,
-                    times.get(i), exp, 0d);
-            }
-
-            testInvalidCardinality(() -> m.times(new DenseLocalOnHeapVector(m.columnSize() + 1)), desc);
-        });
-    }
-
-    /** */
-    @Test
-    public void testTimesMatrix() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            double[][] data = fillAndReturn(m);
-
-            double[] arr = fillArray(m.columnSize());
-
-            Matrix mult = new DenseLocalOnHeapMatrix(m.columnSize(), 1);
-
-            mult.setColumn(0, arr);
-
-            Matrix times = m.times(mult);
-
-            assertEquals("Unexpected rows for " + desc, times.rowSize(), m.rowSize());
-
-            assertEquals("Unexpected cols for " + desc, times.columnSize(), 1);
-
-            for (int i = 0; i < m.rowSize(); i++) {
-                double exp = 0.0;
-
-                for (int j = 0; j < m.columnSize(); j++)
-                    exp += arr[j] * data[i][j];
-
-                assertEquals("Unexpected value for " + desc + " at " + i,
-                    exp, times.get(i, 0), 0d);
-            }
-
-            testInvalidCardinality(() -> m.times(new DenseLocalOnHeapMatrix(m.columnSize() + 1, 1)), desc);
-        });
-    }
-
-    /** */
-    @Test
-    public void testDivide() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            double[][] data = fillAndReturn(m);
-
-            double divVal = Math.random();
-
-            Matrix divide = m.divide(divVal);
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
-                        data[i][j] / divVal, divide.get(i, j), 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testTranspose() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            fillMatrix(m);
-
-            Matrix transpose = m.transpose();
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
-                        m.get(i, j), transpose.get(j, i), 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testDeterminant() {
-        consumeSampleMatrix((m, desc) -> {
-            if (m.rowSize() != m.columnSize())
-                return;
-
-            if (ignore(m.getClass()))
-                return;
-
-            double[][] doubles = fillIntAndReturn(m);
-
-            if (m.rowSize() == 1) {
-                assertEquals("Unexpected value " + desc, m.determinant(), doubles[0][0], 0d);
-
-                return;
-            }
-
-            if (m.rowSize() == 2) {
-                double det = doubles[0][0] * doubles[1][1] - doubles[0][1] * doubles[1][0];
-                assertEquals("Unexpected value " + desc, m.determinant(), det, 0d);
-
-                return;
-            }
-
-            if (m.rowSize() > 512)
-                return; // IMPL NOTE if row size >= 30000 it takes unacceptably long for normal test run.
-
-            Matrix diagMtx = m.like(m.rowSize(), m.columnSize());
-
-            diagMtx.assign(0);
-            for (int i = 0; i < m.rowSize(); i++)
-                diagMtx.set(i, i, m.get(i, i));
-
-            double det = 1;
-
-            for (int i = 0; i < diagMtx.rowSize(); i++)
-                det *= diagMtx.get(i, i);
-
-            try {
-                assertEquals("Unexpected value " + desc, det, diagMtx.determinant(), DEFAULT_DELTA);
-            }
-            catch (Exception e) {
-                System.out.println(desc);
-                throw e;
-            }
-        });
-    }
-
-    /** */
-    @Test
-    public void testInverse() {
-        consumeSampleMatrix((m, desc) -> {
-            if (m.rowSize() != m.columnSize())
-                return;
-
-            if (ignore(m.getClass()))
-                return;
-
-            if (m.rowSize() > 256)
-                return; // IMPL NOTE this is for quicker test run.
-
-            fillNonSingularMatrix(m);
-
-            assertTrue("Unexpected zero determinant " + desc, Math.abs(m.determinant()) > 0d);
-
-            Matrix inverse = m.inverse();
-
-            Matrix mult = m.times(inverse);
-
-            final double delta = 0.001d;
-
-            assertEquals("Unexpected determinant " + desc, 1d, mult.determinant(), delta);
-
-            assertEquals("Unexpected top left value " + desc, 1d, mult.get(0, 0), delta);
-
-            if (m.rowSize() == 1)
-                return;
-
-            assertEquals("Unexpected center value " + desc,
-                1d, mult.get(m.rowSize() / 2, m.rowSize() / 2), delta);
-
-            assertEquals("Unexpected bottom right value " + desc,
-                1d, mult.get(m.rowSize() - 1, m.rowSize() - 1), delta);
-
-            assertEquals("Unexpected top right value " + desc,
-                0d, mult.get(0, m.rowSize() - 1), delta);
-
-            assertEquals("Unexpected bottom left value " + desc,
-                0d, mult.get(m.rowSize() - 1, 0), delta);
-        });
-    }
-
-    /** */
-    @Test
-    public void testMap() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            fillMatrix(m);
-
-            m.map(x -> 10d);
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
-                        10d, m.get(i, j), 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testMapMatrix() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            double[][] doubles = fillAndReturn(m);
-
-            testMapMatrixWrongCardinality(m, desc);
-
-            Matrix cp = m.copy();
-
-            m.map(cp, (m1, m2) -> m1 + m2);
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
-                        m.get(i, j), doubles[i][j] * 2, 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testViewRow() {
-        consumeSampleMatrix((m, desc) -> {
-            if (!readOnly(m))
-                fillMatrix(m);
-
-            for (int i = 0; i < m.rowSize(); i++) {
-                Vector vector = m.viewRow(i);
-                assert vector != null;
-
-                for (int j = 0; j < m.columnSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
-                        m.get(i, j), vector.get(j), 0d);
-            }
-        });
-    }
-
-    /** */
-    @Test
-    public void testViewCol() {
-        consumeSampleMatrix((m, desc) -> {
-            if (!readOnly(m))
-                fillMatrix(m);
-
-            for (int i = 0; i < m.columnSize(); i++) {
-                Vector vector = m.viewColumn(i);
-                assert vector != null;
-
-                for (int j = 0; j < m.rowSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at (" + i + "," + j + ")",
-                        m.get(j, i), vector.get(j), 0d);
-            }
-        });
-    }
-
-    /** */
-    @Test
-    public void testFoldRow() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            fillMatrix(m);
-
-            Vector foldRows = m.foldRows(Vector::sum);
-
-            for (int i = 0; i < m.rowSize(); i++) {
-                Double locSum = 0d;
-
-                for (int j = 0; j < m.columnSize(); j++)
-                    locSum += m.get(i, j);
-
-                assertEquals("Unexpected value for " + desc + " at " + i,
-                    foldRows.get(i), locSum, 0d);
-            }
-        });
-    }
-
-    /** */
-    @Test
-    public void testFoldCol() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            fillMatrix(m);
-
-            Vector foldCols = m.foldColumns(Vector::sum);
-
-            for (int j = 0; j < m.columnSize(); j++) {
-                Double locSum = 0d;
-
-                for (int i = 0; i < m.rowSize(); i++)
-                    locSum += m.get(i, j);
-
-                assertEquals("Unexpected value for " + desc + " at " + j,
-                    foldCols.get(j), locSum, 0d);
-            }
-        });
-    }
-
-    /** */
-    @Test
-    public void testSum() {
-        consumeSampleMatrix((m, desc) -> {
-            double[][] data = fillAndReturn(m);
-
-            double sum = m.sum();
-
-            double rawSum = 0;
-            for (double[] anArr : data)
-                for (int j = 0; j < data[0].length; j++)
-                    rawSum += anArr[j];
-
-            assertEquals("Unexpected value for " + desc,
-                rawSum, sum, 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testMax() {
-        consumeSampleMatrix((m, desc) -> {
-            double[][] doubles = fillAndReturn(m);
-            double max = Double.NEGATIVE_INFINITY;
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    max = max < doubles[i][j] ? doubles[i][j] : max;
-
-            assertEquals("Unexpected value for " + desc, m.maxValue(), max, 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testMin() {
-        consumeSampleMatrix((m, desc) -> {
-            double[][] doubles = fillAndReturn(m);
-            double min = Double.MAX_VALUE;
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    min = min > doubles[i][j] ? doubles[i][j] : min;
-
-            assertEquals("Unexpected value for " + desc, m.minValue(), min, 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testGetElement() {
-        consumeSampleMatrix((m, desc) -> {
-            if (!(readOnly(m)))
-                fillMatrix(m);
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++) {
-                    final Matrix.Element e = m.getElement(i, j);
-
-                    final String details = desc + " at [" + i + "," + j + "]";
-
-                    assertEquals("Unexpected element row " + details, i, e.row());
-                    assertEquals("Unexpected element col " + details, j, e.column());
-
-                    final double val = m.get(i, j);
-
-                    assertEquals("Unexpected value for " + details, val, e.get(), 0d);
-
-                    boolean expECaught = false;
-
-                    final double newVal = val * 2.0;
-
-                    try {
-                        e.set(newVal);
-                    }
-                    catch (UnsupportedOperationException uoe) {
-                        if (!(readOnly(m)))
-                            throw uoe;
-
-                        expECaught = true;
-                    }
-
-                    if (readOnly(m)) {
-                        if (!expECaught)
-                            fail("Expected exception was not caught for " + details);
-
-                        continue;
-                    }
-
-                    assertEquals("Unexpected value set for " + details, newVal, m.get(i, j), 0d);
-                }
-        });
-    }
-
-    /** */
-    @Test
-    public void testGetX() {
-        consumeSampleMatrix((m, desc) -> {
-            if (!(readOnly(m)))
-                fillMatrix(m);
-
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    assertEquals("Unexpected value for " + desc + " at [" + i + "," + j + "]",
-                        m.get(i, j), m.getX(i, j), 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testGetMetaStorage() {
-        consumeSampleMatrix((m, desc) -> assertNotNull("Null meta storage in " + desc, m.getMetaStorage()));
-    }
-
-    /** */
-    @Test
-    public void testGuid() {
-        consumeSampleMatrix((m, desc) -> assertNotNull("Null guid in " + desc, m.guid()));
-    }
-
-    /** */
-    @Test
-    public void testSwapRows() {
-        consumeSampleMatrix((m, desc) -> {
-            if (readOnly(m))
-                return;
-
-            double[][] doubles = fillAndReturn(m);
-
-            final int swap_i = m.rowSize() == 1 ? 0 : 1;
-            final int swap_j = 0;
-
-            Matrix swap = m.swapRows(swap_i, swap_j);
-
-            for (int col = 0; col < m.columnSize(); col++) {
-                assertEquals("Unexpected value for " + desc + " at col " + col + ", swap_i " + swap_i,
-                    swap.get(swap_i, col), doubles[swap_j][col], 0d);
-
-                assertEquals("Unexpected value for " + desc + " at col " + col + ", swap_j " + swap_j,
-                    swap.get(swap_j, col), doubles[swap_i][col], 0d);
-            }
-
-            testInvalidRowIndex(() -> m.swapRows(-1, 0), desc + " negative first swap index");
-            testInvalidRowIndex(() -> m.swapRows(0, -1), desc + " negative second swap index");
-            testInvalidRowIndex(() -> m.swapRows(m.rowSize(), 0), desc + " too large first swap index");
-            testInvalidRowIndex(() -> m.swapRows(0, m.rowSize()), desc + " too large second swap index");
-        });
-    }
-
-    /** */
-    @Test
-    public void testSwapColumns() {
-        consumeSampleMatrix((m, desc) -> {
-            if (readOnly(m))
-                return;
-
-            double[][] doubles = fillAndReturn(m);
-
-            final int swap_i = m.columnSize() == 1 ? 0 : 1;
-            final int swap_j = 0;
-
-            Matrix swap = m.swapColumns(swap_i, swap_j);
-
-            for (int row = 0; row < m.rowSize(); row++) {
-                assertEquals("Unexpected value for " + desc + " at row " + row + ", swap_i " + swap_i,
-                    swap.get(row, swap_i), doubles[row][swap_j], 0d);
-
-                assertEquals("Unexpected value for " + desc + " at row " + row + ", swap_j " + swap_j,
-                    swap.get(row, swap_j), doubles[row][swap_i], 0d);
-            }
-
-            testInvalidColIndex(() -> m.swapColumns(-1, 0), desc + " negative first swap index");
-            testInvalidColIndex(() -> m.swapColumns(0, -1), desc + " negative second swap index");
-            testInvalidColIndex(() -> m.swapColumns(m.columnSize(), 0), desc + " too large first swap index");
-            testInvalidColIndex(() -> m.swapColumns(0, m.columnSize()), desc + " too large second swap index");
-        });
-    }
-
-    /** */
-    @Test
-    public void testSetRow() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            fillMatrix(m);
-
-            int rowIdx = m.rowSize() / 2;
-
-            double[] newValues = fillArray(m.columnSize());
-
-            m.setRow(rowIdx, newValues);
-
-            for (int col = 0; col < m.columnSize(); col++)
-                assertEquals("Unexpected value for " + desc + " at " + col,
-                    newValues[col], m.get(rowIdx, col), 0d);
-
-            testInvalidCardinality(() -> m.setRow(rowIdx, new double[m.columnSize() + 1]), desc);
-        });
-    }
-
-    /** */
-    @Test
-    public void testSetColumn() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            fillMatrix(m);
-
-            int colIdx = m.columnSize() / 2;
-
-            double[] newValues = fillArray(m.rowSize());
-
-            m.setColumn(colIdx, newValues);
-
-            for (int row = 0; row < m.rowSize(); row++)
-                assertEquals("Unexpected value for " + desc + " at " + row,
-                    newValues[row], m.get(row, colIdx), 0d);
-
-            testInvalidCardinality(() -> m.setColumn(colIdx, new double[m.rowSize() + 1]), desc);
-        });
-    }
-
-    /** */
-    @Test
-    public void testViewPart() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            fillMatrix(m);
-
-            int rowOff = m.rowSize() < 3 ? 0 : 1;
-            int rows = m.rowSize() < 3 ? 1 : m.rowSize() - 2;
-            int colOff = m.columnSize() < 3 ? 0 : 1;
-            int cols = m.columnSize() < 3 ? 1 : m.columnSize() - 2;
-
-            Matrix view1 = m.viewPart(rowOff, rows, colOff, cols);
-            Matrix view2 = m.viewPart(new int[] {rowOff, colOff}, new int[] {rows, cols});
-
-            String details = desc + " view [" + rowOff + ", " + rows + ", " + colOff + ", " + cols + "]";
-
-            for (int i = 0; i < rows; i++)
-                for (int j = 0; j < cols; j++) {
-                    assertEquals("Unexpected view1 value for " + details + " at (" + i + "," + j + ")",
-                        m.get(i + rowOff, j + colOff), view1.get(i, j), 0d);
-
-                    assertEquals("Unexpected view2 value for " + details + " at (" + i + "," + j + ")",
-                        m.get(i + rowOff, j + colOff), view2.get(i, j), 0d);
-                }
-        });
-    }
-
-    /** */
-    @Test
-    public void testDensity() {
-        consumeSampleMatrix((m, desc) -> {
-            if (!readOnly(m))
-                fillMatrix(m);
-
-            assertTrue("Unexpected density with threshold 0 for " + desc, m.density(0.0));
-
-            assertFalse("Unexpected density with threshold 1 for " + desc, m.density(1.0));
-        });
-    }
-
-    /** */
-    @Test
-    public void testMaxAbsRowSumNorm() {
-        consumeSampleMatrix((m, desc) -> {
-            if (!readOnly(m))
-                fillMatrix(m);
-
-            assertEquals("Unexpected value for " + desc,
-                maxAbsRowSumNorm(m), m.maxAbsRowSumNorm(), 0d);
-        });
-    }
-
-    /** */
-    @Test
-    public void testAssignRow() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            fillMatrix(m);
-
-            int rowIdx = m.rowSize() / 2;
-
-            double[] newValues = fillArray(m.columnSize());
-
-            m.assignRow(rowIdx, new DenseLocalOnHeapVector(newValues));
-
-            for (int col = 0; col < m.columnSize(); col++)
-                assertEquals("Unexpected value for " + desc + " at " + col,
-                    newValues[col], m.get(rowIdx, col), 0d);
-
-            testInvalidCardinality(() -> m.assignRow(rowIdx, new DenseLocalOnHeapVector(m.columnSize() + 1)), desc);
-        });
-    }
-
-    /** */
-    @Test
-    public void testAssignColumn() {
-        consumeSampleMatrix((m, desc) -> {
-            if (ignore(m.getClass()))
-                return;
-
-            fillMatrix(m);
-
-            int colIdx = m.columnSize() / 2;
-
-            double[] newValues = fillArray(m.rowSize());
-
-            m.assignColumn(colIdx, new DenseLocalOnHeapVector(newValues));
-
-            for (int row = 0; row < m.rowSize(); row++)
-                assertEquals("Unexpected value for " + desc + " at " + row,
-                    newValues[row], m.get(row, colIdx), 0d);
-        });
-    }
-
-    /** */
-    private double[] fillArray(int len) {
-        double[] newValues = new double[len];
-
-        for (int i = 0; i < newValues.length; i++)
-            newValues[i] = newValues.length - i;
-        return newValues;
-    }
-
-    /** */
-    private double maxAbsRowSumNorm(Matrix m) {
-        double max = 0.0;
-
-        for (int x = 0; x < m.rowSize(); x++) {
-            double sum = 0;
-
-            for (int y = 0; y < m.columnSize(); y++)
-                sum += Math.abs(m.getX(x, y));
-
-            if (sum > max)
-                max = sum;
-        }
-
-        return max;
-    }
-
-    /** */
-    private void testInvalidRowIndex(Supplier<Matrix> supplier, String desc) {
-        try {
-            supplier.get();
-        }
-        catch (RowIndexException | IndexException ie) {
-            return;
-        }
-
-        fail("Expected exception was not caught for " + desc);
-    }
-
-    /** */
-    private void testInvalidColIndex(Supplier<Matrix> supplier, String desc) {
-        try {
-            supplier.get();
-        }
-        catch (ColumnIndexException | IndexException ie) {
-            return;
-        }
-
-        fail("Expected exception was not caught for " + desc);
-    }
-
-    /** */
-    private void testMapMatrixWrongCardinality(Matrix m, String desc) {
-        for (int rowDelta : new int[] {-1, 0, 1})
-            for (int colDelta : new int[] {-1, 0, 1}) {
-                if (rowDelta == 0 && colDelta == 0)
-                    continue;
-
-                int rowNew = m.rowSize() + rowDelta;
-                int colNew = m.columnSize() + colDelta;
-
-                if (rowNew < 1 || colNew < 1)
-                    continue;
-
-                testInvalidCardinality(() -> m.map(new DenseLocalOnHeapMatrix(rowNew, colNew), (m1, m2) -> m1 + m2),
-                    desc + " wrong cardinality when mapping to size " + rowNew + "x" + colNew);
-            }
-    }
-
-    /** */
-    private void testInvalidCardinality(Supplier<Object> supplier, String desc) {
-        try {
-            supplier.get();
-        }
-        catch (CardinalityException ce) {
-            return;
-        }
-
-        fail("Expected exception was not caught for " + desc);
-    }
-
-    /** */
-    private boolean readOnly(Matrix m) {
-        return m instanceof RandomMatrix;
-    }
-
-    /** */
-    private double[][] fillIntAndReturn(Matrix m) {
-        double[][] data = new double[m.rowSize()][m.columnSize()];
-
-        if (readOnly(m)) {
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    data[i][j] = m.get(i, j);
-
-        }
-        else {
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    data[i][j] = i * m.rowSize() + j + 1;
-
-            m.assign(data);
-        }
-        return data;
-    }
-
-    /** */
-    private double[][] fillAndReturn(Matrix m) {
-        double[][] data = new double[m.rowSize()][m.columnSize()];
-
-        if (readOnly(m)) {
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    data[i][j] = m.get(i, j);
-
-        }
-        else {
-            for (int i = 0; i < m.rowSize(); i++)
-                for (int j = 0; j < m.columnSize(); j++)
-                    data[i][j] = -0.5d + Math.random();
-
-            m.assign(data);
-        }
-        return data;
-    }
-
-    /** */
-    private void fillNonSingularMatrix(Matrix m) {
-        for (int i = 0; i < m.rowSize(); i++) {
-            m.set(i, i, 10);
-
-            for (int j = 0; j < m.columnSize(); j++)
-                if (j != i)
-                    m.set(i, j, 0.01d);
-        }
-    }
-
-    /** */
-    private void fillMatrix(Matrix m) {
-        for (int i = 0; i < m.rowSize(); i++)
-            for (int j = 0; j < m.columnSize(); j++)
-                m.set(i, j, Math.random());
-    }
-
-    /** Ignore test for given matrix type. */
-    private boolean ignore(Class<? extends Matrix> clazz) {
-        List<Class<? extends Matrix>> ignoredClasses = Arrays.asList(RandomMatrix.class, PivotedMatrixView.class,
-            MatrixView.class, FunctionMatrix.class, TransposedMatrixView.class);
-
-        for (Class<? extends Matrix> ignoredClass : ignoredClasses)
-            if (ignoredClass.isAssignableFrom(clazz))
-                return true;
-
-        return false;
-    }
-
-    /** */
-    private Class<? extends Matrix> likeMatrixType(Matrix m) {
-        for (Class<? extends Matrix> clazz : likeTypesMap().keySet())
-            if (clazz.isAssignableFrom(m.getClass()))
-                return likeTypesMap().get(clazz);
-
-        return null;
-    }
-
-    /** */
-    private static Map<Class<? extends Matrix>, Class<? extends Vector>> likeVectorTypesMap() {
-        return new LinkedHashMap<Class<? extends Matrix>, Class<? extends Vector>>() {{
-            put(DenseLocalOnHeapMatrix.class, DenseLocalOnHeapVector.class);
-            put(DenseLocalOffHeapMatrix.class, DenseLocalOffHeapVector.class);
-            put(RandomMatrix.class, RandomVector.class);
-            put(SparseLocalOnHeapMatrix.class, SparseLocalVector.class);
-            put(DenseLocalOnHeapMatrix.class, DenseLocalOnHeapVector.class);
-            put(DiagonalMatrix.class, DenseLocalOnHeapVector.class); // IMPL NOTE per fixture
-            // IMPL NOTE check for presence of all implementations here will be done in testHaveLikeMatrix via Fixture
-        }};
-    }
-
-    /** */
-    private static Map<Class<? extends Matrix>, Class<? extends Matrix>> likeTypesMap() {
-        return new LinkedHashMap<Class<? extends Matrix>, Class<? extends Matrix>>() {{
-            put(DenseLocalOnHeapMatrix.class, DenseLocalOnHeapMatrix.class);
-            put(DenseLocalOffHeapMatrix.class, DenseLocalOffHeapMatrix.class);
-            put(RandomMatrix.class, RandomMatrix.class);
-            put(SparseLocalOnHeapMatrix.class, SparseLocalOnHeapMatrix.class);
-            put(DenseLocalOnHeapMatrix.class, DenseLocalOnHeapMatrix.class);
-            put(DiagonalMatrix.class, DenseLocalOnHeapMatrix.class); // IMPL NOTE per fixture
-            put(FunctionMatrix.class, FunctionMatrix.class);
-            // IMPL NOTE check for presence of all implementations here will be done in testHaveLikeMatrix via Fixture
-        }};
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixKeyMapperForTests.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixKeyMapperForTests.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixKeyMapperForTests.java
deleted file mode 100644
index 90fbec4..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixKeyMapperForTests.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.math.MatrixKeyMapper;
-
-/** */
-public class MatrixKeyMapperForTests implements MatrixKeyMapper<Integer> {
-    /** */ private int rows;
-    /** */ private int cols;
-
-    /** */
-    public MatrixKeyMapperForTests() {
-        // No-op.
-    }
-
-    /** */
-    public MatrixKeyMapperForTests(int rows, int cols) {
-        this.rows = rows;
-        this.cols = cols;
-    }
-
-    /** */
-    @Override public Integer apply(int x, int y) {
-        return x * cols + y;
-    }
-
-    /** */
-    @Override public boolean isValid(Integer integer) {
-        return (rows * cols) > integer;
-    }
-
-    /** */
-    @Override public int hashCode() {
-        int hash = 1;
-
-        hash += hash * 31 + rows;
-        hash += hash * 31 + cols;
-
-        return hash;
-    }
-
-    /** */
-    @Override public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-
-        if (obj == null || getClass() != obj.getClass())
-            return false;
-
-        MatrixKeyMapperForTests that = (MatrixKeyMapperForTests)obj;
-
-        return rows == that.rows && cols == that.cols;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixViewConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixViewConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixViewConstructorTest.java
deleted file mode 100644
index 01278da..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/MatrixViewConstructorTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.impls.storage.matrix.MatrixDelegateStorage;
-import org.junit.Test;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-/** */
-public class MatrixViewConstructorTest {
-    /** */
-    @Test
-    public void invalidArgsTest() {
-        Matrix m = new DenseLocalOnHeapMatrix(1, 1);
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new MatrixView((Matrix)null, 0, 0, 1, 1),
-            "Null parent matrix.");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new MatrixView(m, -1, 0, 1, 1),
-            "Invalid row offset.");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new MatrixView(m, 0, -1, 1, 1),
-            "Invalid col offset.");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new MatrixView(m, 0, 0, 0, 1),
-            "Invalid rows.");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new MatrixView(m, 0, 0, 1, 0),
-            "Invalid cols.");
-    }
-
-    /** */
-    @Test
-    public void basicTest() {
-        for (Matrix m : new Matrix[] {
-            new DenseLocalOnHeapMatrix(3, 3),
-            new DenseLocalOnHeapMatrix(3, 4), new DenseLocalOnHeapMatrix(4, 3)})
-            for (int rowOff : new int[] {0, 1})
-                for (int colOff : new int[] {0, 1})
-                    for (int rows : new int[] {1, 2})
-                        for (int cols : new int[] {1, 2})
-                            basicTest(m, rowOff, colOff, rows, cols);
-    }
-
-    /** */
-    private void basicTest(Matrix parent, int rowOff, int colOff, int rows, int cols) {
-        for (int row = 0; row < parent.rowSize(); row++)
-            for (int col = 0; col < parent.columnSize(); col++)
-                parent.set(row, col, row * parent.columnSize() + col + 1);
-
-        Matrix view = new MatrixView(parent, rowOff, colOff, rows, cols);
-
-        assertEquals("Rows in view.", rows, view.rowSize());
-        assertEquals("Cols in view.", cols, view.columnSize());
-
-        for (int row = 0; row < rows; row++)
-            for (int col = 0; col < cols; col++)
-                assertEquals("Unexpected value at " + row + "x" + col,
-                    parent.get(row + rowOff, col + colOff), view.get(row, col), 0d);
-
-        for (int row = 0; row < rows; row++)
-            for (int col = 0; col < cols; col++)
-                view.set(row, col, 0d);
-
-        for (int row = 0; row < rows; row++)
-            for (int col = 0; col < cols; col++)
-                assertEquals("Unexpected value set at " + row + "x" + col,
-                    0d, parent.get(row + rowOff, col + colOff), 0d);
-    }
-
-    /** */
-    @Test
-    public void attributeTest() {
-        for (Matrix m : new Matrix[] {
-            new DenseLocalOnHeapMatrix(3, 3),
-            new DenseLocalOnHeapMatrix(3, 4), new DenseLocalOnHeapMatrix(4, 3)}) {
-            MatrixView matrixView = new MatrixView(m, 0, 0, m.rowSize(), m.columnSize());
-
-            MatrixDelegateStorage delegateStorage = (MatrixDelegateStorage)matrixView.getStorage();
-
-            assertEquals(m.rowSize(), matrixView.rowSize());
-            assertEquals(m.columnSize(), matrixView.columnSize());
-
-            assertEquals(m.rowSize(), (delegateStorage).rowsLength());
-            assertEquals(m.columnSize(), (delegateStorage).columnsLength());
-
-            assertEquals(m.isSequentialAccess(), delegateStorage.isSequentialAccess());
-            assertEquals(m.isRandomAccess(), delegateStorage.isRandomAccess());
-            assertEquals(m.isDistributed(), delegateStorage.isDistributed());
-            assertEquals(m.isDense(), delegateStorage.isDense());
-            assertEquals(m.isArrayBased(), delegateStorage.isArrayBased());
-
-            assertArrayEquals(m.getStorage().data(), delegateStorage.data());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/PivotedMatrixViewConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/PivotedMatrixViewConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/PivotedMatrixViewConstructorTest.java
deleted file mode 100644
index a495745..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/PivotedMatrixViewConstructorTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import java.util.Arrays;
-import org.apache.ignite.math.Matrix;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/** */
-public class PivotedMatrixViewConstructorTest {
-    /** */
-    @Test
-    public void invalidArgsTest() {
-        Matrix m = new DenseLocalOnHeapMatrix(1, 1);
-
-        int[] pivot = new int[] {0};
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new PivotedMatrixView(null),
-            "Null parent matrix.");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new PivotedMatrixView(null, pivot),
-            "Null parent matrix, with pivot.");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new PivotedMatrixView(m, null),
-            "Null pivot.");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new PivotedMatrixView(m, null, pivot),
-            "Null row pivot.");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new PivotedMatrixView(m, pivot, null),
-            "Null col pivot.");
-    }
-
-    /** */
-    @Test
-    public void basicTest() {
-        Matrix m = new DenseLocalOnHeapMatrix(2, 2);
-
-        int[] pivot = new int[] {0, 1};
-
-        PivotedMatrixView view = new PivotedMatrixView(m, pivot);
-
-        assertEquals("Rows in view.", m.rowSize(), view.rowSize());
-        assertEquals("Cols in view.", m.columnSize(), view.columnSize());
-
-        assertTrue("Row pivot array in view.", Arrays.equals(pivot, view.rowPivot()));
-        assertTrue("Col pivot array in view.", Arrays.equals(pivot, view.columnPivot()));
-
-        assertEquals("Base matrix in view.", m, view.getBaseMatrix());
-
-        assertEquals("Row pivot value in view.", 0, view.rowPivot(0));
-        assertEquals("Col pivot value in view.", 0, view.columnPivot(0));
-
-        assertEquals("Row unpivot value in view.", 0, view.rowUnpivot(0));
-        assertEquals("Col unpivot value in view.", 0, view.columnUnpivot(0));
-
-        Matrix swap = view.swap(1, 1);
-
-        for (int row = 0; row < view.rowSize(); row++)
-            for (int col = 0; col < view.columnSize(); col++)
-                assertEquals("Unexpected swap value set at (" + row + "," + col + ").",
-                    view.get(row, col), swap.get(row, col), 0d);
-
-        //noinspection EqualsWithItself
-        assertTrue("View is expected to be equal to self.", view.equals(view));
-        //noinspection ObjectEqualsNull
-        assertFalse("View is expected to be not equal to null.", view.equals(null));
-    }
-
-    /** */
-    @Test
-    public void pivotTest() {
-        int[] pivot = new int[] {2, 1, 0, 3};
-
-        for (Matrix m : new Matrix[] {
-            new DenseLocalOnHeapMatrix(3, 3),
-            new DenseLocalOnHeapMatrix(3, 4), new DenseLocalOnHeapMatrix(4, 3)})
-            pivotTest(m, pivot);
-    }
-
-    /** */
-    private void pivotTest(Matrix parent, int[] pivot) {
-        for (int row = 0; row < parent.rowSize(); row++)
-            for (int col = 0; col < parent.columnSize(); col++)
-                parent.set(row, col, row * parent.columnSize() + col + 1);
-
-        Matrix view = new PivotedMatrixView(parent, pivot);
-
-        int rows = parent.rowSize();
-        int cols = parent.columnSize();
-
-        assertEquals("Rows in view.", rows, view.rowSize());
-        assertEquals("Cols in view.", cols, view.columnSize());
-
-        for (int row = 0; row < rows; row++)
-            for (int col = 0; col < cols; col++)
-                assertEquals("Unexpected value at " + row + "x" + col,
-                    parent.get(pivot[row], pivot[col]), view.get(row, col), 0d);
-
-        int min = rows < cols ? rows : cols;
-
-        for (int idx = 0; idx < min; idx++)
-            view.set(idx, idx, 0d);
-
-        for (int idx = 0; idx < min; idx++)
-            assertEquals("Unexpected value set at " + idx,
-                0d, parent.get(pivot[idx], pivot[idx]), 0d);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/RandomMatrixConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/RandomMatrixConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/RandomMatrixConstructorTest.java
deleted file mode 100644
index e19cfa3..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/RandomMatrixConstructorTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/** */
-public class RandomMatrixConstructorTest {
-    /** */
-    @Test
-    public void invalidArgsTest() {
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new RandomMatrix(0, 1), "invalid row parameter");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new RandomMatrix(1, 0), "invalid col parameter");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new RandomMatrix(0, 1, true), "invalid row parameter, fastHash true");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new RandomMatrix(1, 0, true), "invalid col parameter, fastHash true");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new RandomMatrix(0, 1, false), "invalid row parameter, fastHash false");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new RandomMatrix(1, 0, false), "invalid col parameter, fastHash false");
-    }
-
-    /** */
-    @Test
-    public void basicTest() {
-        assertEquals("Expected number of rows, int parameters.", 1,
-            new RandomMatrix(1, 2).rowSize());
-
-        assertEquals("Expected number of cols, int parameters.", 1,
-            new RandomMatrix(2, 1).columnSize());
-
-        assertEquals("Expected number of rows, int parameters, fastHash true.", 1,
-            new RandomMatrix(1, 2, true).rowSize());
-
-        assertEquals("Expected number of cols, int parameters, fastHash true.", 1,
-            new RandomMatrix(2, 1, true).columnSize());
-
-        assertEquals("Expected number of rows, int parameters, fastHash false.", 1,
-            new RandomMatrix(1, 2, false).rowSize());
-
-        assertEquals("Expected number of cols, int parameters, fastHash false.", 1,
-            new RandomMatrix(2, 1, false).columnSize());
-
-        RandomMatrix m = new RandomMatrix(1, 1);
-        //noinspection EqualsWithItself
-        assertTrue("Matrix is expected to be equal to self.", m.equals(m));
-        //noinspection ObjectEqualsNull
-        assertFalse("Matrix is expected to be not equal to null.", m.equals(null));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/SparseDistributedMatrixTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/SparseDistributedMatrixTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/SparseDistributedMatrixTest.java
deleted file mode 100644
index 8218a12..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/SparseDistributedMatrixTest.java
+++ /dev/null
@@ -1,265 +0,0 @@
-// @java.file.header
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.math.Matrix;
-import org.apache.ignite.math.StorageConstants;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.apache.ignite.testframework.junits.common.GridCommonTest;
-
-import static org.apache.ignite.math.impls.MathTestConstants.UNEXPECTED_VAL;
-
-/**
- * Tests for {@link SparseDistributedMatrix}.
- */
-@GridCommonTest(group = "Distributed Models")
-public class SparseDistributedMatrixTest extends GridCommonAbstractTest {
-    /** Number of nodes in grid */
-    private static final int NODE_COUNT = 3;
-    /** Cache name. */
-    private static final String CACHE_NAME = "test-cache";
-    /** Precision. */
-    private static final double PRECISION = 0.0;
-    /** Grid instance. */
-    private Ignite ignite;
-    /** Matrix rows */
-    private final int rows = MathTestConstants.STORAGE_SIZE;
-    /** Matrix cols */
-    private final int cols = MathTestConstants.STORAGE_SIZE;
-    /** Matrix for tests */
-    private SparseDistributedMatrix cacheMatrix;
-
-    /**
-     * Default constructor.
-     */
-    public SparseDistributedMatrixTest() {
-        super(false);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        for (int i = 1; i <= NODE_COUNT; i++)
-            startGrid(i);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        stopAllGrids();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override protected void beforeTest() throws Exception {
-        ignite = grid(NODE_COUNT);
-
-        ignite.configuration().setPeerClassLoadingEnabled(true);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        ignite.destroyCache(CACHE_NAME);
-
-        if (cacheMatrix != null) {
-            cacheMatrix.destroy();
-            cacheMatrix = null;
-        }
-    }
-
-    /** */
-    public void testGetSet() throws Exception {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
-        for (int i = 0; i < rows; i++) {
-            for (int j = 0; j < cols; j++) {
-                double v = Math.random();
-                cacheMatrix.set(i, j, v);
-
-                assert Double.compare(v, cacheMatrix.get(i, j)) == 0;
-            }
-        }
-    }
-
-    /** */
-    public void testExternalize() throws IOException, ClassNotFoundException {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
-        cacheMatrix.set(1, 1, 1.0);
-
-        ByteArrayOutputStream byteArrOutputStream = new ByteArrayOutputStream();
-        ObjectOutputStream objOutputStream = new ObjectOutputStream(byteArrOutputStream);
-
-        objOutputStream.writeObject(cacheMatrix);
-
-        ByteArrayInputStream byteArrInputStream = new ByteArrayInputStream(byteArrOutputStream.toByteArray());
-        ObjectInputStream objInputStream = new ObjectInputStream(byteArrInputStream);
-
-        SparseDistributedMatrix objRestored = (SparseDistributedMatrix)objInputStream.readObject();
-
-        assertTrue(MathTestConstants.VAL_NOT_EQUALS, cacheMatrix.equals(objRestored));
-        assertEquals(MathTestConstants.VAL_NOT_EQUALS, objRestored.get(1, 1), 1.0, 0.0);
-    }
-
-    /** Test simple math. */
-    public void testMath() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-        initMtx(cacheMatrix);
-
-        cacheMatrix.assign(2.0);
-        for (int i = 0; i < cacheMatrix.rowSize(); i++)
-            for (int j = 0; j < cacheMatrix.columnSize(); j++)
-                assertEquals(UNEXPECTED_VAL, 2.0, cacheMatrix.get(i, j), PRECISION);
-
-        cacheMatrix.plus(3.0);
-        for (int i = 0; i < cacheMatrix.rowSize(); i++)
-            for (int j = 0; j < cacheMatrix.columnSize(); j++)
-                assertEquals(UNEXPECTED_VAL, 5.0, cacheMatrix.get(i, j), PRECISION);
-
-        cacheMatrix.times(2.0);
-        for (int i = 0; i < cacheMatrix.rowSize(); i++)
-            for (int j = 0; j < cacheMatrix.columnSize(); j++)
-                assertEquals(UNEXPECTED_VAL, 10.0, cacheMatrix.get(i, j), PRECISION);
-
-        cacheMatrix.divide(10.0);
-        for (int i = 0; i < cacheMatrix.rowSize(); i++)
-            for (int j = 0; j < cacheMatrix.columnSize(); j++)
-                assertEquals(UNEXPECTED_VAL, 1.0, cacheMatrix.get(i, j), PRECISION);
-
-        assertEquals(UNEXPECTED_VAL, cacheMatrix.rowSize() * cacheMatrix.columnSize(), cacheMatrix.sum(), PRECISION);
-    }
-
-    /** */
-    public void testMinMax() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
-        for (int i = 0; i < cacheMatrix.rowSize(); i++)
-            for (int j = 0; j < cacheMatrix.columnSize(); j++)
-                cacheMatrix.set(i, j, i * cols + j + 1);
-
-        assertEquals(UNEXPECTED_VAL, 1.0, cacheMatrix.minValue(), PRECISION);
-        assertEquals(UNEXPECTED_VAL, rows * cols, cacheMatrix.maxValue(), PRECISION);
-
-        for (int i = 0; i < cacheMatrix.rowSize(); i++)
-            for (int j = 0; j < cacheMatrix.columnSize(); j++)
-                cacheMatrix.set(i, j, -1.0 * (i * cols + j + 1));
-
-        assertEquals(UNEXPECTED_VAL, -rows * cols, cacheMatrix.minValue(), PRECISION);
-        assertEquals(UNEXPECTED_VAL, -1.0, cacheMatrix.maxValue(), PRECISION);
-
-        for (int i = 0; i < cacheMatrix.rowSize(); i++)
-            for (int j = 0; j < cacheMatrix.columnSize(); j++)
-                cacheMatrix.set(i, j, i * cols + j);
-
-        assertEquals(UNEXPECTED_VAL, 1.0, cacheMatrix.minValue(), PRECISION);
-        assertEquals(UNEXPECTED_VAL, rows * cols - 1.0, cacheMatrix.maxValue(), PRECISION);
-    }
-
-    /** */
-    public void testMap() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-        initMtx(cacheMatrix);
-
-        cacheMatrix.map(i -> 100.0);
-        for (int i = 0; i < cacheMatrix.rowSize(); i++)
-            for (int j = 0; j < cacheMatrix.columnSize(); j++)
-                assertEquals(UNEXPECTED_VAL, 100.0, cacheMatrix.get(i, j), PRECISION);
-    }
-
-    /** */
-    public void testCopy() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
-        try {
-            cacheMatrix.copy();
-            fail("UnsupportedOperationException expected.");
-        }
-        catch (UnsupportedOperationException e) {
-            return;
-        }
-        fail("UnsupportedOperationException expected.");
-    }
-
-    /** */
-    public void testLike() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
-        try {
-            cacheMatrix.like(1, 1);
-            fail("UnsupportedOperationException expected.");
-        }
-        catch (UnsupportedOperationException e) {
-            return;
-        }
-        fail("UnsupportedOperationException expected.");
-    }
-
-    /** */
-    public void testLikeVector() {
-        IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
-        cacheMatrix = new SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
-        try {
-            cacheMatrix.likeVector(1);
-            fail("UnsupportedOperationException expected.");
-        }
-        catch (UnsupportedOperationException e) {
-            return;
-        }
-        fail("UnsupportedOperationException expected.");
-    }
-
-    /** */
-    private void initMtx(Matrix m) {
-        for (int i = 0; i < m.rowSize(); i++)
-            for (int j = 0; j < m.columnSize(); j++)
-                m.set(i, j, 1.0);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/SparseLocalOnHeapMatrixConstructorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/SparseLocalOnHeapMatrixConstructorTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/SparseLocalOnHeapMatrixConstructorTest.java
deleted file mode 100644
index fc675c1..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/SparseLocalOnHeapMatrixConstructorTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/** */
-public class SparseLocalOnHeapMatrixConstructorTest {
-    /** */
-    @Test
-    public void invalidArgsTest() {
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new SparseLocalOnHeapMatrix(0, 1),
-            "invalid row parameter");
-
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new SparseLocalOnHeapMatrix(1, 0),
-            "invalid col parameter");
-    }
-
-    /** */
-    @Test
-    public void basicTest() {
-        assertEquals("Expected number of rows.", 1,
-            new SparseLocalOnHeapMatrix(1, 2).rowSize());
-
-        assertEquals("Expected number of cols, int parameters.", 1,
-            new SparseLocalOnHeapMatrix(2, 1).columnSize());
-
-        SparseLocalOnHeapMatrix m = new SparseLocalOnHeapMatrix(1, 1);
-        //noinspection EqualsWithItself
-        assertTrue("Matrix is expected to be equal to self.", m.equals(m));
-        //noinspection ObjectEqualsNull
-        assertFalse("Matrix is expected to be not equal to null.", m.equals(null));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/TransposedMatrixViewTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/TransposedMatrixViewTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/TransposedMatrixViewTest.java
deleted file mode 100644
index 5eacfea..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/matrix/TransposedMatrixViewTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.matrix;
-
-import org.apache.ignite.math.ExternalizeTest;
-import org.apache.ignite.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests for {@link TransposedMatrixView}.
- */
-public class TransposedMatrixViewTest extends ExternalizeTest<TransposedMatrixView> {
-    /** */
-    private static final String UNEXPECTED_VALUE = "Unexpected value";
-    /** */
-    private TransposedMatrixView testMatrix;
-    /** */
-    private DenseLocalOnHeapMatrix parent;
-
-    /** */
-    @Before
-    public void setup() {
-        parent = new DenseLocalOnHeapMatrix(MathTestConstants.STORAGE_SIZE, MathTestConstants.STORAGE_SIZE);
-        fillMatrix(parent);
-        testMatrix = new TransposedMatrixView(parent);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void externalizeTest() {
-        externalizeTest(testMatrix);
-    }
-
-    /** */
-    @Test
-    public void testView() {
-        assertEquals(UNEXPECTED_VALUE, parent.rowSize(), testMatrix.columnSize());
-        assertEquals(UNEXPECTED_VALUE, parent.columnSize(), testMatrix.rowSize());
-
-        for (int i = 0; i < parent.rowSize(); i++)
-            for (int j = 0; j < parent.columnSize(); j++)
-                assertEquals(UNEXPECTED_VALUE, parent.get(i, j), testMatrix.get(j, i), 0d);
-    }
-
-    /** */
-    @Test
-    public void testNullParams() {
-        DenseLocalOnHeapMatrixConstructorTest.verifyAssertionError(() -> new TransposedMatrixView(null), "Null Matrix parameter");
-    }
-
-    /** */
-    @Test(expected = UnsupportedOperationException.class)
-    public void testLike() {
-        testMatrix.like(0, 0);
-    }
-
-    /** */
-    @Test(expected = UnsupportedOperationException.class)
-    public void testLikeVector() {
-        testMatrix.likeVector(0);
-    }
-
-    /** */
-    private void fillMatrix(DenseLocalOnHeapMatrix mtx) {
-        for (int i = 0; i < mtx.rowSize(); i++)
-            for (int j = 0; j < mtx.columnSize(); j++)
-                mtx.setX(i, j, i * mtx.rowSize() + j);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixArrayStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixArrayStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixArrayStorageTest.java
deleted file mode 100644
index 817dd49..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixArrayStorageTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Unit tests for {@link ArrayMatrixStorage}.
- */
-public class MatrixArrayStorageTest extends MatrixBaseStorageTest<ArrayMatrixStorage> {
-    /** {@inheritDoc} */
-    @Override public void setUp() {
-        storage = new ArrayMatrixStorage(MathTestConstants.STORAGE_SIZE, MathTestConstants.STORAGE_SIZE);
-    }
-
-    /** */
-    @Test
-    public void isSequentialAccess() throws Exception {
-        assertFalse(MathTestConstants.UNEXPECTED_VAL, storage.isSequentialAccess());
-    }
-
-    /** */
-    @Test
-    public void isDense() throws Exception {
-        assertTrue(MathTestConstants.UNEXPECTED_VAL, storage.isDense());
-    }
-
-    /** */
-    @Test
-    public void isArrayBased() throws Exception {
-        assertTrue(MathTestConstants.UNEXPECTED_VAL, storage.isArrayBased());
-    }
-
-    /** */
-    @Test
-    public void data() throws Exception {
-        double[][] data = storage.data();
-        assertNotNull(MathTestConstants.NULL_VAL, data);
-        assertTrue(MathTestConstants.UNEXPECTED_VAL, data.length == MathTestConstants.STORAGE_SIZE);
-        assertTrue(MathTestConstants.UNEXPECTED_VAL, data[0].length == MathTestConstants.STORAGE_SIZE);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixBaseStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixBaseStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixBaseStorageTest.java
deleted file mode 100644
index 8df19e4..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixBaseStorageTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import org.apache.ignite.math.ExternalizeTest;
-import org.apache.ignite.math.MatrixStorage;
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Abstract class with base tests for each matrix storage.
- */
-public abstract class MatrixBaseStorageTest<T extends MatrixStorage> extends ExternalizeTest<T> {
-    /** */
-    protected T storage;
-
-    /** */
-    @Before
-    public abstract void setUp();
-
-    /** */
-    @After
-    public void tearDown() throws Exception {
-        storage.destroy();
-    }
-
-    /** */
-    @Test
-    public void getSet() throws Exception {
-        int rows = MathTestConstants.STORAGE_SIZE;
-        int cols = MathTestConstants.STORAGE_SIZE;
-
-        for (int i = 0; i < rows; i++) {
-            for (int j = 0; j < cols; j++) {
-                double data = Math.random();
-
-                storage.set(i, j, data);
-
-                Assert.assertEquals(MathTestConstants.VAL_NOT_EQUALS, storage.get(i, j), data, MathTestConstants.NIL_DELTA);
-            }
-        }
-    }
-
-    /** */
-    @Test
-    public void columnSize() throws Exception {
-        assertEquals(MathTestConstants.VAL_NOT_EQUALS, storage.columnSize(), MathTestConstants.STORAGE_SIZE);
-    }
-
-    /** */
-    @Test
-    public void rowSize() throws Exception {
-        assertEquals(MathTestConstants.VAL_NOT_EQUALS, storage.rowSize(), MathTestConstants.STORAGE_SIZE);
-    }
-
-    /** */
-    @Override public void externalizeTest() {
-        fillMatrix();
-        super.externalizeTest(storage);
-    }
-
-    /** */
-    protected void fillMatrix() {
-        for (int i = 0; i < storage.rowSize(); i++) {
-            for (int j = 0; j < storage.columnSize(); j++)
-                storage.set(i, j, Math.random());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixOffHeapStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixOffHeapStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixOffHeapStorageTest.java
deleted file mode 100644
index a3b21bb..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixOffHeapStorageTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import org.apache.ignite.math.impls.MathTestConstants;
-import org.junit.Test;
-
-import static org.junit.Assert.assertNull;
-
-/**
- * Unit tests for {@link DenseOffHeapMatrixStorage}.
- */
-public class MatrixOffHeapStorageTest extends MatrixBaseStorageTest<DenseOffHeapMatrixStorage> {
-    /** {@inheritDoc} */
-    @Override public void setUp() {
-        storage = new DenseOffHeapMatrixStorage(MathTestConstants.STORAGE_SIZE, MathTestConstants.STORAGE_SIZE);
-    }
-
-    /** */
-    @Test
-    public void data() throws Exception {
-        assertNull(MathTestConstants.UNEXPECTED_VAL, storage.data());
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixStorageFixtures.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixStorageFixtures.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixStorageFixtures.java
deleted file mode 100644
index 6353c38..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixStorageFixtures.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.function.BiConsumer;
-import java.util.function.Supplier;
-import org.apache.ignite.math.MatrixStorage;
-import org.jetbrains.annotations.NotNull;
-
-import static org.apache.ignite.math.StorageConstants.COLUMN_STORAGE_MODE;
-import static org.apache.ignite.math.StorageConstants.RANDOM_ACCESS_MODE;
-import static org.apache.ignite.math.StorageConstants.ROW_STORAGE_MODE;
-import static org.apache.ignite.math.StorageConstants.SEQUENTIAL_ACCESS_MODE;
-
-/**
- *
- */
-class MatrixStorageFixtures {
-    /** */
-    private static final List<Supplier<Iterable<MatrixStorage>>> suppliers = Collections.singletonList(
-        (Supplier<Iterable<MatrixStorage>>) SparseLocalMatrixStorageFixture::new
-    );
-
-    /** */
-    void consumeSampleStorages(BiConsumer<Integer, Integer> paramsConsumer,
-        BiConsumer<MatrixStorage, String> consumer) {
-        for (Supplier<Iterable<MatrixStorage>> fixtureSupplier : suppliers) {
-            final Iterable<MatrixStorage> fixture = fixtureSupplier.get();
-
-            for (MatrixStorage matrixStorage : fixture) {
-                if (paramsConsumer != null)
-                    paramsConsumer.accept(matrixStorage.rowSize(), matrixStorage.columnSize());
-
-                consumer.accept(matrixStorage, fixture.toString());
-            }
-        }
-    }
-
-    /** */
-    private static class SparseLocalMatrixStorageFixture implements Iterable<MatrixStorage> {
-        /** */
-        private final Integer[] rows = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 512, 1024, null};
-        /** */
-        private final Integer[] cols = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1024, 512, null};
-        /** */
-        private final Integer[] randomAccess = new Integer[] {SEQUENTIAL_ACCESS_MODE, RANDOM_ACCESS_MODE, null};
-        /** */
-        private final Integer[] rowStorage = new Integer[] {ROW_STORAGE_MODE, COLUMN_STORAGE_MODE, null};
-        /** */
-        private int sizeIdx = 0;
-        /** */
-        private int acsModeIdx = 0;
-        /** */
-        private int stoModeIdx = 0;
-
-        /** {@inheritDoc} */
-        @NotNull
-        @Override public Iterator<MatrixStorage> iterator() {
-            return new Iterator<MatrixStorage>() {
-                /** {@inheritDoc} */
-                @Override public boolean hasNext() {
-                    return hasNextCol(sizeIdx) && hasNextRow(sizeIdx)
-                        && hasNextAcsMode(acsModeIdx) && hasNextStoMode(stoModeIdx);
-                }
-
-                /** {@inheritDoc} */
-                @Override public MatrixStorage next() {
-                    if (!hasNext())
-                        throw new NoSuchElementException(SparseLocalMatrixStorageFixture.this.toString());
-
-                    MatrixStorage storage = new SparseLocalOnHeapMatrixStorage(
-                        rows[sizeIdx], cols[sizeIdx], randomAccess[acsModeIdx], rowStorage[stoModeIdx]);
-
-                    nextIdx();
-
-                    return storage;
-                }
-
-                private void nextIdx() {
-                    if (hasNextStoMode(stoModeIdx + 1)) {
-                        stoModeIdx++;
-
-                        return;
-                    }
-
-                    stoModeIdx = 0;
-
-                    if (hasNextAcsMode(acsModeIdx + 1)) {
-                        acsModeIdx++;
-
-                        return;
-                    }
-
-                    acsModeIdx = 0;
-                    sizeIdx++;
-                }
-            };
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return "SparseLocalMatrixStorageFixture{ " + "rows=" + rows[sizeIdx] + ", cols=" + cols[sizeIdx] +
-                ", access mode=" + randomAccess[acsModeIdx] + ", storage mode=" + rowStorage[stoModeIdx] + "}";
-        }
-
-        /** */ private boolean hasNextRow(int idx) {
-            return rows[idx] != null;
-        }
-
-        /** */ private boolean hasNextCol(int idx) {
-            return cols[idx] != null;
-        }
-
-        /** */ private boolean hasNextAcsMode(int idx) {
-            return randomAccess[idx] != null;
-        }
-
-        /** */ private boolean hasNextStoMode(int idx) {
-            return rowStorage[idx] != null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0abf6601/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixStorageImplementationTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixStorageImplementationTest.java b/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixStorageImplementationTest.java
deleted file mode 100644
index 6ec09bd..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/math/impls/storage/matrix/MatrixStorageImplementationTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.math.impls.storage.matrix;
-
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.BiConsumer;
-import org.apache.ignite.math.ExternalizeTest;
-import org.apache.ignite.math.MatrixStorage;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * Unit tests for {@link MatrixStorage} implementations.
- *
- * TODO: add attribute tests.
- */
-public class MatrixStorageImplementationTest extends ExternalizeTest<MatrixStorage> {
-    /**
-     * The columnSize() and the rowSize() test.
-     */
-    @Test
-    public void sizeTest() {
-        final AtomicReference<Integer> expRowSize = new AtomicReference<>(0);
-        final AtomicReference<Integer> expColSize = new AtomicReference<>(0);
-
-        consumeSampleStorages((x, y) -> {
-                expRowSize.set(x);
-                expColSize.set(y);
-            },
-            (ms, desc) -> assertTrue("Expected size for " + desc, expColSize.get().equals(ms.columnSize()) && expRowSize.get().equals(ms.rowSize())));
-    }
-
-    /** */
-    @Test
-    public void getSetTest() {
-        consumeSampleStorages(null, (ms, desc) -> {
-            for (int i = 0; i < ms.rowSize(); i++) {
-                for (int j = 0; j < ms.columnSize(); j++) {
-                    double random = Math.random();
-                    ms.set(i, j, random);
-                    assertTrue("Unexpected value for " + desc + " x:" + i + ", y:" + j, Double.compare(random, ms.get(i, j)) == 0);
-                }
-            }
-        });
-    }
-
-    /** */
-    @Override public void externalizeTest() {
-        consumeSampleStorages(null, (ms, desc) -> externalizeTest(ms));
-    }
-
-    /** */
-    private void consumeSampleStorages(BiConsumer<Integer, Integer> paramsConsumer,
-        BiConsumer<MatrixStorage, String> consumer) {
-        new MatrixStorageFixtures().consumeSampleStorages(paramsConsumer, consumer);
-    }
-}


[25/65] [abbrv] ignite git commit: master - Mute test with a correct link

Posted by ag...@apache.org.
master - Mute test with a correct link


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

Branch: refs/heads/ignite-5024
Commit: 364c38661a1864e0b823be737998ed66927d11ca
Parents: 0abf660
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Tue Apr 18 18:40:27 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Apr 18 18:40:27 2017 +0300

----------------------------------------------------------------------
 .../cache/IgniteCacheJoinPartitionedAndReplicatedTest.java         | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/364c3866/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java
index 46b8272..fb78678 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java
@@ -179,6 +179,8 @@ public class IgniteCacheJoinPartitionedAndReplicatedTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     public void testJoin() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-5016");
+
         Ignite client = grid(2);
 
         IgniteCache<Object, Object> personCache = client.cache(PERSON_CACHE);