You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by av...@apache.org on 2018/01/17 10:16:32 UTC
[01/11] ignite git commit: IGNITE-7203 Java 8 by default
Repository: ignite
Updated Branches:
refs/heads/master e02a8d265 -> 43a62cdba
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java
deleted file mode 100644
index de2c99b..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java
+++ /dev/null
@@ -1,32 +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.yardstick.ml.math;
-
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.impls.matrix.SparseLocalOnHeapMatrix;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteSparseLocalMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
- /** {@inheritDoc} */
- @Override Matrix newMatrix(int rowSize, int colSize) {
- return new SparseLocalOnHeapMatrix(rowSize, colSize);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/package-info.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/package-info.java
deleted file mode 100644
index d37e967..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/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. -->
- * ML Grid math benchmarks.
- */
-package org.apache.ignite.yardstick.ml.math;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/package-info.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/package-info.java
deleted file mode 100644
index 4751f35..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/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. -->
- * ML Grid benchmarks.
- */
-package org.apache.ignite.yardstick.ml;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/regression/IgniteOLSMultipleLinearRegressionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/regression/IgniteOLSMultipleLinearRegressionBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/regression/IgniteOLSMultipleLinearRegressionBenchmark.java
deleted file mode 100644
index 89b5471..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/regression/IgniteOLSMultipleLinearRegressionBenchmark.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.yardstick.ml.regression;
-
-import java.util.Map;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionModel;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionQRTrainer;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteOLSMultipleLinearRegressionBenchmark extends IgniteAbstractBenchmark {
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- runLongly();
-
- return true;
- }
-
- /**
- * Based on OLSMultipleLinearRegressionTest#testLongly.
- */
- private void runLongly() {
- // Y values are first, then independent vars
- // Each row is one observation
- double[][] data = new double[][] {
- { 60323, 83.0, 234289, 2356, 1590, 107608, 1947 },
- { 61122, 88.5, 259426, 2325, 1456, 108632, 1948 },
- { 60171, 88.2, 258054, 3682, 1616, 109773, 1949 },
- { 61187, 89.5, 284599, 3351, 1650, 110929, 1950 },
- { 63221, 96.2, 328975, 2099, 3099, 112075, 1951 },
- { 63639, 98.1, 346999, 1932, 3594, 113270, 1952 },
- { 64989, 99.0, 365385, 1870, 3547, 115094, 1953 },
- { 63761, 100.0, 363112, 3578, 3350, 116219, 1954 },
- { 66019, 101.2, 397469, 2904, 3048, 117388, 1955 },
- { 67857, 104.6, 419180, 2822, 2857, 118734, 1956 },
- { 68169, 108.4, 442769, 2936, 2798, 120445, 1957 },
- { 66513, 110.8, 444546, 4681, 2637, 121950, 1958 },
- { 68655, 112.6, 482704, 3813, 2552, 123366, 1959 },
- { 69564, 114.2, 502601, 3931, 2514, 125368, 1960 },
- { 69331, 115.7, 518173, 4806, 2572, 127852, 1961 },
- { 70551, 116.9, 554894, 4007, 2827, 130081, 1962 }
- };
-
- final int nobs = 16;
- final int nvars = 6;
-
- LinearRegressionQRTrainer trainer = new LinearRegressionQRTrainer();
- LinearRegressionModel model = trainer.train(new DenseLocalOnHeapMatrix(data));
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/regression/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/regression/package-info.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/regression/package-info.java
deleted file mode 100644
index 0a5dc1a..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/regression/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. -->
- * ML Grid regression benchmarks.
- */
-package org.apache.ignite.yardstick.ml.regression;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeGiniBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeGiniBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeGiniBenchmark.java
deleted file mode 100644
index f8a7c08..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeGiniBenchmark.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.yardstick.ml.trees;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
-import org.apache.ignite.ml.trees.trainers.columnbased.contsplitcalcs.ContinuousSplitCalculators;
-import org.apache.ignite.ml.trees.trainers.columnbased.regcalcs.RegionCalculators;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.thread.IgniteThread;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteColumnDecisionTreeGiniBenchmark extends IgniteAbstractBenchmark {
- /** */
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
- // because we create ignite cache internally.
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
- this.getClass().getSimpleName(), new Runnable() {
- /** {@inheritDoc} */
- @Override public void run() {
- // IMPL NOTE originally taken from ColumnDecisionTreeTrainerTest#testCacheMixedGini
- int totalPts = 1 << 10;
- int featCnt = 2;
-
- HashMap<Integer, Integer> catsInfo = new HashMap<>();
- catsInfo.put(1, 3);
-
- SplitDataGenerator<DenseLocalOnHeapVector> gen = new SplitDataGenerator<>(
- featCnt, catsInfo, () -> new DenseLocalOnHeapVector(featCnt + 1)).
- split(0, 1, new int[] {0, 2}).
- split(1, 0, -10.0);
-
- gen.testByGen(totalPts, ContinuousSplitCalculators.GINI.apply(ignite),
- RegionCalculators.GINI, RegionCalculators.MEAN, ignite);
- }
- });
-
- igniteThread.start();
-
- igniteThread.join();
-
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeVarianceBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeVarianceBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeVarianceBenchmark.java
deleted file mode 100644
index f9d417f..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeVarianceBenchmark.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.yardstick.ml.trees;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
-import org.apache.ignite.ml.trees.trainers.columnbased.contsplitcalcs.ContinuousSplitCalculators;
-import org.apache.ignite.ml.trees.trainers.columnbased.regcalcs.RegionCalculators;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.thread.IgniteThread;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteColumnDecisionTreeVarianceBenchmark extends IgniteAbstractBenchmark {
- /** */
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
- // because we create ignite cache internally.
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
- this.getClass().getSimpleName(), new Runnable() {
- /** {@inheritDoc} */
- @Override public void run() {
- // IMPL NOTE originally taken from ColumnDecisionTreeTrainerTest#testCacheMixed
- int totalPts = 1 << 10;
- int featCnt = 2;
-
- HashMap<Integer, Integer> catsInfo = new HashMap<>();
- catsInfo.put(1, 3);
-
- SplitDataGenerator<DenseLocalOnHeapVector> gen
- = new SplitDataGenerator<>(
- featCnt, catsInfo, () -> new DenseLocalOnHeapVector(featCnt + 1)).
- split(0, 1, new int[] {0, 2}).
- split(1, 0, -10.0);
-
- gen.testByGen(totalPts,
- ContinuousSplitCalculators.VARIANCE, RegionCalculators.VARIANCE, RegionCalculators.MEAN, ignite);
- }
- });
-
- igniteThread.start();
-
- igniteThread.join();
-
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/SplitDataGenerator.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/SplitDataGenerator.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/SplitDataGenerator.java
deleted file mode 100644
index f9117f4..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/SplitDataGenerator.java
+++ /dev/null
@@ -1,426 +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.yardstick.ml.trees;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.BitSet;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
-import java.util.stream.DoubleStream;
-import java.util.stream.IntStream;
-import java.util.stream.Stream;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.ml.math.StorageConstants;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.exceptions.MathIllegalArgumentException;
-import org.apache.ignite.ml.math.functions.IgniteFunction;
-import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
-import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
-import org.apache.ignite.ml.structures.LabeledVectorDouble;
-import org.apache.ignite.ml.trees.ContinuousRegionInfo;
-import org.apache.ignite.ml.trees.ContinuousSplitCalculator;
-import org.apache.ignite.ml.trees.models.DecisionTreeModel;
-import org.apache.ignite.ml.trees.trainers.columnbased.ColumnDecisionTreeTrainer;
-import org.apache.ignite.ml.trees.trainers.columnbased.ColumnDecisionTreeTrainerInput;
-import org.apache.ignite.ml.trees.trainers.columnbased.MatrixColumnDecisionTreeTrainerInput;
-import org.apache.ignite.ml.util.Utils;
-
-/** */
-class SplitDataGenerator<V extends Vector> {
- /** */
- private static final Random rnd = new Random(12349L);
-
- /** */
- private static final double DELTA = 100.0;
-
- /** Map of the form of (is categorical -> list of region indexes). */
- private final Map<Boolean, List<Integer>> di;
-
- /** List of regions. */
- private final List<Region> regs;
-
- /** Data of bounds of regions. */
- private final Map<Integer, IgniteBiTuple<Double, Double>> boundsData;
-
- /** */
- private final Map<Integer, Integer> catFeaturesInfo;
-
- /** Supplier of vectors. */
- private final Supplier<V> supplier;
-
- /** Features count. */
- private final int featCnt;
-
- /**
- * Create SplitDataGenerator.
- *
- * @param featCnt Features count.
- * @param catFeaturesInfo Information about categorical features in form of map (feature index -> categories
- * count).
- * @param supplier Supplier of vectors.
- */
- SplitDataGenerator(int featCnt, Map<Integer, Integer> catFeaturesInfo, Supplier<V> supplier) {
- regs = new LinkedList<>();
- boundsData = new HashMap<>();
- this.supplier = supplier;
- this.featCnt = featCnt;
- this.catFeaturesInfo = catFeaturesInfo;
-
- // Divide indexes into indexes of categorical coordinates and indexes of continuous coordinates.
- di = IntStream.range(0, featCnt).
- boxed().
- collect(Collectors.partitioningBy(catFeaturesInfo::containsKey));
-
- // Categorical coordinates info.
- Map<Integer, CatCoordInfo> catCoords = new HashMap<>();
- di.get(true).forEach(i -> {
- BitSet bs = new BitSet();
- bs.set(0, catFeaturesInfo.get(i));
- catCoords.put(i, new CatCoordInfo(bs));
- });
-
- // Continuous coordinates info.
- Map<Integer, ContCoordInfo> contCoords = new HashMap<>();
- di.get(false).forEach(i -> {
- contCoords.put(i, new ContCoordInfo());
- boundsData.put(i, new IgniteBiTuple<>(-1.0, 1.0));
- });
-
- Region firstReg = new Region(catCoords, contCoords, 0);
- regs.add(firstReg);
- }
-
- /** */
- <D extends ContinuousRegionInfo> void testByGen(int totalPts,
- IgniteFunction<ColumnDecisionTreeTrainerInput, ? extends ContinuousSplitCalculator<D>> calc,
- IgniteFunction<ColumnDecisionTreeTrainerInput, IgniteFunction<DoubleStream, Double>> catImpCalc,
- IgniteFunction<DoubleStream, Double> regCalc, Ignite ignite) {
-
- List<IgniteBiTuple<Integer, V>> lst = points(totalPts, (i, rn) -> i).collect(Collectors.toList());
-
- Collections.shuffle(lst, rnd);
-
- SparseDistributedMatrix m = new SparseDistributedMatrix(totalPts,
- featCnt + 1, StorageConstants.COLUMN_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
- Map<Integer, List<LabeledVectorDouble>> byRegion = new HashMap<>();
-
- int i = 0;
- for (IgniteBiTuple<Integer, V> bt : lst) {
- byRegion.putIfAbsent(bt.get1(), new LinkedList<>());
- byRegion.get(bt.get1()).add(asLabeledVector(bt.get2().getStorage().data()));
- m.setRow(i, bt.get2().getStorage().data());
- i++;
- }
-
- ColumnDecisionTreeTrainer<D> trainer =
- new ColumnDecisionTreeTrainer<>(3, calc, catImpCalc, regCalc, ignite);
-
- DecisionTreeModel mdl = trainer.train(new MatrixColumnDecisionTreeTrainerInput(m, catFeaturesInfo));
-
- byRegion.keySet().forEach(k -> mdl.apply(byRegion.get(k).get(0).features()));
- }
-
- /**
- * Split region by continuous coordinate using given threshold.
- *
- * @param regIdx Region index.
- * @param coordIdx Coordinate index.
- * @param threshold Threshold.
- * @return {@code this}.
- */
- SplitDataGenerator<V> split(int regIdx, int coordIdx, double threshold) {
- Region regToSplit = regs.get(regIdx);
- ContCoordInfo cci = regToSplit.contCoords.get(coordIdx);
-
- double left = cci.left;
- double right = cci.right;
-
- if (threshold < left || threshold > right)
- throw new MathIllegalArgumentException("Threshold is out of region bounds.");
-
- regToSplit.incTwoPow();
-
- Region newReg = Utils.copy(regToSplit);
- newReg.contCoords.get(coordIdx).left = threshold;
-
- regs.add(regIdx + 1, newReg);
- cci.right = threshold;
-
- IgniteBiTuple<Double, Double> bounds = boundsData.get(coordIdx);
- double min = bounds.get1();
- double max = bounds.get2();
- boundsData.put(coordIdx, new IgniteBiTuple<>(Math.min(threshold, min), Math.max(max, threshold)));
-
- return this;
- }
-
- /**
- * Split region by categorical coordinate.
- *
- * @param regIdx Region index.
- * @param coordIdx Coordinate index.
- * @param cats Categories allowed for the left sub region.
- * @return {@code this}.
- */
- SplitDataGenerator<V> split(int regIdx, int coordIdx, int[] cats) {
- BitSet subset = new BitSet();
- Arrays.stream(cats).forEach(subset::set);
- Region regToSplit = regs.get(regIdx);
- CatCoordInfo cci = regToSplit.catCoords.get(coordIdx);
-
- BitSet ssc = (BitSet)subset.clone();
- BitSet set = cci.bs;
- ssc.and(set);
- if (ssc.length() != subset.length())
- throw new MathIllegalArgumentException("Splitter set is not a subset of a parent subset.");
-
- ssc.xor(set);
- set.and(subset);
-
- regToSplit.incTwoPow();
- Region newReg = Utils.copy(regToSplit);
- newReg.catCoords.put(coordIdx, new CatCoordInfo(ssc));
-
- regs.add(regIdx + 1, newReg);
-
- return this;
- }
-
- /**
- * Get stream of points generated by this generator.
- *
- * @param ptsCnt Points count.
- */
- private Stream<IgniteBiTuple<Integer, V>> points(int ptsCnt, BiFunction<Double, Random, Double> f) {
- return IntStream.range(0, regs.size()).
- boxed().
- map(i -> regs.get(i).generatePoints(ptsCnt, f.apply((double)i, rnd), boundsData, di, supplier, rnd)
- .map(v -> new IgniteBiTuple<>(i, v))).flatMap(Function.identity());
- }
-
- /**
- * Convert double array to {@link LabeledVectorDouble}
- *
- * @param arr Array for conversion.
- * @return LabeledVectorDouble.
- */
- private static LabeledVectorDouble<DenseLocalOnHeapVector> asLabeledVector(double arr[]) {
- return new LabeledVectorDouble<>(new DenseLocalOnHeapVector(
- Arrays.copyOf(arr, arr.length - 1)), arr[arr.length - 1]);
- }
-
- /**
- * Categorical coordinate info.
- */
- private static class CatCoordInfo implements Serializable {
- /**
- * Defines categories which are included in this region
- */
- private final BitSet bs;
-
- /**
- * Construct CatCoordInfo.
- *
- * @param bs Bitset.
- */
- CatCoordInfo(BitSet bs) {
- this.bs = bs;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "CatCoordInfo [" +
- "bs=" + bs +
- ']';
- }
- }
-
- /**
- * Continuous coordinate info.
- */
- private static class ContCoordInfo implements Serializable {
- /**
- * Left (min) bound of region.
- */
- private double left;
-
- /**
- * Right (max) bound of region.
- */
- private double right;
-
- /**
- * Construct ContCoordInfo.
- */
- ContCoordInfo() {
- left = Double.NEGATIVE_INFINITY;
- right = Double.POSITIVE_INFINITY;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "ContCoordInfo [" +
- "left=" + left +
- ", right=" + right +
- ']';
- }
- }
-
- /**
- * Class representing information about region.
- */
- private static class Region implements Serializable {
- /**
- * Information about categorical coordinates restrictions of this region in form of
- * (coordinate index -> restriction)
- */
- private final Map<Integer, CatCoordInfo> catCoords;
-
- /**
- * Information about continuous coordinates restrictions of this region in form of
- * (coordinate index -> restriction)
- */
- private final Map<Integer, ContCoordInfo> contCoords;
-
- /**
- * Region should contain {@code 1/2^twoPow * totalPoints} points.
- */
- private int twoPow;
-
- /**
- * Construct region by information about restrictions on coordinates (features) values.
- *
- * @param catCoords Restrictions on categorical coordinates.
- * @param contCoords Restrictions on continuous coordinates
- * @param twoPow Region should contain {@code 1/2^twoPow * totalPoints} points.
- */
- Region(Map<Integer, CatCoordInfo> catCoords, Map<Integer, ContCoordInfo> contCoords, int twoPow) {
- this.catCoords = catCoords;
- this.contCoords = contCoords;
- this.twoPow = twoPow;
- }
-
- /** */
- int divideBy() {
- return 1 << twoPow;
- }
-
- /** */
- void incTwoPow() {
- twoPow++;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "Region [" +
- "catCoords=" + catCoords +
- ", contCoords=" + contCoords +
- ", twoPow=" + twoPow +
- ']';
- }
-
- /**
- * Generate continuous coordinate for this region.
- *
- * @param coordIdx Coordinate index.
- * @param boundsData Data with bounds
- * @param rnd Random numbers generator.
- * @return Categorical coordinate value.
- */
- double generateContCoord(int coordIdx, Map<Integer, IgniteBiTuple<Double, Double>> boundsData,
- Random rnd) {
- ContCoordInfo cci = contCoords.get(coordIdx);
- double left = cci.left;
- double right = cci.right;
-
- if (left == Double.NEGATIVE_INFINITY)
- left = boundsData.get(coordIdx).get1() - DELTA;
-
- if (right == Double.POSITIVE_INFINITY)
- right = boundsData.get(coordIdx).get2() + DELTA;
-
- double size = right - left;
-
- return left + rnd.nextDouble() * size;
- }
-
- /**
- * Generate categorical coordinate value for this region.
- *
- * @param coordIdx Coordinate index.
- * @param rnd Random numbers generator.
- * @return Categorical coordinate value.
- */
- double generateCatCoord(int coordIdx, Random rnd) {
- // Pick random bit.
- BitSet bs = catCoords.get(coordIdx).bs;
- int j = rnd.nextInt(bs.length());
-
- int i = 0;
- int bn = 0;
- int bnp = 0;
-
- while ((bn = bs.nextSetBit(bn)) != -1 && i <= j) {
- i++;
- bnp = bn;
- bn++;
- }
-
- return bnp;
- }
-
- /**
- * Generate points for this region.
- *
- * @param ptsCnt Count of points to generate.
- * @param val Label for all points in this region.
- * @param boundsData Data about bounds of continuous coordinates.
- * @param catCont Data about which categories can be in this region in the form (coordinate index -> list of
- * categories indexes).
- * @param s Vectors supplier.
- * @param rnd Random numbers generator.
- * @param <V> Type of vectors.
- * @return Stream of generated points for this region.
- */
- <V extends Vector> Stream<V> generatePoints(int ptsCnt, double val,
- Map<Integer, IgniteBiTuple<Double, Double>> boundsData, Map<Boolean, List<Integer>> catCont,
- Supplier<V> s,
- Random rnd) {
- return IntStream.range(0, ptsCnt / divideBy()).mapToObj(i -> {
- V v = s.get();
- int coordsCnt = v.size();
- catCont.get(false).forEach(ci -> v.setX(ci, generateContCoord(ci, boundsData, rnd)));
- catCont.get(true).forEach(ci -> v.setX(ci, generateCatCoord(ci, rnd)));
-
- v.setX(coordsCnt - 1, val);
- return v;
- });
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/package-info.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/package-info.java
deleted file mode 100644
index fc379a6..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/trees/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. -->
- * ML Grid decision tree benchmarks.
- */
-package org.apache.ignite.yardstick.ml.trees;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yarn/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yarn/pom.xml b/modules/yarn/pom.xml
index 28771ab..8f64890 100644
--- a/modules/yarn/pom.xml
+++ b/modules/yarn/pom.xml
@@ -61,17 +61,6 @@
<build>
<plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
-
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index c42b6ef..c87b8bb 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -30,31 +30,27 @@
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
<version>16</version>
- <relativePath></relativePath>
</parent>
<properties>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+
<ignite.edition>fabric</ignite.edition>
- <hadoop.version>2.4.1</hadoop.version>
- <spark.hadoop.version>2.6.5</spark.hadoop.version>
- <spark.version>2.2.0</spark.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>
<docfx.exec>docfx</docfx.exec>
<git.exec>git</git.exec>
- <maven.bundle.plugin.version>2.5.4</maven.bundle.plugin.version>
- <javadoc.opts>-XDenableSunApiLintControl</javadoc.opts>
+ <javadoc.opts>-Xdoclint:none</javadoc.opts>
<update.notifier.enabled.by.default>true</update.notifier.enabled.by.default>
- <!-- Dependency versions. -->
+ <!-- Dependency versions -->
<activemq.version>5.12.0</activemq.version>
<aopalliance.bundle.version>1.0_6</aopalliance.bundle.version>
<asm.version>4.2</asm.version>
- <aspectj.bundle.version>1.7.2_1</aspectj.bundle.version>
- <aspectj.version>1.7.2</aspectj.version>
+ <aspectj.bundle.version>1.8.13_1</aspectj.bundle.version>
+ <aspectj.version>1.8.13</aspectj.version>
<aws.sdk.bundle.version>1.10.12_1</aws.sdk.bundle.version>
<aws.sdk.version>1.11.75</aws.sdk.version>
<camel.version>2.16.0</camel.version>
@@ -74,14 +70,19 @@
<guava14.version>14.0.1</guava14.version>
<guava16.version>16.0.1</guava16.version>
<h2.version>1.4.195</h2.version>
+ <hadoop.version>2.4.1</hadoop.version>
+ <hamcrest.version>1.2</hamcrest.version>
<httpclient.version>4.5.1</httpclient.version>
<httpcore.version>4.4.3</httpcore.version>
<jackson.version>1.9.13</jackson.version>
<jackson2.version>2.6.5</jackson2.version>
+ <javassist.version>3.20.0-GA</javassist.version>
<javax.cache.bundle.version>1.0.0_1</javax.cache.bundle.version>
+ <javax.cache.tck.version>1.0.1</javax.cache.tck.version>
<javax.cache.version>1.0.0</javax.cache.version>
<jetbrains.annotations.version>13.0</jetbrains.annotations.version>
<jetty.version>9.2.11.v20150529</jetty.version>
+ <jmh.version>1.13</jmh.version>
<jms.spec.version>1.1.1</jms.spec.version>
<jsch.bundle.version>0.1.53_1</jsch.bundle.version>
<jsch.version>0.1.53</jsch.version>
@@ -92,30 +93,36 @@
<karaf.version>4.0.2</karaf.version>
<lucene.bundle.version>5.5.2_1</lucene.bundle.version>
<lucene.version>5.5.2</lucene.version>
+ <maven.bundle.plugin.version>2.5.4</maven.bundle.plugin.version>
+ <mysql.connector.version>5.1.39</mysql.connector.version>
+ <netlibjava.version>1.1.2</netlibjava.version>
<oro.bundle.version>2.0.8_6</oro.bundle.version>
<osgi.core.version>5.0.0</osgi.core.version>
<osgi.enterprise.version>5.0.0</osgi.enterprise.version>
<paho.version>1.0.2</paho.version>
+ <postgres.connector.version>9.4.1208.jre7</postgres.connector.version>
<rocketmq.version>4.2.0</rocketmq.version>
<scala210.jline.version>2.10.4</scala210.jline.version>
<scala210.library.version>2.10.6</scala210.library.version>
<scala211.library.version>2.11.8</scala211.library.version>
<slf4j.version>1.7.7</slf4j.version>
<slf4j16.version>1.6.4</slf4j16.version>
+ <spark.hadoop.version>2.6.5</spark.hadoop.version>
+ <spark.version>2.2.0</spark.version>
+ <spring.data.version>1.13.1.RELEASE</spring.data.version> <!-- don't forget to update spring version -->
+ <spring.version>4.3.7.RELEASE</spring.version> <!-- don't forget to update spring-data version -->
<spring41.osgi.feature.version>4.1.7.RELEASE_1</spring41.osgi.feature.version>
<tomcat.version>8.0.23</tomcat.version>
<twitter.hbc.version>2.2.0</twitter.hbc.version>
<yammer.metrics.annotation.version>2.2.0</yammer.metrics.annotation.version>
<yammer.metrics.core.version>2.2.0</yammer.metrics.core.version>
+ <yardstick.version>0.8.3</yardstick.version>
<zkclient.version>0.5</zkclient.version>
<zookeeper.version>3.4.6</zookeeper.version>
- <javassist.version>3.20.0-GA</javassist.version>
<!-- OSGI Manifest generation default property values -->
<osgi.import.package>*</osgi.import.package>
<osgi.export.package>{local-packages}</osgi.export.package>
- <osgi.private.package></osgi.private.package>
- <osgi.embed.dependency></osgi.embed.dependency>
<osgi.embed.transitive>false</osgi.embed.transitive>
<osgi.fail.ok>false</osgi.fail.ok>
@@ -570,15 +577,6 @@
<plugins>
<plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
-
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
@@ -962,27 +960,6 @@
</profile>
<profile>
- <id>java8</id>
- <activation>
- <jdk>[1.8,)</jdk>
- </activation>
- <properties>
- <javadoc.opts>-Xdoclint:none</javadoc.opts>
- </properties>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
<id>tools.jar-default</id>
<activation>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2c7379e..1d8637c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -96,6 +96,7 @@
<module>modules/zeromq</module>
<module>modules/rocketmq</module>
<module>modules/sqlline</module>
+ <module>modules/ml</module>
</modules>
<profiles>
@@ -130,7 +131,6 @@
<profile>
<id>all-other</id> <!-- used to update project versions and check all modules compilation -->
<modules> <!-- sorted alphabetically -->
- <module>modules/ml</module> <!-- it uses Java8 and can't be compiled by Java7 used to compile Ignite -->
<module>modules/web-console</module>
</modules>
</profile>
@@ -752,13 +752,6 @@
</plugins>
</build>
</profile>
-
- <profile>
- <id>ml</id>
- <modules>
- <module>modules/ml</module>
- </modules>
- </profile>
</profiles>
<build>
[09/11] ignite git commit: IGNITE-7203 Java 8 by default
Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/MatrixCustomStorageExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/MatrixCustomStorageExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/MatrixCustomStorageExample.java
new file mode 100644
index 0000000..3b4f27d
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/MatrixCustomStorageExample.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.examples.ml.math.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.impls.matrix.AbstractMatrix;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+
+/**
+ * This example shows how to create custom {@link Matrix} based on custom {@link MatrixStorage}.
+ */
+public final class MatrixCustomStorageExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println();
+ System.out.println(">>> Matrix API usage example started.");
+
+ System.out.println("\n>>> Creating a matrix to be transposed.");
+ double[][] data = new double[][] {{1, 2, 3}, {4, 5, 6}};
+ Matrix m = new MatrixCustomStorage(data);
+ Matrix transposed = m.transpose();
+
+ System.out.println(">>> Matrix: ");
+ MatrixExampleUtil.print(m);
+ System.out.println(">>> Transposed matrix: ");
+ MatrixExampleUtil.print(transposed);
+
+ MatrixExampleUtil.verifyTransposition(m, transposed);
+
+ System.out.println("\n>>> Creating matrices to be multiplied.");
+ double[][] data1 = new double[][] {{1, 2}, {3, 4}};
+ double[][] data2 = new double[][] {{5, 6}, {7, 8}};
+
+ Matrix m1 = new MatrixCustomStorage(data1);
+ Matrix m2 = new MatrixCustomStorage(data2);
+ Matrix mult = m1.times(m2);
+
+ System.out.println(">>> First matrix: ");
+ MatrixExampleUtil.print(m1);
+ System.out.println(">>> Second matrix: ");
+ MatrixExampleUtil.print(m2);
+ System.out.println(">>> Matrix product: ");
+ MatrixExampleUtil.print(mult);
+
+ System.out.println("\n>>> Calculating matrices determinants.");
+ double det1 = m1.determinant();
+ double det2 = m2.determinant();
+ double detMult = mult.determinant();
+ boolean detMultIsAsExp = Math.abs(detMult - det1 * det2) < 0.0001d;
+
+ System.out.println(">>> First matrix determinant: [" + det1 + "].");
+ System.out.println(">>> Second matrix determinant: [" + det2 + "].");
+ System.out.println(">>> Matrix product determinant: [" + detMult
+ + "], equals product of two other matrices determinants: [" + detMultIsAsExp + "].");
+
+ System.out.println("Determinant of product matrix [" + detMult
+ + "] should be equal to product of determinants [" + (det1 * det2) + "].");
+
+ System.out.println("\n>>> Matrix API usage example completed.");
+ }
+
+ /**
+ * Example of vector with custom storage, modeled after
+ * {@link org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix}.
+ */
+ static class MatrixCustomStorage extends AbstractMatrix {
+ /**
+ *
+ */
+ public MatrixCustomStorage() {
+ // No-op.
+ }
+
+ /**
+ * @param rows Amount of rows in a matrix.
+ * @param cols Amount of columns in a matrix.
+ */
+ MatrixCustomStorage(int rows, int cols) {
+ assert rows > 0;
+ assert cols > 0;
+
+ setStorage(new ExampleMatrixStorage(rows, cols));
+ }
+
+ /**
+ * @param mtx Source matrix.
+ */
+ MatrixCustomStorage(double[][] mtx) {
+ assert mtx != null;
+
+ setStorage(new ExampleMatrixStorage(mtx));
+ }
+
+ /**
+ * @param orig original matrix to be copied.
+ */
+ private MatrixCustomStorage(MatrixCustomStorage orig) {
+ assert orig != null;
+
+ setStorage(new ExampleMatrixStorage(orig.rowSize(), orig.columnSize()));
+
+ assign(orig);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Matrix copy() {
+ return new MatrixCustomStorage(this);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Matrix like(int rows, int cols) {
+ return new MatrixCustomStorage(rows, cols);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Vector likeVector(int crd) {
+ return new DenseLocalOnHeapVector(crd);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/MatrixExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/MatrixExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/MatrixExample.java
new file mode 100644
index 0000000..755f36c
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/MatrixExample.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+
+/**
+ * This example shows how to use {@link Matrix} API.
+ */
+public final class MatrixExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println();
+ System.out.println(">>> Basic Matrix API usage example started.");
+
+ System.out.println("\n>>> Creating a matrix to be transposed.");
+ double[][] data = new double[][] {{1, 2, 3}, {4, 5, 6}};
+ Matrix m = new DenseLocalOnHeapMatrix(data);
+ Matrix transposed = m.transpose();
+
+ System.out.println(">>> Matrix: ");
+ MatrixExampleUtil.print(m);
+ System.out.println(">>> Transposed matrix: ");
+ MatrixExampleUtil.print(transposed);
+
+ MatrixExampleUtil.verifyTransposition(m, transposed);
+
+ System.out.println("\n>>> Creating matrices to be multiplied.");
+ double[][] data1 = new double[][] {{1, 2}, {3, 4}};
+ double[][] data2 = new double[][] {{5, 6}, {7, 8}};
+
+ Matrix m1 = new DenseLocalOnHeapMatrix(data1);
+ Matrix m2 = new DenseLocalOnHeapMatrix(data2);
+ Matrix mult = m1.times(m2);
+
+ System.out.println(">>> First matrix: ");
+ MatrixExampleUtil.print(m1);
+ System.out.println(">>> Second matrix: ");
+ MatrixExampleUtil.print(m2);
+ System.out.println(">>> Matrix product: ");
+ MatrixExampleUtil.print(mult);
+
+ System.out.println("\n>>> Calculating matrices determinants.");
+ double det1 = m1.determinant();
+ double det2 = m2.determinant();
+ double detMult = mult.determinant();
+ boolean detMultIsAsExp = Math.abs(detMult - det1 * det2) < 0.0001d;
+
+ System.out.println(">>> First matrix determinant: [" + det1 + "].");
+ System.out.println(">>> Second matrix determinant: [" + det2 + "].");
+ System.out.println(">>> Matrix product determinant: [" + detMult
+ + "], equals product of two other matrices determinants: [" + detMultIsAsExp + "].");
+
+ System.out.println("Determinant of product matrix [" + detMult
+ + "] should be equal to product of determinants [" + (det1 * det2) + "].");
+
+ System.out.println("\n>>> Basic Matrix API usage example completed.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/MatrixExampleUtil.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/MatrixExampleUtil.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/MatrixExampleUtil.java
new file mode 100644
index 0000000..af12e15
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/MatrixExampleUtil.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.examples.ml.math.matrix;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Tracer;
+
+/**
+ * Utility functions for {@link Matrix} API examples.
+ */
+class MatrixExampleUtil {
+ /**
+ * Verifies matrix transposition.
+ *
+ * @param m Original matrix.
+ * @param transposed Transposed matrix.
+ */
+ static void verifyTransposition(Matrix m, Matrix transposed) {
+ for (int row = 0; row < m.rowSize(); row++)
+ for (int col = 0; col < m.columnSize(); col++) {
+ double val = m.get(row, col);
+ double valTransposed = transposed.get(col, row);
+
+ assert val == valTransposed : "Values not equal at (" + row + "," + col
+ + "), original: " + val + " transposed: " + valTransposed;
+ }
+ }
+
+ /**
+ * Prints matrix values to console.
+ *
+ * @param m Matrix to print.
+ */
+ static void print(Matrix m) {
+ Tracer.showAscii(m);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/OffHeapMatrixExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/OffHeapMatrixExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/OffHeapMatrixExample.java
new file mode 100644
index 0000000..db01794
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/OffHeapMatrixExample.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.examples.ml.math.matrix;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOffHeapMatrix;
+
+/**
+ * This example shows how to create and use off-heap versions of {@link Matrix}.
+ */
+public final class OffHeapMatrixExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println();
+ System.out.println(">>> Off-heap matrix API usage example started.");
+
+ System.out.println("\n>>> Creating a matrix to be transposed.");
+ double[][] data = new double[][] {{1, 2, 3}, {4, 5, 6}};
+ Matrix m = new DenseLocalOffHeapMatrix(data.length, data[0].length);
+ m.assign(data);
+ Matrix transposed = m.transpose();
+
+ System.out.println(">>> Matrix: ");
+ MatrixExampleUtil.print(m);
+ System.out.println(">>> Transposed matrix: ");
+ MatrixExampleUtil.print(transposed);
+
+ MatrixExampleUtil.verifyTransposition(m, transposed);
+
+ System.out.println("\n>>> Creating matrices to be multiplied.");
+ double[][] data1 = new double[][] {{1, 2}, {3, 4}};
+ double[][] data2 = new double[][] {{5, 6}, {7, 8}};
+
+ Matrix m1 = new DenseLocalOffHeapMatrix(data1.length, data1[0].length);
+ Matrix m2 = new DenseLocalOffHeapMatrix(data2.length, data2[0].length);
+
+ m1.assign(data1);
+ m2.assign(data2);
+
+ Matrix mult = m1.times(m2);
+
+ System.out.println(">>> First matrix: ");
+ MatrixExampleUtil.print(m1);
+ System.out.println(">>> Second matrix: ");
+ MatrixExampleUtil.print(m2);
+ System.out.println(">>> Matrix product: ");
+ MatrixExampleUtil.print(mult);
+
+ System.out.println("\n>>> Calculating matrices determinants.");
+ double det1 = m1.determinant();
+ double det2 = m2.determinant();
+ double detMult = mult.determinant();
+ boolean detMultIsAsExp = Math.abs(detMult - det1 * det2) < 0.0001d;
+
+ System.out.println(">>> First matrix determinant: [" + det1 + "].");
+ System.out.println(">>> Second matrix determinant: [" + det2 + "].");
+ System.out.println(">>> Matrix product determinant: [" + detMult
+ + "], equals product of two other matrices determinants: [" + detMultIsAsExp + "].");
+
+ System.out.println("Determinant of product matrix [" + detMult
+ + "] should be equal to product of determinants [" + (det1 * det2) + "].");
+
+ System.out.println("\n>>> Off-heap matrix API usage example completed.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/SparseDistributedMatrixExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/SparseDistributedMatrixExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/SparseDistributedMatrixExample.java
new file mode 100644
index 0000000..c73a8a0
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/SparseDistributedMatrixExample.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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.ml.math.Matrix;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.impls.matrix.CacheMatrix;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
+import org.apache.ignite.thread.IgniteThread;
+
+/**
+ * This example shows how to create and use {@link SparseDistributedMatrix} API.
+ *
+ * Unlike the {@link CacheMatrix} the {@link SparseDistributedMatrix} creates it's own cache.
+ */
+public class SparseDistributedMatrixExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) throws InterruptedException {
+ System.out.println();
+ System.out.println(">>> Sparse distributed matrix API usage example started.");
+ // Start ignite grid.
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println(">>> Ignite grid started.");
+ // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
+ // because we create ignite cache internally.
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(), SparseDistributedMatrixExample.class.getSimpleName(), () -> {
+
+ double[][] testValues = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
+
+ System.out.println(">>> Create new SparseDistributedMatrix inside IgniteThread.");
+ // Create SparseDistributedMatrix, new cache will be created automagically.
+ SparseDistributedMatrix distributedMatrix = new SparseDistributedMatrix(testValues.length, testValues[0].length,
+ StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+ distributedMatrix.assign(testValues);
+
+ System.out.println("Sum of all matrix elements is " + distributedMatrix.sum());
+
+ System.out.println(">>> Destroy SparseDistributedMatrix after using.");
+ // Destroy internal cache.
+ distributedMatrix.destroy();
+ });
+
+ igniteThread.start();
+
+ igniteThread.join();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/SparseMatrixExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/SparseMatrixExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/SparseMatrixExample.java
new file mode 100644
index 0000000..a03688d
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/SparseMatrixExample.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.examples.ml.math.matrix;
+
+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.
+ */
+public final class SparseMatrixExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println();
+ System.out.println(">>> Sparse matrix API usage example started.");
+
+ System.out.println("\n>>> Creating a matrix to be transposed.");
+ double[][] data = new double[][] {{1, 2, 3}, {4, 5, 6}};
+ Matrix m = new SparseLocalOnHeapMatrix(data.length, data[0].length);
+ m.assign(data);
+ Matrix transposed = m.transpose();
+
+ System.out.println(">>> Matrix: ");
+ MatrixExampleUtil.print(m);
+ System.out.println(">>> Transposed matrix: ");
+ MatrixExampleUtil.print(transposed);
+
+ MatrixExampleUtil.verifyTransposition(m, transposed);
+
+ System.out.println("\n>>> Creating matrices to be multiplied.");
+ double[][] data1 = new double[][] {{1, 2}, {3, 4}};
+ double[][] data2 = new double[][] {{5, 6}, {7, 8}};
+
+ Matrix m1 = new SparseLocalOnHeapMatrix(data1.length, data1[0].length);
+ Matrix m2 = new SparseLocalOnHeapMatrix(data2.length, data2[0].length);
+
+ m1.assign(data1);
+ m2.assign(data2);
+
+ Matrix mult = m1.times(m2);
+
+ System.out.println(">>> First matrix: ");
+ MatrixExampleUtil.print(m1);
+ System.out.println(">>> Second matrix: ");
+ MatrixExampleUtil.print(m2);
+ System.out.println(">>> Matrix product: ");
+ MatrixExampleUtil.print(mult);
+
+ System.out.println("\n>>> Calculating matrices determinants.");
+ double det1 = m1.determinant();
+ double det2 = m2.determinant();
+ double detMult = mult.determinant();
+ boolean detMultIsAsExp = Math.abs(detMult - det1 * det2) < 0.0001d;
+
+ System.out.println(">>> First matrix determinant: [" + det1 + "].");
+ System.out.println(">>> Second matrix determinant: [" + det2 + "].");
+ System.out.println(">>> Matrix product determinant: [" + detMult
+ + "], equals product of two other matrices determinants: [" + detMultIsAsExp + "].");
+
+ System.out.println("Determinant of product matrix [" + detMult
+ + "] should be equal to product of determinants [" + (det1 * det2) + "].");
+
+ System.out.println("\n>>> Sparse matrix API usage example completed.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/package-info.java
new file mode 100644
index 0000000..354119a
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/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. -->
+ * Core algebra matrix examples.
+ */
+package org.apache.ignite.examples.ml.math.matrix;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/package-info.java
new file mode 100644
index 0000000..52344bf
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/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. -->
+ * Core algebra examples.
+ */
+package org.apache.ignite.examples.ml.math;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/tracer/TracerExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/tracer/TracerExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/tracer/TracerExample.java
new file mode 100644
index 0000000..c14335a
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/tracer/TracerExample.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.examples.ml.math.tracer;
+
+import java.awt.Color;
+import java.io.IOException;
+import org.apache.ignite.ml.math.Tracer;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+
+/**
+ * Example of using {@link Tracer} utility API.
+ */
+public class TracerExample {
+ /**
+ * Double to color mapper example.
+ */
+ private static final Tracer.ColorMapper COLOR_MAPPER = d -> {
+ if (d <= 1.5)
+ return Color.RED;
+ else if (d <= 2.5)
+ return Color.GREEN;
+ else
+ return Color.BLUE;
+ };
+
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) throws IOException {
+ System.out.println(">>> Tracer utility example started.");
+
+ // Tracer is a simple utility class that allows pretty-printing of matrices/vectors.
+ DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(new double[][] {
+ {1.12345, 2.12345},
+ {3.12345, 4.12345}
+ });
+
+ System.out.println("\n>>> Tracer output to console in ASCII.");
+ Tracer.showAscii(m, "%.3g");
+
+ System.out.println("\n>>> Tracer output to browser in HTML.");
+ Tracer.showHtml(m, COLOR_MAPPER, true);
+
+ System.out.println("\n>>> Tracer utility example completed.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/tracer/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/tracer/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/tracer/package-info.java
new file mode 100644
index 0000000..574e598
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/tracer/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. -->
+ * Core algebra tracer example.
+ */
+package org.apache.ignite.examples.ml.math.tracer;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/CacheVectorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/CacheVectorExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/CacheVectorExample.java
new file mode 100644
index 0000000..4253ac1
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/CacheVectorExample.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.ml.math.vector;
+
+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.ml.math.IdentityValueMapper;
+import org.apache.ignite.ml.math.distributed.ValueMapper;
+import org.apache.ignite.ml.math.distributed.VectorKeyMapper;
+import org.apache.ignite.ml.math.impls.vector.CacheVector;
+
+/**
+ * This example shows how to use {@link CacheVector} API.
+ * <p>
+ * Basically CacheVector is a view over existing data in cache. So we have {@link VectorKeyMapper} and
+ * {@link ValueMapper} for this purpose. A {@link VectorKeyMapper} allows us to map vector indices to cache keys.
+ * And a {@link ValueMapper} allows us map cache object to vector elements - doubles.</p>
+ * <p>
+ * In this example we use simple flat mapping for keys and {@link IdentityValueMapper} for cache
+ * objects because they are Doubles.</p>
+ */
+public class CacheVectorExample {
+ /** */
+ private static final String CACHE_NAME = CacheVectorExample.class.getSimpleName();
+
+ /** */
+ private static final int CARDINALITY = 10;
+
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ @SuppressWarnings("unchecked")
+ public static void main(String[] args) {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println(">>> CacheVector example started.");
+
+ CacheConfiguration<Integer, Double> cfg = new CacheConfiguration<>();
+
+ cfg.setName(CACHE_NAME);
+
+ try (IgniteCache<Integer, Double> cache = ignite.getOrCreateCache(cfg)) {
+ double[] testValues1 = {1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
+ double[] testValues2 = {0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
+
+ ValueMapper valMapper = new IdentityValueMapper();
+
+ // Map vector element index to cache keys.
+ VectorKeyMapper<Integer> keyMapper1 = new VectorKeyMapper<Integer>() {
+ @Override public Integer apply(int i) {
+ return i;
+ }
+
+ @Override public boolean isValid(Integer integer) {
+ return integer >= 0 && CARDINALITY > integer;
+ }
+ };
+
+ // Map vector element index to cache keys with shift.
+ VectorKeyMapper<Integer> keyMapper2 = new VectorKeyMapper<Integer>() {
+ @Override public Integer apply(int i) {
+ return i + CARDINALITY;
+ }
+
+ @Override public boolean isValid(Integer integer) {
+ return integer >= 0 && CARDINALITY > integer;
+ }
+ };
+
+ // Create two cache vectors over one cache.
+ CacheVector cacheVector1 = new CacheVector(CARDINALITY, cache, keyMapper1, valMapper);
+ System.out.println(">>> First cache vector created.");
+
+ CacheVector cacheVector2 = new CacheVector(CARDINALITY, cache, keyMapper2, valMapper);
+ System.out.println(">>> Second cache vector created.");
+
+ cacheVector1.assign(testValues1);
+ cacheVector2.assign(testValues2);
+
+ // Dot product for orthogonal vectors is 0.0.
+ assert cacheVector1.dot(cacheVector2) == 0.0;
+
+ System.out.println(">>>");
+ System.out.println(">>> Finished executing Ignite \"CacheVector\" example.");
+ System.out.println(">>> Dot product is 0.0 for orthogonal vectors.");
+ System.out.println(">>>");
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/ExampleVectorStorage.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/ExampleVectorStorage.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/ExampleVectorStorage.java
new file mode 100644
index 0000000..0289a8c
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/ExampleVectorStorage.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.examples.ml.math.vector;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Arrays;
+
+import org.apache.ignite.ml.math.VectorStorage;
+import org.apache.ignite.ml.math.impls.storage.vector.ArrayVectorStorage;
+
+/**
+ * Example vector storage, modeled after {@link ArrayVectorStorage}.
+ */
+class ExampleVectorStorage implements VectorStorage {
+ /** */
+ private double[] data;
+
+ /**
+ * IMPL NOTE required by Externalizable.
+ */
+ public ExampleVectorStorage() {
+ // No-op.
+ }
+
+ /**
+ * @param data Backing data array.
+ */
+ ExampleVectorStorage(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;
+
+ ExampleVectorStorage that = (ExampleVectorStorage)obj;
+
+ return Arrays.equals(data, (that.data));
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/OffHeapVectorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/OffHeapVectorExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/OffHeapVectorExample.java
new file mode 100644
index 0000000..e38f62c
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/OffHeapVectorExample.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.examples.ml.math.vector;
+
+import java.util.Arrays;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOffHeapVector;
+
+/**
+ * This example shows how to create and use off-heap versions of {@link Vector}.
+ */
+public final class OffHeapVectorExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println();
+ System.out.println(">>> Off-heap vector API usage example started.");
+
+ System.out.println("\n>>> Creating perpendicular off-heap vectors.");
+ double[] data1 = new double[] {1, 0, 3, 0, 5, 0};
+ double[] data2 = new double[] {0, 2, 0, 4, 0, 6};
+
+ Vector v1 = new DenseLocalOffHeapVector(data1.length);
+ Vector v2 = new DenseLocalOffHeapVector(data2.length);
+
+ v1.assign(data1);
+ v2.assign(data2);
+
+ System.out.println(">>> First vector: " + Arrays.toString(data1));
+ System.out.println(">>> Second vector: " + Arrays.toString(data2));
+
+ double dotProduct = v1.dot(v2);
+ boolean dotProductIsAsExp = dotProduct == 0;
+
+ System.out.println("\n>>> Dot product of vectors: [" + dotProduct
+ + "], it is 0 as expected: [" + dotProductIsAsExp + "].");
+
+ assert dotProductIsAsExp : "Expect dot product of perpendicular vectors to be 0.";
+
+ Vector hypotenuse = v1.plus(v2);
+
+ System.out.println("\n>>> Hypotenuse (sum of vectors): " + Arrays.toString(hypotenuse.getStorage().data()));
+
+ double lenSquared1 = v1.getLengthSquared();
+ double lenSquared2 = v2.getLengthSquared();
+ double lenSquaredHypotenuse = hypotenuse.getLengthSquared();
+
+ boolean lenSquaredHypotenuseIsAsExp = lenSquaredHypotenuse == lenSquared1 + lenSquared2;
+
+ System.out.println(">>> Squared length of first vector: [" + lenSquared1 + "].");
+ System.out.println(">>> Squared length of second vector: [" + lenSquared2 + "].");
+ System.out.println(">>> Squared length of hypotenuse: [" + lenSquaredHypotenuse
+ + "], equals sum of squared lengths of two original vectors as expected: ["
+ + lenSquaredHypotenuseIsAsExp + "].");
+
+ assert lenSquaredHypotenuseIsAsExp : "Expect squared length of hypotenuse to be as per Pythagorean theorem.";
+
+ System.out.println("\n>>> Off-heap vector API usage example completed.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/SparseVectorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/SparseVectorExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/SparseVectorExample.java
new file mode 100644
index 0000000..be3ade1
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/SparseVectorExample.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.examples.ml.math.vector;
+
+import java.util.Arrays;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.vector.SparseLocalVector;
+
+import static org.apache.ignite.ml.math.StorageConstants.RANDOM_ACCESS_MODE;
+
+/**
+ * This example shows how to use sparse {@link Vector} API.
+ */
+public final class SparseVectorExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println();
+ System.out.println(">>> Sparse vector API usage example started.");
+
+ System.out.println("\n>>> Creating perpendicular sparse vectors.");
+ double[] data1 = new double[] {1, 0, 3, 0, 5, 0};
+ double[] data2 = new double[] {0, 2, 0, 4, 0, 6};
+
+ Vector v1 = new SparseLocalVector(data1.length, RANDOM_ACCESS_MODE);
+ Vector v2 = new SparseLocalVector(data2.length, RANDOM_ACCESS_MODE);
+
+ v1.assign(data1);
+ v2.assign(data2);
+
+ System.out.println(">>> First vector: " + Arrays.toString(data1));
+ System.out.println(">>> Second vector: " + Arrays.toString(data2));
+
+ double dotProduct = v1.dot(v2);
+ boolean dotProductIsAsExp = dotProduct == 0;
+
+ System.out.println("\n>>> Dot product of vectors: [" + dotProduct
+ + "], it is 0 as expected: [" + dotProductIsAsExp + "].");
+
+ Vector hypotenuse = v1.plus(v2);
+
+ System.out.println("\n>>> Hypotenuse (sum of vectors): " + Arrays.toString(hypotenuse.getStorage().data()));
+
+ double lenSquared1 = v1.getLengthSquared();
+ double lenSquared2 = v2.getLengthSquared();
+ double lenSquaredHypotenuse = hypotenuse.getLengthSquared();
+
+ boolean lenSquaredHypotenuseIsAsExp = lenSquaredHypotenuse == lenSquared1 + lenSquared2;
+
+ System.out.println(">>> Squared length of first vector: [" + lenSquared1 + "].");
+ System.out.println(">>> Squared length of second vector: [" + lenSquared2 + "].");
+ System.out.println(">>> Squared length of hypotenuse: [" + lenSquaredHypotenuse
+ + "], equals sum of squared lengths of two original vectors as expected: ["
+ + lenSquaredHypotenuseIsAsExp + "].");
+
+ System.out.println("\n>>> Sparse vector API usage example completed.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/VectorCustomStorageExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/VectorCustomStorageExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/VectorCustomStorageExample.java
new file mode 100644
index 0000000..cbb69d0
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/VectorCustomStorageExample.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.examples.ml.math.vector;
+
+import java.util.Arrays;
+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}.
+ */
+public final class VectorCustomStorageExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println();
+ System.out.println(">>> Vector custom storage API usage example started.");
+
+ System.out.println("\n>>> Creating perpendicular vectors.");
+ double[] data1 = new double[] {1, 0, 3, 0, 5, 0};
+ double[] data2 = new double[] {0, 2, 0, 4, 0, 6};
+
+ Vector v1 = new VectorCustomStorage(data1);
+ Vector v2 = new VectorCustomStorage(data2);
+
+ System.out.println(">>> First vector: " + Arrays.toString(data1));
+ System.out.println(">>> Second vector: " + Arrays.toString(data2));
+
+ double dotProduct = v1.dot(v2);
+ boolean dotProductIsAsExp = dotProduct == 0;
+
+ System.out.println("\n>>> Dot product of vectors: [" + dotProduct
+ + "], it is 0 as expected: [" + dotProductIsAsExp + "].");
+
+ Vector hypotenuse = v1.plus(v2);
+
+ System.out.println("\n>>> Hypotenuse (sum of vectors): " + Arrays.toString(hypotenuse.getStorage().data()));
+
+ double lenSquared1 = v1.getLengthSquared();
+ double lenSquared2 = v2.getLengthSquared();
+ double lenSquaredHypotenuse = hypotenuse.getLengthSquared();
+
+ boolean lenSquaredHypotenuseIsAsExp = lenSquaredHypotenuse == lenSquared1 + lenSquared2;
+
+ System.out.println(">>> Squared length of first vector: [" + lenSquared1 + "].");
+ System.out.println(">>> Squared length of second vector: [" + lenSquared2 + "].");
+ System.out.println(">>> Squared length of hypotenuse: [" + lenSquaredHypotenuse
+ + "], equals sum of squared lengths of two original vectors as expected: ["
+ + lenSquaredHypotenuseIsAsExp + "].");
+
+ System.out.println("\n>>> Vector custom storage API usage example completed.");
+ }
+
+ /**
+ * Example of vector with custom storage, modeled after
+ * {@link org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector}.
+ */
+ static class VectorCustomStorage extends AbstractVector {
+ /**
+ * @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 ExampleVectorStorage(cp ? arr.clone() : arr);
+ }
+
+ /** */
+ public VectorCustomStorage() {
+ // No-op.
+ }
+
+ /**
+ * @param arr Source array.
+ * @param shallowCp {@code true} to use shallow copy.
+ */
+ VectorCustomStorage(double[] arr, boolean shallowCp) {
+ setStorage(mkStorage(arr, shallowCp));
+ }
+
+ /**
+ * @param arr Source array.
+ */
+ VectorCustomStorage(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 org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector(crd);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/VectorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/VectorExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/VectorExample.java
new file mode 100644
index 0000000..9970531
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/VectorExample.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.examples.ml.math.vector;
+
+import java.util.Arrays;
+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.
+ *
+ * Just simple local onheap version.
+ */
+public final class VectorExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println();
+ System.out.println(">>> Basic Vector API usage example started.");
+
+ System.out.println("\n>>> Creating perpendicular vectors.");
+ double[] data1 = new double[] {1, 0, 3, 0, 5, 0};
+ double[] data2 = new double[] {0, 2, 0, 4, 0, 6};
+
+ Vector v1 = new DenseLocalOnHeapVector(data1);
+ Vector v2 = new DenseLocalOnHeapVector(data2);
+
+ System.out.println(">>> First vector: " + Arrays.toString(data1));
+ System.out.println(">>> Second vector: " + Arrays.toString(data2));
+
+ double dotProduct = v1.dot(v2);
+ boolean dotProductIsAsExp = dotProduct == 0;
+
+ System.out.println("\n>>> Dot product of vectors: [" + dotProduct
+ + "], it is 0 as expected: [" + dotProductIsAsExp + "].");
+
+ Vector hypotenuse = v1.plus(v2);
+
+ System.out.println("\n>>> Hypotenuse (sum of vectors): " + Arrays.toString(hypotenuse.getStorage().data()));
+
+ double lenSquared1 = v1.getLengthSquared();
+ double lenSquared2 = v2.getLengthSquared();
+ double lenSquaredHypotenuse = hypotenuse.getLengthSquared();
+
+ boolean lenSquaredHypotenuseIsAsExp = lenSquaredHypotenuse == lenSquared1 + lenSquared2;
+
+ System.out.println(">>> Squared length of first vector: [" + lenSquared1 + "].");
+ System.out.println(">>> Squared length of second vector: [" + lenSquared2 + "].");
+ System.out.println(">>> Squared length of hypotenuse: [" + lenSquaredHypotenuse
+ + "], equals sum of squared lengths of two original vectors as expected: ["
+ + lenSquaredHypotenuseIsAsExp + "].");
+
+ System.out.println("\n>>> Basic Vector API usage example completed.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/vector/package-info.java
new file mode 100644
index 0000000..2cc74ac
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/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. -->
+ * Core algebra vector examples.
+ */
+package org.apache.ignite.examples.ml.math.vector;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/nn/MLPGroupTrainerExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/nn/MLPGroupTrainerExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/nn/MLPGroupTrainerExample.java
new file mode 100644
index 0000000..d106fad
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/nn/MLPGroupTrainerExample.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.examples.ml.nn;
+
+import java.util.Random;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.Tracer;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.nn.Activators;
+import org.apache.ignite.ml.nn.LabeledVectorsCache;
+import org.apache.ignite.ml.nn.MLPGroupUpdateTrainerCacheInput;
+import org.apache.ignite.ml.nn.MultilayerPerceptron;
+import org.apache.ignite.ml.nn.architecture.MLPArchitecture;
+import org.apache.ignite.ml.nn.initializers.RandomInitializer;
+import org.apache.ignite.ml.nn.trainers.distributed.MLPGroupUpdateTrainer;
+import org.apache.ignite.ml.optimization.updatecalculators.RPropParameterUpdate;
+import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.thread.IgniteThread;
+
+/**
+ * <p>
+ * Example of using distributed {@link MultilayerPerceptron}.</p>
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.</p>
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.</p>
+ */
+public class MLPGroupTrainerExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) throws InterruptedException {
+ // IMPL NOTE based on MLPGroupTrainerTest#testXOR
+ System.out.println(">>> Distributed multilayer perceptron example started.");
+
+ // Start ignite grid.
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println(">>> Ignite grid started.");
+
+ // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
+ // because we create ignite cache internally.
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ MLPGroupTrainerExample.class.getSimpleName(), () -> {
+
+ int samplesCnt = 1000;
+
+ Matrix xorInputs = new DenseLocalOnHeapMatrix(
+ new double[][] {{0.0, 0.0}, {0.0, 1.0}, {1.0, 0.0}, {1.0, 1.0}},
+ StorageConstants.ROW_STORAGE_MODE).transpose();
+
+ Matrix xorOutputs = new DenseLocalOnHeapMatrix(
+ new double[][] {{0.0}, {1.0}, {1.0}, {0.0}},
+ StorageConstants.ROW_STORAGE_MODE).transpose();
+
+ MLPArchitecture conf = new MLPArchitecture(2).
+ withAddedLayer(10, true, Activators.RELU).
+ withAddedLayer(1, false, Activators.SIGMOID);
+
+ IgniteCache<Integer, LabeledVector<Vector, Vector>> cache = LabeledVectorsCache.createNew(ignite);
+ String cacheName = cache.getName();
+ Random rnd = new Random(12345L);
+
+ try (IgniteDataStreamer<Integer, LabeledVector<Vector, Vector>> streamer =
+ ignite.dataStreamer(cacheName)) {
+ streamer.perNodeBufferSize(10000);
+
+ for (int i = 0; i < samplesCnt; i++) {
+ int col = Math.abs(rnd.nextInt()) % 4;
+ streamer.addData(i, new LabeledVector<>(xorInputs.getCol(col), xorOutputs.getCol(col)));
+ }
+ }
+
+ int totalCnt = 100;
+ int failCnt = 0;
+ MLPGroupUpdateTrainer<RPropParameterUpdate> trainer = MLPGroupUpdateTrainer.getDefault(ignite).
+ withSyncRate(3).
+ withTolerance(0.001).
+ withMaxGlobalSteps(1000);
+
+ for (int i = 0; i < totalCnt; i++) {
+
+ MLPGroupUpdateTrainerCacheInput trainerInput = new MLPGroupUpdateTrainerCacheInput(conf,
+ new RandomInitializer(rnd), 6, cache, 4);
+
+ MultilayerPerceptron mlp = trainer.train(trainerInput);
+
+ Matrix predict = mlp.apply(xorInputs);
+
+ System.out.println(">>> Prediction data at step " + i + " of total " + totalCnt + ":");
+
+ Tracer.showAscii(predict);
+
+ System.out.println("Difference estimate: " + xorOutputs.getRow(0).minus(predict.getRow(0)).kNorm(2));
+
+ failCnt += closeEnough(xorOutputs.getRow(0), predict.getRow(0)) ? 0 : 1;
+ }
+
+ double failRatio = (double)failCnt / totalCnt;
+
+ System.out.println("\n>>> Fail percentage: " + (failRatio * 100) + "%.");
+
+ System.out.println("\n>>> Distributed multilayer perceptron example completed.");
+ });
+
+ igniteThread.start();
+
+ igniteThread.join();
+ }
+ }
+
+ /** */
+ private static boolean closeEnough(Vector v1, Vector v2) {
+ return v1.minus(v2).kNorm(2) < 5E-1;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/nn/MLPLocalTrainerExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/nn/MLPLocalTrainerExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/nn/MLPLocalTrainerExample.java
new file mode 100644
index 0000000..b557458
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/nn/MLPLocalTrainerExample.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.examples.ml.nn;
+
+import java.util.Random;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.Tracer;
+import org.apache.ignite.ml.math.functions.IgniteSupplier;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.nn.Activators;
+import org.apache.ignite.ml.trainers.local.LocalBatchTrainerInput;
+import org.apache.ignite.ml.optimization.LossFunctions;
+import org.apache.ignite.ml.nn.MultilayerPerceptron;
+import org.apache.ignite.ml.nn.architecture.MLPArchitecture;
+import org.apache.ignite.ml.nn.initializers.RandomInitializer;
+import org.apache.ignite.ml.nn.trainers.local.MLPLocalBatchTrainer;
+import org.apache.ignite.ml.optimization.updatecalculators.RPropUpdateCalculator;
+import org.apache.ignite.ml.util.Utils;
+
+/**
+ * Example of using local {@link MultilayerPerceptron}.
+ */
+public class MLPLocalTrainerExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ // IMPL NOTE based on MLPLocalTrainerTest#testXORRProp
+ System.out.println(">>> Local multilayer perceptron example started.");
+
+ Matrix xorInputs = new DenseLocalOnHeapMatrix(new double[][] {{0.0, 0.0}, {0.0, 1.0}, {1.0, 0.0}, {1.0, 1.0}},
+ StorageConstants.ROW_STORAGE_MODE).transpose();
+
+ System.out.println("\n>>> Input data:");
+
+ Tracer.showAscii(xorInputs);
+
+ Matrix xorOutputs = new DenseLocalOnHeapMatrix(new double[][] {{0.0}, {1.0}, {1.0}, {0.0}},
+ StorageConstants.ROW_STORAGE_MODE).transpose();
+
+ MLPArchitecture conf = new MLPArchitecture(2).
+ withAddedLayer(10, true, Activators.RELU).
+ withAddedLayer(1, false, Activators.SIGMOID);
+
+ SimpleMLPLocalBatchTrainerInput trainerInput = new SimpleMLPLocalBatchTrainerInput(conf,
+ new Random(1234L), xorInputs, xorOutputs, 4);
+
+ System.out.println("\n>>> Perform training.");
+
+ MultilayerPerceptron mlp = new MLPLocalBatchTrainer<>(LossFunctions.MSE,
+ () -> new RPropUpdateCalculator<>(),
+ 0.0001,
+ 16000).train(trainerInput);
+
+ System.out.println("\n>>> Apply model.");
+
+ Matrix predict = mlp.apply(xorInputs);
+
+ System.out.println("\n>>> Predicted data:");
+
+ Tracer.showAscii(predict);
+
+ System.out.println("\n>>> Reference expected data:");
+
+ Tracer.showAscii(xorOutputs);
+
+ System.out.println("\n>>> Difference estimate: " + xorOutputs.getRow(0).minus(predict.getRow(0)).kNorm(2));
+
+ System.out.println("\n>>> Local multilayer perceptron example completed.");
+ }
+
+ /**
+ * Class for local batch training of {@link MultilayerPerceptron}.
+ *
+ * It is constructed from two matrices: one containing inputs of function to approximate and other containing ground truth
+ * values of this function for corresponding inputs.
+ *
+ * We fix batch size given by this input by some constant value.
+ */
+ private static class SimpleMLPLocalBatchTrainerInput implements LocalBatchTrainerInput<MultilayerPerceptron> {
+ /**
+ * Multilayer perceptron to be trained.
+ */
+ private final MultilayerPerceptron mlp;
+
+ /**
+ * Inputs stored as columns.
+ */
+ private final Matrix inputs;
+
+ /**
+ * Ground truths stored as columns.
+ */
+ private final Matrix groundTruth;
+
+ /**
+ * Size of batch returned on each step.
+ */
+ private final int batchSize;
+
+ /**
+ * Construct instance of this class.
+ *
+ * @param arch Architecture of multilayer perceptron.
+ * @param rnd Random numbers generator.
+ * @param inputs Inputs stored as columns.
+ * @param groundTruth Ground truth stored as columns.
+ * @param batchSize Size of batch returned on each step.
+ */
+ SimpleMLPLocalBatchTrainerInput(MLPArchitecture arch, Random rnd, Matrix inputs, Matrix groundTruth, int batchSize) {
+ this.mlp = new MultilayerPerceptron(arch, new RandomInitializer(rnd));
+ this.inputs = inputs;
+ this.groundTruth = groundTruth;
+ this.batchSize = batchSize;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteSupplier<IgniteBiTuple<Matrix, Matrix>> batchSupplier() {
+ return () -> {
+ int inputRowSize = inputs.rowSize();
+ int outputRowSize = groundTruth.rowSize();
+
+ Matrix vectors = new DenseLocalOnHeapMatrix(inputRowSize, batchSize);
+ Matrix labels = new DenseLocalOnHeapMatrix(outputRowSize, batchSize);
+
+ int[] samples = Utils.selectKDistinct(inputs.columnSize(), batchSize);
+
+ for (int i = 0; i < batchSize; i++) {
+ vectors.assignColumn(i, inputs.getCol(samples[i]));
+ labels.assignColumn(i, groundTruth.getCol(samples[i]));
+ }
+
+ return new IgniteBiTuple<>(vectors, labels);
+ };
+ }
+
+ /** {@inheritDoc} */
+ @Override public MultilayerPerceptron mdl() {
+ return mlp;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/nn/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/nn/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/nn/package-info.java
new file mode 100644
index 0000000..3a0ed29
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/nn/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. -->
+ * ML neural network examples.
+ */
+package org.apache.ignite.examples.ml.nn;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/package-info.java
new file mode 100644
index 0000000..52778b5
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/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. -->
+ * Machine learning examples.
+ */
+package org.apache.ignite.examples.ml;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithQRTrainer.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithQRTrainer.java b/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithQRTrainer.java
new file mode 100644
index 0000000..98ff2a2
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithQRTrainer.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.examples.ml.regression.linear;
+
+import java.util.Arrays;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ml.math.matrix.SparseDistributedMatrixExample;
+import org.apache.ignite.ml.Trainer;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
+import org.apache.ignite.ml.math.impls.vector.SparseDistributedVector;
+import org.apache.ignite.ml.regressions.linear.LinearRegressionModel;
+import org.apache.ignite.ml.regressions.linear.LinearRegressionQRTrainer;
+import org.apache.ignite.thread.IgniteThread;
+
+/**
+ * Run linear regression model over distributed matrix.
+ *
+ * @see LinearRegressionQRTrainer
+ */
+public class DistributedLinearRegressionExampleWithQRTrainer {
+ /** */
+ private static final double[][] data = {
+ {8, 78, 284, 9.100000381, 109},
+ {9.300000191, 68, 433, 8.699999809, 144},
+ {7.5, 70, 739, 7.199999809, 113},
+ {8.899999619, 96, 1792, 8.899999619, 97},
+ {10.19999981, 74, 477, 8.300000191, 206},
+ {8.300000191, 111, 362, 10.89999962, 124},
+ {8.800000191, 77, 671, 10, 152},
+ {8.800000191, 168, 636, 9.100000381, 162},
+ {10.69999981, 82, 329, 8.699999809, 150},
+ {11.69999981, 89, 634, 7.599999905, 134},
+ {8.5, 149, 631, 10.80000019, 292},
+ {8.300000191, 60, 257, 9.5, 108},
+ {8.199999809, 96, 284, 8.800000191, 111},
+ {7.900000095, 83, 603, 9.5, 182},
+ {10.30000019, 130, 686, 8.699999809, 129},
+ {7.400000095, 145, 345, 11.19999981, 158},
+ {9.600000381, 112, 1357, 9.699999809, 186},
+ {9.300000191, 131, 544, 9.600000381, 177},
+ {10.60000038, 80, 205, 9.100000381, 127},
+ {9.699999809, 130, 1264, 9.199999809, 179},
+ {11.60000038, 140, 688, 8.300000191, 80},
+ {8.100000381, 154, 354, 8.399999619, 103},
+ {9.800000191, 118, 1632, 9.399999619, 101},
+ {7.400000095, 94, 348, 9.800000191, 117},
+ {9.399999619, 119, 370, 10.39999962, 88},
+ {11.19999981, 153, 648, 9.899999619, 78},
+ {9.100000381, 116, 366, 9.199999809, 102},
+ {10.5, 97, 540, 10.30000019, 95},
+ {11.89999962, 176, 680, 8.899999619, 80},
+ {8.399999619, 75, 345, 9.600000381, 92},
+ {5, 134, 525, 10.30000019, 126},
+ {9.800000191, 161, 870, 10.39999962, 108},
+ {9.800000191, 111, 669, 9.699999809, 77},
+ {10.80000019, 114, 452, 9.600000381, 60},
+ {10.10000038, 142, 430, 10.69999981, 71},
+ {10.89999962, 238, 822, 10.30000019, 86},
+ {9.199999809, 78, 190, 10.69999981, 93},
+ {8.300000191, 196, 867, 9.600000381, 106},
+ {7.300000191, 125, 969, 10.5, 162},
+ {9.399999619, 82, 499, 7.699999809, 95},
+ {9.399999619, 125, 925, 10.19999981, 91},
+ {9.800000191, 129, 353, 9.899999619, 52},
+ {3.599999905, 84, 288, 8.399999619, 110},
+ {8.399999619, 183, 718, 10.39999962, 69},
+ {10.80000019, 119, 540, 9.199999809, 57},
+ {10.10000038, 180, 668, 13, 106},
+ {9, 82, 347, 8.800000191, 40},
+ {10, 71, 345, 9.199999809, 50},
+ {11.30000019, 118, 463, 7.800000191, 35},
+ {11.30000019, 121, 728, 8.199999809, 86},
+ {12.80000019, 68, 383, 7.400000095, 57},
+ {10, 112, 316, 10.39999962, 57},
+ {6.699999809, 109, 388, 8.899999619, 94}
+ };
+
+ /** Run example. */
+ public static void main(String[] args) throws InterruptedException {
+ System.out.println();
+ System.out.println(">>> Linear regression model over sparse distributed matrix API usage example started.");
+ // Start ignite grid.
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println(">>> Ignite grid started.");
+ // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
+ // because we create ignite cache internally.
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ SparseDistributedMatrixExample.class.getSimpleName(), () -> {
+
+ // Create SparseDistributedMatrix, new cache will be created automagically.
+ System.out.println(">>> Create new SparseDistributedMatrix inside IgniteThread.");
+ SparseDistributedMatrix distributedMatrix = new SparseDistributedMatrix(data);
+
+ System.out.println(">>> Create new linear regression trainer object.");
+ Trainer<LinearRegressionModel, Matrix> trainer = new LinearRegressionQRTrainer();
+
+ System.out.println(">>> Perform the training to get the model.");
+ LinearRegressionModel model = trainer.train(distributedMatrix);
+ System.out.println(">>> Linear regression model: " + model);
+
+ System.out.println(">>> ---------------------------------");
+ System.out.println(">>> | Prediction\t| Ground Truth\t|");
+ System.out.println(">>> ---------------------------------");
+ for (double[] observation : data) {
+ Vector inputs = new SparseDistributedVector(Arrays.copyOfRange(observation, 1, observation.length));
+ double prediction = model.apply(inputs);
+ double groundTruth = observation[0];
+ System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", prediction, groundTruth);
+ }
+ System.out.println(">>> ---------------------------------");
+ });
+
+ igniteThread.start();
+
+ igniteThread.join();
+ }
+ }
+}
[08/11] ignite git commit: IGNITE-7203 Java 8 by default
Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithSGDTrainer.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithSGDTrainer.java b/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithSGDTrainer.java
new file mode 100644
index 0000000..3f61762
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithSGDTrainer.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.examples.ml.regression.linear;
+
+import java.util.Arrays;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ml.math.matrix.SparseDistributedMatrixExample;
+import org.apache.ignite.ml.Trainer;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
+import org.apache.ignite.ml.math.impls.vector.SparseDistributedVector;
+import org.apache.ignite.ml.regressions.linear.LinearRegressionModel;
+import org.apache.ignite.ml.regressions.linear.LinearRegressionQRTrainer;
+import org.apache.ignite.ml.regressions.linear.LinearRegressionSGDTrainer;
+import org.apache.ignite.thread.IgniteThread;
+
+/**
+ * Run linear regression model over distributed matrix.
+ *
+ * @see LinearRegressionQRTrainer
+ */
+public class DistributedLinearRegressionExampleWithSGDTrainer {
+ /** */
+ private static final double[][] data = {
+ {8, 78, 284, 9.100000381, 109},
+ {9.300000191, 68, 433, 8.699999809, 144},
+ {7.5, 70, 739, 7.199999809, 113},
+ {8.899999619, 96, 1792, 8.899999619, 97},
+ {10.19999981, 74, 477, 8.300000191, 206},
+ {8.300000191, 111, 362, 10.89999962, 124},
+ {8.800000191, 77, 671, 10, 152},
+ {8.800000191, 168, 636, 9.100000381, 162},
+ {10.69999981, 82, 329, 8.699999809, 150},
+ {11.69999981, 89, 634, 7.599999905, 134},
+ {8.5, 149, 631, 10.80000019, 292},
+ {8.300000191, 60, 257, 9.5, 108},
+ {8.199999809, 96, 284, 8.800000191, 111},
+ {7.900000095, 83, 603, 9.5, 182},
+ {10.30000019, 130, 686, 8.699999809, 129},
+ {7.400000095, 145, 345, 11.19999981, 158},
+ {9.600000381, 112, 1357, 9.699999809, 186},
+ {9.300000191, 131, 544, 9.600000381, 177},
+ {10.60000038, 80, 205, 9.100000381, 127},
+ {9.699999809, 130, 1264, 9.199999809, 179},
+ {11.60000038, 140, 688, 8.300000191, 80},
+ {8.100000381, 154, 354, 8.399999619, 103},
+ {9.800000191, 118, 1632, 9.399999619, 101},
+ {7.400000095, 94, 348, 9.800000191, 117},
+ {9.399999619, 119, 370, 10.39999962, 88},
+ {11.19999981, 153, 648, 9.899999619, 78},
+ {9.100000381, 116, 366, 9.199999809, 102},
+ {10.5, 97, 540, 10.30000019, 95},
+ {11.89999962, 176, 680, 8.899999619, 80},
+ {8.399999619, 75, 345, 9.600000381, 92},
+ {5, 134, 525, 10.30000019, 126},
+ {9.800000191, 161, 870, 10.39999962, 108},
+ {9.800000191, 111, 669, 9.699999809, 77},
+ {10.80000019, 114, 452, 9.600000381, 60},
+ {10.10000038, 142, 430, 10.69999981, 71},
+ {10.89999962, 238, 822, 10.30000019, 86},
+ {9.199999809, 78, 190, 10.69999981, 93},
+ {8.300000191, 196, 867, 9.600000381, 106},
+ {7.300000191, 125, 969, 10.5, 162},
+ {9.399999619, 82, 499, 7.699999809, 95},
+ {9.399999619, 125, 925, 10.19999981, 91},
+ {9.800000191, 129, 353, 9.899999619, 52},
+ {3.599999905, 84, 288, 8.399999619, 110},
+ {8.399999619, 183, 718, 10.39999962, 69},
+ {10.80000019, 119, 540, 9.199999809, 57},
+ {10.10000038, 180, 668, 13, 106},
+ {9, 82, 347, 8.800000191, 40},
+ {10, 71, 345, 9.199999809, 50},
+ {11.30000019, 118, 463, 7.800000191, 35},
+ {11.30000019, 121, 728, 8.199999809, 86},
+ {12.80000019, 68, 383, 7.400000095, 57},
+ {10, 112, 316, 10.39999962, 57},
+ {6.699999809, 109, 388, 8.899999619, 94}
+ };
+
+ /** Run example. */
+ public static void main(String[] args) throws InterruptedException {
+ System.out.println();
+ System.out.println(">>> Linear regression model over sparse distributed matrix API usage example started.");
+ // Start ignite grid.
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println(">>> Ignite grid started.");
+ // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
+ // because we create ignite cache internally.
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ SparseDistributedMatrixExample.class.getSimpleName(), () -> {
+
+ // Create SparseDistributedMatrix, new cache will be created automagically.
+ System.out.println(">>> Create new SparseDistributedMatrix inside IgniteThread.");
+ SparseDistributedMatrix distributedMatrix = new SparseDistributedMatrix(data);
+
+ System.out.println(">>> Create new linear regression trainer object.");
+ Trainer<LinearRegressionModel, Matrix> trainer = new LinearRegressionSGDTrainer(100_000, 1e-12);
+
+ System.out.println(">>> Perform the training to get the model.");
+ LinearRegressionModel model = trainer.train(distributedMatrix);
+ System.out.println(">>> Linear regression model: " + model);
+
+ System.out.println(">>> ---------------------------------");
+ System.out.println(">>> | Prediction\t| Ground Truth\t|");
+ System.out.println(">>> ---------------------------------");
+ for (double[] observation : data) {
+ Vector inputs = new SparseDistributedVector(Arrays.copyOfRange(observation, 1, observation.length));
+ double prediction = model.apply(inputs);
+ double groundTruth = observation[0];
+ System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", prediction, groundTruth);
+ }
+ System.out.println(">>> ---------------------------------");
+ });
+
+ igniteThread.start();
+
+ igniteThread.join();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/package-info.java
new file mode 100644
index 0000000..d0441a4
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/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. -->
+ * ML linear regression examples.
+ */
+package org.apache.ignite.examples.ml.regression.linear;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/regression/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/regression/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/regression/package-info.java
new file mode 100644
index 0000000..c89c80c
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/regression/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. -->
+ * ML regression examples.
+ */
+package org.apache.ignite.examples.ml.regression;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/trees/MNISTExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/trees/MNISTExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/trees/MNISTExample.java
new file mode 100644
index 0000000..6ff121e
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/trees/MNISTExample.java
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.ml.trees;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Random;
+import java.util.function.Function;
+import java.util.stream.Stream;
+import org.apache.commons.cli.BasicParser;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.ml.Model;
+import org.apache.ignite.ml.estimators.Estimators;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.functions.IgniteTriFunction;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.apache.ignite.ml.trees.models.DecisionTreeModel;
+import org.apache.ignite.ml.trees.trainers.columnbased.BiIndex;
+import org.apache.ignite.ml.trees.trainers.columnbased.BiIndexedCacheColumnDecisionTreeTrainerInput;
+import org.apache.ignite.ml.trees.trainers.columnbased.ColumnDecisionTreeTrainer;
+import org.apache.ignite.ml.trees.trainers.columnbased.contsplitcalcs.ContinuousSplitCalculators;
+import org.apache.ignite.ml.trees.trainers.columnbased.contsplitcalcs.GiniSplitCalculator;
+import org.apache.ignite.ml.trees.trainers.columnbased.regcalcs.RegionCalculators;
+import org.apache.ignite.ml.util.MnistUtils;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * <p>
+ * Example of usage of decision trees algorithm for MNIST dataset
+ * (it can be found here: http://yann.lecun.com/exdb/mnist/). </p>
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.</p>
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.</p>
+ * <p>
+ * It is recommended to start at least one node prior to launching this example if you intend
+ * to run it with default memory settings.</p>
+ * <p>
+ * This example should with program arguments, for example
+ * -ts_i /path/to/train-images-idx3-ubyte
+ * -ts_l /path/to/train-labels-idx1-ubyte
+ * -tss_i /path/to/t10k-images-idx3-ubyte
+ * -tss_l /path/to/t10k-labels-idx1-ubyte
+ * -cfg examples/config/example-ignite.xml.</p>
+ * <p>
+ * -ts_i specifies path to training set images of MNIST;
+ * -ts_l specifies path to training set labels of MNIST;
+ * -tss_i specifies path to test set images of MNIST;
+ * -tss_l specifies path to test set labels of MNIST;
+ * -cfg specifies path to a config path.</p>
+ */
+public class MNISTExample {
+ /** Name of parameter specifying path to training set images. */
+ private static final String MNIST_TRAINING_IMAGES_PATH = "ts_i";
+
+ /** Name of parameter specifying path to training set labels. */
+ private static final String MNIST_TRAINING_LABELS_PATH = "ts_l";
+
+ /** Name of parameter specifying path to test set images. */
+ private static final String MNIST_TEST_IMAGES_PATH = "tss_i";
+
+ /** Name of parameter specifying path to test set labels. */
+ private static final String MNIST_TEST_LABELS_PATH = "tss_l";
+
+ /** Name of parameter specifying path of Ignite config. */
+ private static final String CONFIG = "cfg";
+
+ /** Default config path. */
+ private static final String DEFAULT_CONFIG = "examples/config/example-ignite.xml";
+
+ /**
+ * Launches example.
+ *
+ * @param args Program arguments.
+ */
+ public static void main(String[] args) {
+ String igniteCfgPath;
+
+ CommandLineParser parser = new BasicParser();
+
+ String trainingImagesPath;
+ String trainingLabelsPath;
+
+ String testImagesPath;
+ String testLabelsPath;
+
+ try {
+ // Parse the command line arguments.
+ CommandLine line = parser.parse(buildOptions(), args);
+
+ trainingImagesPath = line.getOptionValue(MNIST_TRAINING_IMAGES_PATH);
+ trainingLabelsPath = line.getOptionValue(MNIST_TRAINING_LABELS_PATH);
+ testImagesPath = line.getOptionValue(MNIST_TEST_IMAGES_PATH);
+ testLabelsPath = line.getOptionValue(MNIST_TEST_LABELS_PATH);
+ igniteCfgPath = line.getOptionValue(CONFIG, DEFAULT_CONFIG);
+ }
+ catch (ParseException e) {
+ e.printStackTrace();
+ return;
+ }
+
+ try (Ignite ignite = Ignition.start(igniteCfgPath)) {
+ IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
+
+ int ptsCnt = 60000;
+ int featCnt = 28 * 28;
+
+ Stream<DenseLocalOnHeapVector> trainingMnistStream = MnistUtils.mnist(trainingImagesPath, trainingLabelsPath, new Random(123L), ptsCnt);
+ Stream<DenseLocalOnHeapVector> testMnistStream = MnistUtils.mnist(testImagesPath, testLabelsPath, new Random(123L), 10_000);
+
+ IgniteCache<BiIndex, Double> cache = createBiIndexedCache(ignite);
+
+ loadVectorsIntoBiIndexedCache(cache.getName(), trainingMnistStream.iterator(), featCnt + 1, ignite);
+
+ ColumnDecisionTreeTrainer<GiniSplitCalculator.GiniData> trainer =
+ new ColumnDecisionTreeTrainer<>(10, ContinuousSplitCalculators.GINI.apply(ignite), RegionCalculators.GINI, RegionCalculators.MOST_COMMON, ignite);
+
+ System.out.println(">>> Training started");
+ long before = System.currentTimeMillis();
+ DecisionTreeModel mdl = trainer.train(new BiIndexedCacheColumnDecisionTreeTrainerInput(cache, new HashMap<>(), ptsCnt, featCnt));
+ System.out.println(">>> Training finished in " + (System.currentTimeMillis() - before));
+
+ IgniteTriFunction<Model<Vector, Double>, Stream<IgniteBiTuple<Vector, Double>>, Function<Double, Double>, Double> mse = Estimators.errorsPercentage();
+ Double accuracy = mse.apply(mdl, testMnistStream.map(v -> new IgniteBiTuple<>(v.viewPart(0, featCnt), v.getX(featCnt))), Function.identity());
+ System.out.println(">>> Errs percentage: " + accuracy);
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Build cli options.
+ */
+ @NotNull private static Options buildOptions() {
+ Options options = new Options();
+
+ Option trsImagesPathOpt = OptionBuilder.withArgName(MNIST_TRAINING_IMAGES_PATH).withLongOpt(MNIST_TRAINING_IMAGES_PATH).hasArg()
+ .withDescription("Path to the MNIST training set.")
+ .isRequired(true).create();
+
+ Option trsLabelsPathOpt = OptionBuilder.withArgName(MNIST_TRAINING_LABELS_PATH).withLongOpt(MNIST_TRAINING_LABELS_PATH).hasArg()
+ .withDescription("Path to the MNIST training set.")
+ .isRequired(true).create();
+
+ Option tssImagesPathOpt = OptionBuilder.withArgName(MNIST_TEST_IMAGES_PATH).withLongOpt(MNIST_TEST_IMAGES_PATH).hasArg()
+ .withDescription("Path to the MNIST test set.")
+ .isRequired(true).create();
+
+ Option tssLabelsPathOpt = OptionBuilder.withArgName(MNIST_TEST_LABELS_PATH).withLongOpt(MNIST_TEST_LABELS_PATH).hasArg()
+ .withDescription("Path to the MNIST test set.")
+ .isRequired(true).create();
+
+ Option configOpt = OptionBuilder.withArgName(CONFIG).withLongOpt(CONFIG).hasArg()
+ .withDescription("Path to the config.")
+ .isRequired(false).create();
+
+ options.addOption(trsImagesPathOpt);
+ options.addOption(trsLabelsPathOpt);
+ options.addOption(tssImagesPathOpt);
+ options.addOption(tssLabelsPathOpt);
+ options.addOption(configOpt);
+
+ return options;
+ }
+
+ /**
+ * Creates cache where data for training is stored.
+ *
+ * @param ignite Ignite instance.
+ * @return cache where data for training is stored.
+ */
+ private static IgniteCache<BiIndex, Double> createBiIndexedCache(Ignite ignite) {
+ CacheConfiguration<BiIndex, Double> cfg = new CacheConfiguration<>();
+
+ // 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);
+
+ cfg.setBackups(0);
+
+ cfg.setName("TMP_BI_INDEXED_CACHE");
+
+ return ignite.getOrCreateCache(cfg);
+ }
+
+ /**
+ * Loads vectors into cache.
+ *
+ * @param cacheName Name of cache.
+ * @param vectorsIterator Iterator over vectors to load.
+ * @param vectorSize Size of vector.
+ * @param ignite Ignite instance.
+ */
+ private static void loadVectorsIntoBiIndexedCache(String cacheName, Iterator<? extends Vector> vectorsIterator,
+ int vectorSize, Ignite ignite) {
+ try (IgniteDataStreamer<BiIndex, Double> streamer =
+ ignite.dataStreamer(cacheName)) {
+ int sampleIdx = 0;
+
+ streamer.perNodeBufferSize(10000);
+
+ while (vectorsIterator.hasNext()) {
+ org.apache.ignite.ml.math.Vector next = vectorsIterator.next();
+
+ for (int i = 0; i < vectorSize; i++)
+ streamer.addData(new BiIndex(sampleIdx, i), next.getX(i));
+
+ sampleIdx++;
+
+ if (sampleIdx % 1000 == 0)
+ System.out.println("Loaded " + sampleIdx + " vectors.");
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/trees/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/trees/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/trees/package-info.java
new file mode 100644
index 0000000..d944f60
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/trees/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. -->
+ * Decision trees examples.
+ */
+package org.apache.ignite.examples.ml.trees;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java
index 6934ac3..c89cfbd 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java
@@ -19,7 +19,6 @@ package org.apache.ignite.examples.streaming;
import java.util.List;
import java.util.Random;
-import javax.cache.processor.MutableEntry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteDataStreamer;
@@ -34,9 +33,11 @@ import org.apache.ignite.stream.StreamTransformer;
* Stream random numbers into the streaming cache.
* To start the example, you should:
* <ul>
- * <li>Start a few nodes using {@link ExampleNodeStartup}.</li>
+ * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
* <li>Start streaming using {@link StreamTransformerExample}.</li>
* </ul>
+ * <p>
+ * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
*/
public class StreamTransformerExample {
/** Random number generator. */
@@ -45,6 +46,9 @@ public class StreamTransformerExample {
/** Range within which to generate numbers. */
private static final int RANGE = 1000;
+ /** Cache name. */
+ private static final String CACHE_NAME = "randomNumbers";
+
public static void main(String[] args) throws Exception {
// Mark this cluster member as client.
Ignition.setClientMode(true);
@@ -53,7 +57,7 @@ public class StreamTransformerExample {
if (!ExamplesUtils.hasServerNodes(ignite))
return;
- CacheConfiguration<Integer, Long> cfg = new CacheConfiguration<>("randomNumbers");
+ CacheConfiguration<Integer, Long> cfg = new CacheConfiguration<>(CACHE_NAME);
// Index key and value.
cfg.setIndexedTypes(Integer.class, Long.class);
@@ -65,17 +69,15 @@ public class StreamTransformerExample {
stmr.allowOverwrite(true);
// Configure data transformation to count random numbers added to the stream.
- stmr.receiver(new StreamTransformer<Integer, Long>() {
- @Override public Object process(MutableEntry<Integer, Long> e, Object... args) {
- // Get current count.
- Long val = e.getValue();
+ stmr.receiver(StreamTransformer.from((e, arg) -> {
+ // Get current count.
+ Long val = e.getValue();
- // Increment count by 1.
- e.setValue(val == null ? 1L : val + 1);
+ // Increment count by 1.
+ e.setValue(val == null ? 1L : val + 1);
- return null;
- }
- });
+ return null;
+ }));
// Stream 10 million of random numbers into the streamer cache.
for (int i = 1; i <= 10_000_000; i++) {
@@ -99,7 +101,7 @@ public class StreamTransformerExample {
}
finally {
// Distributed cache could be removed from cluster only by #destroyCache() call.
- ignite.destroyCache(cfg.getName());
+ ignite.destroyCache(CACHE_NAME);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java
index c3d8c64..c8438d2 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java
@@ -19,14 +19,11 @@ package org.apache.ignite.examples.streaming;
import java.io.Serializable;
import java.util.List;
-import java.util.Map;
import java.util.Random;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.Ignition;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -35,16 +32,14 @@ import org.apache.ignite.examples.ExamplesUtils;
import org.apache.ignite.stream.StreamVisitor;
/**
- * This examples demonstrates the stream visitor which allows to customize the processing
- * of the streamed data on the server side. Instead of populating the cache for which the
- * streamer is created, we will calculate aggregated data on the fly and save results in
- * another cache.
+ * Stream random numbers into the streaming cache.
+ * To start the example, you should:
+ * <ul>
+ * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
+ * <li>Start streaming using {@link StreamVisitorExample}.</li>
+ * </ul>
* <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
+ * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
*/
public class StreamVisitorExample {
/** Random number generator. */
@@ -56,10 +51,6 @@ public class StreamVisitorExample {
/** The list of initial instrument prices. */
private static final double[] INITIAL_PRICES = {194.9, 893.49, 34.21, 23.24, 57.93, 45.03, 44.41, 28.44, 378.49, 69.50};
- /** Caches' names. */
- private static final String INSTRUMENTS_CACHE_NAME = "instCache";
- private static final String MARKET_TICKS_CACHE_NAME = "marketTicks";
-
public static void main(String[] args) throws Exception {
// Mark this cluster member as client.
Ignition.setClientMode(true);
@@ -68,8 +59,11 @@ public class StreamVisitorExample {
if (!ExamplesUtils.hasServerNodes(ignite))
return;
+ // Market data cache with default configuration.
+ CacheConfiguration<String, Double> mktDataCfg = new CacheConfiguration<>("marketTicks");
+
// Financial instrument cache configuration.
- CacheConfiguration<String, Instrument> instCfg = new CacheConfiguration<>(INSTRUMENTS_CACHE_NAME);
+ CacheConfiguration<String, Instrument> instCfg = new CacheConfiguration<>("instCache");
// Index key and value for querying financial instruments.
// Note that Instrument class has @QuerySqlField annotation for secondary field indexing.
@@ -77,54 +71,28 @@ public class StreamVisitorExample {
// Auto-close caches at the end of the example.
try (
- IgniteCache<String, Double> mktCache = ignite.getOrCreateCache(MARKET_TICKS_CACHE_NAME); // Default config.
+ IgniteCache<String, Double> mktCache = ignite.getOrCreateCache(mktDataCfg);
IgniteCache<String, Instrument> instCache = ignite.getOrCreateCache(instCfg)
) {
try (IgniteDataStreamer<String, Double> mktStmr = ignite.dataStreamer(mktCache.getName())) {
- // To achieve proper indexing we should use fully-qualified name
- // of the class as a type name when binary object is created.
- final String instTypeName = Instrument.class.getName();
-
// Note that we receive market data, but do not populate 'mktCache' (it remains empty).
// Instead we update the instruments in the 'instCache'.
// Since both, 'instCache' and 'mktCache' use the same key, updates are collocated.
- mktStmr.receiver(new StreamVisitor<String, Double>() {
- @Override public void apply(IgniteCache<String, Double> cache, Map.Entry<String, Double> e) {
- String symbol = e.getKey();
- Double tick = e.getValue();
-
- IgniteCache<String, BinaryObject> binInstCache =
- ignite.cache(INSTRUMENTS_CACHE_NAME).withKeepBinary();
-
- BinaryObject inst = binInstCache.get(symbol);
-
- BinaryObjectBuilder instBuilder;
-
- if (inst == null) {
- instBuilder = ignite.binary().builder(instTypeName);
-
- // Constructor logic.
- instBuilder.setField(
- "symbol",
- symbol);
- }
- else
- instBuilder = inst.toBuilder();
-
- // Instrument.update() logic.
- Double open = instBuilder.<Double>getField("open");
+ mktStmr.receiver(StreamVisitor.from((cache, e) -> {
+ String symbol = e.getKey();
+ Double tick = e.getValue();
- if (open == null || open == 0)
- instBuilder.setField("open", tick);
+ Instrument inst = instCache.get(symbol);
- instBuilder.setField("latest", tick);
+ if (inst == null)
+ inst = new Instrument(symbol);
- // Build instrument object.
- inst = instBuilder.build();
+ // Don't populate market cache, as we don't use it for querying.
+ // Update cached instrument based on the latest market tick.
+ inst.update(tick);
- binInstCache.put(symbol, inst);
- }
- });
+ instCache.put(symbol, inst);
+ }));
// Stream 10 million market data ticks into the system.
for (int i = 1; i <= 10_000_000; i++) {
@@ -155,8 +123,8 @@ public class StreamVisitorExample {
}
finally {
// Distributed cache could be removed from cluster only by #destroyCache() call.
- ignite.destroyCache(INSTRUMENTS_CACHE_NAME);
- ignite.destroyCache(MARKET_TICKS_CACHE_NAME);
+ ignite.destroyCache(mktDataCfg.getName());
+ ignite.destroyCache(instCfg.getName());
}
}
}
@@ -206,4 +174,4 @@ public class StreamVisitorExample {
this.latest = price;
}
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java b/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java
index 7cd31d1..f9e84ef 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java
@@ -16,6 +16,7 @@
*/
/**
+ * <!-- Package description. -->
* Demonstrates usage of data streamer.
*/
package org.apache.ignite.examples.streaming;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
deleted file mode 100644
index 751032b..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.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.examples.java8.cluster;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCluster;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-
-/**
- * Demonstrates new functional APIs.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ClusterGroupExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
- return;
-
- System.out.println();
- System.out.println("Compute example started.");
-
- IgniteCluster cluster = ignite.cluster();
-
- // Say hello to all nodes in the cluster, including local node.
- sayHello(ignite, cluster);
-
- // Say hello to all remote nodes.
- sayHello(ignite, cluster.forRemotes());
-
- // Pick random node out of remote nodes.
- ClusterGroup randomNode = cluster.forRemotes().forRandom();
-
- // Say hello to a random node.
- sayHello(ignite, randomNode);
-
- // Say hello to all nodes residing on the same host with random node.
- sayHello(ignite, cluster.forHost(randomNode.node()));
-
- // Say hello to all nodes that have current CPU load less than 50%.
- sayHello(ignite, cluster.forPredicate(n -> n.metrics().getCurrentCpuLoad() < 0.5));
- }
- }
-
- /**
- * Print 'Hello' message on remote nodes.
- *
- * @param ignite Ignite.
- * @param grp Cluster group.
- * @throws IgniteException If failed.
- */
- private static void sayHello(Ignite ignite, final ClusterGroup grp) throws IgniteException {
- // Print out hello message on all cluster nodes.
- ignite.compute(grp).broadcast(
- () -> System.out.println(">>> Hello Node: " + grp.ignite().cluster().localNode().id()));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java b/examples/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
deleted file mode 100644
index 618e844..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/cluster/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. -->
- * Cluster group example.
- */
-package org.apache.ignite.examples.java8.cluster;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
deleted file mode 100644
index 77d1ac2..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
+++ /dev/null
@@ -1,75 +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.examples.java8.computegrid;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgniteRunnable;
-
-/**
- * Demonstrates a simple use of {@link IgniteRunnable}.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeAsyncExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println("Compute asynchronous example started.");
-
- // Enable asynchronous mode.
- IgniteCompute compute = ignite.compute().withAsync();
-
- Collection<IgniteFuture<?>> futs = new ArrayList<>();
-
- // Iterate through all words in the sentence and create runnable jobs.
- for (final String word : "Print words using runnable".split(" ")) {
- // Execute runnable on some node.
- compute.run(() -> {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
- });
-
- futs.add(compute.future());
- }
-
- // Wait for completion of all futures.
- futs.forEach(IgniteFuture::get);
-
- System.out.println();
- System.out.println(">>> Finished printing words using runnable execution.");
- System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
deleted file mode 100644
index f839911..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.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.examples.java8.computegrid;
-
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-
-/**
- * Demonstrates broadcasting computations within cluster.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeBroadcastExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Compute broadcast example started.");
-
- // Print hello message on all nodes.
- hello(ignite);
-
- // Gather system info from all nodes.
- gatherSystemInfo(ignite);
- }
- }
-
- /**
- * Print 'Hello' message on all nodes.
- *
- * @param ignite Ignite instance.
- * @throws IgniteException If failed.
- */
- private static void hello(Ignite ignite) throws IgniteException {
- // Print out hello message on all nodes.
- ignite.compute().broadcast(() -> {
- System.out.println();
- System.out.println(">>> Hello Node! :)");
- });
-
- System.out.println();
- System.out.println(">>> Check all nodes for hello message output.");
- }
-
- /**
- * Gather system info from all nodes and print it out.
- *
- * @param ignite Ignite instance.
- * @throws IgniteException if failed.
- */
- private static void gatherSystemInfo(Ignite ignite) throws IgniteException {
- // Gather system info from all nodes.
- Collection<String> res = ignite.compute().broadcast(() -> {
- System.out.println();
- System.out.println("Executing task on node: " + ignite.cluster().localNode().id());
-
- return "Node ID: " + ignite.cluster().localNode().id() + "\n" +
- "OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " +
- System.getProperty("os.arch") + "\n" +
- "User: " + System.getProperty("user.name") + "\n" +
- "JRE: " + System.getProperty("java.runtime.name") + " " +
- System.getProperty("java.runtime.version");
- });
-
- // Print result.
- System.out.println();
- System.out.println("Nodes system information:");
- System.out.println();
-
- res.forEach(r -> {
- System.out.println(r);
- System.out.println();
- });
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
deleted file mode 100644
index 2cbece8..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
+++ /dev/null
@@ -1,75 +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.examples.java8.computegrid;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteCallable;
-
-/**
- * Demonstrates using of {@link IgniteCallable} job execution on the cluster.
- * <p>
- * This example takes a sentence composed of multiple words and counts number of non-space
- * characters in the sentence by having each compute job count characters in each individual
- * word.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeCallableExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Compute callable example started.");
-
- Collection<IgniteCallable<Integer>> calls = new ArrayList<>();
-
- // Iterate through all words in the sentence and create callable jobs.
- for (String word : "Count characters using callable".split(" ")) {
- calls.add(() -> {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
-
- return word.length();
- });
- }
-
- // Execute collection of callables on the ignite.
- Collection<Integer> res = ignite.compute().call(calls);
-
- int sum = res.stream().mapToInt(i -> i).sum();
-
- System.out.println();
- System.out.println(">>> Total number of characters in the phrase is '" + sum + "'.");
- System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
deleted file mode 100644
index fc7564f..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.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.examples.java8.computegrid;
-
-import java.util.Arrays;
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-
-/**
- * Demonstrates a simple use of Ignite with reduce closure.
- * <p>
- * This example splits a phrase into collection of words, computes their length on different
- * nodes and then computes total amount of non-whitespaces characters in the phrase.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeClosureExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Compute closure example started.");
-
- // Execute closure on all cluster nodes.
- Collection<Integer> res = ignite.compute().apply(
- (String word) -> {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
-
- // Return number of letters in the word.
- return word.length();
- },
- // Job parameters. Ignite will create as many jobs as there are parameters.
- Arrays.asList("Count characters using closure".split(" "))
- );
-
- int sum = res.stream().mapToInt(i -> i).sum();
-
- System.out.println();
- System.out.println(">>> Total number of characters in the phrase is '" + sum + "'.");
- System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
deleted file mode 100644
index 4dc7c5f..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
+++ /dev/null
@@ -1,64 +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.examples.java8.computegrid;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteRunnable;
-
-/**
- * Demonstrates a simple use of {@link IgniteRunnable}.
- * <p>
- * Remote nodes should always be 0started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeRunnableExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println("Compute runnable example started.");
-
- IgniteCompute compute = ignite.compute();
-
- // Iterate through all words in the sentence and create runnable jobs.
- for (final String word : "Print words using runnable".split(" ")) {
- // Execute runnable on some node.
- compute.run(() -> {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
- });
- }
-
- System.out.println();
- System.out.println(">>> Finished printing words using runnable execution.");
- System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java b/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
deleted file mode 100644
index a293faa..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/computegrid/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. -->
- * Basic examples for computational ignite functionality.
- */
-package org.apache.ignite.examples.java8.computegrid;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
deleted file mode 100644
index 2867bf1..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
+++ /dev/null
@@ -1,142 +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.examples.java8.datagrid;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.affinity.Affinity;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteRunnable;
-
-/**
- * This example demonstrates the simplest code that populates the distributed cache
- * and co-locates simple closure execution with each key. The goal of this particular
- * example is to provide the simplest code example of this logic.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public final class CacheAffinityExample {
- /** Cache name. */
- private static final String CACHE_NAME = CacheAffinityExample.class.getSimpleName();
-
- /** Number of keys. */
- private static final int KEY_CNT = 20;
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Cache affinity example started.");
-
- CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
-
- cfg.setCacheMode(CacheMode.PARTITIONED);
- cfg.setName(CACHE_NAME);
-
- // Auto-close cache at the end of the example.
- try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
- for (int i = 0; i < KEY_CNT; i++)
- cache.put(i, Integer.toString(i));
-
- // Co-locates jobs with data using IgniteCompute.affinityRun(...) method.
- visitUsingAffinityRun();
-
- // Co-locates jobs with data using IgniteCluster.mapKeysToNodes(...) method.
- visitUsingMapKeysToNodes();
- }
- finally {
- // Distributed cache could be removed from cluster only by #destroyCache() call.
- ignite.destroyCache(CACHE_NAME);
- }
- }
- }
-
- /**
- * Collocates jobs with keys they need to work on using
- * {@link IgniteCompute#affinityRun(String, Object, IgniteRunnable)} method.
- */
- private static void visitUsingAffinityRun() {
- Ignite ignite = Ignition.ignite();
-
- final IgniteCache<Integer, String> cache = ignite.cache(CACHE_NAME);
-
- for (int i = 0; i < KEY_CNT; i++) {
- int key = i;
-
- // This runnable will execute on the remote node where
- // data with the given key is located. Since it will be co-located
- // we can use local 'peek' operation safely.
- ignite.compute().affinityRun(CACHE_NAME, key,
- () -> System.out.println("Co-located using affinityRun [key= " + key + ", value=" + cache.localPeek(key) + ']'));
- }
- }
-
- /**
- * Collocates jobs with keys they need to work on using {@link Affinity#mapKeysToNodes(Collection)}
- * method. The difference from {@code affinityRun(...)} method is that here we process multiple keys
- * in a single job.
- */
- private static void visitUsingMapKeysToNodes() {
- final Ignite ignite = Ignition.ignite();
-
- Collection<Integer> keys = new ArrayList<>(KEY_CNT);
-
- for (int i = 0; i < KEY_CNT; i++)
- keys.add(i);
-
- // Map all keys to nodes.
- Map<ClusterNode, Collection<Integer>> mappings = ignite.<Integer>affinity(CACHE_NAME).mapKeysToNodes(keys);
-
- for (Map.Entry<ClusterNode, Collection<Integer>> mapping : mappings.entrySet()) {
- ClusterNode node = mapping.getKey();
-
- final Collection<Integer> mappedKeys = mapping.getValue();
-
- if (node != null) {
- // Bring computations to the nodes where the data resides (i.e. collocation).
- ignite.compute(ignite.cluster().forNode(node)).run(() -> {
- IgniteCache<Integer, String> cache = ignite.cache(CACHE_NAME);
-
- // Peek is a local memory lookup, however, value should never be 'null'
- // as we are co-located with node that has a given key.
- for (Integer key : mappedKeys)
- System.out.println("Co-located using mapKeysToNodes [key= " + key +
- ", value=" + cache.localPeek(key) + ']');
- });
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
deleted file mode 100644
index b78003b..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
+++ /dev/null
@@ -1,110 +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.examples.java8.datagrid;
-
-import java.util.concurrent.ConcurrentMap;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-
-/**
- * This example demonstrates some of the cache rich API capabilities.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class CacheApiExample {
- /** Cache name. */
- private static final String CACHE_NAME = CacheApiExample.class.getSimpleName();
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Cache API example started.");
-
- CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
-
- cfg.setCacheMode(CacheMode.PARTITIONED);
- cfg.setName(CACHE_NAME);
-
- // Auto-close cache at the end of the example.
- try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
- // Demonstrate atomic map operations.
- atomicMapOperations(cache);
- }
- finally {
- // Distributed cache could be removed from cluster only by #destroyCache() call.
- ignite.destroyCache(CACHE_NAME);
- }
- }
- }
-
- /**
- * Demonstrates cache operations similar to {@link ConcurrentMap} API. Note that
- * cache API is a lot richer than the JDK {@link ConcurrentMap}.
- *
- * @throws IgniteException If failed.
- */
- private static void atomicMapOperations(final IgniteCache<Integer, String> cache) throws IgniteException {
- System.out.println();
- System.out.println(">>> Cache atomic map operation examples.");
-
- // Put and return previous value.
- String v = cache.getAndPut(1, "1");
- assert v == null;
-
- // Put and do not return previous value (all methods ending with 'x' return boolean).
- // Performs better when previous value is not needed.
- cache.put(2, "2");
-
- // Put-if-absent.
- boolean b1 = cache.putIfAbsent(4, "4");
- boolean b2 = cache.putIfAbsent(4, "44");
- assert b1 && !b2;
-
- // Invoke - assign new value based on previous value.
- cache.put(6, "6");
-
- cache.invoke(6, (entry, args) -> {
- String val = entry.getValue();
-
- entry.setValue(val + "6"); // Set new value based on previous value.
-
- return null;
- });
-
- // Replace.
- cache.put(7, "7");
- b1 = cache.replace(7, "7", "77");
- b2 = cache.replace(7, "7", "777");
- assert b1 & !b2;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
deleted file mode 100644
index ac80fb6..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.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.examples.java8.datagrid;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteFuture;
-
-/**
- * This example demonstrates some of the cache rich API capabilities.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class CacheAsyncApiExample {
- /** Cache name. */
- private static final String CACHE_NAME = CacheAsyncApiExample.class.getSimpleName();
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Cache asynchronous API example started.");
-
- CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
-
- cfg.setCacheMode(CacheMode.PARTITIONED);
- cfg.setName(CACHE_NAME);
-
- // Auto-close cache at the end of the example.
- try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
- // Enable asynchronous mode.
- IgniteCache<Integer, String> asyncCache = cache.withAsync();
-
- Collection<IgniteFuture<?>> futs = new ArrayList<>();
-
- // Execute several puts asynchronously.
- for (int i = 0; i < 10; i++) {
- asyncCache.put(i, String.valueOf(i));
-
- futs.add(asyncCache.future());
- }
-
- // Wait for completion of all futures.
- futs.forEach(IgniteFuture::get);
-
- // Execute get operation asynchronously.
- asyncCache.get(1);
-
- // Asynchronously wait for result.
- asyncCache.<String>future().listen(fut ->
- System.out.println("Get operation completed [value=" + fut.get() + ']'));
- }
- finally {
- // Distributed cache could be removed from cluster only by #destroyCache() call.
- ignite.destroyCache(CACHE_NAME);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheEntryProcessorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheEntryProcessorExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheEntryProcessorExample.java
deleted file mode 100644
index 24633a8..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheEntryProcessorExample.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.examples.java8.datagrid;
-
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import javax.cache.processor.EntryProcessor;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-
-/**
- * This example demonstrates the simplest code that populates the distributed cache and co-locates simple closure
- * execution with each key. The goal of this particular example is to provide the simplest code example of this logic
- * using EntryProcessor.
- * <p>
- * Remote nodes should always be started with special configuration file which enables P2P
- * class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node with
- * {@code examples/config/example-ignite.xml} configuration.
- */
-public class CacheEntryProcessorExample {
- /** Cache name. */
- private static final String CACHE_NAME = CacheEntryProcessorExample.class.getSimpleName();
-
- /** Number of keys. */
- private static final int KEY_CNT = 20;
-
- /** Set of predefined keys. */
- private static final Set<Integer> KEYS_SET;
-
- /**
- * Initializes keys set that is used in bulked operations in the example.
- */
- static {
- KEYS_SET = new HashSet<>();
-
- for (int i = 0; i < KEY_CNT; i++)
- KEYS_SET.add(i);
- }
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws IgniteException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Entry processor example started.");
-
- // Auto-close cache at the end of the example.
- try (IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(CACHE_NAME)) {
- // Demonstrates usage of EntryProcessor.invoke(...) method.
- populateEntriesWithInvoke(cache);
-
- // Demonstrates usage of EntryProcessor.invokeAll(...) method.
- incrementEntriesWithInvokeAll(cache);
- }
- finally {
- // Distributed cache could be removed from cluster only by #destroyCache() call.
- ignite.destroyCache(CACHE_NAME);
- }
- }
- }
-
- /**
- * Populates cache with values using {@link IgniteCache#invoke(Object, EntryProcessor, Object...)} method.
- *
- * @param cache Cache that must be populated.
- */
- private static void populateEntriesWithInvoke(IgniteCache<Integer, Integer> cache) {
- // Must be no entry in the cache at this point.
- printCacheEntries(cache);
-
- System.out.println("");
- System.out.println(">> Populating the cache using EntryProcessor.");
-
- // Invokes EntryProcessor for every key sequentially.
- for (int i = 0; i < KEY_CNT; i++) {
- cache.invoke(i, (entry, object) -> {
- // Initializes entry's value if it's not set.
- if (entry.getValue() == null)
- entry.setValue((entry.getKey() + 1) * 10);
- return null;
- });
- }
-
- // Print outs entries that are set using the EntryProcessor above.
- printCacheEntries(cache);
- }
-
- /**
- * Increments values of entries stored in the cache using {@link IgniteCache#invokeAll(Set, EntryProcessor,
- * Object...)} method.
- *
- * @param cache Cache instance.
- */
- private static void incrementEntriesWithInvokeAll(IgniteCache<Integer, Integer> cache) {
- System.out.println("");
- System.out.println(">> Incrementing values in the cache using EntryProcessor.");
-
- // Using EntryProcessor.invokeAll to increment every value in place.
- cache.invokeAll(KEYS_SET, (entry, object) -> {
- entry.setValue(entry.getValue() + 5);
-
- return null;
- });
-
- // Print outs entries that are incremented using the EntryProcessor above.
- printCacheEntries(cache);
- }
-
- /**
- * Prints out all the entries that are stored in a cache.
- *
- * @param cache Cache.
- */
- private static void printCacheEntries(IgniteCache<Integer, Integer> cache) {
- System.out.println();
- System.out.println(">>> Entries in the cache.");
-
- Map<Integer, Integer> entries = cache.getAll(KEYS_SET);
-
- if (entries.isEmpty())
- System.out.println("No entries in the cache.");
- else {
- for (Map.Entry<Integer, Integer> entry : entries.entrySet())
- System.out.println("Entry [key=" + entry.getKey() + ", value=" + entry.getValue() + ']');
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
deleted file mode 100644
index d8c45d6..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/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. -->
- * Demonstrates data ignite cache usage.
- */
-package org.apache.ignite.examples.java8.datagrid;
\ No newline at end of file
[06/11] ignite git commit: IGNITE-7203 Java 8 by default
Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/knn/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/knn/package-info.java
deleted file mode 100644
index 8de4656..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/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. -->
- * kNN examples.
- */
-package org.apache.ignite.examples.ml.knn;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/knn/regression/KNNRegressionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/regression/KNNRegressionExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/knn/regression/KNNRegressionExample.java
deleted file mode 100644
index b52613a..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/regression/KNNRegressionExample.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.examples.ml.knn.regression;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ml.knn.classification.KNNClassificationExample;
-import org.apache.ignite.ml.knn.models.KNNStrategy;
-import org.apache.ignite.ml.knn.regression.KNNMultipleLinearRegression;
-import org.apache.ignite.ml.math.distances.ManhattanDistance;
-import org.apache.ignite.ml.structures.LabeledDataset;
-import org.apache.ignite.ml.structures.LabeledDatasetTestTrainPair;
-import org.apache.ignite.ml.structures.preprocessing.LabeledDatasetLoader;
-import org.apache.ignite.ml.structures.preprocessing.LabellingMachine;
-import org.apache.ignite.ml.structures.preprocessing.Normalizer;
-import org.apache.ignite.thread.IgniteThread;
-
-/**
- * <p>
- * Example of using {@link KNNMultipleLinearRegression} with iris dataset.</p>
- * <p>
- * Note that in this example we cannot guarantee order in which nodes return results of intermediate
- * computations and therefore algorithm can return different results.</p>
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.</p>
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.</p>
- */
-public class KNNRegressionExample {
- /** Separator. */
- private static final String SEPARATOR = ",";
-
- /** */
- private static final String KNN_CLEARED_MACHINES_TXT = "../datasets/cleared_machines.txt";
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) throws InterruptedException {
- System.out.println(">>> kNN regression example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
- KNNRegressionExample.class.getSimpleName(), () -> {
-
- try {
- // Prepare path to read
- URL url = KNNClassificationExample.class.getResource(KNN_CLEARED_MACHINES_TXT);
- if (url == null)
- throw new RuntimeException("Can't get URL for: " + KNN_CLEARED_MACHINES_TXT);
-
- Path path = Paths.get(url.toURI());
-
- // Read dataset from file
- LabeledDataset dataset = LabeledDatasetLoader.loadFromTxtFile(path, SEPARATOR, false, false);
-
- // Normalize dataset
- Normalizer.normalizeWithMiniMax(dataset);
-
- // Random splitting of iris data as 80% train and 20% test datasets
- LabeledDatasetTestTrainPair split = new LabeledDatasetTestTrainPair(dataset, 0.2);
-
- System.out.println("\n>>> Amount of observations in train dataset: " + split.train().rowSize());
- System.out.println("\n>>> Amount of observations in test dataset: " + split.test().rowSize());
-
- LabeledDataset test = split.test();
- LabeledDataset train = split.train();
-
- // Builds weighted kNN-regression with Manhattan Distance
- KNNMultipleLinearRegression knnMdl = new KNNMultipleLinearRegression(7, new ManhattanDistance(),
- KNNStrategy.WEIGHTED, train);
-
- // Clone labels
- final double[] labels = test.labels();
-
- // Save predicted classes to test dataset
- LabellingMachine.assignLabels(test, knnMdl);
-
- // Calculate mean squared error (MSE)
- double mse = 0.0;
-
- for (int i = 0; i < test.rowSize(); i++)
- mse += Math.pow(test.label(i) - labels[i], 2.0);
- mse = mse / test.rowSize();
-
- System.out.println("\n>>> Mean squared error (MSE) " + mse);
-
- // Calculate mean absolute error (MAE)
- double mae = 0.0;
-
- for (int i = 0; i < test.rowSize(); i++)
- mae += Math.abs(test.label(i) - labels[i]);
- mae = mae / test.rowSize();
-
- System.out.println("\n>>> Mean absolute error (MAE) " + mae);
-
- // Calculate R^2 as 1 - RSS/TSS
- double avg = 0.0;
-
- for (int i = 0; i < test.rowSize(); i++)
- avg += test.label(i);
-
- avg = avg / test.rowSize();
-
- double detCf = 0.0;
- double tss = 0.0;
-
- for (int i = 0; i < test.rowSize(); i++) {
- detCf += Math.pow(test.label(i) - labels[i], 2.0);
- tss += Math.pow(test.label(i) - avg, 2.0);
- }
-
- detCf = 1 - detCf / tss;
-
- System.out.println("\n>>> R^2 " + detCf);
- }
- catch (URISyntaxException | IOException e) {
- e.printStackTrace();
- System.out.println("\n>>> Unexpected exception, check resources: " + e);
- }
- finally {
- System.out.println("\n>>> kNN regression example completed.");
- }
- });
-
- igniteThread.start();
- igniteThread.join();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/knn/regression/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/regression/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/knn/regression/package-info.java
deleted file mode 100644
index e7ac336..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/regression/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. -->
- * kNN regression examples.
- */
-package org.apache.ignite.examples.ml.knn.regression;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index ebac2b1..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/CholeskyDecompositionExample.java
+++ /dev/null
@@ -1,80 +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.examples.ml.math.decompositions;
-
-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}.
- */
-public class CholeskyDecompositionExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println(">>> Cholesky decomposition example started.");
- // Let's compute a Cholesky decomposition of Hermitian matrix m:
- // m = l l^{*}, where
- // l is a lower triangular matrix
- // l^{*} is its conjugate transpose
-
- DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(new double[][] {
- {2.0d, -1.0d, 0.0d},
- {-1.0d, 2.0d, -1.0d},
- {0.0d, -1.0d, 2.0d}
- });
- System.out.println("\n>>> Matrix m for decomposition: ");
- Tracer.showAscii(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);
- System.out.println("\n>>> Made decomposition m = l * l^{*}.");
- System.out.println(">>> Matrix l is ");
- Tracer.showAscii(dec.getL());
- System.out.println(">>> Matrix l^{*} is ");
- Tracer.showAscii(dec.getLT());
-
- Matrix bs = new DenseLocalOnHeapMatrix(new double[][] {
- {4.0, -6.0, 7.0},
- {1.0, 1.0, 1.0}
- }).transpose();
- System.out.println("\n>>> Solving systems of linear equations of the form m x = b for various bs represented by columns of matrix");
- Tracer.showAscii(bs);
- Matrix sol = dec.solve(bs);
-
- System.out.println("\n>>> List of solutions: ");
- for (int i = 0; i < sol.columnSize(); i++)
- Tracer.showAscii(sol.viewColumn(i));
-
- System.out.println("\n>>> Cholesky decomposition example completed.");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index cda37f4..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/EigenDecompositionExample.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.examples.ml.math.decompositions;
-
-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}.
- */
-public class EigenDecompositionExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println(">>> Eigen decomposition example started.");
-
- // Let's compute EigenDecomposition for some square (n x n) matrix m with real eigenvalues:
- // m = v d v^{-1}, where d is diagonal matrix having eigenvalues of m on diagonal
- // and v is matrix where i-th column is eigenvector for i-th eigenvalue (i from 0 to n - 1)
- DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(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}
- });
- System.out.println("\n>>> Matrix m for decomposition: ");
- Tracer.showAscii(m);
-
- EigenDecomposition dec = new EigenDecomposition(m);
- System.out.println("\n>>> Made decomposition.");
- System.out.println(">>> Matrix getV is ");
- Tracer.showAscii(dec.getV());
- System.out.println(">>> Matrix getD is ");
- Tracer.showAscii(dec.getD());
-
- // From this decomposition we, for example, can easily compute determinant of matrix m
- // det (m) = det (v d v^{-1}) =
- // det(v) det (d) det(v^{-1}) =
- // det(v) det(v)^{-1} det(d) =
- // det (d) =
- // product of diagonal elements of d =
- // product of eigenvalues
- double det = dec.getRealEigenValues().foldMap(Functions.MULT, Functions.IDENTITY, 1.0);
- System.out.println("\n>>> Determinant is " + det);
-
- System.out.println("\n>>> Eigen decomposition example completed.");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index a815047..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/LUDecompositionExample.java
+++ /dev/null
@@ -1,83 +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.examples.ml.math.decompositions;
-
-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}.
- */
-public class LUDecompositionExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println(">>> LU decomposition example started.");
- // Let's compute a LU decomposition for some (n x n) matrix m:
- // m = p l u, where
- // p is an (n x n) is a row-permutation matrix
- // l is a (n x n) lower triangular matrix
- // u is a (n x n) upper triangular matrix
-
- DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(new double[][] {
- {1.0d, 1.0d, -1.0d},
- {1.0d, -2.0d, 3.0d},
- {2.0d, 3.0d, 1.0d}
- });
- System.out.println("\n>>> Matrix m for decomposition: ");
- Tracer.showAscii(m);
-
- // This decomposition is useful when dealing with systems of linear equations.
- // (see https://en.wikipedia.org/wiki/LU_decomposition)
- // suppose we want to solve system
- // m x = b for various bs. Then after we computed LU decomposition, we can feed various bs
- // as a matrix of the form
- // (b1, b2, ..., bm)
- // to the method LUDecomposition::solve which returns solutions in the form
- // (sol1, sol2, ..., solm)
-
- LUDecomposition dec = new LUDecomposition(m);
- System.out.println("\n>>> Made decomposition.");
- System.out.println(">>> Matrix getL is ");
- Tracer.showAscii(dec.getL());
- System.out.println(">>> Matrix getU is ");
- Tracer.showAscii(dec.getU());
- System.out.println(">>> Matrix getP is ");
- Tracer.showAscii(dec.getP());
-
- Matrix bs = new DenseLocalOnHeapMatrix(new double[][] {
- {4.0, -6.0, 7.0},
- {1.0, 1.0, 1.0}
- });
- System.out.println("\n>>> Matrix to solve: ");
- Tracer.showAscii(bs);
-
- Matrix sol = dec.solve(bs.transpose());
-
- System.out.println("\n>>> List of solutions: ");
- for (int i = 0; i < sol.columnSize(); i++)
- Tracer.showAscii(sol.viewColumn(i));
-
- System.out.println("\n>>> LU decomposition example completed.");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/QRDecompositionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/QRDecompositionExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/QRDecompositionExample.java
deleted file mode 100644
index bed99d1..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/QRDecompositionExample.java
+++ /dev/null
@@ -1,82 +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.examples.ml.math.decompositions;
-
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.Tracer;
-import org.apache.ignite.ml.math.decompositions.QRDecomposition;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-
-/**
- * Example of using {@link QRDecomposition}.
- */
-public class QRDecompositionExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println(">>> QR decomposition example started.");
- Matrix m = new DenseLocalOnHeapMatrix(new double[][] {
- {2.0d, -1.0d, 0.0d},
- {-1.0d, 2.0d, -1.0d},
- {0.0d, -1.0d, 2.0d}
- });
-
- System.out.println("\n>>> Input matrix:");
- Tracer.showAscii(m);
-
- QRDecomposition dec = new QRDecomposition(m);
- System.out.println("\n>>> Value for full rank in decomposition: [" + dec.hasFullRank() + "].");
-
- Matrix q = dec.getQ();
- Matrix r = dec.getR();
-
- System.out.println("\n>>> Orthogonal matrix Q:");
- Tracer.showAscii(q);
- System.out.println("\n>>> Upper triangular matrix R:");
- Tracer.showAscii(r);
-
- Matrix qSafeCp = safeCopy(q);
-
- Matrix identity = qSafeCp.times(qSafeCp.transpose());
-
- System.out.println("\n>>> Identity matrix obtained from Q:");
- Tracer.showAscii(identity);
-
- Matrix recomposed = qSafeCp.times(r);
-
- System.out.println("\n>>> Recomposed input matrix:");
- Tracer.showAscii(recomposed);
-
- Matrix sol = dec.solve(new DenseLocalOnHeapMatrix(3, 10));
-
- System.out.println("\n>>> Solved matrix:");
- Tracer.showAscii(sol);
-
- dec.destroy();
-
- System.out.println("\n>>> QR decomposition example completed.");
- }
-
- /** */
- private static Matrix safeCopy(Matrix orig) {
- return new DenseLocalOnHeapMatrix(orig.rowSize(), orig.columnSize()).assign(orig);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index 81406ae..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/SingularValueDecompositionExample.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.examples.ml.math.decompositions;
-
-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}.
- */
-public class SingularValueDecompositionExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println(">>> Singular value decomposition (SVD) example started.");
-
- // Let's compute a SVD of (l x k) matrix m. This decomposition can be thought as extension of EigenDecomposition to
- // rectangular matrices. The factorization we get is following:
- // m = u * s * v^{*}, where
- // u is a real or complex unitary matrix
- // s is a rectangular diagonal matrix with non-negative real numbers on diagonal (this numbers are singular values of m)
- // v is a real or complex unitary matrix
- // If m is real then u and v are also real.
- // Complex case is not supported for the moment.
- DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(new double[][] {
- {1.0d, 0.0d, 0.0d, 0.0d, 2.0d},
- {0.0d, 0.0d, 3.0d, 0.0d, 0.0d},
- {0.0d, 0.0d, 0.0d, 0.0d, 0.0d},
- {0.0d, 2.0d, 0.0d, 0.0d, 0.0d}
- });
- System.out.println("\n>>> Matrix m for decomposition: ");
- Tracer.showAscii(m);
-
- SingularValueDecomposition dec = new SingularValueDecomposition(m);
- System.out.println("\n>>> Made decomposition m = u * s * v^{*}.");
- System.out.println(">>> Matrix u is ");
- Tracer.showAscii(dec.getU());
- System.out.println(">>> Matrix s is ");
- Tracer.showAscii(dec.getS());
- System.out.println(">>> Matrix v is ");
- Tracer.showAscii(dec.getV());
-
- // This decomposition can in particular help with solving problem of finding x minimizing 2-norm of m x such
- // that 2-norm of x is 1. It appears that it is the right singular vector corresponding to minimal singular
- // value, which is always last.
- System.out.println("\n>>> Vector x minimizing 2-norm of m x such that 2 norm of x is 1: ");
- Tracer.showAscii(dec.getV().viewColumn(dec.getSingularValues().length - 1));
-
- System.out.println("\n>>> Singular value decomposition (SVD) example completed.");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/decompositions/package-info.java
deleted file mode 100644
index 644f8ba..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/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. -->
- * Core algebra decomposition examples.
- */
-package org.apache.ignite.examples.ml.math.decompositions;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index a7cbaab..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/CacheMatrixExample.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.examples.ml.math.matrix;
-
-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.examples.ml.math.vector.CacheVectorExample;
-import org.apache.ignite.ml.math.IdentityValueMapper;
-import org.apache.ignite.ml.math.Tracer;
-import org.apache.ignite.ml.math.distributed.MatrixKeyMapper;
-import org.apache.ignite.ml.math.distributed.ValueMapper;
-import org.apache.ignite.ml.math.functions.Functions;
-import org.apache.ignite.ml.math.impls.matrix.CacheMatrix;
-
-/**
- * Example that demonstrates how to use {@link CacheMatrix}.
- *
- * Basically CacheMatrix is view over existing data in cache. So we have {@link MatrixKeyMapper} and {@link ValueMapper}
- * for this purpose. A {@link MatrixKeyMapper} allows us to map matrix indices to cache keys. And a {@link ValueMapper}
- * allows us map cache object to matrix elements - doubles.
- *
- * In this example we use simple flat mapping for keys and {@link IdentityValueMapper} for cache objects
- * because they are Doubles.
- *
- * @see CacheVectorExample
- */
-public class CacheMatrixExample {
- /** */ private static final String CACHE_NAME = CacheMatrixExample.class.getSimpleName();
- /** */ private static final int ROWS = 3;
- /** */ private static final int COLS = 3;
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> CacheMatrix example started.");
-
- CacheConfiguration<Integer, Double> cfg = new CacheConfiguration<>();
-
- cfg.setName(CACHE_NAME);
-
- try (IgniteCache<Integer, Double> cache = ignite.getOrCreateCache(cfg)) {
- double[][] testValues = {{1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {1.0, 1.0, 1.0}};
-
- ValueMapper valMapper = new IdentityValueMapper();
-
- // Map matrix element indices to cache keys.
- MatrixKeyMapper<Integer> keyMapper = new MatrixKeyMapper<Integer>() {
- @Override public Integer apply(int x, int y) {
- return x * COLS + y;
- }
-
- @Override public boolean isValid(Integer integer) {
- return integer >= 0 && integer < COLS * ROWS;
- }
- };
-
- // Create cache matrix.
- CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(ROWS, COLS, cache, keyMapper, valMapper);
-
- cacheMatrix.assign(testValues);
-
- Tracer.showAscii(cacheMatrix);
-
- // Find all positive elements.
- Integer nonZeroes = cacheMatrix.foldMap((o, aDouble) -> {
- if (aDouble > 0)
- return o + 1;
- return o;
- }, Functions.IDENTITY, 0);
-
- System.out.println("Quantity of non zeroes elements is " + nonZeroes.intValue());
-
- System.out.println(">>>");
- System.out.println(">>> Finished executing Ignite \"CacheMatrix\" example.");
- System.out.println(">>> Lower triangular matrix 3x3 have only 6 positive elements.");
- System.out.println(">>>");
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index 542fbdc..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.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.examples.ml.math.matrix;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Arrays;
-import org.apache.ignite.ml.math.MatrixStorage;
-import org.apache.ignite.ml.math.StorageConstants;
-import org.apache.ignite.ml.math.impls.storage.matrix.ArrayMatrixStorage;
-import org.apache.ignite.ml.math.util.MatrixUtil;
-
-/**
- * Example matrix storage implementation, modeled after {@link ArrayMatrixStorage}.
- */
-class ExampleMatrixStorage implements MatrixStorage {
- /** Backing data array. */
- private double[][] data;
- /** Amount of rows in a matrix storage. */
- private int rows;
- /** Amount of columns in a matrix storage. */
- private int cols;
-
- /**
- *
- */
- public ExampleMatrixStorage() {
- // No-op.
- }
-
- /**
- * @param rows Amount of rows in a matrix storage.
- * @param cols Amount of columns in a matrix storage.
- */
- ExampleMatrixStorage(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.
- */
- ExampleMatrixStorage(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 int storageMode() {
- // This value indicate that we store matrix data by rows.
- return StorageConstants.ROW_STORAGE_MODE;
- }
-
- /** {@inheritDoc} */
- @Override public int accessMode() {
- return StorageConstants.RANDOM_ACCESS_MODE;
- }
-
- /** {@inheritDoc} */
- @Override public boolean isArrayBased() {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public double[] data() {
- return MatrixUtil.flatten(data, StorageConstants.ROW_STORAGE_MODE);
- }
-
- /** {@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;
-
- ExampleMatrixStorage that = (ExampleMatrixStorage)o;
-
- return Arrays.deepEquals(data, that.data);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index 3b4f27d..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixCustomStorageExample.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.examples.ml.math.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.impls.matrix.AbstractMatrix;
-import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
-
-/**
- * This example shows how to create custom {@link Matrix} based on custom {@link MatrixStorage}.
- */
-public final class MatrixCustomStorageExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> Matrix API usage example started.");
-
- System.out.println("\n>>> Creating a matrix to be transposed.");
- double[][] data = new double[][] {{1, 2, 3}, {4, 5, 6}};
- Matrix m = new MatrixCustomStorage(data);
- Matrix transposed = m.transpose();
-
- System.out.println(">>> Matrix: ");
- MatrixExampleUtil.print(m);
- System.out.println(">>> Transposed matrix: ");
- MatrixExampleUtil.print(transposed);
-
- MatrixExampleUtil.verifyTransposition(m, transposed);
-
- System.out.println("\n>>> Creating matrices to be multiplied.");
- double[][] data1 = new double[][] {{1, 2}, {3, 4}};
- double[][] data2 = new double[][] {{5, 6}, {7, 8}};
-
- Matrix m1 = new MatrixCustomStorage(data1);
- Matrix m2 = new MatrixCustomStorage(data2);
- Matrix mult = m1.times(m2);
-
- System.out.println(">>> First matrix: ");
- MatrixExampleUtil.print(m1);
- System.out.println(">>> Second matrix: ");
- MatrixExampleUtil.print(m2);
- System.out.println(">>> Matrix product: ");
- MatrixExampleUtil.print(mult);
-
- System.out.println("\n>>> Calculating matrices determinants.");
- double det1 = m1.determinant();
- double det2 = m2.determinant();
- double detMult = mult.determinant();
- boolean detMultIsAsExp = Math.abs(detMult - det1 * det2) < 0.0001d;
-
- System.out.println(">>> First matrix determinant: [" + det1 + "].");
- System.out.println(">>> Second matrix determinant: [" + det2 + "].");
- System.out.println(">>> Matrix product determinant: [" + detMult
- + "], equals product of two other matrices determinants: [" + detMultIsAsExp + "].");
-
- System.out.println("Determinant of product matrix [" + detMult
- + "] should be equal to product of determinants [" + (det1 * det2) + "].");
-
- System.out.println("\n>>> Matrix API usage example completed.");
- }
-
- /**
- * Example of vector with custom storage, modeled after
- * {@link org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix}.
- */
- static class MatrixCustomStorage extends AbstractMatrix {
- /**
- *
- */
- public MatrixCustomStorage() {
- // No-op.
- }
-
- /**
- * @param rows Amount of rows in a matrix.
- * @param cols Amount of columns in a matrix.
- */
- MatrixCustomStorage(int rows, int cols) {
- assert rows > 0;
- assert cols > 0;
-
- setStorage(new ExampleMatrixStorage(rows, cols));
- }
-
- /**
- * @param mtx Source matrix.
- */
- MatrixCustomStorage(double[][] mtx) {
- assert mtx != null;
-
- setStorage(new ExampleMatrixStorage(mtx));
- }
-
- /**
- * @param orig original matrix to be copied.
- */
- private MatrixCustomStorage(MatrixCustomStorage orig) {
- assert orig != null;
-
- setStorage(new ExampleMatrixStorage(orig.rowSize(), orig.columnSize()));
-
- assign(orig);
- }
-
- /** {@inheritDoc} */
- @Override public Matrix copy() {
- return new MatrixCustomStorage(this);
- }
-
- /** {@inheritDoc} */
- @Override public Matrix like(int rows, int cols) {
- return new MatrixCustomStorage(rows, cols);
- }
-
- /** {@inheritDoc} */
- @Override public Vector likeVector(int crd) {
- return new DenseLocalOnHeapVector(crd);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index 755f36c..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixExample.java
+++ /dev/null
@@ -1,79 +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.examples.ml.math.matrix;
-
-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.
- */
-public final class MatrixExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> Basic Matrix API usage example started.");
-
- System.out.println("\n>>> Creating a matrix to be transposed.");
- double[][] data = new double[][] {{1, 2, 3}, {4, 5, 6}};
- Matrix m = new DenseLocalOnHeapMatrix(data);
- Matrix transposed = m.transpose();
-
- System.out.println(">>> Matrix: ");
- MatrixExampleUtil.print(m);
- System.out.println(">>> Transposed matrix: ");
- MatrixExampleUtil.print(transposed);
-
- MatrixExampleUtil.verifyTransposition(m, transposed);
-
- System.out.println("\n>>> Creating matrices to be multiplied.");
- double[][] data1 = new double[][] {{1, 2}, {3, 4}};
- double[][] data2 = new double[][] {{5, 6}, {7, 8}};
-
- Matrix m1 = new DenseLocalOnHeapMatrix(data1);
- Matrix m2 = new DenseLocalOnHeapMatrix(data2);
- Matrix mult = m1.times(m2);
-
- System.out.println(">>> First matrix: ");
- MatrixExampleUtil.print(m1);
- System.out.println(">>> Second matrix: ");
- MatrixExampleUtil.print(m2);
- System.out.println(">>> Matrix product: ");
- MatrixExampleUtil.print(mult);
-
- System.out.println("\n>>> Calculating matrices determinants.");
- double det1 = m1.determinant();
- double det2 = m2.determinant();
- double detMult = mult.determinant();
- boolean detMultIsAsExp = Math.abs(detMult - det1 * det2) < 0.0001d;
-
- System.out.println(">>> First matrix determinant: [" + det1 + "].");
- System.out.println(">>> Second matrix determinant: [" + det2 + "].");
- System.out.println(">>> Matrix product determinant: [" + detMult
- + "], equals product of two other matrices determinants: [" + detMultIsAsExp + "].");
-
- System.out.println("Determinant of product matrix [" + detMult
- + "] should be equal to product of determinants [" + (det1 * det2) + "].");
-
- System.out.println("\n>>> Basic Matrix API usage example completed.");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index af12e15..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/MatrixExampleUtil.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.examples.ml.math.matrix;
-
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.Tracer;
-
-/**
- * Utility functions for {@link Matrix} API examples.
- */
-class MatrixExampleUtil {
- /**
- * Verifies matrix transposition.
- *
- * @param m Original matrix.
- * @param transposed Transposed matrix.
- */
- static void verifyTransposition(Matrix m, Matrix transposed) {
- for (int row = 0; row < m.rowSize(); row++)
- for (int col = 0; col < m.columnSize(); col++) {
- double val = m.get(row, col);
- double valTransposed = transposed.get(col, row);
-
- assert val == valTransposed : "Values not equal at (" + row + "," + col
- + "), original: " + val + " transposed: " + valTransposed;
- }
- }
-
- /**
- * Prints matrix values to console.
- *
- * @param m Matrix to print.
- */
- static void print(Matrix m) {
- Tracer.showAscii(m);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index db01794..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/OffHeapMatrixExample.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.examples.ml.math.matrix;
-
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOffHeapMatrix;
-
-/**
- * This example shows how to create and use off-heap versions of {@link Matrix}.
- */
-public final class OffHeapMatrixExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> Off-heap matrix API usage example started.");
-
- System.out.println("\n>>> Creating a matrix to be transposed.");
- double[][] data = new double[][] {{1, 2, 3}, {4, 5, 6}};
- Matrix m = new DenseLocalOffHeapMatrix(data.length, data[0].length);
- m.assign(data);
- Matrix transposed = m.transpose();
-
- System.out.println(">>> Matrix: ");
- MatrixExampleUtil.print(m);
- System.out.println(">>> Transposed matrix: ");
- MatrixExampleUtil.print(transposed);
-
- MatrixExampleUtil.verifyTransposition(m, transposed);
-
- System.out.println("\n>>> Creating matrices to be multiplied.");
- double[][] data1 = new double[][] {{1, 2}, {3, 4}};
- double[][] data2 = new double[][] {{5, 6}, {7, 8}};
-
- Matrix m1 = new DenseLocalOffHeapMatrix(data1.length, data1[0].length);
- Matrix m2 = new DenseLocalOffHeapMatrix(data2.length, data2[0].length);
-
- m1.assign(data1);
- m2.assign(data2);
-
- Matrix mult = m1.times(m2);
-
- System.out.println(">>> First matrix: ");
- MatrixExampleUtil.print(m1);
- System.out.println(">>> Second matrix: ");
- MatrixExampleUtil.print(m2);
- System.out.println(">>> Matrix product: ");
- MatrixExampleUtil.print(mult);
-
- System.out.println("\n>>> Calculating matrices determinants.");
- double det1 = m1.determinant();
- double det2 = m2.determinant();
- double detMult = mult.determinant();
- boolean detMultIsAsExp = Math.abs(detMult - det1 * det2) < 0.0001d;
-
- System.out.println(">>> First matrix determinant: [" + det1 + "].");
- System.out.println(">>> Second matrix determinant: [" + det2 + "].");
- System.out.println(">>> Matrix product determinant: [" + detMult
- + "], equals product of two other matrices determinants: [" + detMultIsAsExp + "].");
-
- System.out.println("Determinant of product matrix [" + detMult
- + "] should be equal to product of determinants [" + (det1 * det2) + "].");
-
- System.out.println("\n>>> Off-heap matrix API usage example completed.");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index c73a8a0..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/SparseDistributedMatrixExample.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.examples.ml.math.matrix;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.StorageConstants;
-import org.apache.ignite.ml.math.impls.matrix.CacheMatrix;
-import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
-import org.apache.ignite.thread.IgniteThread;
-
-/**
- * This example shows how to create and use {@link SparseDistributedMatrix} API.
- *
- * Unlike the {@link CacheMatrix} the {@link SparseDistributedMatrix} creates it's own cache.
- */
-public class SparseDistributedMatrixExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) throws InterruptedException {
- System.out.println();
- System.out.println(">>> Sparse distributed matrix API usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
- // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
- // because we create ignite cache internally.
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(), SparseDistributedMatrixExample.class.getSimpleName(), () -> {
-
- double[][] testValues = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
-
- System.out.println(">>> Create new SparseDistributedMatrix inside IgniteThread.");
- // Create SparseDistributedMatrix, new cache will be created automagically.
- SparseDistributedMatrix distributedMatrix = new SparseDistributedMatrix(testValues.length, testValues[0].length,
- StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
- distributedMatrix.assign(testValues);
-
- System.out.println("Sum of all matrix elements is " + distributedMatrix.sum());
-
- System.out.println(">>> Destroy SparseDistributedMatrix after using.");
- // Destroy internal cache.
- distributedMatrix.destroy();
- });
-
- igniteThread.start();
-
- igniteThread.join();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index a03688d..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/SparseMatrixExample.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.examples.ml.math.matrix;
-
-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.
- */
-public final class SparseMatrixExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> Sparse matrix API usage example started.");
-
- System.out.println("\n>>> Creating a matrix to be transposed.");
- double[][] data = new double[][] {{1, 2, 3}, {4, 5, 6}};
- Matrix m = new SparseLocalOnHeapMatrix(data.length, data[0].length);
- m.assign(data);
- Matrix transposed = m.transpose();
-
- System.out.println(">>> Matrix: ");
- MatrixExampleUtil.print(m);
- System.out.println(">>> Transposed matrix: ");
- MatrixExampleUtil.print(transposed);
-
- MatrixExampleUtil.verifyTransposition(m, transposed);
-
- System.out.println("\n>>> Creating matrices to be multiplied.");
- double[][] data1 = new double[][] {{1, 2}, {3, 4}};
- double[][] data2 = new double[][] {{5, 6}, {7, 8}};
-
- Matrix m1 = new SparseLocalOnHeapMatrix(data1.length, data1[0].length);
- Matrix m2 = new SparseLocalOnHeapMatrix(data2.length, data2[0].length);
-
- m1.assign(data1);
- m2.assign(data2);
-
- Matrix mult = m1.times(m2);
-
- System.out.println(">>> First matrix: ");
- MatrixExampleUtil.print(m1);
- System.out.println(">>> Second matrix: ");
- MatrixExampleUtil.print(m2);
- System.out.println(">>> Matrix product: ");
- MatrixExampleUtil.print(mult);
-
- System.out.println("\n>>> Calculating matrices determinants.");
- double det1 = m1.determinant();
- double det2 = m2.determinant();
- double detMult = mult.determinant();
- boolean detMultIsAsExp = Math.abs(detMult - det1 * det2) < 0.0001d;
-
- System.out.println(">>> First matrix determinant: [" + det1 + "].");
- System.out.println(">>> Second matrix determinant: [" + det2 + "].");
- System.out.println(">>> Matrix product determinant: [" + detMult
- + "], equals product of two other matrices determinants: [" + detMultIsAsExp + "].");
-
- System.out.println("Determinant of product matrix [" + detMult
- + "] should be equal to product of determinants [" + (det1 * det2) + "].");
-
- System.out.println("\n>>> Sparse matrix API usage example completed.");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/package-info.java
deleted file mode 100644
index 354119a..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/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. -->
- * Core algebra matrix examples.
- */
-package org.apache.ignite.examples.ml.math.matrix;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/math/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/package-info.java
deleted file mode 100644
index 52344bf..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/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. -->
- * Core algebra examples.
- */
-package org.apache.ignite.examples.ml.math;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index c14335a..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/tracer/TracerExample.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.examples.ml.math.tracer;
-
-import java.awt.Color;
-import java.io.IOException;
-import org.apache.ignite.ml.math.Tracer;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-
-/**
- * Example of using {@link Tracer} utility API.
- */
-public class TracerExample {
- /**
- * Double to color mapper example.
- */
- private static final Tracer.ColorMapper COLOR_MAPPER = d -> {
- if (d <= 1.5)
- return Color.RED;
- else if (d <= 2.5)
- return Color.GREEN;
- else
- return Color.BLUE;
- };
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) throws IOException {
- System.out.println(">>> Tracer utility example started.");
-
- // Tracer is a simple utility class that allows pretty-printing of matrices/vectors.
- DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(new double[][] {
- {1.12345, 2.12345},
- {3.12345, 4.12345}
- });
-
- System.out.println("\n>>> Tracer output to console in ASCII.");
- Tracer.showAscii(m, "%.3g");
-
- System.out.println("\n>>> Tracer output to browser in HTML.");
- Tracer.showHtml(m, COLOR_MAPPER, true);
-
- System.out.println("\n>>> Tracer utility example completed.");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/math/tracer/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/tracer/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/tracer/package-info.java
deleted file mode 100644
index 574e598..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/tracer/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. -->
- * Core algebra tracer example.
- */
-package org.apache.ignite.examples.ml.math.tracer;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index 4253ac1..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/CacheVectorExample.java
+++ /dev/null
@@ -1,109 +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.examples.ml.math.vector;
-
-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.ml.math.IdentityValueMapper;
-import org.apache.ignite.ml.math.distributed.ValueMapper;
-import org.apache.ignite.ml.math.distributed.VectorKeyMapper;
-import org.apache.ignite.ml.math.impls.vector.CacheVector;
-
-/**
- * This example shows how to use {@link CacheVector} API.
- * <p>
- * Basically CacheVector is a view over existing data in cache. So we have {@link VectorKeyMapper} and
- * {@link ValueMapper} for this purpose. A {@link VectorKeyMapper} allows us to map vector indices to cache keys.
- * And a {@link ValueMapper} allows us map cache object to vector elements - doubles.</p>
- * <p>
- * In this example we use simple flat mapping for keys and {@link IdentityValueMapper} for cache
- * objects because they are Doubles.</p>
- */
-public class CacheVectorExample {
- /** */
- private static final String CACHE_NAME = CacheVectorExample.class.getSimpleName();
-
- /** */
- private static final int CARDINALITY = 10;
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- @SuppressWarnings("unchecked")
- public static void main(String[] args) {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> CacheVector example started.");
-
- CacheConfiguration<Integer, Double> cfg = new CacheConfiguration<>();
-
- cfg.setName(CACHE_NAME);
-
- try (IgniteCache<Integer, Double> cache = ignite.getOrCreateCache(cfg)) {
- double[] testValues1 = {1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
- double[] testValues2 = {0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
-
- ValueMapper valMapper = new IdentityValueMapper();
-
- // Map vector element index to cache keys.
- VectorKeyMapper<Integer> keyMapper1 = new VectorKeyMapper<Integer>() {
- @Override public Integer apply(int i) {
- return i;
- }
-
- @Override public boolean isValid(Integer integer) {
- return integer >= 0 && CARDINALITY > integer;
- }
- };
-
- // Map vector element index to cache keys with shift.
- VectorKeyMapper<Integer> keyMapper2 = new VectorKeyMapper<Integer>() {
- @Override public Integer apply(int i) {
- return i + CARDINALITY;
- }
-
- @Override public boolean isValid(Integer integer) {
- return integer >= 0 && CARDINALITY > integer;
- }
- };
-
- // Create two cache vectors over one cache.
- CacheVector cacheVector1 = new CacheVector(CARDINALITY, cache, keyMapper1, valMapper);
- System.out.println(">>> First cache vector created.");
-
- CacheVector cacheVector2 = new CacheVector(CARDINALITY, cache, keyMapper2, valMapper);
- System.out.println(">>> Second cache vector created.");
-
- cacheVector1.assign(testValues1);
- cacheVector2.assign(testValues2);
-
- // Dot product for orthogonal vectors is 0.0.
- assert cacheVector1.dot(cacheVector2) == 0.0;
-
- System.out.println(">>>");
- System.out.println(">>> Finished executing Ignite \"CacheVector\" example.");
- System.out.println(">>> Dot product is 0.0 for orthogonal vectors.");
- System.out.println(">>>");
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index 0289a8c..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/ExampleVectorStorage.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.examples.ml.math.vector;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Arrays;
-
-import org.apache.ignite.ml.math.VectorStorage;
-import org.apache.ignite.ml.math.impls.storage.vector.ArrayVectorStorage;
-
-/**
- * Example vector storage, modeled after {@link ArrayVectorStorage}.
- */
-class ExampleVectorStorage implements VectorStorage {
- /** */
- private double[] data;
-
- /**
- * IMPL NOTE required by Externalizable.
- */
- public ExampleVectorStorage() {
- // No-op.
- }
-
- /**
- * @param data Backing data array.
- */
- ExampleVectorStorage(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;
-
- ExampleVectorStorage that = (ExampleVectorStorage)obj;
-
- return Arrays.equals(data, (that.data));
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index e38f62c..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/OffHeapVectorExample.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.examples.ml.math.vector;
-
-import java.util.Arrays;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.impls.vector.DenseLocalOffHeapVector;
-
-/**
- * This example shows how to create and use off-heap versions of {@link Vector}.
- */
-public final class OffHeapVectorExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> Off-heap vector API usage example started.");
-
- System.out.println("\n>>> Creating perpendicular off-heap vectors.");
- double[] data1 = new double[] {1, 0, 3, 0, 5, 0};
- double[] data2 = new double[] {0, 2, 0, 4, 0, 6};
-
- Vector v1 = new DenseLocalOffHeapVector(data1.length);
- Vector v2 = new DenseLocalOffHeapVector(data2.length);
-
- v1.assign(data1);
- v2.assign(data2);
-
- System.out.println(">>> First vector: " + Arrays.toString(data1));
- System.out.println(">>> Second vector: " + Arrays.toString(data2));
-
- double dotProduct = v1.dot(v2);
- boolean dotProductIsAsExp = dotProduct == 0;
-
- System.out.println("\n>>> Dot product of vectors: [" + dotProduct
- + "], it is 0 as expected: [" + dotProductIsAsExp + "].");
-
- assert dotProductIsAsExp : "Expect dot product of perpendicular vectors to be 0.";
-
- Vector hypotenuse = v1.plus(v2);
-
- System.out.println("\n>>> Hypotenuse (sum of vectors): " + Arrays.toString(hypotenuse.getStorage().data()));
-
- double lenSquared1 = v1.getLengthSquared();
- double lenSquared2 = v2.getLengthSquared();
- double lenSquaredHypotenuse = hypotenuse.getLengthSquared();
-
- boolean lenSquaredHypotenuseIsAsExp = lenSquaredHypotenuse == lenSquared1 + lenSquared2;
-
- System.out.println(">>> Squared length of first vector: [" + lenSquared1 + "].");
- System.out.println(">>> Squared length of second vector: [" + lenSquared2 + "].");
- System.out.println(">>> Squared length of hypotenuse: [" + lenSquaredHypotenuse
- + "], equals sum of squared lengths of two original vectors as expected: ["
- + lenSquaredHypotenuseIsAsExp + "].");
-
- assert lenSquaredHypotenuseIsAsExp : "Expect squared length of hypotenuse to be as per Pythagorean theorem.";
-
- System.out.println("\n>>> Off-heap vector API usage example completed.");
- }
-}
[02/11] ignite git commit: IGNITE-7203 Java 8 by default
Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java
new file mode 100644
index 0000000..6cb2200
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.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.yardstick.ml.math;
+
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.thread.IgniteThread;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+import org.apache.ignite.yardstick.ml.DataChanger;
+
+/**
+ * Ignite benchmark that performs ML Grid operations of matrix multiplication.
+ */
+abstract class IgniteAbstractMatrixMulBenchmark extends IgniteAbstractBenchmark {
+ /** */
+ private static final int SIZE = 1 << 7;
+
+ /** */
+ private double[][] dataSquare = createAndFill(SIZE, SIZE);
+
+ /** */
+ private double[][] dataRect1 = createAndFill(SIZE / 2, SIZE);
+
+ /** */
+ private double[][] dataRect2 = createAndFill(SIZE, SIZE / 2);
+
+ /** */
+ @SuppressWarnings("unused")
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final double scale = DataChanger.next();
+
+ // Create IgniteThread, we may want to work with SparseDistributedMatrix inside IgniteThread
+ // because we create ignite cache internally.
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ this.getClass().getSimpleName(), new Runnable() {
+ /** {@inheritDoc} */
+ @Override public void run() {
+ Matrix m1, m2, m3, m4, m5, m6;
+
+ Matrix m7 = times(m1 = createAndFill(dataSquare, scale), m2 = createAndFill(dataSquare, scale));
+ Matrix m8 = times(m3 = createAndFill(dataRect1, scale), m4 = createAndFill(dataRect2, scale));
+ Matrix m9 = times(m5 = createAndFill(dataRect2, scale), m6 = createAndFill(dataRect1, scale));
+
+ m1.destroy();
+ m2.destroy();
+ m3.destroy();
+ m4.destroy();
+ m5.destroy();
+ m6.destroy();
+ m7.destroy();
+ m8.destroy();
+ m9.destroy();
+ }
+ });
+
+ igniteThread.start();
+
+ igniteThread.join();
+
+ return true;
+ }
+
+ /**
+ * Override in subclasses with specific type Matrix. Note that size of result matrix may be smaller than requested.
+ *
+ * @param rowSize Requested row size.
+ * @param colSize Requested column size.
+ * @return Matrix of desired type of size that doesn't exceed requested.
+ */
+ abstract Matrix newMatrix(int rowSize, int colSize);
+
+ /** Override in subclasses if needed. */
+ Matrix times(Matrix m1, Matrix m2) {
+ return m1.times(m2);
+ }
+
+ /** Override in subclasses if needed to account for smaller matrix size. */
+ Matrix createAndFill(double[][] data, double scale) {
+ // IMPL NOTE yardstick 0.8.3 fails to discover benchmark if we try to account for smaller size
+ // matrix by using method with lambda parameter here: assign((row, col) -> data[row][col]).
+ Matrix res = newMatrix(data.length, data[0].length).assign(data);
+
+ for (int i = 0; i < data.length && i < data[0].length; i++)
+ res.set(i, i, data[i][i] * scale);
+
+ return res;
+ }
+
+ /** */
+ private double[][] createAndFill(int rowSize, int colSize) {
+ double[][] data = new double[rowSize][colSize];
+
+ for (int i = 0; i < rowSize; i++)
+ for (int j = 0; j < colSize; j++)
+ data[i][j] = -0.5d + Math.random();
+
+ return data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java
new file mode 100644
index 0000000..027b515
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.ml.math;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOffHeapMatrix;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteDenseLocalOffHeapMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
+ /** {@inheritDoc} */
+ @Override Matrix newMatrix(int rowSize, int colSize) {
+ return new DenseLocalOffHeapMatrix(rowSize, colSize);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java
new file mode 100644
index 0000000..6830130
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.ml.math;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteDenseLocalOnHeapMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
+ /** {@inheritDoc} */
+ @Override Matrix newMatrix(int rowSize, int colSize) {
+ return new DenseLocalOnHeapMatrix(rowSize, colSize);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java
new file mode 100644
index 0000000..8762620
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.ml.math;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.SparseBlockDistributedMatrix;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteSparseBlockDistributedMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
+ /** {@inheritDoc} */
+ @Override Matrix newMatrix(int rowSize, int colSize) {
+ return new SparseBlockDistributedMatrix(rowSize, colSize);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java
new file mode 100644
index 0000000..0f9d288
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.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.yardstick.ml.math;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
+
+/**
+ * Ignite benchmark that performs unoptimized matrix multiplication of {@link SparseDistributedMatrix}.
+ * For optimized benchmark refer {@link IgniteSparseBlockDistributedMatrixMulBenchmark}.
+ */
+@SuppressWarnings("unused")
+public class IgniteSparseDistributedMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
+ /** This benchmark is unacceptably slow without scaling down, see IGNITE-7097. */
+ private static final int SCALE_DOWN = 2;
+
+ /** {@inheritDoc} */
+ @Override Matrix newMatrix(int rowSize, int colSize) {
+ return new SparseDistributedMatrix(rowSize >> SCALE_DOWN, colSize >> SCALE_DOWN,
+ StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+ }
+
+ /** {@inheritDoc} */
+ @Override Matrix createAndFill(double[][] data, double scale) {
+ Matrix res = newMatrix(data.length, data[0].length);
+
+ for (int row = 0; row < res.rowSize(); row++)
+ for (int col = 0; col < res.columnSize(); col++)
+ res.set(row, col, row == col ? data[row][col] * scale : data[row][col]);
+
+ return res;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java
new file mode 100644
index 0000000..de2c99b
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.ml.math;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.SparseLocalOnHeapMatrix;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteSparseLocalMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
+ /** {@inheritDoc} */
+ @Override Matrix newMatrix(int rowSize, int colSize) {
+ return new SparseLocalOnHeapMatrix(rowSize, colSize);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/package-info.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/package-info.java
new file mode 100644
index 0000000..d37e967
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/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. -->
+ * ML Grid math benchmarks.
+ */
+package org.apache.ignite.yardstick.ml.math;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/package-info.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/package-info.java
new file mode 100644
index 0000000..4751f35
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/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. -->
+ * ML Grid benchmarks.
+ */
+package org.apache.ignite.yardstick.ml;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/IgniteOLSMultipleLinearRegressionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/IgniteOLSMultipleLinearRegressionBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/IgniteOLSMultipleLinearRegressionBenchmark.java
new file mode 100644
index 0000000..89b5471
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/IgniteOLSMultipleLinearRegressionBenchmark.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.yardstick.ml.regression;
+
+import java.util.Map;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.regressions.linear.LinearRegressionModel;
+import org.apache.ignite.ml.regressions.linear.LinearRegressionQRTrainer;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteOLSMultipleLinearRegressionBenchmark extends IgniteAbstractBenchmark {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ runLongly();
+
+ return true;
+ }
+
+ /**
+ * Based on OLSMultipleLinearRegressionTest#testLongly.
+ */
+ private void runLongly() {
+ // Y values are first, then independent vars
+ // Each row is one observation
+ double[][] data = new double[][] {
+ { 60323, 83.0, 234289, 2356, 1590, 107608, 1947 },
+ { 61122, 88.5, 259426, 2325, 1456, 108632, 1948 },
+ { 60171, 88.2, 258054, 3682, 1616, 109773, 1949 },
+ { 61187, 89.5, 284599, 3351, 1650, 110929, 1950 },
+ { 63221, 96.2, 328975, 2099, 3099, 112075, 1951 },
+ { 63639, 98.1, 346999, 1932, 3594, 113270, 1952 },
+ { 64989, 99.0, 365385, 1870, 3547, 115094, 1953 },
+ { 63761, 100.0, 363112, 3578, 3350, 116219, 1954 },
+ { 66019, 101.2, 397469, 2904, 3048, 117388, 1955 },
+ { 67857, 104.6, 419180, 2822, 2857, 118734, 1956 },
+ { 68169, 108.4, 442769, 2936, 2798, 120445, 1957 },
+ { 66513, 110.8, 444546, 4681, 2637, 121950, 1958 },
+ { 68655, 112.6, 482704, 3813, 2552, 123366, 1959 },
+ { 69564, 114.2, 502601, 3931, 2514, 125368, 1960 },
+ { 69331, 115.7, 518173, 4806, 2572, 127852, 1961 },
+ { 70551, 116.9, 554894, 4007, 2827, 130081, 1962 }
+ };
+
+ final int nobs = 16;
+ final int nvars = 6;
+
+ LinearRegressionQRTrainer trainer = new LinearRegressionQRTrainer();
+ LinearRegressionModel model = trainer.train(new DenseLocalOnHeapMatrix(data));
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/package-info.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/package-info.java
new file mode 100644
index 0000000..0a5dc1a
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/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. -->
+ * ML Grid regression benchmarks.
+ */
+package org.apache.ignite.yardstick.ml.regression;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeGiniBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeGiniBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeGiniBenchmark.java
new file mode 100644
index 0000000..f8a7c08
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeGiniBenchmark.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.ml.trees;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.apache.ignite.ml.trees.trainers.columnbased.contsplitcalcs.ContinuousSplitCalculators;
+import org.apache.ignite.ml.trees.trainers.columnbased.regcalcs.RegionCalculators;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.thread.IgniteThread;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteColumnDecisionTreeGiniBenchmark extends IgniteAbstractBenchmark {
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
+ // because we create ignite cache internally.
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ this.getClass().getSimpleName(), new Runnable() {
+ /** {@inheritDoc} */
+ @Override public void run() {
+ // IMPL NOTE originally taken from ColumnDecisionTreeTrainerTest#testCacheMixedGini
+ int totalPts = 1 << 10;
+ int featCnt = 2;
+
+ HashMap<Integer, Integer> catsInfo = new HashMap<>();
+ catsInfo.put(1, 3);
+
+ SplitDataGenerator<DenseLocalOnHeapVector> gen = new SplitDataGenerator<>(
+ featCnt, catsInfo, () -> new DenseLocalOnHeapVector(featCnt + 1)).
+ split(0, 1, new int[] {0, 2}).
+ split(1, 0, -10.0);
+
+ gen.testByGen(totalPts, ContinuousSplitCalculators.GINI.apply(ignite),
+ RegionCalculators.GINI, RegionCalculators.MEAN, ignite);
+ }
+ });
+
+ igniteThread.start();
+
+ igniteThread.join();
+
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeVarianceBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeVarianceBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeVarianceBenchmark.java
new file mode 100644
index 0000000..f9d417f
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeVarianceBenchmark.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.yardstick.ml.trees;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.apache.ignite.ml.trees.trainers.columnbased.contsplitcalcs.ContinuousSplitCalculators;
+import org.apache.ignite.ml.trees.trainers.columnbased.regcalcs.RegionCalculators;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.thread.IgniteThread;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteColumnDecisionTreeVarianceBenchmark extends IgniteAbstractBenchmark {
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
+ // because we create ignite cache internally.
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ this.getClass().getSimpleName(), new Runnable() {
+ /** {@inheritDoc} */
+ @Override public void run() {
+ // IMPL NOTE originally taken from ColumnDecisionTreeTrainerTest#testCacheMixed
+ int totalPts = 1 << 10;
+ int featCnt = 2;
+
+ HashMap<Integer, Integer> catsInfo = new HashMap<>();
+ catsInfo.put(1, 3);
+
+ SplitDataGenerator<DenseLocalOnHeapVector> gen
+ = new SplitDataGenerator<>(
+ featCnt, catsInfo, () -> new DenseLocalOnHeapVector(featCnt + 1)).
+ split(0, 1, new int[] {0, 2}).
+ split(1, 0, -10.0);
+
+ gen.testByGen(totalPts,
+ ContinuousSplitCalculators.VARIANCE, RegionCalculators.VARIANCE, RegionCalculators.MEAN, ignite);
+ }
+ });
+
+ igniteThread.start();
+
+ igniteThread.join();
+
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/SplitDataGenerator.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/SplitDataGenerator.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/SplitDataGenerator.java
new file mode 100644
index 0000000..f9117f4
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/SplitDataGenerator.java
@@ -0,0 +1,426 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.ml.trees;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+import java.util.stream.DoubleStream;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.MathIllegalArgumentException;
+import org.apache.ignite.ml.math.functions.IgniteFunction;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.apache.ignite.ml.structures.LabeledVectorDouble;
+import org.apache.ignite.ml.trees.ContinuousRegionInfo;
+import org.apache.ignite.ml.trees.ContinuousSplitCalculator;
+import org.apache.ignite.ml.trees.models.DecisionTreeModel;
+import org.apache.ignite.ml.trees.trainers.columnbased.ColumnDecisionTreeTrainer;
+import org.apache.ignite.ml.trees.trainers.columnbased.ColumnDecisionTreeTrainerInput;
+import org.apache.ignite.ml.trees.trainers.columnbased.MatrixColumnDecisionTreeTrainerInput;
+import org.apache.ignite.ml.util.Utils;
+
+/** */
+class SplitDataGenerator<V extends Vector> {
+ /** */
+ private static final Random rnd = new Random(12349L);
+
+ /** */
+ private static final double DELTA = 100.0;
+
+ /** Map of the form of (is categorical -> list of region indexes). */
+ private final Map<Boolean, List<Integer>> di;
+
+ /** List of regions. */
+ private final List<Region> regs;
+
+ /** Data of bounds of regions. */
+ private final Map<Integer, IgniteBiTuple<Double, Double>> boundsData;
+
+ /** */
+ private final Map<Integer, Integer> catFeaturesInfo;
+
+ /** Supplier of vectors. */
+ private final Supplier<V> supplier;
+
+ /** Features count. */
+ private final int featCnt;
+
+ /**
+ * Create SplitDataGenerator.
+ *
+ * @param featCnt Features count.
+ * @param catFeaturesInfo Information about categorical features in form of map (feature index -> categories
+ * count).
+ * @param supplier Supplier of vectors.
+ */
+ SplitDataGenerator(int featCnt, Map<Integer, Integer> catFeaturesInfo, Supplier<V> supplier) {
+ regs = new LinkedList<>();
+ boundsData = new HashMap<>();
+ this.supplier = supplier;
+ this.featCnt = featCnt;
+ this.catFeaturesInfo = catFeaturesInfo;
+
+ // Divide indexes into indexes of categorical coordinates and indexes of continuous coordinates.
+ di = IntStream.range(0, featCnt).
+ boxed().
+ collect(Collectors.partitioningBy(catFeaturesInfo::containsKey));
+
+ // Categorical coordinates info.
+ Map<Integer, CatCoordInfo> catCoords = new HashMap<>();
+ di.get(true).forEach(i -> {
+ BitSet bs = new BitSet();
+ bs.set(0, catFeaturesInfo.get(i));
+ catCoords.put(i, new CatCoordInfo(bs));
+ });
+
+ // Continuous coordinates info.
+ Map<Integer, ContCoordInfo> contCoords = new HashMap<>();
+ di.get(false).forEach(i -> {
+ contCoords.put(i, new ContCoordInfo());
+ boundsData.put(i, new IgniteBiTuple<>(-1.0, 1.0));
+ });
+
+ Region firstReg = new Region(catCoords, contCoords, 0);
+ regs.add(firstReg);
+ }
+
+ /** */
+ <D extends ContinuousRegionInfo> void testByGen(int totalPts,
+ IgniteFunction<ColumnDecisionTreeTrainerInput, ? extends ContinuousSplitCalculator<D>> calc,
+ IgniteFunction<ColumnDecisionTreeTrainerInput, IgniteFunction<DoubleStream, Double>> catImpCalc,
+ IgniteFunction<DoubleStream, Double> regCalc, Ignite ignite) {
+
+ List<IgniteBiTuple<Integer, V>> lst = points(totalPts, (i, rn) -> i).collect(Collectors.toList());
+
+ Collections.shuffle(lst, rnd);
+
+ SparseDistributedMatrix m = new SparseDistributedMatrix(totalPts,
+ featCnt + 1, StorageConstants.COLUMN_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+ Map<Integer, List<LabeledVectorDouble>> byRegion = new HashMap<>();
+
+ int i = 0;
+ for (IgniteBiTuple<Integer, V> bt : lst) {
+ byRegion.putIfAbsent(bt.get1(), new LinkedList<>());
+ byRegion.get(bt.get1()).add(asLabeledVector(bt.get2().getStorage().data()));
+ m.setRow(i, bt.get2().getStorage().data());
+ i++;
+ }
+
+ ColumnDecisionTreeTrainer<D> trainer =
+ new ColumnDecisionTreeTrainer<>(3, calc, catImpCalc, regCalc, ignite);
+
+ DecisionTreeModel mdl = trainer.train(new MatrixColumnDecisionTreeTrainerInput(m, catFeaturesInfo));
+
+ byRegion.keySet().forEach(k -> mdl.apply(byRegion.get(k).get(0).features()));
+ }
+
+ /**
+ * Split region by continuous coordinate using given threshold.
+ *
+ * @param regIdx Region index.
+ * @param coordIdx Coordinate index.
+ * @param threshold Threshold.
+ * @return {@code this}.
+ */
+ SplitDataGenerator<V> split(int regIdx, int coordIdx, double threshold) {
+ Region regToSplit = regs.get(regIdx);
+ ContCoordInfo cci = regToSplit.contCoords.get(coordIdx);
+
+ double left = cci.left;
+ double right = cci.right;
+
+ if (threshold < left || threshold > right)
+ throw new MathIllegalArgumentException("Threshold is out of region bounds.");
+
+ regToSplit.incTwoPow();
+
+ Region newReg = Utils.copy(regToSplit);
+ newReg.contCoords.get(coordIdx).left = threshold;
+
+ regs.add(regIdx + 1, newReg);
+ cci.right = threshold;
+
+ IgniteBiTuple<Double, Double> bounds = boundsData.get(coordIdx);
+ double min = bounds.get1();
+ double max = bounds.get2();
+ boundsData.put(coordIdx, new IgniteBiTuple<>(Math.min(threshold, min), Math.max(max, threshold)));
+
+ return this;
+ }
+
+ /**
+ * Split region by categorical coordinate.
+ *
+ * @param regIdx Region index.
+ * @param coordIdx Coordinate index.
+ * @param cats Categories allowed for the left sub region.
+ * @return {@code this}.
+ */
+ SplitDataGenerator<V> split(int regIdx, int coordIdx, int[] cats) {
+ BitSet subset = new BitSet();
+ Arrays.stream(cats).forEach(subset::set);
+ Region regToSplit = regs.get(regIdx);
+ CatCoordInfo cci = regToSplit.catCoords.get(coordIdx);
+
+ BitSet ssc = (BitSet)subset.clone();
+ BitSet set = cci.bs;
+ ssc.and(set);
+ if (ssc.length() != subset.length())
+ throw new MathIllegalArgumentException("Splitter set is not a subset of a parent subset.");
+
+ ssc.xor(set);
+ set.and(subset);
+
+ regToSplit.incTwoPow();
+ Region newReg = Utils.copy(regToSplit);
+ newReg.catCoords.put(coordIdx, new CatCoordInfo(ssc));
+
+ regs.add(regIdx + 1, newReg);
+
+ return this;
+ }
+
+ /**
+ * Get stream of points generated by this generator.
+ *
+ * @param ptsCnt Points count.
+ */
+ private Stream<IgniteBiTuple<Integer, V>> points(int ptsCnt, BiFunction<Double, Random, Double> f) {
+ return IntStream.range(0, regs.size()).
+ boxed().
+ map(i -> regs.get(i).generatePoints(ptsCnt, f.apply((double)i, rnd), boundsData, di, supplier, rnd)
+ .map(v -> new IgniteBiTuple<>(i, v))).flatMap(Function.identity());
+ }
+
+ /**
+ * Convert double array to {@link LabeledVectorDouble}
+ *
+ * @param arr Array for conversion.
+ * @return LabeledVectorDouble.
+ */
+ private static LabeledVectorDouble<DenseLocalOnHeapVector> asLabeledVector(double arr[]) {
+ return new LabeledVectorDouble<>(new DenseLocalOnHeapVector(
+ Arrays.copyOf(arr, arr.length - 1)), arr[arr.length - 1]);
+ }
+
+ /**
+ * Categorical coordinate info.
+ */
+ private static class CatCoordInfo implements Serializable {
+ /**
+ * Defines categories which are included in this region
+ */
+ private final BitSet bs;
+
+ /**
+ * Construct CatCoordInfo.
+ *
+ * @param bs Bitset.
+ */
+ CatCoordInfo(BitSet bs) {
+ this.bs = bs;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "CatCoordInfo [" +
+ "bs=" + bs +
+ ']';
+ }
+ }
+
+ /**
+ * Continuous coordinate info.
+ */
+ private static class ContCoordInfo implements Serializable {
+ /**
+ * Left (min) bound of region.
+ */
+ private double left;
+
+ /**
+ * Right (max) bound of region.
+ */
+ private double right;
+
+ /**
+ * Construct ContCoordInfo.
+ */
+ ContCoordInfo() {
+ left = Double.NEGATIVE_INFINITY;
+ right = Double.POSITIVE_INFINITY;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "ContCoordInfo [" +
+ "left=" + left +
+ ", right=" + right +
+ ']';
+ }
+ }
+
+ /**
+ * Class representing information about region.
+ */
+ private static class Region implements Serializable {
+ /**
+ * Information about categorical coordinates restrictions of this region in form of
+ * (coordinate index -> restriction)
+ */
+ private final Map<Integer, CatCoordInfo> catCoords;
+
+ /**
+ * Information about continuous coordinates restrictions of this region in form of
+ * (coordinate index -> restriction)
+ */
+ private final Map<Integer, ContCoordInfo> contCoords;
+
+ /**
+ * Region should contain {@code 1/2^twoPow * totalPoints} points.
+ */
+ private int twoPow;
+
+ /**
+ * Construct region by information about restrictions on coordinates (features) values.
+ *
+ * @param catCoords Restrictions on categorical coordinates.
+ * @param contCoords Restrictions on continuous coordinates
+ * @param twoPow Region should contain {@code 1/2^twoPow * totalPoints} points.
+ */
+ Region(Map<Integer, CatCoordInfo> catCoords, Map<Integer, ContCoordInfo> contCoords, int twoPow) {
+ this.catCoords = catCoords;
+ this.contCoords = contCoords;
+ this.twoPow = twoPow;
+ }
+
+ /** */
+ int divideBy() {
+ return 1 << twoPow;
+ }
+
+ /** */
+ void incTwoPow() {
+ twoPow++;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "Region [" +
+ "catCoords=" + catCoords +
+ ", contCoords=" + contCoords +
+ ", twoPow=" + twoPow +
+ ']';
+ }
+
+ /**
+ * Generate continuous coordinate for this region.
+ *
+ * @param coordIdx Coordinate index.
+ * @param boundsData Data with bounds
+ * @param rnd Random numbers generator.
+ * @return Categorical coordinate value.
+ */
+ double generateContCoord(int coordIdx, Map<Integer, IgniteBiTuple<Double, Double>> boundsData,
+ Random rnd) {
+ ContCoordInfo cci = contCoords.get(coordIdx);
+ double left = cci.left;
+ double right = cci.right;
+
+ if (left == Double.NEGATIVE_INFINITY)
+ left = boundsData.get(coordIdx).get1() - DELTA;
+
+ if (right == Double.POSITIVE_INFINITY)
+ right = boundsData.get(coordIdx).get2() + DELTA;
+
+ double size = right - left;
+
+ return left + rnd.nextDouble() * size;
+ }
+
+ /**
+ * Generate categorical coordinate value for this region.
+ *
+ * @param coordIdx Coordinate index.
+ * @param rnd Random numbers generator.
+ * @return Categorical coordinate value.
+ */
+ double generateCatCoord(int coordIdx, Random rnd) {
+ // Pick random bit.
+ BitSet bs = catCoords.get(coordIdx).bs;
+ int j = rnd.nextInt(bs.length());
+
+ int i = 0;
+ int bn = 0;
+ int bnp = 0;
+
+ while ((bn = bs.nextSetBit(bn)) != -1 && i <= j) {
+ i++;
+ bnp = bn;
+ bn++;
+ }
+
+ return bnp;
+ }
+
+ /**
+ * Generate points for this region.
+ *
+ * @param ptsCnt Count of points to generate.
+ * @param val Label for all points in this region.
+ * @param boundsData Data about bounds of continuous coordinates.
+ * @param catCont Data about which categories can be in this region in the form (coordinate index -> list of
+ * categories indexes).
+ * @param s Vectors supplier.
+ * @param rnd Random numbers generator.
+ * @param <V> Type of vectors.
+ * @return Stream of generated points for this region.
+ */
+ <V extends Vector> Stream<V> generatePoints(int ptsCnt, double val,
+ Map<Integer, IgniteBiTuple<Double, Double>> boundsData, Map<Boolean, List<Integer>> catCont,
+ Supplier<V> s,
+ Random rnd) {
+ return IntStream.range(0, ptsCnt / divideBy()).mapToObj(i -> {
+ V v = s.get();
+ int coordsCnt = v.size();
+ catCont.get(false).forEach(ci -> v.setX(ci, generateContCoord(ci, boundsData, rnd)));
+ catCont.get(true).forEach(ci -> v.setX(ci, generateCatCoord(ci, rnd)));
+
+ v.setX(coordsCnt - 1, val);
+ return v;
+ });
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/package-info.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/package-info.java
new file mode 100644
index 0000000..fc379a6
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/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. -->
+ * ML Grid decision tree benchmarks.
+ */
+package org.apache.ignite.yardstick.ml.trees;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/DataChanger.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/DataChanger.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/DataChanger.java
deleted file mode 100644
index 600113b..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/DataChanger.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.yardstick.ml;
-
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-
-/**
- * Helps to ensure use of meaningfully different data in repeated invocations of benchmarked code in
- * {@link IgniteAbstractBenchmark#test(Map)} method.
- */
-public class DataChanger {
- /** */
- private static final AtomicInteger changer = new AtomicInteger(0);
-
- /**
- * @return Positive "seed" to mutate data.
- */
- public static double next() {
- return (changer.incrementAndGet() % 17) + 1;
- }
-
- /** */
- public static class Scale {
- /** */
- private final double scale;
-
- /** */
- public Scale() {
- this.scale = DataChanger.next();
- }
-
- /** */
- public double[][] mutate(double[][] orig) {
- for (int i = 0; i < orig.length; i++)
- orig[i] = mutate(orig[i]);
-
- return orig;
- }
-
- /** */
- public double[] mutate(double[] orig) {
- for (int i = 0; i < orig.length; i++)
- orig[i] *= scale;
-
- return orig;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansDistributedClustererBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansDistributedClustererBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansDistributedClustererBenchmark.java
deleted file mode 100644
index de928e8..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansDistributedClustererBenchmark.java
+++ /dev/null
@@ -1,75 +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.yardstick.ml.clustering;
-
-import java.util.Map;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.ml.clustering.KMeansDistributedClusterer;
-import org.apache.ignite.ml.math.StorageConstants;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.thread.IgniteThread;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteKMeansDistributedClustererBenchmark extends IgniteAbstractBenchmark {
- /** */
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- final DataChanger.Scale scale = new DataChanger.Scale();
-
- // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
- // because we create ignite cache internally.
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
- this.getClass().getSimpleName(), new Runnable() {
- /** {@inheritDoc} */
- @Override public void run() {
- // IMPL NOTE originally taken from KMeansDistributedClustererTest
- KMeansDistributedClusterer clusterer = new KMeansDistributedClusterer(
- new EuclideanDistance(), 1, 1, 1L);
-
- double[] v1 = scale.mutate(new double[] {1959, 325100});
- double[] v2 = scale.mutate(new double[] {1960, 373200});
-
- SparseDistributedMatrix points = new SparseDistributedMatrix(
- 2, 2, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
- points.setRow(0, v1);
- points.setRow(1, v2);
-
- clusterer.cluster(points, 1);
-
- points.destroy();
- }
- });
-
- igniteThread.start();
-
- igniteThread.join();
-
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansLocalClustererBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansLocalClustererBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansLocalClustererBenchmark.java
deleted file mode 100644
index d68fc6d..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansLocalClustererBenchmark.java
+++ /dev/null
@@ -1,50 +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.yardstick.ml.clustering;
-
-import java.util.Map;
-import org.apache.ignite.ml.clustering.KMeansLocalClusterer;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteKMeansLocalClustererBenchmark extends IgniteAbstractBenchmark {
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- final DataChanger.Scale scale = new DataChanger.Scale();
-
- // IMPL NOTE originally taken from KMeansLocalClustererTest
- KMeansLocalClusterer clusterer = new KMeansLocalClusterer(new EuclideanDistance(), 1, 1L);
-
- double[] v1 = scale.mutate(new double[] {1959, 325100});
- double[] v2 = scale.mutate(new double[] {1960, 373200});
-
- DenseLocalOnHeapMatrix points = new DenseLocalOnHeapMatrix(new double[][] {
- v1,
- v2});
-
- clusterer.cluster(points, 1);
-
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/package-info.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/package-info.java
deleted file mode 100644
index af217d2..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/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. -->
- * ML Grid clustering benchmarks.
- */
-package org.apache.ignite.yardstick.ml.clustering;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java
deleted file mode 100644
index 6997180..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.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.yardstick.ml.decomposition;
-
-import java.util.Map;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.decompositions.CholeskyDecomposition;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteCholeskyDecompositionBenchmark extends IgniteAbstractBenchmark {
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- runCholeskyDecomposition();
-
- return true;
- }
-
- /**
- * Based on CholeskyDecompositionTest.
- */
- private void runCholeskyDecomposition() {
- final DataChanger.Scale scale = new DataChanger.Scale();
-
- Matrix m = new DenseLocalOnHeapMatrix(scale.mutate(new double[][] {
- {2.0d, -1.0d, 0.0d},
- {-1.0d, 2.0d, -1.0d},
- {0.0d, -1.0d, 2.0d}
- }));
-
- CholeskyDecomposition dec = new CholeskyDecomposition(m);
-
- dec.getL();
- dec.getLT();
-
- Matrix bs = new DenseLocalOnHeapMatrix(scale.mutate(new double[][] {
- {4.0, -6.0, 7.0},
- {1.0, 1.0, 1.0}
- })).transpose();
- dec.solve(bs);
-
- Vector b = new DenseLocalOnHeapVector(scale.mutate(new double[] {4.0, -6.0, 7.0}));
- dec.solve(b);
-
- dec.destroy();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java
deleted file mode 100644
index e61c40c..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.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.yardstick.ml.decomposition;
-
-import java.util.Map;
-import org.apache.ignite.ml.math.decompositions.EigenDecomposition;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteEigenDecompositionBenchmark extends IgniteAbstractBenchmark {
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- runEigenDecomposition();
-
- return true;
- }
-
- /**
- * Based on EigenDecompositionTest.
- */
- private void runEigenDecomposition() {
- final DataChanger.Scale scale = new DataChanger.Scale();
-
- EigenDecomposition decomposition1 = new EigenDecomposition(new DenseLocalOnHeapMatrix(
- scale.mutate(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}})));
-
- decomposition1.getD();
- decomposition1.getV();
-
- decomposition1.destroy();
-
- EigenDecomposition decomposition2 = new EigenDecomposition(new DenseLocalOnHeapMatrix(
- scale.mutate(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: IGNITE-5828, find out why decomposition of 3X4 matrix throws row index exception
-
- decomposition2.getD();
- decomposition2.getV();
-
- decomposition2.destroy();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java
deleted file mode 100644
index 1368ef9..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java
+++ /dev/null
@@ -1,75 +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.yardstick.ml.decomposition;
-
-import java.util.Map;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.decompositions.LUDecomposition;
-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.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteLUDecompositionBenchmark extends IgniteAbstractBenchmark {
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- runLUDecomposition();
-
- return true;
- }
-
- /**
- * Based on LUDecompositionTest.
- */
- private void runLUDecomposition() {
- Matrix testMatrix = new DenseLocalOnHeapMatrix(new DataChanger.Scale().mutate(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}}));
-
- LUDecomposition dec1 = new LUDecomposition(new PivotedMatrixView(testMatrix));
-
- dec1.solve(new DenseLocalOnHeapVector(testMatrix.rowSize()));
-
- dec1.destroy();
-
- LUDecomposition dec2 = new LUDecomposition(new PivotedMatrixView(testMatrix));
-
- dec2.solve(new DenseLocalOnHeapMatrix(testMatrix.rowSize(), testMatrix.rowSize()));
-
- dec2.destroy();
-
- LUDecomposition dec3 = new LUDecomposition(testMatrix);
-
- dec3.getL();
-
- dec3.getU();
-
- dec3.getP();
-
- dec3.getPivot();
-
- dec3.destroy();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java
deleted file mode 100644
index 9f02852..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.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.yardstick.ml.decomposition;
-
-import java.util.Map;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.decompositions.SingularValueDecomposition;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteSingularValueDecompositionBenchmark extends IgniteAbstractBenchmark {
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- runSingularValueDecomposition();
-
- return true;
- }
-
- /**
- * Based on SingularValueDecompositionTest#basicTest.
- */
- private void runSingularValueDecomposition() {
- Matrix m = new DenseLocalOnHeapMatrix(new DataChanger.Scale().mutate(new double[][] {
- {2.0d, -1.0d, 0.0d},
- {-1.0d, 2.0d, -1.0d},
- {0.0d, -1.0d, 2.0d}
- }));
-
- SingularValueDecomposition dec = new SingularValueDecomposition(m);
-
- Matrix s = dec.getS();
- Matrix u = dec.getU();
- Matrix v = dec.getV();
-
- u.times(s).times(v.transpose());
-
- dec.destroy();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/package-info.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/package-info.java
deleted file mode 100644
index 4aaece3..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/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. -->
- * ML Grid decomposition benchmarks.
- */
-package org.apache.ignite.yardstick.ml.decomposition;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java
deleted file mode 100644
index 6cb2200..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.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.yardstick.ml.math;
-
-import java.util.Map;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.thread.IgniteThread;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations of matrix multiplication.
- */
-abstract class IgniteAbstractMatrixMulBenchmark extends IgniteAbstractBenchmark {
- /** */
- private static final int SIZE = 1 << 7;
-
- /** */
- private double[][] dataSquare = createAndFill(SIZE, SIZE);
-
- /** */
- private double[][] dataRect1 = createAndFill(SIZE / 2, SIZE);
-
- /** */
- private double[][] dataRect2 = createAndFill(SIZE, SIZE / 2);
-
- /** */
- @SuppressWarnings("unused")
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- final double scale = DataChanger.next();
-
- // Create IgniteThread, we may want to work with SparseDistributedMatrix inside IgniteThread
- // because we create ignite cache internally.
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
- this.getClass().getSimpleName(), new Runnable() {
- /** {@inheritDoc} */
- @Override public void run() {
- Matrix m1, m2, m3, m4, m5, m6;
-
- Matrix m7 = times(m1 = createAndFill(dataSquare, scale), m2 = createAndFill(dataSquare, scale));
- Matrix m8 = times(m3 = createAndFill(dataRect1, scale), m4 = createAndFill(dataRect2, scale));
- Matrix m9 = times(m5 = createAndFill(dataRect2, scale), m6 = createAndFill(dataRect1, scale));
-
- m1.destroy();
- m2.destroy();
- m3.destroy();
- m4.destroy();
- m5.destroy();
- m6.destroy();
- m7.destroy();
- m8.destroy();
- m9.destroy();
- }
- });
-
- igniteThread.start();
-
- igniteThread.join();
-
- return true;
- }
-
- /**
- * Override in subclasses with specific type Matrix. Note that size of result matrix may be smaller than requested.
- *
- * @param rowSize Requested row size.
- * @param colSize Requested column size.
- * @return Matrix of desired type of size that doesn't exceed requested.
- */
- abstract Matrix newMatrix(int rowSize, int colSize);
-
- /** Override in subclasses if needed. */
- Matrix times(Matrix m1, Matrix m2) {
- return m1.times(m2);
- }
-
- /** Override in subclasses if needed to account for smaller matrix size. */
- Matrix createAndFill(double[][] data, double scale) {
- // IMPL NOTE yardstick 0.8.3 fails to discover benchmark if we try to account for smaller size
- // matrix by using method with lambda parameter here: assign((row, col) -> data[row][col]).
- Matrix res = newMatrix(data.length, data[0].length).assign(data);
-
- for (int i = 0; i < data.length && i < data[0].length; i++)
- res.set(i, i, data[i][i] * scale);
-
- return res;
- }
-
- /** */
- private double[][] createAndFill(int rowSize, int colSize) {
- double[][] data = new double[rowSize][colSize];
-
- for (int i = 0; i < rowSize; i++)
- for (int j = 0; j < colSize; j++)
- data[i][j] = -0.5d + Math.random();
-
- return data;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java
deleted file mode 100644
index 027b515..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java
+++ /dev/null
@@ -1,32 +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.yardstick.ml.math;
-
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOffHeapMatrix;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteDenseLocalOffHeapMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
- /** {@inheritDoc} */
- @Override Matrix newMatrix(int rowSize, int colSize) {
- return new DenseLocalOffHeapMatrix(rowSize, colSize);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java
deleted file mode 100644
index 6830130..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java
+++ /dev/null
@@ -1,32 +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.yardstick.ml.math;
-
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteDenseLocalOnHeapMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
- /** {@inheritDoc} */
- @Override Matrix newMatrix(int rowSize, int colSize) {
- return new DenseLocalOnHeapMatrix(rowSize, colSize);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java
deleted file mode 100644
index 8762620..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java
+++ /dev/null
@@ -1,32 +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.yardstick.ml.math;
-
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.impls.matrix.SparseBlockDistributedMatrix;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteSparseBlockDistributedMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
- /** {@inheritDoc} */
- @Override Matrix newMatrix(int rowSize, int colSize) {
- return new SparseBlockDistributedMatrix(rowSize, colSize);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java
deleted file mode 100644
index 0f9d288..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.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.yardstick.ml.math;
-
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.StorageConstants;
-import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
-
-/**
- * Ignite benchmark that performs unoptimized matrix multiplication of {@link SparseDistributedMatrix}.
- * For optimized benchmark refer {@link IgniteSparseBlockDistributedMatrixMulBenchmark}.
- */
-@SuppressWarnings("unused")
-public class IgniteSparseDistributedMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
- /** This benchmark is unacceptably slow without scaling down, see IGNITE-7097. */
- private static final int SCALE_DOWN = 2;
-
- /** {@inheritDoc} */
- @Override Matrix newMatrix(int rowSize, int colSize) {
- return new SparseDistributedMatrix(rowSize >> SCALE_DOWN, colSize >> SCALE_DOWN,
- StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
- }
-
- /** {@inheritDoc} */
- @Override Matrix createAndFill(double[][] data, double scale) {
- Matrix res = newMatrix(data.length, data[0].length);
-
- for (int row = 0; row < res.rowSize(); row++)
- for (int col = 0; col < res.columnSize(); col++)
- res.set(row, col, row == col ? data[row][col] * scale : data[row][col]);
-
- return res;
- }
-}
[05/11] ignite git commit: IGNITE-7203 Java 8 by default
Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index be3ade1..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/SparseVectorExample.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.examples.ml.math.vector;
-
-import java.util.Arrays;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.impls.vector.SparseLocalVector;
-
-import static org.apache.ignite.ml.math.StorageConstants.RANDOM_ACCESS_MODE;
-
-/**
- * This example shows how to use sparse {@link Vector} API.
- */
-public final class SparseVectorExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> Sparse vector API usage example started.");
-
- System.out.println("\n>>> Creating perpendicular sparse vectors.");
- double[] data1 = new double[] {1, 0, 3, 0, 5, 0};
- double[] data2 = new double[] {0, 2, 0, 4, 0, 6};
-
- Vector v1 = new SparseLocalVector(data1.length, RANDOM_ACCESS_MODE);
- Vector v2 = new SparseLocalVector(data2.length, RANDOM_ACCESS_MODE);
-
- v1.assign(data1);
- v2.assign(data2);
-
- System.out.println(">>> First vector: " + Arrays.toString(data1));
- System.out.println(">>> Second vector: " + Arrays.toString(data2));
-
- double dotProduct = v1.dot(v2);
- boolean dotProductIsAsExp = dotProduct == 0;
-
- System.out.println("\n>>> Dot product of vectors: [" + dotProduct
- + "], it is 0 as expected: [" + dotProductIsAsExp + "].");
-
- Vector hypotenuse = v1.plus(v2);
-
- System.out.println("\n>>> Hypotenuse (sum of vectors): " + Arrays.toString(hypotenuse.getStorage().data()));
-
- double lenSquared1 = v1.getLengthSquared();
- double lenSquared2 = v2.getLengthSquared();
- double lenSquaredHypotenuse = hypotenuse.getLengthSquared();
-
- boolean lenSquaredHypotenuseIsAsExp = lenSquaredHypotenuse == lenSquared1 + lenSquared2;
-
- System.out.println(">>> Squared length of first vector: [" + lenSquared1 + "].");
- System.out.println(">>> Squared length of second vector: [" + lenSquared2 + "].");
- System.out.println(">>> Squared length of hypotenuse: [" + lenSquaredHypotenuse
- + "], equals sum of squared lengths of two original vectors as expected: ["
- + lenSquaredHypotenuseIsAsExp + "].");
-
- System.out.println("\n>>> Sparse vector API usage example completed.");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index cbb69d0..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/VectorCustomStorageExample.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.examples.ml.math.vector;
-
-import java.util.Arrays;
-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}.
- */
-public final class VectorCustomStorageExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> Vector custom storage API usage example started.");
-
- System.out.println("\n>>> Creating perpendicular vectors.");
- double[] data1 = new double[] {1, 0, 3, 0, 5, 0};
- double[] data2 = new double[] {0, 2, 0, 4, 0, 6};
-
- Vector v1 = new VectorCustomStorage(data1);
- Vector v2 = new VectorCustomStorage(data2);
-
- System.out.println(">>> First vector: " + Arrays.toString(data1));
- System.out.println(">>> Second vector: " + Arrays.toString(data2));
-
- double dotProduct = v1.dot(v2);
- boolean dotProductIsAsExp = dotProduct == 0;
-
- System.out.println("\n>>> Dot product of vectors: [" + dotProduct
- + "], it is 0 as expected: [" + dotProductIsAsExp + "].");
-
- Vector hypotenuse = v1.plus(v2);
-
- System.out.println("\n>>> Hypotenuse (sum of vectors): " + Arrays.toString(hypotenuse.getStorage().data()));
-
- double lenSquared1 = v1.getLengthSquared();
- double lenSquared2 = v2.getLengthSquared();
- double lenSquaredHypotenuse = hypotenuse.getLengthSquared();
-
- boolean lenSquaredHypotenuseIsAsExp = lenSquaredHypotenuse == lenSquared1 + lenSquared2;
-
- System.out.println(">>> Squared length of first vector: [" + lenSquared1 + "].");
- System.out.println(">>> Squared length of second vector: [" + lenSquared2 + "].");
- System.out.println(">>> Squared length of hypotenuse: [" + lenSquaredHypotenuse
- + "], equals sum of squared lengths of two original vectors as expected: ["
- + lenSquaredHypotenuseIsAsExp + "].");
-
- System.out.println("\n>>> Vector custom storage API usage example completed.");
- }
-
- /**
- * Example of vector with custom storage, modeled after
- * {@link org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector}.
- */
- static class VectorCustomStorage extends AbstractVector {
- /**
- * @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 ExampleVectorStorage(cp ? arr.clone() : arr);
- }
-
- /** */
- public VectorCustomStorage() {
- // No-op.
- }
-
- /**
- * @param arr Source array.
- * @param shallowCp {@code true} to use shallow copy.
- */
- VectorCustomStorage(double[] arr, boolean shallowCp) {
- setStorage(mkStorage(arr, shallowCp));
- }
-
- /**
- * @param arr Source array.
- */
- VectorCustomStorage(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 org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector(crd);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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
deleted file mode 100644
index 9970531..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/VectorExample.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.examples.ml.math.vector;
-
-import java.util.Arrays;
-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.
- *
- * Just simple local onheap version.
- */
-public final class VectorExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> Basic Vector API usage example started.");
-
- System.out.println("\n>>> Creating perpendicular vectors.");
- double[] data1 = new double[] {1, 0, 3, 0, 5, 0};
- double[] data2 = new double[] {0, 2, 0, 4, 0, 6};
-
- Vector v1 = new DenseLocalOnHeapVector(data1);
- Vector v2 = new DenseLocalOnHeapVector(data2);
-
- System.out.println(">>> First vector: " + Arrays.toString(data1));
- System.out.println(">>> Second vector: " + Arrays.toString(data2));
-
- double dotProduct = v1.dot(v2);
- boolean dotProductIsAsExp = dotProduct == 0;
-
- System.out.println("\n>>> Dot product of vectors: [" + dotProduct
- + "], it is 0 as expected: [" + dotProductIsAsExp + "].");
-
- Vector hypotenuse = v1.plus(v2);
-
- System.out.println("\n>>> Hypotenuse (sum of vectors): " + Arrays.toString(hypotenuse.getStorage().data()));
-
- double lenSquared1 = v1.getLengthSquared();
- double lenSquared2 = v2.getLengthSquared();
- double lenSquaredHypotenuse = hypotenuse.getLengthSquared();
-
- boolean lenSquaredHypotenuseIsAsExp = lenSquaredHypotenuse == lenSquared1 + lenSquared2;
-
- System.out.println(">>> Squared length of first vector: [" + lenSquared1 + "].");
- System.out.println(">>> Squared length of second vector: [" + lenSquared2 + "].");
- System.out.println(">>> Squared length of hypotenuse: [" + lenSquaredHypotenuse
- + "], equals sum of squared lengths of two original vectors as expected: ["
- + lenSquaredHypotenuseIsAsExp + "].");
-
- System.out.println("\n>>> Basic Vector API usage example completed.");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/math/vector/package-info.java
deleted file mode 100644
index 2cc74ac..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/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. -->
- * Core algebra vector examples.
- */
-package org.apache.ignite.examples.ml.math.vector;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/nn/MLPGroupTrainerExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/nn/MLPGroupTrainerExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/nn/MLPGroupTrainerExample.java
deleted file mode 100644
index d106fad..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/nn/MLPGroupTrainerExample.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.examples.ml.nn;
-
-import java.util.Random;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.StorageConstants;
-import org.apache.ignite.ml.math.Tracer;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.ml.nn.Activators;
-import org.apache.ignite.ml.nn.LabeledVectorsCache;
-import org.apache.ignite.ml.nn.MLPGroupUpdateTrainerCacheInput;
-import org.apache.ignite.ml.nn.MultilayerPerceptron;
-import org.apache.ignite.ml.nn.architecture.MLPArchitecture;
-import org.apache.ignite.ml.nn.initializers.RandomInitializer;
-import org.apache.ignite.ml.nn.trainers.distributed.MLPGroupUpdateTrainer;
-import org.apache.ignite.ml.optimization.updatecalculators.RPropParameterUpdate;
-import org.apache.ignite.ml.structures.LabeledVector;
-import org.apache.ignite.thread.IgniteThread;
-
-/**
- * <p>
- * Example of using distributed {@link MultilayerPerceptron}.</p>
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.</p>
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.</p>
- */
-public class MLPGroupTrainerExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) throws InterruptedException {
- // IMPL NOTE based on MLPGroupTrainerTest#testXOR
- System.out.println(">>> Distributed multilayer perceptron example started.");
-
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
- // because we create ignite cache internally.
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
- MLPGroupTrainerExample.class.getSimpleName(), () -> {
-
- int samplesCnt = 1000;
-
- Matrix xorInputs = new DenseLocalOnHeapMatrix(
- new double[][] {{0.0, 0.0}, {0.0, 1.0}, {1.0, 0.0}, {1.0, 1.0}},
- StorageConstants.ROW_STORAGE_MODE).transpose();
-
- Matrix xorOutputs = new DenseLocalOnHeapMatrix(
- new double[][] {{0.0}, {1.0}, {1.0}, {0.0}},
- StorageConstants.ROW_STORAGE_MODE).transpose();
-
- MLPArchitecture conf = new MLPArchitecture(2).
- withAddedLayer(10, true, Activators.RELU).
- withAddedLayer(1, false, Activators.SIGMOID);
-
- IgniteCache<Integer, LabeledVector<Vector, Vector>> cache = LabeledVectorsCache.createNew(ignite);
- String cacheName = cache.getName();
- Random rnd = new Random(12345L);
-
- try (IgniteDataStreamer<Integer, LabeledVector<Vector, Vector>> streamer =
- ignite.dataStreamer(cacheName)) {
- streamer.perNodeBufferSize(10000);
-
- for (int i = 0; i < samplesCnt; i++) {
- int col = Math.abs(rnd.nextInt()) % 4;
- streamer.addData(i, new LabeledVector<>(xorInputs.getCol(col), xorOutputs.getCol(col)));
- }
- }
-
- int totalCnt = 100;
- int failCnt = 0;
- MLPGroupUpdateTrainer<RPropParameterUpdate> trainer = MLPGroupUpdateTrainer.getDefault(ignite).
- withSyncRate(3).
- withTolerance(0.001).
- withMaxGlobalSteps(1000);
-
- for (int i = 0; i < totalCnt; i++) {
-
- MLPGroupUpdateTrainerCacheInput trainerInput = new MLPGroupUpdateTrainerCacheInput(conf,
- new RandomInitializer(rnd), 6, cache, 4);
-
- MultilayerPerceptron mlp = trainer.train(trainerInput);
-
- Matrix predict = mlp.apply(xorInputs);
-
- System.out.println(">>> Prediction data at step " + i + " of total " + totalCnt + ":");
-
- Tracer.showAscii(predict);
-
- System.out.println("Difference estimate: " + xorOutputs.getRow(0).minus(predict.getRow(0)).kNorm(2));
-
- failCnt += closeEnough(xorOutputs.getRow(0), predict.getRow(0)) ? 0 : 1;
- }
-
- double failRatio = (double)failCnt / totalCnt;
-
- System.out.println("\n>>> Fail percentage: " + (failRatio * 100) + "%.");
-
- System.out.println("\n>>> Distributed multilayer perceptron example completed.");
- });
-
- igniteThread.start();
-
- igniteThread.join();
- }
- }
-
- /** */
- private static boolean closeEnough(Vector v1, Vector v2) {
- return v1.minus(v2).kNorm(2) < 5E-1;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/nn/MLPLocalTrainerExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/nn/MLPLocalTrainerExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/nn/MLPLocalTrainerExample.java
deleted file mode 100644
index b557458..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/nn/MLPLocalTrainerExample.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.examples.ml.nn;
-
-import java.util.Random;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.StorageConstants;
-import org.apache.ignite.ml.math.Tracer;
-import org.apache.ignite.ml.math.functions.IgniteSupplier;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.ml.nn.Activators;
-import org.apache.ignite.ml.trainers.local.LocalBatchTrainerInput;
-import org.apache.ignite.ml.optimization.LossFunctions;
-import org.apache.ignite.ml.nn.MultilayerPerceptron;
-import org.apache.ignite.ml.nn.architecture.MLPArchitecture;
-import org.apache.ignite.ml.nn.initializers.RandomInitializer;
-import org.apache.ignite.ml.nn.trainers.local.MLPLocalBatchTrainer;
-import org.apache.ignite.ml.optimization.updatecalculators.RPropUpdateCalculator;
-import org.apache.ignite.ml.util.Utils;
-
-/**
- * Example of using local {@link MultilayerPerceptron}.
- */
-public class MLPLocalTrainerExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- // IMPL NOTE based on MLPLocalTrainerTest#testXORRProp
- System.out.println(">>> Local multilayer perceptron example started.");
-
- Matrix xorInputs = new DenseLocalOnHeapMatrix(new double[][] {{0.0, 0.0}, {0.0, 1.0}, {1.0, 0.0}, {1.0, 1.0}},
- StorageConstants.ROW_STORAGE_MODE).transpose();
-
- System.out.println("\n>>> Input data:");
-
- Tracer.showAscii(xorInputs);
-
- Matrix xorOutputs = new DenseLocalOnHeapMatrix(new double[][] {{0.0}, {1.0}, {1.0}, {0.0}},
- StorageConstants.ROW_STORAGE_MODE).transpose();
-
- MLPArchitecture conf = new MLPArchitecture(2).
- withAddedLayer(10, true, Activators.RELU).
- withAddedLayer(1, false, Activators.SIGMOID);
-
- SimpleMLPLocalBatchTrainerInput trainerInput = new SimpleMLPLocalBatchTrainerInput(conf,
- new Random(1234L), xorInputs, xorOutputs, 4);
-
- System.out.println("\n>>> Perform training.");
-
- MultilayerPerceptron mlp = new MLPLocalBatchTrainer<>(LossFunctions.MSE,
- () -> new RPropUpdateCalculator<>(),
- 0.0001,
- 16000).train(trainerInput);
-
- System.out.println("\n>>> Apply model.");
-
- Matrix predict = mlp.apply(xorInputs);
-
- System.out.println("\n>>> Predicted data:");
-
- Tracer.showAscii(predict);
-
- System.out.println("\n>>> Reference expected data:");
-
- Tracer.showAscii(xorOutputs);
-
- System.out.println("\n>>> Difference estimate: " + xorOutputs.getRow(0).minus(predict.getRow(0)).kNorm(2));
-
- System.out.println("\n>>> Local multilayer perceptron example completed.");
- }
-
- /**
- * Class for local batch training of {@link MultilayerPerceptron}.
- *
- * It is constructed from two matrices: one containing inputs of function to approximate and other containing ground truth
- * values of this function for corresponding inputs.
- *
- * We fix batch size given by this input by some constant value.
- */
- private static class SimpleMLPLocalBatchTrainerInput implements LocalBatchTrainerInput<MultilayerPerceptron> {
- /**
- * Multilayer perceptron to be trained.
- */
- private final MultilayerPerceptron mlp;
-
- /**
- * Inputs stored as columns.
- */
- private final Matrix inputs;
-
- /**
- * Ground truths stored as columns.
- */
- private final Matrix groundTruth;
-
- /**
- * Size of batch returned on each step.
- */
- private final int batchSize;
-
- /**
- * Construct instance of this class.
- *
- * @param arch Architecture of multilayer perceptron.
- * @param rnd Random numbers generator.
- * @param inputs Inputs stored as columns.
- * @param groundTruth Ground truth stored as columns.
- * @param batchSize Size of batch returned on each step.
- */
- SimpleMLPLocalBatchTrainerInput(MLPArchitecture arch, Random rnd, Matrix inputs, Matrix groundTruth, int batchSize) {
- this.mlp = new MultilayerPerceptron(arch, new RandomInitializer(rnd));
- this.inputs = inputs;
- this.groundTruth = groundTruth;
- this.batchSize = batchSize;
- }
-
- /** {@inheritDoc} */
- @Override public IgniteSupplier<IgniteBiTuple<Matrix, Matrix>> batchSupplier() {
- return () -> {
- int inputRowSize = inputs.rowSize();
- int outputRowSize = groundTruth.rowSize();
-
- Matrix vectors = new DenseLocalOnHeapMatrix(inputRowSize, batchSize);
- Matrix labels = new DenseLocalOnHeapMatrix(outputRowSize, batchSize);
-
- int[] samples = Utils.selectKDistinct(inputs.columnSize(), batchSize);
-
- for (int i = 0; i < batchSize; i++) {
- vectors.assignColumn(i, inputs.getCol(samples[i]));
- labels.assignColumn(i, groundTruth.getCol(samples[i]));
- }
-
- return new IgniteBiTuple<>(vectors, labels);
- };
- }
-
- /** {@inheritDoc} */
- @Override public MultilayerPerceptron mdl() {
- return mlp;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/nn/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/nn/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/nn/package-info.java
deleted file mode 100644
index 3a0ed29..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/nn/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. -->
- * ML neural network examples.
- */
-package org.apache.ignite.examples.ml.nn;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/package-info.java
deleted file mode 100644
index 52778b5..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/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. -->
- * Machine learning examples.
- */
-package org.apache.ignite.examples.ml;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithQRTrainer.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithQRTrainer.java b/examples/src/main/ml/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithQRTrainer.java
deleted file mode 100644
index 98ff2a2..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithQRTrainer.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.examples.ml.regression.linear;
-
-import java.util.Arrays;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.math.matrix.SparseDistributedMatrixExample;
-import org.apache.ignite.ml.Trainer;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
-import org.apache.ignite.ml.math.impls.vector.SparseDistributedVector;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionModel;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionQRTrainer;
-import org.apache.ignite.thread.IgniteThread;
-
-/**
- * Run linear regression model over distributed matrix.
- *
- * @see LinearRegressionQRTrainer
- */
-public class DistributedLinearRegressionExampleWithQRTrainer {
- /** */
- private static final double[][] data = {
- {8, 78, 284, 9.100000381, 109},
- {9.300000191, 68, 433, 8.699999809, 144},
- {7.5, 70, 739, 7.199999809, 113},
- {8.899999619, 96, 1792, 8.899999619, 97},
- {10.19999981, 74, 477, 8.300000191, 206},
- {8.300000191, 111, 362, 10.89999962, 124},
- {8.800000191, 77, 671, 10, 152},
- {8.800000191, 168, 636, 9.100000381, 162},
- {10.69999981, 82, 329, 8.699999809, 150},
- {11.69999981, 89, 634, 7.599999905, 134},
- {8.5, 149, 631, 10.80000019, 292},
- {8.300000191, 60, 257, 9.5, 108},
- {8.199999809, 96, 284, 8.800000191, 111},
- {7.900000095, 83, 603, 9.5, 182},
- {10.30000019, 130, 686, 8.699999809, 129},
- {7.400000095, 145, 345, 11.19999981, 158},
- {9.600000381, 112, 1357, 9.699999809, 186},
- {9.300000191, 131, 544, 9.600000381, 177},
- {10.60000038, 80, 205, 9.100000381, 127},
- {9.699999809, 130, 1264, 9.199999809, 179},
- {11.60000038, 140, 688, 8.300000191, 80},
- {8.100000381, 154, 354, 8.399999619, 103},
- {9.800000191, 118, 1632, 9.399999619, 101},
- {7.400000095, 94, 348, 9.800000191, 117},
- {9.399999619, 119, 370, 10.39999962, 88},
- {11.19999981, 153, 648, 9.899999619, 78},
- {9.100000381, 116, 366, 9.199999809, 102},
- {10.5, 97, 540, 10.30000019, 95},
- {11.89999962, 176, 680, 8.899999619, 80},
- {8.399999619, 75, 345, 9.600000381, 92},
- {5, 134, 525, 10.30000019, 126},
- {9.800000191, 161, 870, 10.39999962, 108},
- {9.800000191, 111, 669, 9.699999809, 77},
- {10.80000019, 114, 452, 9.600000381, 60},
- {10.10000038, 142, 430, 10.69999981, 71},
- {10.89999962, 238, 822, 10.30000019, 86},
- {9.199999809, 78, 190, 10.69999981, 93},
- {8.300000191, 196, 867, 9.600000381, 106},
- {7.300000191, 125, 969, 10.5, 162},
- {9.399999619, 82, 499, 7.699999809, 95},
- {9.399999619, 125, 925, 10.19999981, 91},
- {9.800000191, 129, 353, 9.899999619, 52},
- {3.599999905, 84, 288, 8.399999619, 110},
- {8.399999619, 183, 718, 10.39999962, 69},
- {10.80000019, 119, 540, 9.199999809, 57},
- {10.10000038, 180, 668, 13, 106},
- {9, 82, 347, 8.800000191, 40},
- {10, 71, 345, 9.199999809, 50},
- {11.30000019, 118, 463, 7.800000191, 35},
- {11.30000019, 121, 728, 8.199999809, 86},
- {12.80000019, 68, 383, 7.400000095, 57},
- {10, 112, 316, 10.39999962, 57},
- {6.699999809, 109, 388, 8.899999619, 94}
- };
-
- /** Run example. */
- public static void main(String[] args) throws InterruptedException {
- System.out.println();
- System.out.println(">>> Linear regression model over sparse distributed matrix API usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
- // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
- // because we create ignite cache internally.
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
- SparseDistributedMatrixExample.class.getSimpleName(), () -> {
-
- // Create SparseDistributedMatrix, new cache will be created automagically.
- System.out.println(">>> Create new SparseDistributedMatrix inside IgniteThread.");
- SparseDistributedMatrix distributedMatrix = new SparseDistributedMatrix(data);
-
- System.out.println(">>> Create new linear regression trainer object.");
- Trainer<LinearRegressionModel, Matrix> trainer = new LinearRegressionQRTrainer();
-
- System.out.println(">>> Perform the training to get the model.");
- LinearRegressionModel model = trainer.train(distributedMatrix);
- System.out.println(">>> Linear regression model: " + model);
-
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> | Prediction\t| Ground Truth\t|");
- System.out.println(">>> ---------------------------------");
- for (double[] observation : data) {
- Vector inputs = new SparseDistributedVector(Arrays.copyOfRange(observation, 1, observation.length));
- double prediction = model.apply(inputs);
- double groundTruth = observation[0];
- System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", prediction, groundTruth);
- }
- System.out.println(">>> ---------------------------------");
- });
-
- igniteThread.start();
-
- igniteThread.join();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithSGDTrainer.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithSGDTrainer.java b/examples/src/main/ml/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithSGDTrainer.java
deleted file mode 100644
index 3f61762..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/regression/linear/DistributedLinearRegressionExampleWithSGDTrainer.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.examples.ml.regression.linear;
-
-import java.util.Arrays;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.math.matrix.SparseDistributedMatrixExample;
-import org.apache.ignite.ml.Trainer;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
-import org.apache.ignite.ml.math.impls.vector.SparseDistributedVector;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionModel;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionQRTrainer;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionSGDTrainer;
-import org.apache.ignite.thread.IgniteThread;
-
-/**
- * Run linear regression model over distributed matrix.
- *
- * @see LinearRegressionQRTrainer
- */
-public class DistributedLinearRegressionExampleWithSGDTrainer {
- /** */
- private static final double[][] data = {
- {8, 78, 284, 9.100000381, 109},
- {9.300000191, 68, 433, 8.699999809, 144},
- {7.5, 70, 739, 7.199999809, 113},
- {8.899999619, 96, 1792, 8.899999619, 97},
- {10.19999981, 74, 477, 8.300000191, 206},
- {8.300000191, 111, 362, 10.89999962, 124},
- {8.800000191, 77, 671, 10, 152},
- {8.800000191, 168, 636, 9.100000381, 162},
- {10.69999981, 82, 329, 8.699999809, 150},
- {11.69999981, 89, 634, 7.599999905, 134},
- {8.5, 149, 631, 10.80000019, 292},
- {8.300000191, 60, 257, 9.5, 108},
- {8.199999809, 96, 284, 8.800000191, 111},
- {7.900000095, 83, 603, 9.5, 182},
- {10.30000019, 130, 686, 8.699999809, 129},
- {7.400000095, 145, 345, 11.19999981, 158},
- {9.600000381, 112, 1357, 9.699999809, 186},
- {9.300000191, 131, 544, 9.600000381, 177},
- {10.60000038, 80, 205, 9.100000381, 127},
- {9.699999809, 130, 1264, 9.199999809, 179},
- {11.60000038, 140, 688, 8.300000191, 80},
- {8.100000381, 154, 354, 8.399999619, 103},
- {9.800000191, 118, 1632, 9.399999619, 101},
- {7.400000095, 94, 348, 9.800000191, 117},
- {9.399999619, 119, 370, 10.39999962, 88},
- {11.19999981, 153, 648, 9.899999619, 78},
- {9.100000381, 116, 366, 9.199999809, 102},
- {10.5, 97, 540, 10.30000019, 95},
- {11.89999962, 176, 680, 8.899999619, 80},
- {8.399999619, 75, 345, 9.600000381, 92},
- {5, 134, 525, 10.30000019, 126},
- {9.800000191, 161, 870, 10.39999962, 108},
- {9.800000191, 111, 669, 9.699999809, 77},
- {10.80000019, 114, 452, 9.600000381, 60},
- {10.10000038, 142, 430, 10.69999981, 71},
- {10.89999962, 238, 822, 10.30000019, 86},
- {9.199999809, 78, 190, 10.69999981, 93},
- {8.300000191, 196, 867, 9.600000381, 106},
- {7.300000191, 125, 969, 10.5, 162},
- {9.399999619, 82, 499, 7.699999809, 95},
- {9.399999619, 125, 925, 10.19999981, 91},
- {9.800000191, 129, 353, 9.899999619, 52},
- {3.599999905, 84, 288, 8.399999619, 110},
- {8.399999619, 183, 718, 10.39999962, 69},
- {10.80000019, 119, 540, 9.199999809, 57},
- {10.10000038, 180, 668, 13, 106},
- {9, 82, 347, 8.800000191, 40},
- {10, 71, 345, 9.199999809, 50},
- {11.30000019, 118, 463, 7.800000191, 35},
- {11.30000019, 121, 728, 8.199999809, 86},
- {12.80000019, 68, 383, 7.400000095, 57},
- {10, 112, 316, 10.39999962, 57},
- {6.699999809, 109, 388, 8.899999619, 94}
- };
-
- /** Run example. */
- public static void main(String[] args) throws InterruptedException {
- System.out.println();
- System.out.println(">>> Linear regression model over sparse distributed matrix API usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
- // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
- // because we create ignite cache internally.
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
- SparseDistributedMatrixExample.class.getSimpleName(), () -> {
-
- // Create SparseDistributedMatrix, new cache will be created automagically.
- System.out.println(">>> Create new SparseDistributedMatrix inside IgniteThread.");
- SparseDistributedMatrix distributedMatrix = new SparseDistributedMatrix(data);
-
- System.out.println(">>> Create new linear regression trainer object.");
- Trainer<LinearRegressionModel, Matrix> trainer = new LinearRegressionSGDTrainer(100_000, 1e-12);
-
- System.out.println(">>> Perform the training to get the model.");
- LinearRegressionModel model = trainer.train(distributedMatrix);
- System.out.println(">>> Linear regression model: " + model);
-
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> | Prediction\t| Ground Truth\t|");
- System.out.println(">>> ---------------------------------");
- for (double[] observation : data) {
- Vector inputs = new SparseDistributedVector(Arrays.copyOfRange(observation, 1, observation.length));
- double prediction = model.apply(inputs);
- double groundTruth = observation[0];
- System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", prediction, groundTruth);
- }
- System.out.println(">>> ---------------------------------");
- });
-
- igniteThread.start();
-
- igniteThread.join();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/regression/linear/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/regression/linear/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/regression/linear/package-info.java
deleted file mode 100644
index d0441a4..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/regression/linear/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. -->
- * ML linear regression examples.
- */
-package org.apache.ignite.examples.ml.regression.linear;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/regression/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/regression/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/regression/package-info.java
deleted file mode 100644
index c89c80c..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/regression/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. -->
- * ML regression examples.
- */
-package org.apache.ignite.examples.ml.regression;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/trees/MNISTExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/trees/MNISTExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/trees/MNISTExample.java
deleted file mode 100644
index 6ff121e..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/trees/MNISTExample.java
+++ /dev/null
@@ -1,261 +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.examples.ml.trees;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Random;
-import java.util.function.Function;
-import java.util.stream.Stream;
-import org.apache.commons.cli.BasicParser;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.ml.Model;
-import org.apache.ignite.ml.estimators.Estimators;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.functions.IgniteTriFunction;
-import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
-import org.apache.ignite.ml.trees.models.DecisionTreeModel;
-import org.apache.ignite.ml.trees.trainers.columnbased.BiIndex;
-import org.apache.ignite.ml.trees.trainers.columnbased.BiIndexedCacheColumnDecisionTreeTrainerInput;
-import org.apache.ignite.ml.trees.trainers.columnbased.ColumnDecisionTreeTrainer;
-import org.apache.ignite.ml.trees.trainers.columnbased.contsplitcalcs.ContinuousSplitCalculators;
-import org.apache.ignite.ml.trees.trainers.columnbased.contsplitcalcs.GiniSplitCalculator;
-import org.apache.ignite.ml.trees.trainers.columnbased.regcalcs.RegionCalculators;
-import org.apache.ignite.ml.util.MnistUtils;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * <p>
- * Example of usage of decision trees algorithm for MNIST dataset
- * (it can be found here: http://yann.lecun.com/exdb/mnist/). </p>
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.</p>
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.</p>
- * <p>
- * It is recommended to start at least one node prior to launching this example if you intend
- * to run it with default memory settings.</p>
- * <p>
- * This example should with program arguments, for example
- * -ts_i /path/to/train-images-idx3-ubyte
- * -ts_l /path/to/train-labels-idx1-ubyte
- * -tss_i /path/to/t10k-images-idx3-ubyte
- * -tss_l /path/to/t10k-labels-idx1-ubyte
- * -cfg examples/config/example-ignite.xml.</p>
- * <p>
- * -ts_i specifies path to training set images of MNIST;
- * -ts_l specifies path to training set labels of MNIST;
- * -tss_i specifies path to test set images of MNIST;
- * -tss_l specifies path to test set labels of MNIST;
- * -cfg specifies path to a config path.</p>
- */
-public class MNISTExample {
- /** Name of parameter specifying path to training set images. */
- private static final String MNIST_TRAINING_IMAGES_PATH = "ts_i";
-
- /** Name of parameter specifying path to training set labels. */
- private static final String MNIST_TRAINING_LABELS_PATH = "ts_l";
-
- /** Name of parameter specifying path to test set images. */
- private static final String MNIST_TEST_IMAGES_PATH = "tss_i";
-
- /** Name of parameter specifying path to test set labels. */
- private static final String MNIST_TEST_LABELS_PATH = "tss_l";
-
- /** Name of parameter specifying path of Ignite config. */
- private static final String CONFIG = "cfg";
-
- /** Default config path. */
- private static final String DEFAULT_CONFIG = "examples/config/example-ignite.xml";
-
- /**
- * Launches example.
- *
- * @param args Program arguments.
- */
- public static void main(String[] args) {
- String igniteCfgPath;
-
- CommandLineParser parser = new BasicParser();
-
- String trainingImagesPath;
- String trainingLabelsPath;
-
- String testImagesPath;
- String testLabelsPath;
-
- try {
- // Parse the command line arguments.
- CommandLine line = parser.parse(buildOptions(), args);
-
- trainingImagesPath = line.getOptionValue(MNIST_TRAINING_IMAGES_PATH);
- trainingLabelsPath = line.getOptionValue(MNIST_TRAINING_LABELS_PATH);
- testImagesPath = line.getOptionValue(MNIST_TEST_IMAGES_PATH);
- testLabelsPath = line.getOptionValue(MNIST_TEST_LABELS_PATH);
- igniteCfgPath = line.getOptionValue(CONFIG, DEFAULT_CONFIG);
- }
- catch (ParseException e) {
- e.printStackTrace();
- return;
- }
-
- try (Ignite ignite = Ignition.start(igniteCfgPath)) {
- IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
-
- int ptsCnt = 60000;
- int featCnt = 28 * 28;
-
- Stream<DenseLocalOnHeapVector> trainingMnistStream = MnistUtils.mnist(trainingImagesPath, trainingLabelsPath, new Random(123L), ptsCnt);
- Stream<DenseLocalOnHeapVector> testMnistStream = MnistUtils.mnist(testImagesPath, testLabelsPath, new Random(123L), 10_000);
-
- IgniteCache<BiIndex, Double> cache = createBiIndexedCache(ignite);
-
- loadVectorsIntoBiIndexedCache(cache.getName(), trainingMnistStream.iterator(), featCnt + 1, ignite);
-
- ColumnDecisionTreeTrainer<GiniSplitCalculator.GiniData> trainer =
- new ColumnDecisionTreeTrainer<>(10, ContinuousSplitCalculators.GINI.apply(ignite), RegionCalculators.GINI, RegionCalculators.MOST_COMMON, ignite);
-
- System.out.println(">>> Training started");
- long before = System.currentTimeMillis();
- DecisionTreeModel mdl = trainer.train(new BiIndexedCacheColumnDecisionTreeTrainerInput(cache, new HashMap<>(), ptsCnt, featCnt));
- System.out.println(">>> Training finished in " + (System.currentTimeMillis() - before));
-
- IgniteTriFunction<Model<Vector, Double>, Stream<IgniteBiTuple<Vector, Double>>, Function<Double, Double>, Double> mse = Estimators.errorsPercentage();
- Double accuracy = mse.apply(mdl, testMnistStream.map(v -> new IgniteBiTuple<>(v.viewPart(0, featCnt), v.getX(featCnt))), Function.identity());
- System.out.println(">>> Errs percentage: " + accuracy);
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Build cli options.
- */
- @NotNull private static Options buildOptions() {
- Options options = new Options();
-
- Option trsImagesPathOpt = OptionBuilder.withArgName(MNIST_TRAINING_IMAGES_PATH).withLongOpt(MNIST_TRAINING_IMAGES_PATH).hasArg()
- .withDescription("Path to the MNIST training set.")
- .isRequired(true).create();
-
- Option trsLabelsPathOpt = OptionBuilder.withArgName(MNIST_TRAINING_LABELS_PATH).withLongOpt(MNIST_TRAINING_LABELS_PATH).hasArg()
- .withDescription("Path to the MNIST training set.")
- .isRequired(true).create();
-
- Option tssImagesPathOpt = OptionBuilder.withArgName(MNIST_TEST_IMAGES_PATH).withLongOpt(MNIST_TEST_IMAGES_PATH).hasArg()
- .withDescription("Path to the MNIST test set.")
- .isRequired(true).create();
-
- Option tssLabelsPathOpt = OptionBuilder.withArgName(MNIST_TEST_LABELS_PATH).withLongOpt(MNIST_TEST_LABELS_PATH).hasArg()
- .withDescription("Path to the MNIST test set.")
- .isRequired(true).create();
-
- Option configOpt = OptionBuilder.withArgName(CONFIG).withLongOpt(CONFIG).hasArg()
- .withDescription("Path to the config.")
- .isRequired(false).create();
-
- options.addOption(trsImagesPathOpt);
- options.addOption(trsLabelsPathOpt);
- options.addOption(tssImagesPathOpt);
- options.addOption(tssLabelsPathOpt);
- options.addOption(configOpt);
-
- return options;
- }
-
- /**
- * Creates cache where data for training is stored.
- *
- * @param ignite Ignite instance.
- * @return cache where data for training is stored.
- */
- private static IgniteCache<BiIndex, Double> createBiIndexedCache(Ignite ignite) {
- CacheConfiguration<BiIndex, Double> cfg = new CacheConfiguration<>();
-
- // 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);
-
- cfg.setBackups(0);
-
- cfg.setName("TMP_BI_INDEXED_CACHE");
-
- return ignite.getOrCreateCache(cfg);
- }
-
- /**
- * Loads vectors into cache.
- *
- * @param cacheName Name of cache.
- * @param vectorsIterator Iterator over vectors to load.
- * @param vectorSize Size of vector.
- * @param ignite Ignite instance.
- */
- private static void loadVectorsIntoBiIndexedCache(String cacheName, Iterator<? extends Vector> vectorsIterator,
- int vectorSize, Ignite ignite) {
- try (IgniteDataStreamer<BiIndex, Double> streamer =
- ignite.dataStreamer(cacheName)) {
- int sampleIdx = 0;
-
- streamer.perNodeBufferSize(10000);
-
- while (vectorsIterator.hasNext()) {
- org.apache.ignite.ml.math.Vector next = vectorsIterator.next();
-
- for (int i = 0; i < vectorSize; i++)
- streamer.addData(new BiIndex(sampleIdx, i), next.getX(i));
-
- sampleIdx++;
-
- if (sampleIdx % 1000 == 0)
- System.out.println("Loaded " + sampleIdx + " vectors.");
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/trees/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/trees/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/trees/package-info.java
deleted file mode 100644
index d944f60..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/trees/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. -->
- * Decision trees examples.
- */
-package org.apache.ignite.examples.ml.trees;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/BasicExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/BasicExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/BasicExamplesSelfTest.java
index 30e1456..41ae90a 100644
--- a/examples/src/test/java/org/apache/ignite/examples/BasicExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/BasicExamplesSelfTest.java
@@ -20,10 +20,7 @@ package org.apache.ignite.examples;
import org.apache.ignite.examples.computegrid.ComputeBroadcastExample;
import org.apache.ignite.examples.computegrid.ComputeCallableExample;
import org.apache.ignite.examples.computegrid.ComputeClosureExample;
-import org.apache.ignite.examples.computegrid.ComputeReducerExample;
import org.apache.ignite.examples.computegrid.ComputeRunnableExample;
-import org.apache.ignite.examples.computegrid.ComputeTaskMapExample;
-import org.apache.ignite.examples.computegrid.ComputeTaskSplitExample;
import org.apache.ignite.examples.datastructures.IgniteExecutorServiceExample;
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
@@ -59,12 +56,13 @@ public class BasicExamplesSelfTest extends GridAbstractExamplesTest {
IgniteExecutorServiceExample.main(EMPTY_ARGS);
}
- /**
- * @throws Exception If failed.
- */
- public void testReducerExample() throws Exception {
- ComputeReducerExample.main(EMPTY_ARGS);
- }
+// TODO: IGNITE-711 next example(s) should be implemented for java 8 or testing method(s) should be removed if example(s) does not applicable for java 8.
+// /**
+// * @throws Exception If failed.
+// */
+// public void testReducerExample() throws Exception {
+// ComputeReducerExample.main(EMPTY_ARGS);
+// }
/**
* @throws Exception If failed.
@@ -73,17 +71,19 @@ public class BasicExamplesSelfTest extends GridAbstractExamplesTest {
ComputeRunnableExample.main(EMPTY_ARGS);
}
- /**
- * @throws Exception If failed.
- */
- public void testTaskMapExample() throws Exception {
- ComputeTaskMapExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTaskSplitExample() throws Exception {
- ComputeTaskSplitExample.main(EMPTY_ARGS);
- }
-}
\ No newline at end of file
+// TODO: IGNITE-711 next example(s) should be implemented for java 8
+// or testing method(s) should be removed if example(s) does not applicable for java 8.
+// /**
+// * @throws Exception If failed.
+// */
+// public void testTaskMapExample() throws Exception {
+// ComputeTaskMapExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testTaskSplitExample() throws Exception {
+// ComputeTaskSplitExample.main(EMPTY_ARGS);
+// }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/CacheExamplesMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/CacheExamplesMultiNodeSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/CacheExamplesMultiNodeSelfTest.java
index c04f97e..06ceaac 100644
--- a/examples/src/test/java/org/apache/ignite/examples/CacheExamplesMultiNodeSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/CacheExamplesMultiNodeSelfTest.java
@@ -17,8 +17,6 @@
package org.apache.ignite.examples;
-import org.apache.ignite.examples.sql.SqlJdbcExample;
-
/**
* Cache examples multi-node self test.
*/
@@ -37,18 +35,4 @@ public class CacheExamplesMultiNodeSelfTest extends CacheExamplesSelfTest {
@Override protected long getTestTimeout() {
return 10 * 60 * 1000;
}
-
- /** {@inheritDoc} */
- @Override public void testCacheLockExample() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-4309");
-
- super.testCacheLockExample();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testJdbcThinExample() throws Exception {
- SqlJdbcExample.main(EMPTY_ARGS);
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/CacheExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/CacheExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/CacheExamplesSelfTest.java
index d39fab5..0085573 100644
--- a/examples/src/test/java/org/apache/ignite/examples/CacheExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/CacheExamplesSelfTest.java
@@ -20,27 +20,12 @@ package org.apache.ignite.examples;
import org.apache.ignite.examples.datagrid.CacheAffinityExample;
import org.apache.ignite.examples.datagrid.CacheEntryProcessorExample;
import org.apache.ignite.examples.datagrid.CacheApiExample;
-import org.apache.ignite.examples.datagrid.CacheContinuousQueryExample;
-import org.apache.ignite.examples.datagrid.CacheDataStreamerExample;
-import org.apache.ignite.examples.datagrid.CachePutGetExample;
-import org.apache.ignite.examples.sql.SqlDdlExample;
-import org.apache.ignite.examples.sql.SqlDmlExample;
-import org.apache.ignite.examples.datagrid.CacheQueryExample;
-import org.apache.ignite.examples.datagrid.CacheTransactionExample;
-import org.apache.ignite.examples.datagrid.DataRegionsExample;
-import org.apache.ignite.examples.datagrid.starschema.CacheStarSchemaExample;
-import org.apache.ignite.examples.datagrid.store.CacheLoadOnlyStoreExample;
-import org.apache.ignite.examples.datastructures.IgniteAtomicLongExample;
-import org.apache.ignite.examples.datastructures.IgniteAtomicReferenceExample;
-import org.apache.ignite.examples.datastructures.IgniteAtomicSequenceExample;
-import org.apache.ignite.examples.datastructures.IgniteAtomicStampedExample;
-import org.apache.ignite.examples.datastructures.IgniteCountDownLatchExample;
-import org.apache.ignite.examples.datastructures.IgniteQueueExample;
-import org.apache.ignite.examples.datastructures.IgniteLockExample;
-import org.apache.ignite.examples.datastructures.IgniteSemaphoreExample;
-import org.apache.ignite.examples.datastructures.IgniteSetExample;
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+//import org.apache.ignite.examples.datagrid.starschema.*;
+//import org.apache.ignite.examples.datagrid.store.dummy.*;
+//import org.apache.ignite.examples.datastructures.*;
+
/**
* Cache examples self test.
*/
@@ -59,89 +44,70 @@ public class CacheExamplesSelfTest extends GridAbstractExamplesTest {
CacheEntryProcessorExample.main(EMPTY_ARGS);
}
- /**
- * @throws Exception If failed.
- */
- public void testCacheAtomicLongExample() throws Exception {
- IgniteAtomicLongExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheAtomicReferenceExample() throws Exception {
- IgniteAtomicReferenceExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheAtomicSequenceExample() throws Exception {
- IgniteAtomicSequenceExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheAtomicStampedExample() throws Exception {
- IgniteAtomicStampedExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheCountDownLatchExample() throws Exception {
- IgniteCountDownLatchExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheSemaphoreExample() throws Exception {
- IgniteSemaphoreExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheLockExample() throws Exception {
- IgniteLockExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheQueueExample() throws Exception {
- IgniteQueueExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheSetExample() throws Exception {
- IgniteSetExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheQueryExample() throws Exception {
- CacheQueryExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheQueryDmlExample() throws Exception {
- SqlDmlExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheQueryDdlExample() throws Exception {
- SqlDdlExample.main(EMPTY_ARGS);
- }
+// TODO: IGNITE-711 next example(s) should be implemented for java 8
+// or testing method(s) should be removed if example(s) does not applicable for java 8.
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCacheAtomicLongExample() throws Exception {
+// IgniteAtomicLongExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCacheAtomicReferenceExample() throws Exception {
+// IgniteAtomicReferenceExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCacheAtomicSequenceExample() throws Exception {
+// IgniteAtomicSequenceExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCacheAtomicStampedExample() throws Exception {
+// IgniteAtomicStampedExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCacheCountDownLatchExample() throws Exception {
+// IgniteCountDownLatchExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCacheQueueExample() throws Exception {
+// IgniteQueueExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCacheSetExample() throws Exception {
+// IgniteSetExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCacheDummyStoreExample() throws Exception {
+// CacheDummyStoreExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCacheQueryExample() throws Exception {
+// CacheQueryExample.main(EMPTY_ARGS);
+// }
/**
* @throws Exception If failed.
@@ -150,52 +116,40 @@ public class CacheExamplesSelfTest extends GridAbstractExamplesTest {
CacheApiExample.main(EMPTY_ARGS);
}
- /**
- * @throws Exception If failed.
- */
- public void testCacheTransactionExample() throws Exception {
- CacheTransactionExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheDataStreamerExample() throws Exception {
- CacheDataStreamerExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCachePutGetExample() throws Exception {
- CachePutGetExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testSnowflakeSchemaExample() throws Exception {
- CacheStarSchemaExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheContinuousQueryExample() throws Exception {
- CacheContinuousQueryExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheLoadOnlyStoreExample() throws Exception {
- CacheLoadOnlyStoreExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDataRegionExample() throws Exception {
- DataRegionsExample.main(EMPTY_ARGS);
- }
+// TODO: IGNITE-711 next example(s) should be implemented for java 8
+// or testing method(s) should be removed if example(s) does not applicable for java 8.
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCacheTransactionExample() throws Exception {
+// CacheTransactionExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCacheDataStreamerExample() throws Exception {
+// CacheDataStreamerExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCachePutGetExample() throws Exception {
+// CachePutGetExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testSnowflakeSchemaExample() throws Exception {
+// CacheStarSchemaExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCacheContinuousQueryExample() throws Exception {
+// CacheContinuousQueryExample.main(EMPTY_ARGS);
+// }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/CheckpointExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/CheckpointExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/CheckpointExamplesSelfTest.java
index 226a573..03185c8 100644
--- a/examples/src/test/java/org/apache/ignite/examples/CheckpointExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/CheckpointExamplesSelfTest.java
@@ -17,8 +17,6 @@
package org.apache.ignite.examples;
-import org.apache.ignite.examples.computegrid.failover.ComputeFailoverExample;
-import org.apache.ignite.examples.computegrid.failover.ComputeFailoverNodeStartup;
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
/**
@@ -26,21 +24,24 @@ import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
*/
public class CheckpointExamplesSelfTest extends GridAbstractExamplesTest {
/**
+ * TODO: IGNITE-711 next example(s) should be implemented for java 8
+ * or testing method(s) should be removed if example(s) does not applicable for java 8.
+ *
* Starts remote nodes before each test.
*
* Note: using beforeTestsStarted() to start nodes only once won't work.
*
* @throws Exception If remote nodes start failed.
*/
- @Override protected void beforeTest() throws Exception {
- for (int i = 0; i < RMT_NODES_CNT; i++)
- startGrid("node-" + i, ComputeFailoverNodeStartup.configuration());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCheckpointExample() throws Exception {
- ComputeFailoverExample.main(EMPTY_ARGS);
- }
-}
\ No newline at end of file
+// @Override protected void beforeTest() throws Exception {
+// for (int i = 0; i < RMT_NODES_CNT; i++)
+// startGrid("node-" + i, ComputeFailoverNodeStartup.configuration());
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testCheckpointExample() throws Exception {
+// ComputeFailoverExample.main(EMPTY_ARGS);
+// }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/ClusterGroupExampleSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/ClusterGroupExampleSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/ClusterGroupExampleSelfTest.java
index 3746de7..35b2510 100644
--- a/examples/src/test/java/org/apache/ignite/examples/ClusterGroupExampleSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/ClusterGroupExampleSelfTest.java
@@ -17,7 +17,6 @@
package org.apache.ignite.examples;
-import org.apache.ignite.examples.computegrid.cluster.ClusterGroupExample;
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
/**
@@ -30,10 +29,12 @@ public class ClusterGroupExampleSelfTest extends GridAbstractExamplesTest {
startGrid("ignite-cluster-groups-example", DFLT_CFG);
}
- /**
- * @throws Exception If failed.
- */
- public void testComputeClusterGroupsExample() throws Exception {
- ClusterGroupExample.main(EMPTY_ARGS);
- }
-}
\ No newline at end of file
+// TODO: IGNITE-711 next example(s) should be implemented for java 8
+// or testing method(s) should be removed if example(s) does not applicable for java 8.
+// /**
+// * @throws Exception If failed.
+// */
+// public void testComputeClusterGroupsExample() throws Exception {
+// ClusterGroupExample.main(EMPTY_ARGS);
+// }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/ContinuationExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/ContinuationExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/ContinuationExamplesSelfTest.java
index d1cfaf5..512a55b 100644
--- a/examples/src/test/java/org/apache/ignite/examples/ContinuationExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/ContinuationExamplesSelfTest.java
@@ -17,7 +17,8 @@
package org.apache.ignite.examples;
-import org.apache.ignite.examples.computegrid.ComputeFibonacciContinuationExample;
+//import org.apache.ignite.examples.computegrid.*;
+
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
/**
@@ -25,9 +26,12 @@ import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
*/
public class ContinuationExamplesSelfTest extends GridAbstractExamplesTest {
/**
+ * TODO: IGNITE-711 next example(s) should be implemented for java 8
+ * or testing method(s) should be removed if example(s) does not applicable for java 8.
+ *
* @throws Exception If failed.
*/
- public void testContinuationExample() throws Exception {
- ComputeFibonacciContinuationExample.main(EMPTY_ARGS);
- }
-}
\ No newline at end of file
+// public void testContinuationExample() throws Exception {
+// ComputeFibonacciContinuationExample.main(EMPTY_ARGS);
+// }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/ContinuousMapperExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/ContinuousMapperExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/ContinuousMapperExamplesSelfTest.java
index 2dda7d6..0ae7dc1 100644
--- a/examples/src/test/java/org/apache/ignite/examples/ContinuousMapperExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/ContinuousMapperExamplesSelfTest.java
@@ -17,7 +17,6 @@
package org.apache.ignite.examples;
-import org.apache.ignite.examples.computegrid.ComputeContinuousMapperExample;
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
/**
@@ -25,9 +24,12 @@ import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
*/
public class ContinuousMapperExamplesSelfTest extends GridAbstractExamplesTest {
/**
+ * TODO: IGNITE-711 next example(s) should be implemented for java 8
+ * or testing method(s) should be removed if example(s) does not applicable for java 8.
+ *
* @throws Exception If failed.
*/
- public void testContinuousMapperExample() throws Exception {
- ComputeContinuousMapperExample.main(EMPTY_ARGS);
- }
-}
\ No newline at end of file
+// public void testContinuousMapperExample() throws Exception {
+// ComputeContinuousMapperExample.main(EMPTY_ARGS);
+// }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesMultiNodeSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesMultiNodeSelfTest.java
index 73b7e4c..c57f285 100644
--- a/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesMultiNodeSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesMultiNodeSelfTest.java
@@ -21,10 +21,12 @@ package org.apache.ignite.examples;
* Deployment examples multi-node self test.
*/
public class DeploymentExamplesMultiNodeSelfTest extends DeploymentExamplesSelfTest {
+ // TODO: IGNITE-711 next example(s) should be implemented for java 8
+ // or testing method(s) should be removed if example(s) does not applicable for java 8.
/** {@inheritDoc} */
- @Override public void testDeploymentExample() throws Exception {
- startRemoteNodes();
-
- super.testDeploymentExample();
- }
+// @Override public void testDeploymentExample() throws Exception {
+// startRemoteNodes();
+//
+// super.testDeploymentExample();
+// }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesSelfTest.java
index 0059429..8a01b9b 100644
--- a/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesSelfTest.java
@@ -17,17 +17,20 @@
package org.apache.ignite.examples;
-import org.apache.ignite.examples.misc.deployment.DeploymentExample;
+//import org.apache.ignite.examples.misc.deployment.*;
+
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
/**
* Deployment examples self test.
*/
public class DeploymentExamplesSelfTest extends GridAbstractExamplesTest {
+ // TODO: IGNITE-711 next example(s) should be implemented for java 8
+ // or testing method(s) should be removed if example(s) does not applicable for java 8.
/**
* @throws Exception If failed.
*/
- public void testDeploymentExample() throws Exception {
- DeploymentExample.main(EMPTY_ARGS);
- }
-}
\ No newline at end of file
+// public void testDeploymentExample() throws Exception {
+// DeploymentExample.main(EMPTY_ARGS);
+// }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/EventsExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/EventsExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/EventsExamplesSelfTest.java
index 6eea95e..8e675a3 100644
--- a/examples/src/test/java/org/apache/ignite/examples/EventsExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/EventsExamplesSelfTest.java
@@ -30,4 +30,4 @@ public class EventsExamplesSelfTest extends GridAbstractExamplesTest {
public void testEventsExample() throws Exception {
EventsExample.main(EMPTY_ARGS);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/IgfsExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/IgfsExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/IgfsExamplesSelfTest.java
index 766c22c..1be686c 100644
--- a/examples/src/test/java/org/apache/ignite/examples/IgfsExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/IgfsExamplesSelfTest.java
@@ -17,8 +17,9 @@
package org.apache.ignite.examples;
-import org.apache.ignite.examples.igfs.IgfsExample;
-import org.apache.ignite.internal.util.typedef.internal.U;
+//import org.apache.ignite.examples.igfs.*;
+//import org.apache.ignite.internal.util.typedef.internal.*;
+
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
/**
@@ -32,20 +33,23 @@ public class IgfsExamplesSelfTest extends GridAbstractExamplesTest {
private static final String IGFS_LOOPBACK_CFG = "modules/core/src/test/config/igfs-loopback.xml";
/**
+ * TODO: IGNITE-711 next example(s) should be implemented for java 8
+ * or testing method(s) should be removed if example(s) does not applicable for java 8.
+ *
* @throws Exception If failed.
*/
- public void testIgniteFsApiExample() throws Exception {
- String configPath = U.isWindows() ? IGFS_LOOPBACK_CFG : IGFS_SHMEM_CFG;
-
- try {
- startGrid("test1", configPath);
- startGrid("test2", configPath);
- startGrid("test3", configPath);
-
- IgfsExample.main(EMPTY_ARGS);
- }
- finally {
- stopAllGrids();
- }
- }
-}
\ No newline at end of file
+// public void testIgniteFsApiExample() throws Exception {
+// String configPath = U.isWindows() ? IGFS_LOOPBACK_CFG : IGFS_SHMEM_CFG;
+//
+// try {
+// startGrid("test1", configPath);
+// startGrid("test2", configPath);
+// startGrid("test3", configPath);
+//
+// IgfsExample.main(EMPTY_ARGS);
+// }
+// finally {
+// stopAllGrids();
+// }
+// }
+}
[03/11] ignite git commit: IGNITE-7203 Java 8 by default
Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/ml/org/apache/ignite/ml/testsuites/IgniteExamplesMLTestSuite.java
----------------------------------------------------------------------
diff --git a/examples/src/test/ml/org/apache/ignite/ml/testsuites/IgniteExamplesMLTestSuite.java b/examples/src/test/ml/org/apache/ignite/ml/testsuites/IgniteExamplesMLTestSuite.java
deleted file mode 100644
index bc917b9..0000000
--- a/examples/src/test/ml/org/apache/ignite/ml/testsuites/IgniteExamplesMLTestSuite.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.ml.testsuites;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import javassist.CannotCompileException;
-import javassist.ClassClassPath;
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.CtNewMethod;
-import javassist.NotFoundException;
-import junit.framework.TestSuite;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP;
-
-/**
- * Examples test suite.
- * <p>
- * Contains only Spring ignite examples tests.
- */
-public class IgniteExamplesMLTestSuite extends TestSuite {
- /**
- * @return Suite.
- * @throws Exception If failed.
- */
- public static TestSuite suite() throws Exception {
- System.setProperty(IGNITE_OVERRIDE_MCAST_GRP,
- GridTestUtils.getNextMulticastGroup(IgniteExamplesMLTestSuite.class));
-
- TestSuite suite = new TestSuite("Ignite ML Examples Test Suite");
-
- for (Class clazz : getClasses("org.apache.ignite.examples.ml", ".*Example$"))
- suite.addTest(new TestSuite(makeTestClass(clazz, "org.apache.ignite.ml.examples")));
-
- return suite;
- }
-
- /**
- * Creates test class for given example.
- *
- * @param exampleCls Class of the example to be tested
- * @param basePkgForTests Base package to create test classes in
- * @return Test class
- * @throws NotFoundException if class not found
- * @throws CannotCompileException if test class cannot be compiled
- */
- private static Class makeTestClass(Class<?> exampleCls, String basePkgForTests)
- throws NotFoundException, CannotCompileException {
- ClassPool cp = ClassPool.getDefault();
- cp.insertClassPath(new ClassClassPath(IgniteExamplesMLTestSuite.class));
-
- CtClass cl = cp.makeClass(basePkgForTests + "." + exampleCls.getSimpleName() + "SelfName");
-
- cl.setSuperclass(cp.get(GridAbstractExamplesTest.class.getName()));
-
- cl.addMethod(CtNewMethod.make("public void testExample() { "
- + exampleCls.getCanonicalName()
- + ".main("
- + GridAbstractExamplesTest.class.getName()
- + ".EMPTY_ARGS); }", cl));
-
- return cl.toClass();
- }
-
- /**
- * Scans all classes accessible from the context class loader which belong to the given package and subpackages.
- *
- * @param pkgName The base package
- * @return The classes
- * @throws ClassNotFoundException if some classes not found
- * @throws IOException if some resources unavailable
- */
- private static List<Class> getClasses(String pkgName, String clsNamePtrn) throws ClassNotFoundException, IOException {
- String path = pkgName.replace('.', '/');
-
- Enumeration<URL> resources = Thread.currentThread()
- .getContextClassLoader()
- .getResources(path);
-
- List<File> dirs = new ArrayList<>();
- while (resources.hasMoreElements())
- dirs.add(new File(resources.nextElement().getFile()));
-
- List<Class> classes = new ArrayList<>();
- for (File directory : dirs)
- classes.addAll(findClasses(directory, pkgName, clsNamePtrn));
-
- return classes;
- }
-
- /**
- * Recursive method used to find all classes in a given directory and subdirs.
- *
- * @param dir The base directory
- * @param pkgName The package name for classes found inside the base directory
- * @return The classes
- * @throws ClassNotFoundException if class not found
- */
- private static List<Class> findClasses(File dir, String pkgName, String clsNamePtrn) throws ClassNotFoundException {
- List<Class> classes = new ArrayList<>();
- if (!dir.exists())
- return classes;
-
- File[] files = dir.listFiles();
- if (files != null)
- for (File file : files) {
- if (file.isDirectory())
- classes.addAll(findClasses(file, pkgName + "." + file.getName(), clsNamePtrn));
- else if (file.getName().endsWith(".class")) {
- String clsName = pkgName + '.' + file.getName().substring(0, file.getName().length() - 6);
- if (clsName.matches(clsNamePtrn))
- classes.add(Class.forName(clsName));
- }
- }
-
- return classes;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/aop/pom.xml
----------------------------------------------------------------------
diff --git a/modules/aop/pom.xml b/modules/aop/pom.xml
index 12fe5e0..3e20931 100644
--- a/modules/aop/pom.xml
+++ b/modules/aop/pom.xml
@@ -114,6 +114,17 @@
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>pertest</forkMode>
+ <argLine>-javaagent:${basedir}/target/libs/aspectjweaver-${aspectj.version}.jar</argLine>
+ <workingDirectory>${basedir}/target</workingDirectory>
+ </configuration>
+ </plugin>
+
</plugins>
</build>
</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/aop/src/test/java/org/apache/ignite/gridify/BasicAopSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/BasicAopSelfTest.java b/modules/aop/src/test/java/org/apache/ignite/gridify/BasicAopSelfTest.java
index 28b7320..54ac74f 100644
--- a/modules/aop/src/test/java/org/apache/ignite/gridify/BasicAopSelfTest.java
+++ b/modules/aop/src/test/java/org/apache/ignite/gridify/BasicAopSelfTest.java
@@ -17,18 +17,16 @@
package org.apache.ignite.gridify;
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.Callable;
-import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.compute.ComputeJob;
import org.apache.ignite.compute.ComputeJobResult;
import org.apache.ignite.compute.gridify.Gridify;
import org.apache.ignite.compute.gridify.GridifyArgument;
import org.apache.ignite.compute.gridify.GridifyTaskSplitAdapter;
-import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import java.util.Collection;
+import java.util.List;
+
/**
* Tries to execute dummy gridified task. It should fail because grid is not started.
* <p>
@@ -40,18 +38,14 @@ public class BasicAopSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAop() throws Exception {
- GridTestUtils.assertThrows(
- log,
- new Callable<Object>() {
- @Override public Object call() throws Exception {
- gridify();
+ try {
+ gridify();
- return null;
- }
- },
- IgniteCheckedException.class,
- "Grid is not locally started: null"
- );
+ fail();
+ }
+ catch (Exception e) {
+ // No-op.
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/aop/src/test/java/org/apache/ignite/testsuites/IgniteAopSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/aop/src/test/java/org/apache/ignite/testsuites/IgniteAopSelfTestSuite.java b/modules/aop/src/test/java/org/apache/ignite/testsuites/IgniteAopSelfTestSuite.java
index 7c2d3ea..b2dcea2 100644
--- a/modules/aop/src/test/java/org/apache/ignite/testsuites/IgniteAopSelfTestSuite.java
+++ b/modules/aop/src/test/java/org/apache/ignite/testsuites/IgniteAopSelfTestSuite.java
@@ -40,13 +40,13 @@ public class IgniteAopSelfTestSuite extends TestSuite {
TestSuite suite = new TestSuite("Ignite AOP Test Suite");
// Test configuration.
- suite.addTest(new TestSuite(BasicAopSelfTest.class));
+ suite.addTestSuite(BasicAopSelfTest.class);
- suite.addTest(new TestSuite(SpringAopSelfTest.class));
- suite.addTest(new TestSuite(NonSpringAopSelfTest.class));
- suite.addTest(new TestSuite(GridifySetToXXXSpringAopSelfTest.class));
- suite.addTest(new TestSuite(GridifySetToXXXNonSpringAopSelfTest.class));
- suite.addTest(new TestSuite(ExternalNonSpringAopSelfTest.class));
+ suite.addTestSuite(SpringAopSelfTest.class);
+ suite.addTestSuite(NonSpringAopSelfTest.class);
+ suite.addTestSuite(GridifySetToXXXSpringAopSelfTest.class);
+ suite.addTestSuite(GridifySetToXXXNonSpringAopSelfTest.class);
+ suite.addTestSuite(ExternalNonSpringAopSelfTest.class);
// Examples
System.setProperty(IGNITE_OVERRIDE_MCAST_GRP, GridTestUtils.getNextMulticastGroup(IgniteAopSelfTestSuite.class));
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/benchmarks/pom.xml
----------------------------------------------------------------------
diff --git a/modules/benchmarks/pom.xml b/modules/benchmarks/pom.xml
index a2b4ac8..1c71b48 100644
--- a/modules/benchmarks/pom.xml
+++ b/modules/benchmarks/pom.xml
@@ -35,9 +35,6 @@
<url>http://ignite.apache.org</url>
<properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <jmh.version>1.13</jmh.version>
- <javac.target>1.7</javac.target>
<uberjar.name>benchmarks</uberjar.name>
</properties>
@@ -71,16 +68,6 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <compilerVersion>${javac.target}</compilerVersion>
- <source>${javac.target}</source>
- <target>${javac.target}</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/cassandra/serializers/pom.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/serializers/pom.xml b/modules/cassandra/serializers/pom.xml
index 07bb1a9..6d040e3 100644
--- a/modules/cassandra/serializers/pom.xml
+++ b/modules/cassandra/serializers/pom.xml
@@ -87,9 +87,6 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
- <source>1.7</source>
- <target>1.7</target>
- <compilerVersion>1.7</compilerVersion>
<encoding>UTF-8</encoding>
<fork>true</fork>
<debug>false</debug>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/cassandra/store/pom.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/pom.xml b/modules/cassandra/store/pom.xml
index 848c858..0729e08 100644
--- a/modules/cassandra/store/pom.xml
+++ b/modules/cassandra/store/pom.xml
@@ -149,9 +149,6 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
- <source>1.7</source>
- <target>1.7</target>
- <compilerVersion>1.7</compilerVersion>
<encoding>UTF-8</encoding>
<fork>true</fork>
<debug>false</debug>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/codegen/pom.xml
----------------------------------------------------------------------
diff --git a/modules/codegen/pom.xml b/modules/codegen/pom.xml
index bce03eb..bf20d06 100644
--- a/modules/codegen/pom.xml
+++ b/modules/codegen/pom.xml
@@ -20,7 +20,8 @@
<!--
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>
@@ -34,12 +35,6 @@
<version>2.4.0-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.compiler.source>1.7</maven.compiler.source>
- <maven.compiler.target>1.7</maven.compiler.target>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.apache.ignite</groupId>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 5ddc8ce..e946789 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -399,8 +399,6 @@
<properties>
<domain-lib-dir>${project.build.directory}/domainlib</domain-lib-dir>
<domain-jar>domain.jar</domain-jar>
-
- <javax.cache.tck.version>1.0.1</javax.cache.tck.version>
</properties>
<dependencies>
@@ -421,7 +419,7 @@
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
- <version>1.2</version>
+ <version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/indexing/pom.xml
----------------------------------------------------------------------
diff --git a/modules/indexing/pom.xml b/modules/indexing/pom.xml
index fc965c5..f2e1797 100644
--- a/modules/indexing/pom.xml
+++ b/modules/indexing/pom.xml
@@ -34,10 +34,6 @@
<version>2.4.0-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
- <properties>
- <java8.test.folder>${project.build.testSourceDirectory}</java8.test.folder>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.apache.ignite</groupId>
@@ -125,53 +121,9 @@
</dependency>
</dependencies>
- <profiles>
- <profile>
- <id>java8</id>
- <activation>
- <jdk>[1.8,)</jdk>
- </activation>
- <properties>
- <javadoc.opts>-Xdoclint:none</javadoc.opts>
- <java8.test.folder>${project.build.testSourceDirectory}/../java8</java8.test.folder>
- </properties>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.9.1</version>
- <executions>
- <execution>
- <id>add-tests</id>
- <phase>generate-test-sources</phase>
- <goals>
- <goal>add-test-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>${java8.test.folder}</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/mesos/pom.xml
----------------------------------------------------------------------
diff --git a/modules/mesos/pom.xml b/modules/mesos/pom.xml
index 19f24f1..792191b 100644
--- a/modules/mesos/pom.xml
+++ b/modules/mesos/pom.xml
@@ -63,17 +63,6 @@
<build>
<plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
-
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/ml/pom.xml
----------------------------------------------------------------------
diff --git a/modules/ml/pom.xml b/modules/ml/pom.xml
index 4ee4ecf..a20a596 100644
--- a/modules/ml/pom.xml
+++ b/modules/ml/pom.xml
@@ -33,11 +33,6 @@
<version>2.4.0-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <netlibjava.version>1.1.2</netlibjava.version>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.apache.ignite</groupId>
@@ -108,7 +103,6 @@
<profiles>
<profile>
<id>lgpl</id>
-
<dependencies>
<dependency>
<groupId>com.github.fommil.netlib</groupId>
@@ -119,16 +113,4 @@
</dependencies>
</profile>
</profiles>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/DataStorageConfigurationParityTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/DataStorageConfigurationParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/DataStorageConfigurationParityTest.cs
index 9ccef2b..51f2865 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/DataStorageConfigurationParityTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/DataStorageConfigurationParityTest.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/DataStorageMetricsParityTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/DataStorageMetricsParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/DataStorageMetricsParityTest.cs
index a182587..2206891 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/DataStorageMetricsParityTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/DataStorageMetricsParityTest.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/QueryEntityConfigurationParityTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/QueryEntityConfigurationParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/QueryEntityConfigurationParityTest.cs
index 0b481ed..a9830d8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/QueryEntityConfigurationParityTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/QueryEntityConfigurationParityTest.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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 fbd8775..6834d5d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs
index c1be392..4a60f7b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTestObsolete.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTestObsolete.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTestObsolete.cs
index 6b59377..e0e393f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTestObsolete.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTestObsolete.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs
index 7ee6695..5c48284 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ClientCacheConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ClientCacheConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ClientCacheConfigurationTest.cs
index 903b038..04ad7dc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ClientCacheConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ClientCacheConfigurationTest.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CreateCacheTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CreateCacheTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CreateCacheTest.cs
index 047fc2b..51f54ab 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CreateCacheTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CreateCacheTest.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
index 417e60a..999fdf8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
index 9fea52c..71e4a6f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test
index 2bda365..c6aaa52 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test
@@ -32,9 +32,9 @@
<add key="Ignite.Assembly.2" value="test-2.dll" />
<add key="Ignite.JvmOption.1" value="-DOPT1" />
<add key="Ignite.JvmOption.2" value="-DOPT2" />
- <add key="Ignite.JvmOption.3" value="-Xms601m" />
+ <add key="Ignite.JvmOption.3" value="-Xms602m" />
<add key="Ignite.JvmOption.4" value="-Xmx702m" />
- <add key="Ignite.JvmInitialMemoryMB" value="601" />
+ <add key="Ignite.JvmInitialMemoryMB" value="602" />
<add key="Ignite.JvmMaxMemoryMB" value="702" />
</appSettings>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test2
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test2 b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test2
index f40f220..566b57b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test2
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Apache.Ignite.exe.config.test2
@@ -51,7 +51,7 @@
<add key="Ignite.Assembly.2" value="test-2.dll" />
<add key="Ignite.JvmOption.1" value="-DOPT1" />
<add key="Ignite.JvmOption.2" value="-DOPT2" />
- <add key="Ignite.JvmOption.3" value="-Xms601m" />
+ <add key="Ignite.JvmOption.3" value="-Xms602m" />
<add key="Ignite.ConfigSectionName" value="igniteConfiguration" />
</appSettings>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml
index 29aa704..e1ca13a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
index 0ba0de6..eb1e68e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
@@ -111,7 +111,7 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual(SpringCfgPath, cfg.SpringConfigUrl);
Assert.IsTrue(cfg.JvmOptions.Contains("-DOPT1") && cfg.JvmOptions.Contains("-DOPT2"));
Assert.IsTrue(cfg.Assemblies.Contains("test-1.dll") && cfg.Assemblies.Contains("test-2.dll"));
- Assert.AreEqual(601, cfg.JvmInitialMemoryMb);
+ Assert.AreEqual(602, cfg.JvmInitialMemoryMb);
Assert.AreEqual(702, cfg.JvmMaxMemoryMb);
}
@@ -192,18 +192,18 @@ namespace Apache.Ignite.Core.Tests
var proc = new IgniteProcess(
"-jvmClasspath=" + TestUtils.CreateTestClasspath(),
"-springConfigUrl=" + SpringCfgPath,
- "-JvmInitialMemoryMB=615",
- "-JvmMaxMemoryMB=863"
+ "-JvmInitialMemoryMB=616",
+ "-JvmMaxMemoryMB=866"
);
Assert.IsTrue(proc.Alive);
Assert.IsTrue(_grid.WaitTopology(2));
var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
- Assert.AreEqual((long) 615*1024*1024, minMem);
+ Assert.AreEqual((long) 616*1024*1024, minMem);
var maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
- AssertJvmMaxMemory((long) 863*1024*1024, maxMem);
+ AssertJvmMaxMemory((long) 866*1024*1024, maxMem);
}
/// <summary>
@@ -224,7 +224,7 @@ namespace Apache.Ignite.Core.Tests
Assert.IsTrue(_grid.WaitTopology(2));
var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
- Assert.AreEqual((long) 601*1024*1024, minMem);
+ Assert.AreEqual((long) 602*1024*1024, minMem);
var maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
AssertJvmMaxMemory((long) 702*1024*1024, maxMem);
@@ -236,13 +236,13 @@ namespace Apache.Ignite.Core.Tests
// Command line options overwrite config file options
// ReSharper disable once RedundantAssignment
proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath(),
- "-J-Xms605m", "-J-Xmx706m");
+ "-J-Xms606m", "-J-Xmx706m");
Assert.IsTrue(proc.Alive);
Assert.IsTrue(_grid.WaitTopology(2));
minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
- Assert.AreEqual((long) 605*1024*1024, minMem);
+ Assert.AreEqual((long) 606*1024*1024, minMem);
maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
AssertJvmMaxMemory((long) 706*1024*1024, maxMem);
@@ -257,7 +257,7 @@ namespace Apache.Ignite.Core.Tests
var proc = new IgniteProcess(
"-jvmClasspath=" + TestUtils.CreateTestClasspath(),
"-springConfigUrl=" + SpringCfgPath,
- "-J-Xms555m",
+ "-J-Xms556m",
"-J-Xmx666m",
"-JvmInitialMemoryMB=128",
"-JvmMaxMemoryMB=256"
@@ -268,7 +268,7 @@ namespace Apache.Ignite.Core.Tests
// Raw JVM options (Xms/Xmx) should override custom options
var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
- Assert.AreEqual((long) 555*1024*1024, minMem);
+ Assert.AreEqual((long) 556*1024*1024, minMem);
var maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MaxMemTask, null);
AssertJvmMaxMemory((long) 666*1024*1024, maxMem);
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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 1260aa5..543bb6d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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 0b1b499..0bc4e0f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/WindowsServiceTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/WindowsServiceTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/WindowsServiceTest.cs
index 08d365a..ee909f3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/WindowsServiceTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/WindowsServiceTest.cs
@@ -18,10 +18,13 @@
namespace Apache.Ignite.Core.Tests
{
using System;
+ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Impl.Unmanaged.Jni;
+ using Apache.Ignite.Core.Log;
using Apache.Ignite.Core.Tests.Process;
using NUnit.Framework;
@@ -56,23 +59,29 @@ namespace Apache.Ignite.Core.Tests
[Test]
public void TestStopFromJava()
{
+ var startTime = DateTime.Now.AddSeconds(-1);
+
var exePath = typeof(IgniteRunner).Assembly.Location;
var springPath = Path.GetFullPath(@"config\compute\compute-grid1.xml");
+ JvmDll.Load(null, new NoopLogger());
+ var jvmDll = System.Diagnostics.Process.GetCurrentProcess().Modules
+ .OfType<ProcessModule>()
+ .Single(x => JvmDll.FileJvmDll.Equals(x.ModuleName, StringComparison.OrdinalIgnoreCase));
+
IgniteProcess.Start(exePath, string.Empty, args: new[]
{
"/install",
"ForceTestClasspath=true",
"-springConfigUrl=" + springPath,
- "-J-Xms513m",
- "-J-Xmx555m"
+ "-jvmDll=" + jvmDll.FileName
}).WaitForExit();
var service = GetIgniteService();
Assert.IsNotNull(service);
service.Start(); // see IGNITE_HOME\work\log for service instance logs
- service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(30));
+ WaitForStatus(service, startTime, ServiceControllerStatus.Running);
using (var ignite = Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration())
{
@@ -89,8 +98,33 @@ namespace Apache.Ignite.Core.Tests
Assert.IsTrue(ignite.WaitTopology(1), "Failed to stop remote node");
- // Check that service has stopped
- service.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(30));
+ // Check that service has stopped.
+ WaitForStatus(service, startTime, ServiceControllerStatus.Stopped);
+ }
+ }
+
+ /// <summary>
+ /// Waits for service status.
+ /// </summary>
+ private static void WaitForStatus(ServiceController service, DateTime startTime,
+ ServiceControllerStatus status)
+ {
+ try
+ {
+ service.WaitForStatus(status, TimeSpan.FromSeconds(30));
+ }
+ catch (Exception ex)
+ {
+ // Check Windows log for more details.
+ var log = EventLog.GetEventLogs().Single(x => x.Log == "Application");
+ var entries = log.Entries;
+ var recentEntries = Enumerable.Range(0, entries.Count)
+ .Select(x => entries[x])
+ .Where(x => x.TimeGenerated >= startTime)
+ .Select(x => x.Message);
+ var msg = string.Join("\n===\n", recentEntries);
+
+ throw new Exception("Failed to start service. Event entries:\n" + msg, ex);
}
}
@@ -120,5 +154,19 @@ namespace Apache.Ignite.Core.Tests
{
return ServiceController.GetServices().FirstOrDefault(x => x.ServiceName.StartsWith("Apache Ignite.NET"));
}
+
+ private class NoopLogger : ILogger
+ {
+ public void Log(LogLevel level, string message, object[] args, IFormatProvider formatProvider, string category,
+ string nativeErrorInfo, Exception ex)
+ {
+ // No-op.
+ }
+
+ public bool IsEnabled(LogLevel level)
+ {
+ return false;
+ }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
index a1fb4e0..8855535 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs
index 38aeed3..a96f1bf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs
index 96912dd..dd131f9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/CacheClientConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/CacheClientConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/CacheClientConfiguration.cs
index 1c1874f..fad6b58 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/CacheClientConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/CacheClientConfiguration.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/ClientConnectorConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/ClientConnectorConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/ClientConnectorConfiguration.cs
index aff2716..e51a08c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/ClientConnectorConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/ClientConnectorConfiguration.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/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 84afdc4..7deebc5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/ClientCacheConfigurationSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/ClientCacheConfigurationSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/ClientCacheConfigurationSerializer.cs
index b11b175..552c778 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/ClientCacheConfigurationSerializer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/ClientCacheConfigurationSerializer.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Env.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Env.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Env.cs
index 93b5e69..f3632ce 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Env.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Env.cs
@@ -19,9 +19,11 @@ namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
{
using System;
using System.Diagnostics;
+ using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl.Common;
/// <summary>
/// JNIEnv.
@@ -236,8 +238,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
if (res == IntPtr.Zero)
{
- throw new IgniteException("Java class is not found (did you set IGNITE_HOME environment " +
- "variable?): " + name);
+ var msg = "Java class is not found (did you set IGNITE_HOME environment variable?): " + name;
+
+ throw new IgniteException(msg);
}
return NewGlobalRef(res);
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs b/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs
index c6660c3..8924591 100644
--- a/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs
@@ -137,7 +137,7 @@ namespace Apache.Ignite
Console.WriteLine("\t-ConfigSectionName name of the IgniteConfigurationSection in app.config to use.");
Console.WriteLine("\t-ConfigFileName path to the app.config file (if not provided Apache.Ignite.exe.config is used).");
Console.WriteLine("\t-springConfigUrl path to Spring configuration file.");
- Console.WriteLine("\t-jvmDllPath path to JVM library jvm.dll (if not provided JAVA_HOME environment variable is used).");
+ Console.WriteLine("\t-jvmDll path to JVM library jvm.dll (if not provided JAVA_HOME environment variable is used).");
Console.WriteLine("\t-jvmClasspath classpath passed to JVM (enlist additional jar files here).");
Console.WriteLine("\t-suppressWarnings whether to print warnings.");
Console.WriteLine("\t-J<javaOption> JVM options passed to created JVM.");
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/platforms/dotnet/Apache.Ignite/Service/IgniteService.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/Service/IgniteService.cs b/modules/platforms/dotnet/Apache.Ignite/Service/IgniteService.cs
index 839727e..b34ad71 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Service/IgniteService.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Service/IgniteService.cs
@@ -42,7 +42,7 @@ namespace Apache.Ignite.Service
Assembly.GetExecutingAssembly().GetName().Version.ToString(4);
/** Service description. */
- public const string SvcDesc = "Apache Ignite.NET Service.";
+ public const string SvcDesc = "Apache Ignite.NET Service";
/** Current executable name. */
private static readonly string ExeName =
@@ -152,7 +152,16 @@ namespace Apache.Ignite.Service
var argString = new StringBuilder(IgniteRunner.Svc);
foreach (var arg in args)
- argString.Append(" ").AppendFormat("-{0}={1}", arg.Item1, arg.Item2);
+ {
+ var val = arg.Item2;
+
+ if (val.Contains(' '))
+ {
+ val = '"' + val + '"';
+ }
+
+ argString.Append(" ").AppendFormat("-{0}={1}", arg.Item1, val);
+ }
IgniteServiceInstaller.Args = argString.ToString();
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/sqlline/pom.xml
----------------------------------------------------------------------
diff --git a/modules/sqlline/pom.xml b/modules/sqlline/pom.xml
index ac80948..30a72db 100644
--- a/modules/sqlline/pom.xml
+++ b/modules/sqlline/pom.xml
@@ -35,10 +35,6 @@
<version>2.4.0-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
-
<dependencies>
<dependency>
<groupId>sqlline</groupId>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/tools/pom.xml
----------------------------------------------------------------------
diff --git a/modules/tools/pom.xml b/modules/tools/pom.xml
index b71c421..653d470 100644
--- a/modules/tools/pom.xml
+++ b/modules/tools/pom.xml
@@ -34,12 +34,6 @@
<version>2.4.0-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.compiler.source>1.7</maven.compiler.source>
- <maven.compiler.target>1.7</maven.compiler.target>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.jodd</groupId>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/pom-standalone.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom-standalone.xml b/modules/yardstick/pom-standalone.xml
index 58920b9..577a95e 100644
--- a/modules/yardstick/pom-standalone.xml
+++ b/modules/yardstick/pom-standalone.xml
@@ -31,8 +31,6 @@
<properties>
<yardstick.version>0.8.3</yardstick.version>
<spring.version>4.1.0.RELEASE</spring.version>
- <!-- Will be changed by profile activation. Allows to combine profiles. -->
- <ml.folder>src/main/java</ml.folder>
</properties>
<dependencies>
@@ -103,63 +101,9 @@
</dependency>
</dependencies>
- <profiles>
- <profile>
- <id>ml</id>
-
- <activation>
- <jdk>[1.8,)</jdk>
- </activation>
-
- <properties>
- <ml.folder>src/main/ml</ml.folder>
- <java.ver>1.8</java.ver>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-ml</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-sources</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>${ml.folder}</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>2.8</version>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml
index 8dda6a7..6327288 100644
--- a/modules/yardstick/pom.xml
+++ b/modules/yardstick/pom.xml
@@ -34,15 +34,6 @@
<version>2.4.0-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
- <properties>
- <yardstick.version>0.8.3</yardstick.version>
- <mysql.connector.version>5.1.39</mysql.connector.version>
- <postgres.connector.version>9.4.1208.jre7</postgres.connector.version>
- <spring.version>4.1.0.RELEASE</spring.version>
- <!-- Will be changed by profile activation. Allows to combine profiles. -->
- <ml.folder>src/main/java</ml.folder>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.apache.ignite</groupId>
@@ -69,6 +60,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-ml</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.yardstickframework</groupId>
<artifactId>yardstick</artifactId>
<version>${yardstick.version}</version>
@@ -123,63 +120,9 @@
</dependency>
</dependencies>
- <profiles>
- <profile>
- <id>ml</id>
-
- <activation>
- <jdk>[1.8,)</jdk>
- </activation>
-
- <properties>
- <ml.folder>src/main/ml</ml.folder>
- <java.ver>1.8</java.ver>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-ml</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-sources</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>${ml.folder}</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>2.8</version>
@@ -189,15 +132,6 @@
</plugin>
<plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
-
- <plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/DataChanger.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/DataChanger.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/DataChanger.java
new file mode 100644
index 0000000..600113b
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/DataChanger.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.yardstick.ml;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+
+/**
+ * Helps to ensure use of meaningfully different data in repeated invocations of benchmarked code in
+ * {@link IgniteAbstractBenchmark#test(Map)} method.
+ */
+public class DataChanger {
+ /** */
+ private static final AtomicInteger changer = new AtomicInteger(0);
+
+ /**
+ * @return Positive "seed" to mutate data.
+ */
+ public static double next() {
+ return (changer.incrementAndGet() % 17) + 1;
+ }
+
+ /** */
+ public static class Scale {
+ /** */
+ private final double scale;
+
+ /** */
+ public Scale() {
+ this.scale = DataChanger.next();
+ }
+
+ /** */
+ public double[][] mutate(double[][] orig) {
+ for (int i = 0; i < orig.length; i++)
+ orig[i] = mutate(orig[i]);
+
+ return orig;
+ }
+
+ /** */
+ public double[] mutate(double[] orig) {
+ for (int i = 0; i < orig.length; i++)
+ orig[i] *= scale;
+
+ return orig;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansDistributedClustererBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansDistributedClustererBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansDistributedClustererBenchmark.java
new file mode 100644
index 0000000..de928e8
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansDistributedClustererBenchmark.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.ml.clustering;
+
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.ml.clustering.KMeansDistributedClusterer;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.distances.EuclideanDistance;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.thread.IgniteThread;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+import org.apache.ignite.yardstick.ml.DataChanger;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteKMeansDistributedClustererBenchmark extends IgniteAbstractBenchmark {
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final DataChanger.Scale scale = new DataChanger.Scale();
+
+ // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
+ // because we create ignite cache internally.
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ this.getClass().getSimpleName(), new Runnable() {
+ /** {@inheritDoc} */
+ @Override public void run() {
+ // IMPL NOTE originally taken from KMeansDistributedClustererTest
+ KMeansDistributedClusterer clusterer = new KMeansDistributedClusterer(
+ new EuclideanDistance(), 1, 1, 1L);
+
+ double[] v1 = scale.mutate(new double[] {1959, 325100});
+ double[] v2 = scale.mutate(new double[] {1960, 373200});
+
+ SparseDistributedMatrix points = new SparseDistributedMatrix(
+ 2, 2, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+ points.setRow(0, v1);
+ points.setRow(1, v2);
+
+ clusterer.cluster(points, 1);
+
+ points.destroy();
+ }
+ });
+
+ igniteThread.start();
+
+ igniteThread.join();
+
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansLocalClustererBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansLocalClustererBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansLocalClustererBenchmark.java
new file mode 100644
index 0000000..d68fc6d
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansLocalClustererBenchmark.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.ml.clustering;
+
+import java.util.Map;
+import org.apache.ignite.ml.clustering.KMeansLocalClusterer;
+import org.apache.ignite.ml.math.distances.EuclideanDistance;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+import org.apache.ignite.yardstick.ml.DataChanger;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteKMeansLocalClustererBenchmark extends IgniteAbstractBenchmark {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final DataChanger.Scale scale = new DataChanger.Scale();
+
+ // IMPL NOTE originally taken from KMeansLocalClustererTest
+ KMeansLocalClusterer clusterer = new KMeansLocalClusterer(new EuclideanDistance(), 1, 1L);
+
+ double[] v1 = scale.mutate(new double[] {1959, 325100});
+ double[] v2 = scale.mutate(new double[] {1960, 373200});
+
+ DenseLocalOnHeapMatrix points = new DenseLocalOnHeapMatrix(new double[][] {
+ v1,
+ v2});
+
+ clusterer.cluster(points, 1);
+
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/clustering/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/clustering/package-info.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/clustering/package-info.java
new file mode 100644
index 0000000..af217d2
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/clustering/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. -->
+ * ML Grid clustering benchmarks.
+ */
+package org.apache.ignite.yardstick.ml.clustering;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java
new file mode 100644
index 0000000..6997180
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.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.yardstick.ml.decomposition;
+
+import java.util.Map;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.decompositions.CholeskyDecomposition;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+import org.apache.ignite.yardstick.ml.DataChanger;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteCholeskyDecompositionBenchmark extends IgniteAbstractBenchmark {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ runCholeskyDecomposition();
+
+ return true;
+ }
+
+ /**
+ * Based on CholeskyDecompositionTest.
+ */
+ private void runCholeskyDecomposition() {
+ final DataChanger.Scale scale = new DataChanger.Scale();
+
+ Matrix m = new DenseLocalOnHeapMatrix(scale.mutate(new double[][] {
+ {2.0d, -1.0d, 0.0d},
+ {-1.0d, 2.0d, -1.0d},
+ {0.0d, -1.0d, 2.0d}
+ }));
+
+ CholeskyDecomposition dec = new CholeskyDecomposition(m);
+
+ dec.getL();
+ dec.getLT();
+
+ Matrix bs = new DenseLocalOnHeapMatrix(scale.mutate(new double[][] {
+ {4.0, -6.0, 7.0},
+ {1.0, 1.0, 1.0}
+ })).transpose();
+ dec.solve(bs);
+
+ Vector b = new DenseLocalOnHeapVector(scale.mutate(new double[] {4.0, -6.0, 7.0}));
+ dec.solve(b);
+
+ dec.destroy();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java
new file mode 100644
index 0000000..e61c40c
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.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.yardstick.ml.decomposition;
+
+import java.util.Map;
+import org.apache.ignite.ml.math.decompositions.EigenDecomposition;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+import org.apache.ignite.yardstick.ml.DataChanger;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteEigenDecompositionBenchmark extends IgniteAbstractBenchmark {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ runEigenDecomposition();
+
+ return true;
+ }
+
+ /**
+ * Based on EigenDecompositionTest.
+ */
+ private void runEigenDecomposition() {
+ final DataChanger.Scale scale = new DataChanger.Scale();
+
+ EigenDecomposition decomposition1 = new EigenDecomposition(new DenseLocalOnHeapMatrix(
+ scale.mutate(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}})));
+
+ decomposition1.getD();
+ decomposition1.getV();
+
+ decomposition1.destroy();
+
+ EigenDecomposition decomposition2 = new EigenDecomposition(new DenseLocalOnHeapMatrix(
+ scale.mutate(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: IGNITE-5828, find out why decomposition of 3X4 matrix throws row index exception
+
+ decomposition2.getD();
+ decomposition2.getV();
+
+ decomposition2.destroy();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java
new file mode 100644
index 0000000..1368ef9
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.ml.decomposition;
+
+import java.util.Map;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.decompositions.LUDecomposition;
+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.apache.ignite.yardstick.IgniteAbstractBenchmark;
+import org.apache.ignite.yardstick.ml.DataChanger;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteLUDecompositionBenchmark extends IgniteAbstractBenchmark {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ runLUDecomposition();
+
+ return true;
+ }
+
+ /**
+ * Based on LUDecompositionTest.
+ */
+ private void runLUDecomposition() {
+ Matrix testMatrix = new DenseLocalOnHeapMatrix(new DataChanger.Scale().mutate(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}}));
+
+ LUDecomposition dec1 = new LUDecomposition(new PivotedMatrixView(testMatrix));
+
+ dec1.solve(new DenseLocalOnHeapVector(testMatrix.rowSize()));
+
+ dec1.destroy();
+
+ LUDecomposition dec2 = new LUDecomposition(new PivotedMatrixView(testMatrix));
+
+ dec2.solve(new DenseLocalOnHeapMatrix(testMatrix.rowSize(), testMatrix.rowSize()));
+
+ dec2.destroy();
+
+ LUDecomposition dec3 = new LUDecomposition(testMatrix);
+
+ dec3.getL();
+
+ dec3.getU();
+
+ dec3.getP();
+
+ dec3.getPivot();
+
+ dec3.destroy();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java
new file mode 100644
index 0000000..9f02852
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.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.yardstick.ml.decomposition;
+
+import java.util.Map;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.decompositions.SingularValueDecomposition;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+import org.apache.ignite.yardstick.ml.DataChanger;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteSingularValueDecompositionBenchmark extends IgniteAbstractBenchmark {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ runSingularValueDecomposition();
+
+ return true;
+ }
+
+ /**
+ * Based on SingularValueDecompositionTest#basicTest.
+ */
+ private void runSingularValueDecomposition() {
+ Matrix m = new DenseLocalOnHeapMatrix(new DataChanger.Scale().mutate(new double[][] {
+ {2.0d, -1.0d, 0.0d},
+ {-1.0d, 2.0d, -1.0d},
+ {0.0d, -1.0d, 2.0d}
+ }));
+
+ SingularValueDecomposition dec = new SingularValueDecomposition(m);
+
+ Matrix s = dec.getS();
+ Matrix u = dec.getU();
+ Matrix v = dec.getV();
+
+ u.times(s).times(v.transpose());
+
+ dec.destroy();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/package-info.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/package-info.java
new file mode 100644
index 0000000..4aaece3
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/decomposition/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. -->
+ * ML Grid decomposition benchmarks.
+ */
+package org.apache.ignite.yardstick.ml.decomposition;
\ No newline at end of file
[07/11] ignite git commit: IGNITE-7203 Java 8 by default
Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
deleted file mode 100644
index a0c9701..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.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.examples.java8.datastructures;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteRunnable;
-
-/**
- * Simple example to demonstrate usage of distributed executor service provided by Ignite.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public final class IgniteExecutorServiceExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws Exception If example execution failed.
- */
- @SuppressWarnings({"TooBroadScope"})
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Compute executor service example started.");
-
- // Get ignite-enabled executor service.
- ExecutorService exec = ignite.executorService();
-
- // Iterate through all words in the sentence and create callable jobs.
- for (final String word : "Print words using runnable".split(" ")) {
- // Execute runnable on some node.
- exec.submit((IgniteRunnable)() -> {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
- });
- }
-
- exec.shutdown();
-
- // Wait for all jobs to complete (0 means no limit).
- exec.awaitTermination(0, TimeUnit.MILLISECONDS);
-
- System.out.println();
- System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java b/examples/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
deleted file mode 100644
index 79b2f9a..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/datastructures/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. -->
- * Demonstrates using of blocking and non-blocking queues and atomic data structures.
- */
-package org.apache.ignite.examples.java8.datastructures;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
deleted file mode 100644
index 83a39ec..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.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.examples.java8.events;
-
-import java.util.UUID;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.compute.ComputeTaskSession;
-import org.apache.ignite.events.TaskEvent;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteBiPredicate;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.lang.IgniteRunnable;
-import org.apache.ignite.resources.TaskSessionResource;
-
-import static org.apache.ignite.events.EventType.EVTS_TASK_EXECUTION;
-
-/**
- * Demonstrates event consume API that allows to register event listeners on remote nodes.
- * Note that ignite events are disabled by default and must be specifically enabled,
- * just like in {@code examples/config/example-ignite.xml} file.
- * <p>
- * Remote nodes should always be started with configuration: {@code 'ignite.sh examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start
- * node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class EventsExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws Exception If example execution failed.
- */
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println();
- System.out.println(">>> Events API example started.");
-
- // Listen to events happening on local node.
- localListen();
-
- // Listen to events happening on all cluster nodes.
- remoteListen();
-
- // Wait for a while while callback is notified about remaining puts.
- Thread.sleep(1000);
- }
- }
-
- /**
- * Listen to events that happen only on local node.
- *
- * @throws IgniteException If failed.
- */
- private static void localListen() throws IgniteException {
- System.out.println();
- System.out.println(">>> Local event listener example.");
-
- Ignite ignite = Ignition.ignite();
-
- IgnitePredicate<TaskEvent> lsnr = evt -> {
- System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName() + ']');
-
- return true; // Return true to continue listening.
- };
-
- // Register event listener for all local task execution events.
- ignite.events().localListen(lsnr, EVTS_TASK_EXECUTION);
-
- // Generate task events.
- ignite.compute().withName("example-event-task").run(() -> System.out.println("Executing sample job."));
-
- // Unsubscribe local task event listener.
- ignite.events().stopLocalListen(lsnr);
- }
-
- /**
- * Listen to events coming from all cluster nodes.
- *
- * @throws IgniteException If failed.
- */
- private static void remoteListen() throws IgniteException {
- System.out.println();
- System.out.println(">>> Remote event listener example.");
-
- // This optional local callback is called for each event notification
- // that passed remote predicate listener.
- IgniteBiPredicate<UUID, TaskEvent> locLsnr = (nodeId, evt) -> {
- // Remote filter only accepts tasks whose name being with "good-task" prefix.
- assert evt.taskName().startsWith("good-task");
-
- System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName());
-
- return true; // Return true to continue listening.
- };
-
- // Remote filter which only accepts tasks whose name begins with "good-task" prefix.
- IgnitePredicate<TaskEvent> rmtLsnr = evt -> evt.taskName().startsWith("good-task");
-
- Ignite ignite = Ignition.ignite();
-
- // Register event listeners on all nodes to listen for task events.
- ignite.events().remoteListen(locLsnr, rmtLsnr, EVTS_TASK_EXECUTION);
-
- // Generate task events.
- for (int i = 0; i < 10; i++) {
- ignite.compute().withName(i < 5 ? "good-task-" + i : "bad-task-" + i).run(new IgniteRunnable() {
- // Auto-inject task session.
- @TaskSessionResource
- private ComputeTaskSession ses;
-
- @Override public void run() {
- System.out.println("Executing sample job for task: " + ses.getTaskName());
- }
- });
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java b/examples/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
deleted file mode 100644
index 2fadf17..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/events/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. -->
- * Demonstrates events management API.
- */
-package org.apache.ignite.examples.java8.events;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
deleted file mode 100644
index de060a7..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.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.examples.java8.messaging;
-
-import java.util.concurrent.CountDownLatch;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteMessaging;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-
-/**
- * Example that demonstrates how to exchange messages between nodes. Use such
- * functionality for cases when you need to communicate to other nodes outside
- * of ignite task.
- * <p>
- * To run this example you must have at least one remote node started.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public final class MessagingExample {
- /** Number of messages. */
- private static final int MESSAGES_NUM = 10;
-
- /** Message topics. */
- private enum TOPIC { ORDERED, UNORDERED }
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If example execution failed.
- */
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
- return;
-
- System.out.println();
- System.out.println(">>> Messaging example started.");
-
- // Group for remote nodes.
- ClusterGroup rmtGrp = ignite.cluster().forRemotes();
-
- // Listen for messages from remote nodes to make sure that they received all the messages.
- int msgCnt = rmtGrp.nodes().size() * MESSAGES_NUM;
-
- CountDownLatch orderedLatch = new CountDownLatch(msgCnt);
- CountDownLatch unorderedLatch = new CountDownLatch(msgCnt);
-
- localListen(ignite.message(ignite.cluster().forLocal()), orderedLatch, unorderedLatch);
-
- // Register listeners on all cluster nodes.
- startListening(ignite, ignite.message(rmtGrp));
-
- // Send unordered messages to all remote nodes.
- for (int i = 0; i < MESSAGES_NUM; i++)
- ignite.message(rmtGrp).send(TOPIC.UNORDERED, Integer.toString(i));
-
- System.out.println(">>> Finished sending unordered messages.");
-
- // Send ordered messages to all remote nodes.
- for (int i = 0; i < MESSAGES_NUM; i++)
- ignite.message(rmtGrp).sendOrdered(TOPIC.ORDERED, Integer.toString(i), 0);
-
- System.out.println(">>> Finished sending ordered messages.");
- System.out.println(">>> Check output on all nodes for message printouts.");
- System.out.println(">>> Will wait for messages acknowledgements from all remote nodes.");
-
- orderedLatch.await();
- unorderedLatch.await();
-
- System.out.println(">>> Messaging example finished.");
- }
- }
-
- /**
- * Start listening to messages on remote cluster nodes.
- *
- * @param ignite Ignite.
- * @param imsg Ignite messaging.
- * @throws IgniteException If failed.
- */
- private static void startListening(final Ignite ignite, IgniteMessaging imsg) throws IgniteException {
- // Add ordered message listener.
- imsg.remoteListen(TOPIC.ORDERED, (nodeId, msg) -> {
- System.out.println("Received ordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
-
- try {
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(TOPIC.ORDERED, msg);
- }
- catch (IgniteException e) {
- e.printStackTrace();
- }
-
- return true; // Return true to continue listening.
- });
-
- // Add unordered message listener.
- imsg.remoteListen(TOPIC.UNORDERED, (nodeId, msg) -> {
- System.out.println("Received unordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
-
- try {
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(TOPIC.UNORDERED, msg);
- }
- catch (IgniteException e) {
- e.printStackTrace();
- }
-
- return true; // Return true to continue listening.
- });
- }
-
- /**
- * Listen for messages from remote nodes.
- *
- * @param imsg Ignite messaging.
- * @param orderedLatch Latch for ordered messages acks.
- * @param unorderedLatch Latch for unordered messages acks.
- */
- private static void localListen(
- IgniteMessaging imsg,
- final CountDownLatch orderedLatch,
- final CountDownLatch unorderedLatch
- ) {
- imsg.localListen(TOPIC.ORDERED, (nodeId, msg) -> {
- orderedLatch.countDown();
-
- // Return true to continue listening, false to stop.
- return orderedLatch.getCount() > 0;
- });
-
- imsg.localListen(TOPIC.UNORDERED, (nodeId, msg) -> {
- unorderedLatch.countDown();
-
- // Return true to continue listening, false to stop.
- return unorderedLatch.getCount() > 0;
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
deleted file mode 100644
index 133e735..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.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.examples.java8.messaging;
-
-import java.util.concurrent.CountDownLatch;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-
-/**
- * Demonstrates simple message exchange between local and remote nodes.
- * <p>
- * To run this example you must have at least one remote node started.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class MessagingPingPongExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- * @throws Exception If example execution failed.
- */
- public static void main(String[] args) throws Exception {
- // Game is played over the default ignite.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
- return;
-
- System.out.println();
- System.out.println(">>> Messaging ping-pong example started.");
-
- // Pick random remote node as a partner.
- ClusterGroup nodeB = ignite.cluster().forRemotes().forRandom();
-
- // Note that both nodeA and nodeB will always point to
- // same nodes regardless of whether they were implicitly
- // serialized and deserialized on another node as part of
- // anonymous closure's state during its remote execution.
-
- // Set up remote player.
- ignite.message(nodeB).remoteListen(null, (nodeId, rcvMsg) -> {
- System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
-
- if ("PING".equals(rcvMsg)) {
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PONG");
-
- return true; // Continue listening.
- }
-
- return false; // Unsubscribe.
- });
-
- int MAX_PLAYS = 10;
-
- final CountDownLatch cnt = new CountDownLatch(MAX_PLAYS);
-
- // Set up local player.
- ignite.message().localListen(null, (nodeId, rcvMsg) -> {
- System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
-
- if (cnt.getCount() == 1) {
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "STOP");
-
- cnt.countDown();
-
- return false; // Stop listening.
- }
- else if ("PONG".equals(rcvMsg))
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PING");
- else
- throw new IgniteException("Received unexpected message: " + rcvMsg);
-
- cnt.countDown();
-
- return true; // Continue listening.
- });
-
- // Serve!
- ignite.message(nodeB).send(null, "PING");
-
- // Wait til the game is over.
- try {
- cnt.await();
- }
- catch (InterruptedException e) {
- System.err.println("Hm... let us finish the game!\n" + e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java b/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
deleted file mode 100644
index c950225..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/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. -->
- * Demonstrates how to exchange messages between nodes.
- */
-package org.apache.ignite.examples.java8.messaging;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/package-info.java b/examples/src/main/java8/org/apache/ignite/examples/java8/package-info.java
deleted file mode 100644
index 6d46cd0..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/package-info.java
+++ /dev/null
@@ -1,23 +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. -->
- * Basic examples for ignite functionality utilizing Java8 lambdas.
- * Use "java8" examples with JDK8 in addition to the "java" examples.
- */
-package org.apache.ignite.examples.java8;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
deleted file mode 100644
index 358faff..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
+++ /dev/null
@@ -1,108 +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.examples.java8.streaming;
-
-import java.util.List;
-import java.util.Random;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-import org.apache.ignite.stream.StreamTransformer;
-
-/**
- * Stream random numbers into the streaming cache.
- * To start the example, you should:
- * <ul>
- * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
- * <li>Start streaming using {@link StreamTransformerExample}.</li>
- * </ul>
- * <p>
- * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
- */
-public class StreamTransformerExample {
- /** Random number generator. */
- private static final Random RAND = new Random();
-
- /** Range within which to generate numbers. */
- private static final int RANGE = 1000;
-
- /** Cache name. */
- private static final String CACHE_NAME = "randomNumbers";
-
- public static void main(String[] args) throws Exception {
- // Mark this cluster member as client.
- Ignition.setClientMode(true);
-
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- if (!ExamplesUtils.hasServerNodes(ignite))
- return;
-
- CacheConfiguration<Integer, Long> cfg = new CacheConfiguration<>(CACHE_NAME);
-
- // Index key and value.
- cfg.setIndexedTypes(Integer.class, Long.class);
-
- // Auto-close cache at the end of the example.
- try (IgniteCache<Integer, Long> stmCache = ignite.getOrCreateCache(cfg)) {
- try (IgniteDataStreamer<Integer, Long> stmr = ignite.dataStreamer(stmCache.getName())) {
- // Allow data updates.
- stmr.allowOverwrite(true);
-
- // Configure data transformation to count random numbers added to the stream.
- stmr.receiver(StreamTransformer.from((e, arg) -> {
- // Get current count.
- Long val = e.getValue();
-
- // Increment count by 1.
- e.setValue(val == null ? 1L : val + 1);
-
- return null;
- }));
-
- // Stream 10 million of random numbers into the streamer cache.
- for (int i = 1; i <= 10_000_000; i++) {
- stmr.addData(RAND.nextInt(RANGE), 1L);
-
- if (i % 500_000 == 0)
- System.out.println("Number of tuples streamed into Ignite: " + i);
- }
- }
-
- // Query top 10 most popular numbers every.
- SqlFieldsQuery top10Qry = new SqlFieldsQuery("select _key, _val from Long order by _val desc limit 10");
-
- // Execute queries.
- List<List<?>> top10 = stmCache.query(top10Qry).getAll();
-
- System.out.println("Top 10 most popular numbers:");
-
- // Print top 10 words.
- ExamplesUtils.printQueryResults(top10);
- }
- finally {
- // Distributed cache could be removed from cluster only by #destroyCache() call.
- ignite.destroyCache(CACHE_NAME);
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
deleted file mode 100644
index bbb4f76..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
+++ /dev/null
@@ -1,177 +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.examples.java8.streaming;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Random;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-import org.apache.ignite.stream.StreamVisitor;
-
-/**
- * Stream random numbers into the streaming cache.
- * To start the example, you should:
- * <ul>
- * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
- * <li>Start streaming using {@link StreamVisitorExample}.</li>
- * </ul>
- * <p>
- * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
- */
-public class StreamVisitorExample {
- /** Random number generator. */
- private static final Random RAND = new Random();
-
- /** The list of instruments. */
- private static final String[] INSTRUMENTS = {"IBM", "GOOG", "MSFT", "GE", "EBAY", "YHOO", "ORCL", "CSCO", "AMZN", "RHT"};
-
- /** The list of initial instrument prices. */
- private static final double[] INITIAL_PRICES = {194.9, 893.49, 34.21, 23.24, 57.93, 45.03, 44.41, 28.44, 378.49, 69.50};
-
- public static void main(String[] args) throws Exception {
- // Mark this cluster member as client.
- Ignition.setClientMode(true);
-
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- if (!ExamplesUtils.hasServerNodes(ignite))
- return;
-
- // Market data cache with default configuration.
- CacheConfiguration<String, Double> mktDataCfg = new CacheConfiguration<>("marketTicks");
-
- // Financial instrument cache configuration.
- CacheConfiguration<String, Instrument> instCfg = new CacheConfiguration<>("instCache");
-
- // Index key and value for querying financial instruments.
- // Note that Instrument class has @QuerySqlField annotation for secondary field indexing.
- instCfg.setIndexedTypes(String.class, Instrument.class);
-
- // Auto-close caches at the end of the example.
- try (
- IgniteCache<String, Double> mktCache = ignite.getOrCreateCache(mktDataCfg);
- IgniteCache<String, Instrument> instCache = ignite.getOrCreateCache(instCfg)
- ) {
- try (IgniteDataStreamer<String, Double> mktStmr = ignite.dataStreamer(mktCache.getName())) {
- // Note that we receive market data, but do not populate 'mktCache' (it remains empty).
- // Instead we update the instruments in the 'instCache'.
- // Since both, 'instCache' and 'mktCache' use the same key, updates are collocated.
- mktStmr.receiver(StreamVisitor.from((cache, e) -> {
- String symbol = e.getKey();
- Double tick = e.getValue();
-
- Instrument inst = instCache.get(symbol);
-
- if (inst == null)
- inst = new Instrument(symbol);
-
- // Don't populate market cache, as we don't use it for querying.
- // Update cached instrument based on the latest market tick.
- inst.update(tick);
-
- instCache.put(symbol, inst);
- }));
-
- // Stream 10 million market data ticks into the system.
- for (int i = 1; i <= 10_000_000; i++) {
- int idx = RAND.nextInt(INSTRUMENTS.length);
-
- // Use gaussian distribution to ensure that
- // numbers closer to 0 have higher probability.
- double price = round2(INITIAL_PRICES[idx] + RAND.nextGaussian());
-
- mktStmr.addData(INSTRUMENTS[idx], price);
-
- if (i % 500_000 == 0)
- System.out.println("Number of tuples streamed into Ignite: " + i);
- }
- }
-
- // Select top 3 best performing instruments.
- SqlFieldsQuery top3qry = new SqlFieldsQuery(
- "select symbol, (latest - open) from Instrument order by (latest - open) desc limit 3");
-
- // Execute queries.
- List<List<?>> top3 = instCache.query(top3qry).getAll();
-
- System.out.println("Top performing financial instruments: ");
-
- // Print top 10 words.
- ExamplesUtils.printQueryResults(top3);
- }
- finally {
- // Distributed cache could be removed from cluster only by #destroyCache() call.
- ignite.destroyCache(mktDataCfg.getName());
- ignite.destroyCache(instCfg.getName());
- }
- }
- }
-
- /**
- * Rounds double value to two significant signs.
- *
- * @param val value to be rounded.
- * @return rounded double value.
- */
- private static double round2(double val) {
- return Math.floor(100 * val + 0.5) / 100;
- }
-
- /**
- * Financial instrument.
- */
- public static class Instrument implements Serializable {
- /** Instrument symbol. */
- @QuerySqlField(index = true)
- private final String symbol;
-
- /** Open price. */
- @QuerySqlField(index = true)
- private double open;
-
- /** Close price. */
- @QuerySqlField(index = true)
- private double latest;
-
- /**
- * @param symbol Symbol.
- */
- public Instrument(String symbol) {
- this.symbol = symbol;
- }
-
- /**
- * Updates this instrument based on the latest market tick price.
- *
- * @param price Latest price.
- */
- public void update(double price) {
- if (open == 0)
- open = price;
-
- this.latest = price;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
deleted file mode 100644
index a3e8734..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/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. -->
- * Demonstrates usage of data streamer.
- */
-package org.apache.ignite.examples.java8.streaming;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/DatasetWithObviousStructure.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/DatasetWithObviousStructure.java b/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/DatasetWithObviousStructure.java
deleted file mode 100644
index 5cd0e09..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/DatasetWithObviousStructure.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.examples.ml.clustering;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.stream.Collectors;
-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.VectorUtils;
-import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
-
-/**
- * See KMeansDistributedClustererTestSingleNode#testClusterizationOnDatasetWithObviousStructure.
- */
-class DatasetWithObviousStructure {
- /** */
- private final Random rnd = new Random(123456L);
-
- /** Let centers be in the vertices of square. */
- private final Map<Integer, Vector> centers = new HashMap<>();
-
- /** Square side length. */
- private final int squareSideLen;
-
- /** */
- DatasetWithObviousStructure(int squareSideLen) {
- this.squareSideLen = squareSideLen;
- centers.put(100, new DenseLocalOnHeapVector(new double[] {0.0, 0.0}));
- centers.put(900, new DenseLocalOnHeapVector(new double[] {squareSideLen, 0.0}));
- centers.put(3000, new DenseLocalOnHeapVector(new double[] {0.0, squareSideLen}));
- centers.put(6000, new DenseLocalOnHeapVector(new double[] {squareSideLen, squareSideLen}));
- }
-
- /** */
- List<Vector> generate(Matrix points) {
- int ptsCnt = points.rowSize();
-
- // Mass centers of dataset.
- List<Vector> massCenters = new ArrayList<>();
-
- int centersCnt = centers.size();
-
- List<Integer> permutation = IntStream.range(0, ptsCnt).boxed().collect(Collectors.toList());
- Collections.shuffle(permutation, rnd);
-
- Vector[] mc = new Vector[centersCnt];
- Arrays.fill(mc, VectorUtils.zeroes(2));
-
- int totalCnt = 0;
-
- int centIdx = 0;
- massCenters.clear();
-
- for (Integer count : centers.keySet()) {
- for (int i = 0; i < count; i++) {
- Vector pnt = getPoint(count);
-
- mc[centIdx] = mc[centIdx].plus(pnt);
-
- points.assignRow(permutation.get(totalCnt), pnt);
-
- totalCnt++;
- }
- massCenters.add(mc[centIdx].times(1 / (double)count));
- centIdx++;
- }
-
- return massCenters;
- }
-
- /** */
- Map<Integer, Vector> centers() {
- return centers;
- }
-
- /** */
- private Vector getPoint(Integer cnt) {
- Vector pnt = new DenseLocalOnHeapVector(2).assign(centers.get(cnt));
- // Perturbate point on random value.
- pnt.map(val -> val + rnd.nextDouble() * squareSideLen / 100);
- return pnt;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/FuzzyCMeansExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/FuzzyCMeansExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/FuzzyCMeansExample.java
deleted file mode 100644
index 23aeed7..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/FuzzyCMeansExample.java
+++ /dev/null
@@ -1,134 +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.examples.ml.clustering;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.ml.clustering.BaseFuzzyCMeansClusterer;
-import org.apache.ignite.ml.clustering.FuzzyCMeansDistributedClusterer;
-import org.apache.ignite.ml.clustering.FuzzyCMeansModel;
-import org.apache.ignite.ml.math.StorageConstants;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.distances.DistanceMeasure;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
-import org.apache.ignite.thread.IgniteThread;
-
-/**
- * <p>
- * This example shows how to use {@link FuzzyCMeansDistributedClusterer}.</p>
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.</p>
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.</p>
- */
-public final class FuzzyCMeansExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) throws InterruptedException {
- System.out.println(">>> Fuzzy C-Means usage example started.");
-
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- // Start new Ignite thread.
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
- FuzzyCMeansExample.class.getSimpleName(),
- () -> {
- // Distance measure that computes distance between two points.
- DistanceMeasure distanceMeasure = new EuclideanDistance();
-
- // "Fuzziness" - specific constant that is used in membership calculation (1.0+-eps ~ K-Means).
- double exponentialWeight = 2.0;
-
- // Condition that indicated when algorithm must stop.
- // In this example algorithm stops if memberships have changed insignificantly.
- BaseFuzzyCMeansClusterer.StopCondition stopCond =
- BaseFuzzyCMeansClusterer.StopCondition.STABLE_MEMBERSHIPS;
-
- // Maximum difference between new and old membership values with which algorithm will continue to work.
- double maxDelta = 0.01;
-
- // The maximum number of FCM iterations.
- int maxIterations = 50;
-
- // Value that is used to initialize random numbers generator. You can choose it randomly.
- Long seed = null;
-
- // Number of steps of primary centers selection (more steps more candidates).
- int initializationSteps = 2;
-
- // Number of K-Means iteration that is used to choose required number of primary centers from candidates.
- int kMeansMaxIterations = 50;
-
- // Create new distributed clusterer with parameters described above.
- System.out.println(">>> Create new Distributed Fuzzy C-Means clusterer.");
- FuzzyCMeansDistributedClusterer clusterer = new FuzzyCMeansDistributedClusterer(
- distanceMeasure, exponentialWeight, stopCond, maxDelta, maxIterations,
- seed, initializationSteps, kMeansMaxIterations);
-
- // Create sample data.
- double[][] points = new double[][] {
- {-10, -10}, {-9, -11}, {-10, -9}, {-11, -9},
- {10, 10}, {9, 11}, {10, 9}, {11, 9},
- {-10, 10}, {-9, 11}, {-10, 9}, {-11, 9},
- {10, -10}, {9, -11}, {10, -9}, {11, -9}};
-
- // Initialize matrix of data points. Each row contains one point.
- int rows = points.length;
- int cols = points[0].length;
-
- System.out.println(">>> Create the matrix that contains sample points.");
- SparseDistributedMatrix pntMatrix = new SparseDistributedMatrix(rows, cols,
- StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
- // Store points into matrix.
- pntMatrix.assign(points);
-
- // Call clusterization method with some number of centers.
- // It returns model that can predict results for new points.
- System.out.println(">>> Perform clusterization.");
- int numCenters = 4;
- FuzzyCMeansModel mdl = clusterer.cluster(pntMatrix, numCenters);
-
- // You can also get centers of clusters that is computed by Fuzzy C-Means algorithm.
- Vector[] centers = mdl.centers();
-
- String res = ">>> Results:\n"
- + ">>> 1st center: " + centers[0].get(0) + " " + centers[0].get(1) + "\n"
- + ">>> 2nd center: " + centers[1].get(0) + " " + centers[1].get(1) + "\n"
- + ">>> 3rd center: " + centers[2].get(0) + " " + centers[2].get(1) + "\n"
- + ">>> 4th center: " + centers[3].get(0) + " " + centers[3].get(1) + "\n";
-
- System.out.println(res);
-
- pntMatrix.destroy();
- });
-
- igniteThread.start();
- igniteThread.join();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/FuzzyCMeansLocalExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/FuzzyCMeansLocalExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/FuzzyCMeansLocalExample.java
deleted file mode 100644
index 5c1753a..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/FuzzyCMeansLocalExample.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.examples.ml.clustering;
-
-import org.apache.ignite.ml.clustering.BaseFuzzyCMeansClusterer;
-import org.apache.ignite.ml.clustering.FuzzyCMeansLocalClusterer;
-import org.apache.ignite.ml.clustering.FuzzyCMeansModel;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.distances.DistanceMeasure;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-
-/**
- * This example shows how to use {@link FuzzyCMeansLocalClusterer}.
- */
-public final class FuzzyCMeansLocalExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- System.out.println(">>> Local Fuzzy C-Means usage example started.");
-
- // Distance measure that computes distance between two points.
- DistanceMeasure distanceMeasure = new EuclideanDistance();
-
- // "Fuzziness" - specific constant that is used in membership calculation (1.0+-eps ~ K-Means).
- double exponentialWeight = 2.0;
-
- // Condition that indicated when algorithm must stop.
- // In this example algorithm stops if memberships have changed insignificantly.
- BaseFuzzyCMeansClusterer.StopCondition stopCond =
- BaseFuzzyCMeansClusterer.StopCondition.STABLE_MEMBERSHIPS;
-
- // Maximum difference between new and old membership values with which algorithm will continue to work.
- double maxDelta = 0.01;
-
- // The maximum number of FCM iterations.
- int maxIterations = 50;
-
- // Value that is used to initialize random numbers generator. You can choose it randomly.
- Long seed = null;
-
- // Create new distributed clusterer with parameters described above.
- System.out.println(">>> Create new Local Fuzzy C-Means clusterer.");
- FuzzyCMeansLocalClusterer clusterer = new FuzzyCMeansLocalClusterer(distanceMeasure,
- exponentialWeight, stopCond,
- maxDelta, maxIterations, seed);
-
- // Create sample data.
- double[][] points = new double[][] {
- {-10, -10}, {-9, -11}, {-10, -9}, {-11, -9},
- {10, 10}, {9, 11}, {10, 9}, {11, 9},
- {-10, 10}, {-9, 11}, {-10, 9}, {-11, 9},
- {10, -10}, {9, -11}, {10, -9}, {11, -9}};
-
- // Initialize matrix of data points. Each row contains one point.
- System.out.println(">>> Create the matrix that contains sample points.");
- // Store points into matrix.
- DenseLocalOnHeapMatrix pntMatrix = new DenseLocalOnHeapMatrix(points);
-
- // Call clusterization method with some number of centers.
- // It returns model that can predict results for new points.
- System.out.println(">>> Perform clusterization.");
- int numCenters = 4;
- FuzzyCMeansModel mdl = clusterer.cluster(pntMatrix, numCenters);
-
- // You can also get centers of clusters that is computed by Fuzzy C-Means algorithm.
- Vector[] centers = mdl.centers();
-
- String res = ">>> Results:\n"
- + ">>> 1st center: " + centers[0].get(0) + " " + centers[0].get(1) + "\n"
- + ">>> 2nd center: " + centers[1].get(0) + " " + centers[1].get(1) + "\n"
- + ">>> 3rd center: " + centers[2].get(0) + " " + centers[2].get(1) + "\n"
- + ">>> 4th center: " + centers[3].get(0) + " " + centers[3].get(1) + "\n";
-
- System.out.println(res);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/KMeansDistributedClustererExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/KMeansDistributedClustererExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/KMeansDistributedClustererExample.java
deleted file mode 100644
index f8709e6..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/KMeansDistributedClustererExample.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.examples.ml.clustering;
-
-import java.util.Arrays;
-import java.util.List;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ml.math.matrix.SparseDistributedMatrixExample;
-import org.apache.ignite.ml.clustering.KMeansDistributedClusterer;
-import org.apache.ignite.ml.math.StorageConstants;
-import org.apache.ignite.ml.math.Tracer;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
-import org.apache.ignite.thread.IgniteThread;
-
-/**
- * <p>
- * Example of using {@link KMeansDistributedClusterer}.</p>
- * <p>
- * Note that in this example we cannot guarantee order in which nodes return results of intermediate
- * computations and therefore algorithm can return different results.</p>
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.</p>
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.</p>
- */
-public class KMeansDistributedClustererExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) throws InterruptedException {
- // IMPL NOTE based on KMeansDistributedClustererTestSingleNode#testClusterizationOnDatasetWithObviousStructure
- System.out.println(">>> K-means distributed clusterer example started.");
-
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
- // because we create ignite cache internally.
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
- SparseDistributedMatrixExample.class.getSimpleName(), () -> {
-
- int ptsCnt = 10000;
-
- SparseDistributedMatrix points = new SparseDistributedMatrix(ptsCnt, 2,
- StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
- DatasetWithObviousStructure dataset = new DatasetWithObviousStructure(10000);
-
- List<Vector> massCenters = dataset.generate(points);
-
- EuclideanDistance dist = new EuclideanDistance();
-
- KMeansDistributedClusterer clusterer = new KMeansDistributedClusterer(dist, 3, 100, 1L);
-
- Vector[] resCenters = clusterer.cluster(points, 4).centers();
-
- System.out.println("Mass centers:");
- massCenters.forEach(Tracer::showAscii);
-
- System.out.println("Cluster centers:");
- Arrays.asList(resCenters).forEach(Tracer::showAscii);
-
- points.destroy();
-
- System.out.println("\n>>> K-means distributed clusterer example completed.");
- });
-
- igniteThread.start();
-
- igniteThread.join();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/KMeansLocalClustererExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/KMeansLocalClustererExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/KMeansLocalClustererExample.java
deleted file mode 100644
index 28ca9d9..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/KMeansLocalClustererExample.java
+++ /dev/null
@@ -1,106 +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.examples.ml.clustering;
-
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import org.apache.ignite.ml.clustering.KMeansLocalClusterer;
-import org.apache.ignite.ml.clustering.KMeansModel;
-import org.apache.ignite.ml.math.Tracer;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.distances.DistanceMeasure;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.math.functions.Functions;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-
-/**
- * Example of using {@link KMeansLocalClusterer}.
- */
-public class KMeansLocalClustererExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- // IMPL NOTE based on KMeansDistributedClustererTestSingleNode#testClusterizationOnDatasetWithObviousStructure
- System.out.println(">>> K-means local clusterer example started.");
-
- int ptsCnt = 10000;
- DenseLocalOnHeapMatrix points = new DenseLocalOnHeapMatrix(ptsCnt, 2);
-
- DatasetWithObviousStructure dataset = new DatasetWithObviousStructure(10000);
-
- List<Vector> massCenters = dataset.generate(points);
-
- EuclideanDistance dist = new EuclideanDistance();
- OrderedNodesComparator comp = new OrderedNodesComparator(
- dataset.centers().values().toArray(new Vector[] {}), dist);
-
- massCenters.sort(comp);
-
- KMeansLocalClusterer clusterer = new KMeansLocalClusterer(dist, 100, 1L);
-
- KMeansModel mdl = clusterer.cluster(points, 4);
- Vector[] resCenters = mdl.centers();
- Arrays.sort(resCenters, comp);
-
- System.out.println("Mass centers:");
- massCenters.forEach(Tracer::showAscii);
-
- System.out.println("Cluster centers:");
- Arrays.asList(resCenters).forEach(Tracer::showAscii);
-
- System.out.println("\n>>> K-means local clusterer example completed.");
- }
-
- /** */
- private static class OrderedNodesComparator implements Comparator<Vector> {
- /** */
- private final DistanceMeasure measure;
-
- /** */
- List<Vector> orderedNodes;
-
- /** */
- OrderedNodesComparator(Vector[] orderedNodes, DistanceMeasure measure) {
- this.orderedNodes = Arrays.asList(orderedNodes);
- this.measure = measure;
- }
-
- /** */
- private int findClosestNodeIndex(Vector v) {
- return Functions.argmin(orderedNodes, v1 -> measure.compute(v1, v)).get1();
- }
-
- /** */
- @Override public int compare(Vector v1, Vector v2) {
- int ind1 = findClosestNodeIndex(v1);
- int ind2 = findClosestNodeIndex(v2);
-
- int signum = (int)Math.signum(ind1 - ind2);
-
- if (signum != 0)
- return signum;
-
- return (int)Math.signum(orderedNodes.get(ind1).minus(v1).kNorm(2) -
- orderedNodes.get(ind2).minus(v2).kNorm(2));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/package-info.java
deleted file mode 100644
index 872aa16..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/clustering/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. -->
- * ML clustering examples.
- */
-package org.apache.ignite.examples.ml.clustering;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/knn/classification/KNNClassificationExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/classification/KNNClassificationExample.java b/examples/src/main/ml/org/apache/ignite/examples/ml/knn/classification/KNNClassificationExample.java
deleted file mode 100644
index 0e1a52f..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/classification/KNNClassificationExample.java
+++ /dev/null
@@ -1,155 +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.examples.ml.knn.classification;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Arrays;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.ml.knn.models.KNNModel;
-import org.apache.ignite.ml.knn.models.KNNStrategy;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.structures.LabeledDataset;
-import org.apache.ignite.ml.structures.LabeledDatasetTestTrainPair;
-import org.apache.ignite.ml.structures.preprocessing.LabeledDatasetLoader;
-import org.apache.ignite.ml.structures.preprocessing.LabellingMachine;
-import org.apache.ignite.thread.IgniteThread;
-
-/**
- * <p>
- * Example of using {@link KNNModel} with iris dataset.</p>
- * <p>
- * Note that in this example we cannot guarantee order in which nodes return results of intermediate
- * computations and therefore algorithm can return different results.</p>
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.</p>
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.</p>
- */
-public class KNNClassificationExample {
- /** Separator. */
- private static final String SEPARATOR = "\t";
-
- /** Path to the Iris dataset. */
- private static final String KNN_IRIS_TXT = "../datasets/iris.txt";
-
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) throws InterruptedException {
- System.out.println(">>> kNN classification example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
- KNNClassificationExample.class.getSimpleName(), () -> {
-
- try {
- // Prepare path to read
- URL url = KNNClassificationExample.class.getResource(KNN_IRIS_TXT);
- if (url == null)
- throw new RuntimeException("Can't get URL for: " + KNN_IRIS_TXT);
-
- Path path = Paths.get(url.toURI());
-
- // Read dataset from file
- LabeledDataset dataset = LabeledDatasetLoader.loadFromTxtFile(path, SEPARATOR, true, false);
-
- // Random splitting of iris data as 70% train and 30% test datasets
- LabeledDatasetTestTrainPair split = new LabeledDatasetTestTrainPair(dataset, 0.3);
-
- System.out.println("\n>>> Amount of observations in train dataset " + split.train().rowSize());
- System.out.println("\n>>> Amount of observations in test dataset " + split.test().rowSize());
-
- LabeledDataset test = split.test();
- LabeledDataset train = split.train();
-
- KNNModel knnMdl = new KNNModel(5, new EuclideanDistance(), KNNStrategy.SIMPLE, train);
-
- // Clone labels
- final double[] labels = test.labels();
-
- // Save predicted classes to test dataset
- LabellingMachine.assignLabels(test, knnMdl);
-
- // Calculate amount of errors on test dataset
- int amountOfErrors = 0;
- for (int i = 0; i < test.rowSize(); i++) {
- if (test.label(i) != labels[i])
- amountOfErrors++;
- }
-
- System.out.println("\n>>> Absolute amount of errors " + amountOfErrors);
- System.out.println("\n>>> Accuracy " + amountOfErrors / (double)test.rowSize());
-
- // Build confusion matrix. See https://en.wikipedia.org/wiki/Confusion_matrix
- int[][] confusionMtx = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
- for (int i = 0; i < test.rowSize(); i++) {
- int idx1 = (int)test.label(i);
- int idx2 = (int)labels[i];
- confusionMtx[idx1 - 1][idx2 - 1]++;
- }
- System.out.println("\n>>> Confusion matrix is " + Arrays.deepToString(confusionMtx));
-
- // Calculate precision, recall and F-metric for each class
- for (int i = 0; i < 3; i++) {
- double precision = 0.0;
- for (int j = 0; j < 3; j++)
- precision += confusionMtx[i][j];
- precision = confusionMtx[i][i] / precision;
-
- double clsLb = (double)(i + 1);
-
- System.out.println("\n>>> Precision for class " + clsLb + " is " + precision);
-
- double recall = 0.0;
- for (int j = 0; j < 3; j++)
- recall += confusionMtx[j][i];
- recall = confusionMtx[i][i] / recall;
- System.out.println("\n>>> Recall for class " + clsLb + " is " + recall);
-
- double fScore = 2 * precision * recall / (precision + recall);
- System.out.println("\n>>> F-score for class " + clsLb + " is " + fScore);
- }
-
- }
- catch (URISyntaxException | IOException e) {
- e.printStackTrace();
- System.out.println("\n>>> Unexpected exception, check resources: " + e);
- }
- finally {
- System.out.println("\n>>> kNN classification example completed.");
- }
-
- });
-
- igniteThread.start();
- igniteThread.join();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/knn/classification/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/classification/package-info.java b/examples/src/main/ml/org/apache/ignite/examples/ml/knn/classification/package-info.java
deleted file mode 100644
index d853f0d..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/classification/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. -->
- * kNN classification examples.
- */
-package org.apache.ignite.examples.ml.knn.classification;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/knn/datasets/README.md
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/datasets/README.md b/examples/src/main/ml/org/apache/ignite/examples/ml/knn/datasets/README.md
deleted file mode 100644
index 2f9c5ec..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/datasets/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-iris.txt and cleared_machines are from Lichman, M. (2013). UCI Machine Learning Repository [http://archive.ics.uci.edu/ml]. Irvine, CA: University of California, School of Information and Computer Science.
-Read more about machine dataset http://archive.ics.uci.edu/ml/machine-learning-databases/cpu-performance/machine.names
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/knn/datasets/cleared_machines.txt
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/datasets/cleared_machines.txt b/examples/src/main/ml/org/apache/ignite/examples/ml/knn/datasets/cleared_machines.txt
deleted file mode 100644
index cf8b6b0..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/datasets/cleared_machines.txt
+++ /dev/null
@@ -1,209 +0,0 @@
-199,125,256,6000,256,16,128
-253,29,8000,32000,32,8,32
-253,29,8000,32000,32,8,32
-253,29,8000,32000,32,8,32
-132,29,8000,16000,32,8,16
-290,26,8000,32000,64,8,32
-381,23,16000,32000,64,16,32
-381,23,16000,32000,64,16,32
-749,23,16000,64000,64,16,32
-1238,23,32000,64000,128,32,64
-23,400,1000,3000,0,1,2
-24,400,512,3500,4,1,6
-70,60,2000,8000,65,1,8
-117,50,4000,16000,65,1,8
-15,350,64,64,0,1,4
-64,200,512,16000,0,4,32
-23,167,524,2000,8,4,15
-29,143,512,5000,0,7,32
-22,143,1000,2000,0,5,16
-124,110,5000,5000,142,8,64
-35,143,1500,6300,0,5,32
-39,143,3100,6200,0,5,20
-40,143,2300,6200,0,6,64
-45,110,3100,6200,0,6,64
-28,320,128,6000,0,1,12
-21,320,512,2000,4,1,3
-28,320,256,6000,0,1,6
-22,320,256,3000,4,1,3
-28,320,512,5000,4,1,5
-27,320,256,5000,4,1,6
-102,25,1310,2620,131,12,24
-102,25,1310,2620,131,12,24
-74,50,2620,10480,30,12,24
-74,50,2620,10480,30,12,24
-138,56,5240,20970,30,12,24
-136,64,5240,20970,30,12,24
-23,50,500,2000,8,1,4
-29,50,1000,4000,8,1,5
-44,50,2000,8000,8,1,5
-30,50,1000,4000,8,3,5
-41,50,1000,8000,8,3,5
-74,50,2000,16000,8,3,5
-74,50,2000,16000,8,3,6
-74,50,2000,16000,8,3,6
-54,133,1000,12000,9,3,12
-41,133,1000,8000,9,3,12
-18,810,512,512,8,1,1
-28,810,1000,5000,0,1,1
-36,320,512,8000,4,1,5
-38,200,512,8000,8,1,8
-34,700,384,8000,0,1,1
-19,700,256,2000,0,1,1
-72,140,1000,16000,16,1,3
-36,200,1000,8000,0,1,2
-30,110,1000,4000,16,1,2
-56,110,1000,12000,16,1,2
-42,220,1000,8000,16,1,2
-34,800,256,8000,0,1,4
-34,800,256,8000,0,1,4
-34,800,256,8000,0,1,4
-34,800,256,8000,0,1,4
-34,800,256,8000,0,1,4
-19,125,512,1000,0,8,20
-75,75,2000,8000,64,1,38
-113,75,2000,16000,64,1,38
-157,75,2000,16000,128,1,38
-18,90,256,1000,0,3,10
-20,105,256,2000,0,3,10
-28,105,1000,4000,0,3,24
-33,105,2000,4000,8,3,19
-47,75,2000,8000,8,3,24
-54,75,3000,8000,8,3,48
-20,175,256,2000,0,3,24
-23,300,768,3000,0,6,24
-25,300,768,3000,6,6,24
-52,300,768,12000,6,6,24
-27,300,768,4500,0,1,24
-50,300,384,12000,6,1,24
-18,300,192,768,6,6,24
-53,180,768,12000,6,1,31
-23,330,1000,3000,0,2,4
-30,300,1000,4000,8,3,64
-73,300,1000,16000,8,2,112
-20,330,1000,2000,0,1,2
-25,330,1000,4000,0,3,6
-28,140,2000,4000,0,3,6
-29,140,2000,4000,0,4,8
-32,140,2000,4000,8,1,20
-175,140,2000,32000,32,1,20
-57,140,2000,8000,32,1,54
-181,140,2000,32000,32,1,54
-181,140,2000,32000,32,1,54
-32,140,2000,4000,8,1,20
-82,57,4000,16000,1,6,12
-171,57,4000,24000,64,12,16
-361,26,16000,32000,64,16,24
-350,26,16000,32000,64,8,24
-220,26,8000,32000,0,8,24
-113,26,8000,16000,0,8,16
-15,480,96,512,0,1,1
-21,203,1000,2000,0,1,5
-35,115,512,6000,16,1,6
-18,1100,512,1500,0,1,1
-20,1100,768,2000,0,1,1
-20,600,768,2000,0,1,1
-28,400,2000,4000,0,1,1
-45,400,4000,8000,0,1,1
-18,900,1000,1000,0,1,2
-17,900,512,1000,0,1,2
-26,900,1000,4000,4,1,2
-28,900,1000,4000,8,1,2
-28,900,2000,4000,0,3,6
-31,225,2000,4000,8,3,6
-31,225,2000,4000,8,3,6
-42,180,2000,8000,8,1,6
-76,185,2000,16000,16,1,6
-76,180,2000,16000,16,1,6
-26,225,1000,4000,2,3,6
-59,25,2000,12000,8,1,4
-65,25,2000,12000,16,3,5
-101,17,4000,16000,8,6,12
-116,17,4000,16000,32,6,12
-18,1500,768,1000,0,0,0
-20,1500,768,2000,0,0,0
-20,800,768,2000,0,0,0
-30,50,2000,4000,0,3,6
-44,50,2000,8000,8,3,6
-44,50,2000,8000,8,1,6
-82,50,2000,16000,24,1,6
-82,50,2000,16000,24,1,6
-128,50,8000,16000,48,1,10
-37,100,1000,8000,0,2,6
-46,100,1000,8000,24,2,6
-46,100,1000,8000,24,3,6
-80,50,2000,16000,12,3,16
-88,50,2000,16000,24,6,16
-88,50,2000,16000,24,6,16
-33,150,512,4000,0,8,128
-46,115,2000,8000,16,1,3
-29,115,2000,4000,2,1,5
-53,92,2000,8000,32,1,6
-53,92,2000,8000,32,1,6
-41,92,2000,8000,4,1,6
-86,75,4000,16000,16,1,6
-95,60,4000,16000,32,1,6
-107,60,2000,16000,64,5,8
-117,60,4000,16000,64,5,8
-119,50,4000,16000,64,5,10
-120,72,4000,16000,64,8,16
-48,72,2000,8000,16,6,8
-126,40,8000,16000,32,8,16
-266,40,8000,32000,64,8,24
-270,35,8000,32000,64,8,24
-426,38,16000,32000,128,16,32
-151,48,4000,24000,32,8,24
-267,38,8000,32000,64,8,24
-603,30,16000,32000,256,16,24
-19,112,1000,1000,0,1,4
-21,84,1000,2000,0,1,6
-26,56,1000,4000,0,1,6
-35,56,2000,6000,0,1,8
-41,56,2000,8000,0,1,8
-47,56,4000,8000,0,1,8
-62,56,4000,12000,0,1,8
-78,56,4000,16000,0,1,8
-80,38,4000,8000,32,16,32
-80,38,4000,8000,32,16,32
-142,38,8000,16000,64,4,8
-281,38,8000,24000,160,4,8
-190,38,4000,16000,128,16,32
-21,200,1000,2000,0,1,2
-25,200,1000,4000,0,1,4
-67,200,2000,8000,64,1,5
-24,250,512,4000,0,1,7
-24,250,512,4000,0,4,7
-64,250,1000,16000,1,1,8
-25,160,512,4000,2,1,5
-20,160,512,2000,2,3,8
-29,160,1000,4000,8,1,14
-43,160,1000,8000,16,1,14
-53,160,2000,8000,32,1,13
-19,240,512,1000,8,1,3
-22,240,512,2000,8,1,5
-31,105,2000,4000,8,3,8
-41,105,2000,6000,16,6,16
-47,105,2000,8000,16,4,14
-99,52,4000,16000,32,4,12
-67,70,4000,12000,8,6,8
-81,59,4000,12000,32,6,12
-149,59,8000,16000,64,12,24
-183,26,8000,24000,32,8,16
-275,26,8000,32000,64,12,16
-382,26,8000,32000,128,24,32
-56,116,2000,8000,32,5,28
-182,50,2000,32000,24,6,26
-227,50,2000,32000,48,26,52
-341,50,2000,32000,112,52,104
-360,50,4000,32000,112,52,104
-919,30,8000,64000,96,12,176
-978,30,8000,64000,128,12,176
-24,180,262,4000,0,1,3
-24,180,512,4000,0,1,3
-24,180,262,4000,0,1,3
-24,180,512,4000,0,1,3
-37,124,1000,8000,0,1,8
-50,98,1000,8000,32,2,8
-41,125,2000,8000,0,2,14
-47,480,512,8000,32,0,0
-25,480,1000,4000,0,0,0
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/ml/org/apache/ignite/examples/ml/knn/datasets/iris.txt
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/datasets/iris.txt b/examples/src/main/ml/org/apache/ignite/examples/ml/knn/datasets/iris.txt
deleted file mode 100644
index 18f5f7c..0000000
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/knn/datasets/iris.txt
+++ /dev/null
@@ -1,150 +0,0 @@
-1.0 5.1 3.5 1.4 0.2
-1.0 4.9 3.0 1.4 0.2
-1.0 4.7 3.2 1.3 0.2
-1.0 4.6 3.1 1.5 0.2
-1.0 5.0 3.6 1.4 0.2
-1.0 5.4 3.9 1.7 0.4
-1.0 4.6 3.4 1.4 0.3
-1.0 5.0 3.4 1.5 0.2
-1.0 4.4 2.9 1.4 0.2
-1.0 4.9 3.1 1.5 0.1
-1.0 5.4 3.7 1.5 0.2
-1.0 4.8 3.4 1.6 0.2
-1.0 4.8 3.0 1.4 0.1
-1.0 4.3 3.0 1.1 0.1
-1.0 5.8 4.0 1.2 0.2
-1.0 5.7 4.4 1.5 0.4
-1.0 5.4 3.9 1.3 0.4
-1.0 5.1 3.5 1.4 0.3
-1.0 5.7 3.8 1.7 0.3
-1.0 5.1 3.8 1.5 0.3
-1.0 5.4 3.4 1.7 0.2
-1.0 5.1 3.7 1.5 0.4
-1.0 4.6 3.6 1.0 0.2
-1.0 5.1 3.3 1.7 0.5
-1.0 4.8 3.4 1.9 0.2
-1.0 5.0 3.0 1.6 0.2
-1.0 5.0 3.4 1.6 0.4
-1.0 5.2 3.5 1.5 0.2
-1.0 5.2 3.4 1.4 0.2
-1.0 4.7 3.2 1.6 0.2
-1.0 4.8 3.1 1.6 0.2
-1.0 5.4 3.4 1.5 0.4
-1.0 5.2 4.1 1.5 0.1
-1.0 5.5 4.2 1.4 0.2
-1.0 4.9 3.1 1.5 0.1
-1.0 5.0 3.2 1.2 0.2
-1.0 5.5 3.5 1.3 0.2
-1.0 4.9 3.1 1.5 0.1
-1.0 4.4 3.0 1.3 0.2
-1.0 5.1 3.4 1.5 0.2
-1.0 5.0 3.5 1.3 0.3
-1.0 4.5 2.3 1.3 0.3
-1.0 4.4 3.2 1.3 0.2
-1.0 5.0 3.5 1.6 0.6
-1.0 5.1 3.8 1.9 0.4
-1.0 4.8 3.0 1.4 0.3
-1.0 5.1 3.8 1.6 0.2
-1.0 4.6 3.2 1.4 0.2
-1.0 5.3 3.7 1.5 0.2
-1.0 5.0 3.3 1.4 0.2
-2.0 7.0 3.2 4.7 1.4
-2.0 6.4 3.2 4.5 1.5
-2.0 6.9 3.1 4.9 1.5
-2.0 5.5 2.3 4.0 1.3
-2.0 6.5 2.8 4.6 1.5
-2.0 5.7 2.8 4.5 1.3
-2.0 6.3 3.3 4.7 1.6
-2.0 4.9 2.4 3.3 1.0
-2.0 6.6 2.9 4.6 1.3
-2.0 5.2 2.7 3.9 1.4
-2.0 5.0 2.0 3.5 1.0
-2.0 5.9 3.0 4.2 1.5
-2.0 6.0 2.2 4.0 1.0
-2.0 6.1 2.9 4.7 1.4
-2.0 5.6 2.9 3.6 1.3
-2.0 6.7 3.1 4.4 1.4
-2.0 5.6 3.0 4.5 1.5
-2.0 5.8 2.7 4.1 1.0
-2.0 6.2 2.2 4.5 1.5
-2.0 5.6 2.5 3.9 1.1
-2.0 5.9 3.2 4.8 1.8
-2.0 6.1 2.8 4.0 1.3
-2.0 6.3 2.5 4.9 1.5
-2.0 6.1 2.8 4.7 1.2
-2.0 6.4 2.9 4.3 1.3
-2.0 6.6 3.0 4.4 1.4
-2.0 6.8 2.8 4.8 1.4
-2.0 6.7 3.0 5.0 1.7
-2.0 6.0 2.9 4.5 1.5
-2.0 5.7 2.6 3.5 1.0
-2.0 5.5 2.4 3.8 1.1
-2.0 5.5 2.4 3.7 1.0
-2.0 5.8 2.7 3.9 1.2
-2.0 6.0 2.7 5.1 1.6
-2.0 5.4 3.0 4.5 1.5
-2.0 6.0 3.4 4.5 1.6
-2.0 6.7 3.1 4.7 1.5
-2.0 6.3 2.3 4.4 1.3
-2.0 5.6 3.0 4.1 1.3
-2.0 5.5 2.5 4.0 1.3
-2.0 5.5 2.6 4.4 1.2
-2.0 6.1 3.0 4.6 1.4
-2.0 5.8 2.6 4.0 1.2
-2.0 5.0 2.3 3.3 1.0
-2.0 5.6 2.7 4.2 1.3
-2.0 5.7 3.0 4.2 1.2
-2.0 5.7 2.9 4.2 1.3
-2.0 6.2 2.9 4.3 1.3
-2.0 5.1 2.5 3.0 1.1
-2.0 5.7 2.8 4.1 1.3
-3.0 6.3 3.3 6.0 2.5
-3.0 5.8 2.7 5.1 1.9
-3.0 7.1 3.0 5.9 2.1
-3.0 6.3 2.9 5.6 1.8
-3.0 6.5 3.0 5.8 2.2
-3.0 7.6 3.0 6.6 2.1
-3.0 4.9 2.5 4.5 1.7
-3.0 7.3 2.9 6.3 1.8
-3.0 6.7 2.5 5.8 1.8
-3.0 7.2 3.6 6.1 2.5
-3.0 6.5 3.2 5.1 2.0
-3.0 6.4 2.7 5.3 1.9
-3.0 6.8 3.0 5.5 2.1
-3.0 5.7 2.5 5.0 2.0
-3.0 5.8 2.8 5.1 2.4
-3.0 6.4 3.2 5.3 2.3
-3.0 6.5 3.0 5.5 1.8
-3.0 7.7 3.8 6.7 2.2
-3.0 7.7 2.6 6.9 2.3
-3.0 6.0 2.2 5.0 1.5
-3.0 6.9 3.2 5.7 2.3
-3.0 5.6 2.8 4.9 2.0
-3.0 7.7 2.8 6.7 2.0
-3.0 6.3 2.7 4.9 1.8
-3.0 6.7 3.3 5.7 2.1
-3.0 7.2 3.2 6.0 1.8
-3.0 6.2 2.8 4.8 1.8
-3.0 6.1 3.0 4.9 1.8
-3.0 6.4 2.8 5.6 2.1
-3.0 7.2 3.0 5.8 1.6
-3.0 7.4 2.8 6.1 1.9
-3.0 7.9 3.8 6.4 2.0
-3.0 6.4 2.8 5.6 2.2
-3.0 6.3 2.8 5.1 1.5
-3.0 6.1 2.6 5.6 1.4
-3.0 7.7 3.0 6.1 2.3
-3.0 6.3 3.4 5.6 2.4
-3.0 6.4 3.1 5.5 1.8
-3.0 6.0 3.0 4.8 1.8
-3.0 6.9 3.1 5.4 2.1
-3.0 6.7 3.1 5.6 2.4
-3.0 6.9 3.1 5.1 2.3
-3.0 5.8 2.7 5.1 1.9
-3.0 6.8 3.2 5.9 2.3
-3.0 6.7 3.3 5.7 2.5
-3.0 6.7 3.0 5.2 2.3
-3.0 6.3 2.5 5.0 1.9
-3.0 6.5 3.0 5.2 2.0
-3.0 6.2 3.4 5.4 2.3
-3.0 5.9 3.0 5.1 1.8
[10/11] ignite git commit: IGNITE-7203 Java 8 by default
Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/clustering/DatasetWithObviousStructure.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/DatasetWithObviousStructure.java b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/DatasetWithObviousStructure.java
new file mode 100644
index 0000000..5cd0e09
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/DatasetWithObviousStructure.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.examples.ml.clustering;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.stream.Collectors;
+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.VectorUtils;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+
+/**
+ * See KMeansDistributedClustererTestSingleNode#testClusterizationOnDatasetWithObviousStructure.
+ */
+class DatasetWithObviousStructure {
+ /** */
+ private final Random rnd = new Random(123456L);
+
+ /** Let centers be in the vertices of square. */
+ private final Map<Integer, Vector> centers = new HashMap<>();
+
+ /** Square side length. */
+ private final int squareSideLen;
+
+ /** */
+ DatasetWithObviousStructure(int squareSideLen) {
+ this.squareSideLen = squareSideLen;
+ centers.put(100, new DenseLocalOnHeapVector(new double[] {0.0, 0.0}));
+ centers.put(900, new DenseLocalOnHeapVector(new double[] {squareSideLen, 0.0}));
+ centers.put(3000, new DenseLocalOnHeapVector(new double[] {0.0, squareSideLen}));
+ centers.put(6000, new DenseLocalOnHeapVector(new double[] {squareSideLen, squareSideLen}));
+ }
+
+ /** */
+ List<Vector> generate(Matrix points) {
+ int ptsCnt = points.rowSize();
+
+ // Mass centers of dataset.
+ List<Vector> massCenters = new ArrayList<>();
+
+ int centersCnt = centers.size();
+
+ List<Integer> permutation = IntStream.range(0, ptsCnt).boxed().collect(Collectors.toList());
+ Collections.shuffle(permutation, rnd);
+
+ Vector[] mc = new Vector[centersCnt];
+ Arrays.fill(mc, VectorUtils.zeroes(2));
+
+ int totalCnt = 0;
+
+ int centIdx = 0;
+ massCenters.clear();
+
+ for (Integer count : centers.keySet()) {
+ for (int i = 0; i < count; i++) {
+ Vector pnt = getPoint(count);
+
+ mc[centIdx] = mc[centIdx].plus(pnt);
+
+ points.assignRow(permutation.get(totalCnt), pnt);
+
+ totalCnt++;
+ }
+ massCenters.add(mc[centIdx].times(1 / (double)count));
+ centIdx++;
+ }
+
+ return massCenters;
+ }
+
+ /** */
+ Map<Integer, Vector> centers() {
+ return centers;
+ }
+
+ /** */
+ private Vector getPoint(Integer cnt) {
+ Vector pnt = new DenseLocalOnHeapVector(2).assign(centers.get(cnt));
+ // Perturbate point on random value.
+ pnt.map(val -> val + rnd.nextDouble() * squareSideLen / 100);
+ return pnt;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/clustering/FuzzyCMeansExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/FuzzyCMeansExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/FuzzyCMeansExample.java
new file mode 100644
index 0000000..23aeed7
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/FuzzyCMeansExample.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.ml.clustering;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.ml.clustering.BaseFuzzyCMeansClusterer;
+import org.apache.ignite.ml.clustering.FuzzyCMeansDistributedClusterer;
+import org.apache.ignite.ml.clustering.FuzzyCMeansModel;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.distances.DistanceMeasure;
+import org.apache.ignite.ml.math.distances.EuclideanDistance;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
+import org.apache.ignite.thread.IgniteThread;
+
+/**
+ * <p>
+ * This example shows how to use {@link FuzzyCMeansDistributedClusterer}.</p>
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.</p>
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.</p>
+ */
+public final class FuzzyCMeansExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) throws InterruptedException {
+ System.out.println(">>> Fuzzy C-Means usage example started.");
+
+ // Start ignite grid.
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println(">>> Ignite grid started.");
+
+ // Start new Ignite thread.
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ FuzzyCMeansExample.class.getSimpleName(),
+ () -> {
+ // Distance measure that computes distance between two points.
+ DistanceMeasure distanceMeasure = new EuclideanDistance();
+
+ // "Fuzziness" - specific constant that is used in membership calculation (1.0+-eps ~ K-Means).
+ double exponentialWeight = 2.0;
+
+ // Condition that indicated when algorithm must stop.
+ // In this example algorithm stops if memberships have changed insignificantly.
+ BaseFuzzyCMeansClusterer.StopCondition stopCond =
+ BaseFuzzyCMeansClusterer.StopCondition.STABLE_MEMBERSHIPS;
+
+ // Maximum difference between new and old membership values with which algorithm will continue to work.
+ double maxDelta = 0.01;
+
+ // The maximum number of FCM iterations.
+ int maxIterations = 50;
+
+ // Value that is used to initialize random numbers generator. You can choose it randomly.
+ Long seed = null;
+
+ // Number of steps of primary centers selection (more steps more candidates).
+ int initializationSteps = 2;
+
+ // Number of K-Means iteration that is used to choose required number of primary centers from candidates.
+ int kMeansMaxIterations = 50;
+
+ // Create new distributed clusterer with parameters described above.
+ System.out.println(">>> Create new Distributed Fuzzy C-Means clusterer.");
+ FuzzyCMeansDistributedClusterer clusterer = new FuzzyCMeansDistributedClusterer(
+ distanceMeasure, exponentialWeight, stopCond, maxDelta, maxIterations,
+ seed, initializationSteps, kMeansMaxIterations);
+
+ // Create sample data.
+ double[][] points = new double[][] {
+ {-10, -10}, {-9, -11}, {-10, -9}, {-11, -9},
+ {10, 10}, {9, 11}, {10, 9}, {11, 9},
+ {-10, 10}, {-9, 11}, {-10, 9}, {-11, 9},
+ {10, -10}, {9, -11}, {10, -9}, {11, -9}};
+
+ // Initialize matrix of data points. Each row contains one point.
+ int rows = points.length;
+ int cols = points[0].length;
+
+ System.out.println(">>> Create the matrix that contains sample points.");
+ SparseDistributedMatrix pntMatrix = new SparseDistributedMatrix(rows, cols,
+ StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+ // Store points into matrix.
+ pntMatrix.assign(points);
+
+ // Call clusterization method with some number of centers.
+ // It returns model that can predict results for new points.
+ System.out.println(">>> Perform clusterization.");
+ int numCenters = 4;
+ FuzzyCMeansModel mdl = clusterer.cluster(pntMatrix, numCenters);
+
+ // You can also get centers of clusters that is computed by Fuzzy C-Means algorithm.
+ Vector[] centers = mdl.centers();
+
+ String res = ">>> Results:\n"
+ + ">>> 1st center: " + centers[0].get(0) + " " + centers[0].get(1) + "\n"
+ + ">>> 2nd center: " + centers[1].get(0) + " " + centers[1].get(1) + "\n"
+ + ">>> 3rd center: " + centers[2].get(0) + " " + centers[2].get(1) + "\n"
+ + ">>> 4th center: " + centers[3].get(0) + " " + centers[3].get(1) + "\n";
+
+ System.out.println(res);
+
+ pntMatrix.destroy();
+ });
+
+ igniteThread.start();
+ igniteThread.join();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/clustering/FuzzyCMeansLocalExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/FuzzyCMeansLocalExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/FuzzyCMeansLocalExample.java
new file mode 100644
index 0000000..5c1753a
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/FuzzyCMeansLocalExample.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.examples.ml.clustering;
+
+import org.apache.ignite.ml.clustering.BaseFuzzyCMeansClusterer;
+import org.apache.ignite.ml.clustering.FuzzyCMeansLocalClusterer;
+import org.apache.ignite.ml.clustering.FuzzyCMeansModel;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.distances.DistanceMeasure;
+import org.apache.ignite.ml.math.distances.EuclideanDistance;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+
+/**
+ * This example shows how to use {@link FuzzyCMeansLocalClusterer}.
+ */
+public final class FuzzyCMeansLocalExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println(">>> Local Fuzzy C-Means usage example started.");
+
+ // Distance measure that computes distance between two points.
+ DistanceMeasure distanceMeasure = new EuclideanDistance();
+
+ // "Fuzziness" - specific constant that is used in membership calculation (1.0+-eps ~ K-Means).
+ double exponentialWeight = 2.0;
+
+ // Condition that indicated when algorithm must stop.
+ // In this example algorithm stops if memberships have changed insignificantly.
+ BaseFuzzyCMeansClusterer.StopCondition stopCond =
+ BaseFuzzyCMeansClusterer.StopCondition.STABLE_MEMBERSHIPS;
+
+ // Maximum difference between new and old membership values with which algorithm will continue to work.
+ double maxDelta = 0.01;
+
+ // The maximum number of FCM iterations.
+ int maxIterations = 50;
+
+ // Value that is used to initialize random numbers generator. You can choose it randomly.
+ Long seed = null;
+
+ // Create new distributed clusterer with parameters described above.
+ System.out.println(">>> Create new Local Fuzzy C-Means clusterer.");
+ FuzzyCMeansLocalClusterer clusterer = new FuzzyCMeansLocalClusterer(distanceMeasure,
+ exponentialWeight, stopCond,
+ maxDelta, maxIterations, seed);
+
+ // Create sample data.
+ double[][] points = new double[][] {
+ {-10, -10}, {-9, -11}, {-10, -9}, {-11, -9},
+ {10, 10}, {9, 11}, {10, 9}, {11, 9},
+ {-10, 10}, {-9, 11}, {-10, 9}, {-11, 9},
+ {10, -10}, {9, -11}, {10, -9}, {11, -9}};
+
+ // Initialize matrix of data points. Each row contains one point.
+ System.out.println(">>> Create the matrix that contains sample points.");
+ // Store points into matrix.
+ DenseLocalOnHeapMatrix pntMatrix = new DenseLocalOnHeapMatrix(points);
+
+ // Call clusterization method with some number of centers.
+ // It returns model that can predict results for new points.
+ System.out.println(">>> Perform clusterization.");
+ int numCenters = 4;
+ FuzzyCMeansModel mdl = clusterer.cluster(pntMatrix, numCenters);
+
+ // You can also get centers of clusters that is computed by Fuzzy C-Means algorithm.
+ Vector[] centers = mdl.centers();
+
+ String res = ">>> Results:\n"
+ + ">>> 1st center: " + centers[0].get(0) + " " + centers[0].get(1) + "\n"
+ + ">>> 2nd center: " + centers[1].get(0) + " " + centers[1].get(1) + "\n"
+ + ">>> 3rd center: " + centers[2].get(0) + " " + centers[2].get(1) + "\n"
+ + ">>> 4th center: " + centers[3].get(0) + " " + centers[3].get(1) + "\n";
+
+ System.out.println(res);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/clustering/KMeansDistributedClustererExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/KMeansDistributedClustererExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/KMeansDistributedClustererExample.java
new file mode 100644
index 0000000..f8709e6
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/KMeansDistributedClustererExample.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.examples.ml.clustering;
+
+import java.util.Arrays;
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ml.math.matrix.SparseDistributedMatrixExample;
+import org.apache.ignite.ml.clustering.KMeansDistributedClusterer;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.Tracer;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.distances.EuclideanDistance;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
+import org.apache.ignite.thread.IgniteThread;
+
+/**
+ * <p>
+ * Example of using {@link KMeansDistributedClusterer}.</p>
+ * <p>
+ * Note that in this example we cannot guarantee order in which nodes return results of intermediate
+ * computations and therefore algorithm can return different results.</p>
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.</p>
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.</p>
+ */
+public class KMeansDistributedClustererExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) throws InterruptedException {
+ // IMPL NOTE based on KMeansDistributedClustererTestSingleNode#testClusterizationOnDatasetWithObviousStructure
+ System.out.println(">>> K-means distributed clusterer example started.");
+
+ // Start ignite grid.
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println(">>> Ignite grid started.");
+
+ // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
+ // because we create ignite cache internally.
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ SparseDistributedMatrixExample.class.getSimpleName(), () -> {
+
+ int ptsCnt = 10000;
+
+ SparseDistributedMatrix points = new SparseDistributedMatrix(ptsCnt, 2,
+ StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+ DatasetWithObviousStructure dataset = new DatasetWithObviousStructure(10000);
+
+ List<Vector> massCenters = dataset.generate(points);
+
+ EuclideanDistance dist = new EuclideanDistance();
+
+ KMeansDistributedClusterer clusterer = new KMeansDistributedClusterer(dist, 3, 100, 1L);
+
+ Vector[] resCenters = clusterer.cluster(points, 4).centers();
+
+ System.out.println("Mass centers:");
+ massCenters.forEach(Tracer::showAscii);
+
+ System.out.println("Cluster centers:");
+ Arrays.asList(resCenters).forEach(Tracer::showAscii);
+
+ points.destroy();
+
+ System.out.println("\n>>> K-means distributed clusterer example completed.");
+ });
+
+ igniteThread.start();
+
+ igniteThread.join();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/clustering/KMeansLocalClustererExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/KMeansLocalClustererExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/KMeansLocalClustererExample.java
new file mode 100644
index 0000000..28ca9d9
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/KMeansLocalClustererExample.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.ml.clustering;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import org.apache.ignite.ml.clustering.KMeansLocalClusterer;
+import org.apache.ignite.ml.clustering.KMeansModel;
+import org.apache.ignite.ml.math.Tracer;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.distances.DistanceMeasure;
+import org.apache.ignite.ml.math.distances.EuclideanDistance;
+import org.apache.ignite.ml.math.functions.Functions;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+
+/**
+ * Example of using {@link KMeansLocalClusterer}.
+ */
+public class KMeansLocalClustererExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ // IMPL NOTE based on KMeansDistributedClustererTestSingleNode#testClusterizationOnDatasetWithObviousStructure
+ System.out.println(">>> K-means local clusterer example started.");
+
+ int ptsCnt = 10000;
+ DenseLocalOnHeapMatrix points = new DenseLocalOnHeapMatrix(ptsCnt, 2);
+
+ DatasetWithObviousStructure dataset = new DatasetWithObviousStructure(10000);
+
+ List<Vector> massCenters = dataset.generate(points);
+
+ EuclideanDistance dist = new EuclideanDistance();
+ OrderedNodesComparator comp = new OrderedNodesComparator(
+ dataset.centers().values().toArray(new Vector[] {}), dist);
+
+ massCenters.sort(comp);
+
+ KMeansLocalClusterer clusterer = new KMeansLocalClusterer(dist, 100, 1L);
+
+ KMeansModel mdl = clusterer.cluster(points, 4);
+ Vector[] resCenters = mdl.centers();
+ Arrays.sort(resCenters, comp);
+
+ System.out.println("Mass centers:");
+ massCenters.forEach(Tracer::showAscii);
+
+ System.out.println("Cluster centers:");
+ Arrays.asList(resCenters).forEach(Tracer::showAscii);
+
+ System.out.println("\n>>> K-means local clusterer example completed.");
+ }
+
+ /** */
+ private static class OrderedNodesComparator implements Comparator<Vector> {
+ /** */
+ private final DistanceMeasure measure;
+
+ /** */
+ List<Vector> orderedNodes;
+
+ /** */
+ OrderedNodesComparator(Vector[] orderedNodes, DistanceMeasure measure) {
+ this.orderedNodes = Arrays.asList(orderedNodes);
+ this.measure = measure;
+ }
+
+ /** */
+ private int findClosestNodeIndex(Vector v) {
+ return Functions.argmin(orderedNodes, v1 -> measure.compute(v1, v)).get1();
+ }
+
+ /** */
+ @Override public int compare(Vector v1, Vector v2) {
+ int ind1 = findClosestNodeIndex(v1);
+ int ind2 = findClosestNodeIndex(v2);
+
+ int signum = (int)Math.signum(ind1 - ind2);
+
+ if (signum != 0)
+ return signum;
+
+ return (int)Math.signum(orderedNodes.get(ind1).minus(v1).kNorm(2) -
+ orderedNodes.get(ind2).minus(v2).kNorm(2));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/clustering/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/package-info.java
new file mode 100644
index 0000000..872aa16
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/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. -->
+ * ML clustering examples.
+ */
+package org.apache.ignite.examples.ml.clustering;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/knn/classification/KNNClassificationExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/classification/KNNClassificationExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/knn/classification/KNNClassificationExample.java
new file mode 100644
index 0000000..0e1a52f
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/knn/classification/KNNClassificationExample.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.ml.knn.classification;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.ml.knn.models.KNNModel;
+import org.apache.ignite.ml.knn.models.KNNStrategy;
+import org.apache.ignite.ml.math.distances.EuclideanDistance;
+import org.apache.ignite.ml.structures.LabeledDataset;
+import org.apache.ignite.ml.structures.LabeledDatasetTestTrainPair;
+import org.apache.ignite.ml.structures.preprocessing.LabeledDatasetLoader;
+import org.apache.ignite.ml.structures.preprocessing.LabellingMachine;
+import org.apache.ignite.thread.IgniteThread;
+
+/**
+ * <p>
+ * Example of using {@link KNNModel} with iris dataset.</p>
+ * <p>
+ * Note that in this example we cannot guarantee order in which nodes return results of intermediate
+ * computations and therefore algorithm can return different results.</p>
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.</p>
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.</p>
+ */
+public class KNNClassificationExample {
+ /** Separator. */
+ private static final String SEPARATOR = "\t";
+
+ /** Path to the Iris dataset. */
+ private static final String KNN_IRIS_TXT = "../datasets/iris.txt";
+
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) throws InterruptedException {
+ System.out.println(">>> kNN classification example started.");
+ // Start ignite grid.
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println(">>> Ignite grid started.");
+
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ KNNClassificationExample.class.getSimpleName(), () -> {
+
+ try {
+ // Prepare path to read
+ URL url = KNNClassificationExample.class.getResource(KNN_IRIS_TXT);
+ if (url == null)
+ throw new RuntimeException("Can't get URL for: " + KNN_IRIS_TXT);
+
+ Path path = Paths.get(url.toURI());
+
+ // Read dataset from file
+ LabeledDataset dataset = LabeledDatasetLoader.loadFromTxtFile(path, SEPARATOR, true, false);
+
+ // Random splitting of iris data as 70% train and 30% test datasets
+ LabeledDatasetTestTrainPair split = new LabeledDatasetTestTrainPair(dataset, 0.3);
+
+ System.out.println("\n>>> Amount of observations in train dataset " + split.train().rowSize());
+ System.out.println("\n>>> Amount of observations in test dataset " + split.test().rowSize());
+
+ LabeledDataset test = split.test();
+ LabeledDataset train = split.train();
+
+ KNNModel knnMdl = new KNNModel(5, new EuclideanDistance(), KNNStrategy.SIMPLE, train);
+
+ // Clone labels
+ final double[] labels = test.labels();
+
+ // Save predicted classes to test dataset
+ LabellingMachine.assignLabels(test, knnMdl);
+
+ // Calculate amount of errors on test dataset
+ int amountOfErrors = 0;
+ for (int i = 0; i < test.rowSize(); i++) {
+ if (test.label(i) != labels[i])
+ amountOfErrors++;
+ }
+
+ System.out.println("\n>>> Absolute amount of errors " + amountOfErrors);
+ System.out.println("\n>>> Accuracy " + amountOfErrors / (double)test.rowSize());
+
+ // Build confusion matrix. See https://en.wikipedia.org/wiki/Confusion_matrix
+ int[][] confusionMtx = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
+ for (int i = 0; i < test.rowSize(); i++) {
+ int idx1 = (int)test.label(i);
+ int idx2 = (int)labels[i];
+ confusionMtx[idx1 - 1][idx2 - 1]++;
+ }
+ System.out.println("\n>>> Confusion matrix is " + Arrays.deepToString(confusionMtx));
+
+ // Calculate precision, recall and F-metric for each class
+ for (int i = 0; i < 3; i++) {
+ double precision = 0.0;
+ for (int j = 0; j < 3; j++)
+ precision += confusionMtx[i][j];
+ precision = confusionMtx[i][i] / precision;
+
+ double clsLb = (double)(i + 1);
+
+ System.out.println("\n>>> Precision for class " + clsLb + " is " + precision);
+
+ double recall = 0.0;
+ for (int j = 0; j < 3; j++)
+ recall += confusionMtx[j][i];
+ recall = confusionMtx[i][i] / recall;
+ System.out.println("\n>>> Recall for class " + clsLb + " is " + recall);
+
+ double fScore = 2 * precision * recall / (precision + recall);
+ System.out.println("\n>>> F-score for class " + clsLb + " is " + fScore);
+ }
+
+ }
+ catch (URISyntaxException | IOException e) {
+ e.printStackTrace();
+ System.out.println("\n>>> Unexpected exception, check resources: " + e);
+ }
+ finally {
+ System.out.println("\n>>> kNN classification example completed.");
+ }
+
+ });
+
+ igniteThread.start();
+ igniteThread.join();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/knn/classification/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/classification/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/knn/classification/package-info.java
new file mode 100644
index 0000000..d853f0d
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/knn/classification/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. -->
+ * kNN classification examples.
+ */
+package org.apache.ignite.examples.ml.knn.classification;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/knn/datasets/README.md
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/datasets/README.md b/examples/src/main/java/org/apache/ignite/examples/ml/knn/datasets/README.md
new file mode 100644
index 0000000..2f9c5ec
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/knn/datasets/README.md
@@ -0,0 +1,2 @@
+iris.txt and cleared_machines are from Lichman, M. (2013). UCI Machine Learning Repository [http://archive.ics.uci.edu/ml]. Irvine, CA: University of California, School of Information and Computer Science.
+Read more about machine dataset http://archive.ics.uci.edu/ml/machine-learning-databases/cpu-performance/machine.names
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/knn/datasets/cleared_machines.txt
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/datasets/cleared_machines.txt b/examples/src/main/java/org/apache/ignite/examples/ml/knn/datasets/cleared_machines.txt
new file mode 100644
index 0000000..cf8b6b0
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/knn/datasets/cleared_machines.txt
@@ -0,0 +1,209 @@
+199,125,256,6000,256,16,128
+253,29,8000,32000,32,8,32
+253,29,8000,32000,32,8,32
+253,29,8000,32000,32,8,32
+132,29,8000,16000,32,8,16
+290,26,8000,32000,64,8,32
+381,23,16000,32000,64,16,32
+381,23,16000,32000,64,16,32
+749,23,16000,64000,64,16,32
+1238,23,32000,64000,128,32,64
+23,400,1000,3000,0,1,2
+24,400,512,3500,4,1,6
+70,60,2000,8000,65,1,8
+117,50,4000,16000,65,1,8
+15,350,64,64,0,1,4
+64,200,512,16000,0,4,32
+23,167,524,2000,8,4,15
+29,143,512,5000,0,7,32
+22,143,1000,2000,0,5,16
+124,110,5000,5000,142,8,64
+35,143,1500,6300,0,5,32
+39,143,3100,6200,0,5,20
+40,143,2300,6200,0,6,64
+45,110,3100,6200,0,6,64
+28,320,128,6000,0,1,12
+21,320,512,2000,4,1,3
+28,320,256,6000,0,1,6
+22,320,256,3000,4,1,3
+28,320,512,5000,4,1,5
+27,320,256,5000,4,1,6
+102,25,1310,2620,131,12,24
+102,25,1310,2620,131,12,24
+74,50,2620,10480,30,12,24
+74,50,2620,10480,30,12,24
+138,56,5240,20970,30,12,24
+136,64,5240,20970,30,12,24
+23,50,500,2000,8,1,4
+29,50,1000,4000,8,1,5
+44,50,2000,8000,8,1,5
+30,50,1000,4000,8,3,5
+41,50,1000,8000,8,3,5
+74,50,2000,16000,8,3,5
+74,50,2000,16000,8,3,6
+74,50,2000,16000,8,3,6
+54,133,1000,12000,9,3,12
+41,133,1000,8000,9,3,12
+18,810,512,512,8,1,1
+28,810,1000,5000,0,1,1
+36,320,512,8000,4,1,5
+38,200,512,8000,8,1,8
+34,700,384,8000,0,1,1
+19,700,256,2000,0,1,1
+72,140,1000,16000,16,1,3
+36,200,1000,8000,0,1,2
+30,110,1000,4000,16,1,2
+56,110,1000,12000,16,1,2
+42,220,1000,8000,16,1,2
+34,800,256,8000,0,1,4
+34,800,256,8000,0,1,4
+34,800,256,8000,0,1,4
+34,800,256,8000,0,1,4
+34,800,256,8000,0,1,4
+19,125,512,1000,0,8,20
+75,75,2000,8000,64,1,38
+113,75,2000,16000,64,1,38
+157,75,2000,16000,128,1,38
+18,90,256,1000,0,3,10
+20,105,256,2000,0,3,10
+28,105,1000,4000,0,3,24
+33,105,2000,4000,8,3,19
+47,75,2000,8000,8,3,24
+54,75,3000,8000,8,3,48
+20,175,256,2000,0,3,24
+23,300,768,3000,0,6,24
+25,300,768,3000,6,6,24
+52,300,768,12000,6,6,24
+27,300,768,4500,0,1,24
+50,300,384,12000,6,1,24
+18,300,192,768,6,6,24
+53,180,768,12000,6,1,31
+23,330,1000,3000,0,2,4
+30,300,1000,4000,8,3,64
+73,300,1000,16000,8,2,112
+20,330,1000,2000,0,1,2
+25,330,1000,4000,0,3,6
+28,140,2000,4000,0,3,6
+29,140,2000,4000,0,4,8
+32,140,2000,4000,8,1,20
+175,140,2000,32000,32,1,20
+57,140,2000,8000,32,1,54
+181,140,2000,32000,32,1,54
+181,140,2000,32000,32,1,54
+32,140,2000,4000,8,1,20
+82,57,4000,16000,1,6,12
+171,57,4000,24000,64,12,16
+361,26,16000,32000,64,16,24
+350,26,16000,32000,64,8,24
+220,26,8000,32000,0,8,24
+113,26,8000,16000,0,8,16
+15,480,96,512,0,1,1
+21,203,1000,2000,0,1,5
+35,115,512,6000,16,1,6
+18,1100,512,1500,0,1,1
+20,1100,768,2000,0,1,1
+20,600,768,2000,0,1,1
+28,400,2000,4000,0,1,1
+45,400,4000,8000,0,1,1
+18,900,1000,1000,0,1,2
+17,900,512,1000,0,1,2
+26,900,1000,4000,4,1,2
+28,900,1000,4000,8,1,2
+28,900,2000,4000,0,3,6
+31,225,2000,4000,8,3,6
+31,225,2000,4000,8,3,6
+42,180,2000,8000,8,1,6
+76,185,2000,16000,16,1,6
+76,180,2000,16000,16,1,6
+26,225,1000,4000,2,3,6
+59,25,2000,12000,8,1,4
+65,25,2000,12000,16,3,5
+101,17,4000,16000,8,6,12
+116,17,4000,16000,32,6,12
+18,1500,768,1000,0,0,0
+20,1500,768,2000,0,0,0
+20,800,768,2000,0,0,0
+30,50,2000,4000,0,3,6
+44,50,2000,8000,8,3,6
+44,50,2000,8000,8,1,6
+82,50,2000,16000,24,1,6
+82,50,2000,16000,24,1,6
+128,50,8000,16000,48,1,10
+37,100,1000,8000,0,2,6
+46,100,1000,8000,24,2,6
+46,100,1000,8000,24,3,6
+80,50,2000,16000,12,3,16
+88,50,2000,16000,24,6,16
+88,50,2000,16000,24,6,16
+33,150,512,4000,0,8,128
+46,115,2000,8000,16,1,3
+29,115,2000,4000,2,1,5
+53,92,2000,8000,32,1,6
+53,92,2000,8000,32,1,6
+41,92,2000,8000,4,1,6
+86,75,4000,16000,16,1,6
+95,60,4000,16000,32,1,6
+107,60,2000,16000,64,5,8
+117,60,4000,16000,64,5,8
+119,50,4000,16000,64,5,10
+120,72,4000,16000,64,8,16
+48,72,2000,8000,16,6,8
+126,40,8000,16000,32,8,16
+266,40,8000,32000,64,8,24
+270,35,8000,32000,64,8,24
+426,38,16000,32000,128,16,32
+151,48,4000,24000,32,8,24
+267,38,8000,32000,64,8,24
+603,30,16000,32000,256,16,24
+19,112,1000,1000,0,1,4
+21,84,1000,2000,0,1,6
+26,56,1000,4000,0,1,6
+35,56,2000,6000,0,1,8
+41,56,2000,8000,0,1,8
+47,56,4000,8000,0,1,8
+62,56,4000,12000,0,1,8
+78,56,4000,16000,0,1,8
+80,38,4000,8000,32,16,32
+80,38,4000,8000,32,16,32
+142,38,8000,16000,64,4,8
+281,38,8000,24000,160,4,8
+190,38,4000,16000,128,16,32
+21,200,1000,2000,0,1,2
+25,200,1000,4000,0,1,4
+67,200,2000,8000,64,1,5
+24,250,512,4000,0,1,7
+24,250,512,4000,0,4,7
+64,250,1000,16000,1,1,8
+25,160,512,4000,2,1,5
+20,160,512,2000,2,3,8
+29,160,1000,4000,8,1,14
+43,160,1000,8000,16,1,14
+53,160,2000,8000,32,1,13
+19,240,512,1000,8,1,3
+22,240,512,2000,8,1,5
+31,105,2000,4000,8,3,8
+41,105,2000,6000,16,6,16
+47,105,2000,8000,16,4,14
+99,52,4000,16000,32,4,12
+67,70,4000,12000,8,6,8
+81,59,4000,12000,32,6,12
+149,59,8000,16000,64,12,24
+183,26,8000,24000,32,8,16
+275,26,8000,32000,64,12,16
+382,26,8000,32000,128,24,32
+56,116,2000,8000,32,5,28
+182,50,2000,32000,24,6,26
+227,50,2000,32000,48,26,52
+341,50,2000,32000,112,52,104
+360,50,4000,32000,112,52,104
+919,30,8000,64000,96,12,176
+978,30,8000,64000,128,12,176
+24,180,262,4000,0,1,3
+24,180,512,4000,0,1,3
+24,180,262,4000,0,1,3
+24,180,512,4000,0,1,3
+37,124,1000,8000,0,1,8
+50,98,1000,8000,32,2,8
+41,125,2000,8000,0,2,14
+47,480,512,8000,32,0,0
+25,480,1000,4000,0,0,0
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/knn/datasets/iris.txt
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/datasets/iris.txt b/examples/src/main/java/org/apache/ignite/examples/ml/knn/datasets/iris.txt
new file mode 100644
index 0000000..18f5f7c
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/knn/datasets/iris.txt
@@ -0,0 +1,150 @@
+1.0 5.1 3.5 1.4 0.2
+1.0 4.9 3.0 1.4 0.2
+1.0 4.7 3.2 1.3 0.2
+1.0 4.6 3.1 1.5 0.2
+1.0 5.0 3.6 1.4 0.2
+1.0 5.4 3.9 1.7 0.4
+1.0 4.6 3.4 1.4 0.3
+1.0 5.0 3.4 1.5 0.2
+1.0 4.4 2.9 1.4 0.2
+1.0 4.9 3.1 1.5 0.1
+1.0 5.4 3.7 1.5 0.2
+1.0 4.8 3.4 1.6 0.2
+1.0 4.8 3.0 1.4 0.1
+1.0 4.3 3.0 1.1 0.1
+1.0 5.8 4.0 1.2 0.2
+1.0 5.7 4.4 1.5 0.4
+1.0 5.4 3.9 1.3 0.4
+1.0 5.1 3.5 1.4 0.3
+1.0 5.7 3.8 1.7 0.3
+1.0 5.1 3.8 1.5 0.3
+1.0 5.4 3.4 1.7 0.2
+1.0 5.1 3.7 1.5 0.4
+1.0 4.6 3.6 1.0 0.2
+1.0 5.1 3.3 1.7 0.5
+1.0 4.8 3.4 1.9 0.2
+1.0 5.0 3.0 1.6 0.2
+1.0 5.0 3.4 1.6 0.4
+1.0 5.2 3.5 1.5 0.2
+1.0 5.2 3.4 1.4 0.2
+1.0 4.7 3.2 1.6 0.2
+1.0 4.8 3.1 1.6 0.2
+1.0 5.4 3.4 1.5 0.4
+1.0 5.2 4.1 1.5 0.1
+1.0 5.5 4.2 1.4 0.2
+1.0 4.9 3.1 1.5 0.1
+1.0 5.0 3.2 1.2 0.2
+1.0 5.5 3.5 1.3 0.2
+1.0 4.9 3.1 1.5 0.1
+1.0 4.4 3.0 1.3 0.2
+1.0 5.1 3.4 1.5 0.2
+1.0 5.0 3.5 1.3 0.3
+1.0 4.5 2.3 1.3 0.3
+1.0 4.4 3.2 1.3 0.2
+1.0 5.0 3.5 1.6 0.6
+1.0 5.1 3.8 1.9 0.4
+1.0 4.8 3.0 1.4 0.3
+1.0 5.1 3.8 1.6 0.2
+1.0 4.6 3.2 1.4 0.2
+1.0 5.3 3.7 1.5 0.2
+1.0 5.0 3.3 1.4 0.2
+2.0 7.0 3.2 4.7 1.4
+2.0 6.4 3.2 4.5 1.5
+2.0 6.9 3.1 4.9 1.5
+2.0 5.5 2.3 4.0 1.3
+2.0 6.5 2.8 4.6 1.5
+2.0 5.7 2.8 4.5 1.3
+2.0 6.3 3.3 4.7 1.6
+2.0 4.9 2.4 3.3 1.0
+2.0 6.6 2.9 4.6 1.3
+2.0 5.2 2.7 3.9 1.4
+2.0 5.0 2.0 3.5 1.0
+2.0 5.9 3.0 4.2 1.5
+2.0 6.0 2.2 4.0 1.0
+2.0 6.1 2.9 4.7 1.4
+2.0 5.6 2.9 3.6 1.3
+2.0 6.7 3.1 4.4 1.4
+2.0 5.6 3.0 4.5 1.5
+2.0 5.8 2.7 4.1 1.0
+2.0 6.2 2.2 4.5 1.5
+2.0 5.6 2.5 3.9 1.1
+2.0 5.9 3.2 4.8 1.8
+2.0 6.1 2.8 4.0 1.3
+2.0 6.3 2.5 4.9 1.5
+2.0 6.1 2.8 4.7 1.2
+2.0 6.4 2.9 4.3 1.3
+2.0 6.6 3.0 4.4 1.4
+2.0 6.8 2.8 4.8 1.4
+2.0 6.7 3.0 5.0 1.7
+2.0 6.0 2.9 4.5 1.5
+2.0 5.7 2.6 3.5 1.0
+2.0 5.5 2.4 3.8 1.1
+2.0 5.5 2.4 3.7 1.0
+2.0 5.8 2.7 3.9 1.2
+2.0 6.0 2.7 5.1 1.6
+2.0 5.4 3.0 4.5 1.5
+2.0 6.0 3.4 4.5 1.6
+2.0 6.7 3.1 4.7 1.5
+2.0 6.3 2.3 4.4 1.3
+2.0 5.6 3.0 4.1 1.3
+2.0 5.5 2.5 4.0 1.3
+2.0 5.5 2.6 4.4 1.2
+2.0 6.1 3.0 4.6 1.4
+2.0 5.8 2.6 4.0 1.2
+2.0 5.0 2.3 3.3 1.0
+2.0 5.6 2.7 4.2 1.3
+2.0 5.7 3.0 4.2 1.2
+2.0 5.7 2.9 4.2 1.3
+2.0 6.2 2.9 4.3 1.3
+2.0 5.1 2.5 3.0 1.1
+2.0 5.7 2.8 4.1 1.3
+3.0 6.3 3.3 6.0 2.5
+3.0 5.8 2.7 5.1 1.9
+3.0 7.1 3.0 5.9 2.1
+3.0 6.3 2.9 5.6 1.8
+3.0 6.5 3.0 5.8 2.2
+3.0 7.6 3.0 6.6 2.1
+3.0 4.9 2.5 4.5 1.7
+3.0 7.3 2.9 6.3 1.8
+3.0 6.7 2.5 5.8 1.8
+3.0 7.2 3.6 6.1 2.5
+3.0 6.5 3.2 5.1 2.0
+3.0 6.4 2.7 5.3 1.9
+3.0 6.8 3.0 5.5 2.1
+3.0 5.7 2.5 5.0 2.0
+3.0 5.8 2.8 5.1 2.4
+3.0 6.4 3.2 5.3 2.3
+3.0 6.5 3.0 5.5 1.8
+3.0 7.7 3.8 6.7 2.2
+3.0 7.7 2.6 6.9 2.3
+3.0 6.0 2.2 5.0 1.5
+3.0 6.9 3.2 5.7 2.3
+3.0 5.6 2.8 4.9 2.0
+3.0 7.7 2.8 6.7 2.0
+3.0 6.3 2.7 4.9 1.8
+3.0 6.7 3.3 5.7 2.1
+3.0 7.2 3.2 6.0 1.8
+3.0 6.2 2.8 4.8 1.8
+3.0 6.1 3.0 4.9 1.8
+3.0 6.4 2.8 5.6 2.1
+3.0 7.2 3.0 5.8 1.6
+3.0 7.4 2.8 6.1 1.9
+3.0 7.9 3.8 6.4 2.0
+3.0 6.4 2.8 5.6 2.2
+3.0 6.3 2.8 5.1 1.5
+3.0 6.1 2.6 5.6 1.4
+3.0 7.7 3.0 6.1 2.3
+3.0 6.3 3.4 5.6 2.4
+3.0 6.4 3.1 5.5 1.8
+3.0 6.0 3.0 4.8 1.8
+3.0 6.9 3.1 5.4 2.1
+3.0 6.7 3.1 5.6 2.4
+3.0 6.9 3.1 5.1 2.3
+3.0 5.8 2.7 5.1 1.9
+3.0 6.8 3.2 5.9 2.3
+3.0 6.7 3.3 5.7 2.5
+3.0 6.7 3.0 5.2 2.3
+3.0 6.3 2.5 5.0 1.9
+3.0 6.5 3.0 5.2 2.0
+3.0 6.2 3.4 5.4 2.3
+3.0 5.9 3.0 5.1 1.8
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/knn/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/knn/package-info.java
new file mode 100644
index 0000000..8de4656
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/knn/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. -->
+ * kNN examples.
+ */
+package org.apache.ignite.examples.ml.knn;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/knn/regression/KNNRegressionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/regression/KNNRegressionExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/knn/regression/KNNRegressionExample.java
new file mode 100644
index 0000000..b52613a
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/knn/regression/KNNRegressionExample.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.examples.ml.knn.regression;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ml.knn.classification.KNNClassificationExample;
+import org.apache.ignite.ml.knn.models.KNNStrategy;
+import org.apache.ignite.ml.knn.regression.KNNMultipleLinearRegression;
+import org.apache.ignite.ml.math.distances.ManhattanDistance;
+import org.apache.ignite.ml.structures.LabeledDataset;
+import org.apache.ignite.ml.structures.LabeledDatasetTestTrainPair;
+import org.apache.ignite.ml.structures.preprocessing.LabeledDatasetLoader;
+import org.apache.ignite.ml.structures.preprocessing.LabellingMachine;
+import org.apache.ignite.ml.structures.preprocessing.Normalizer;
+import org.apache.ignite.thread.IgniteThread;
+
+/**
+ * <p>
+ * Example of using {@link KNNMultipleLinearRegression} with iris dataset.</p>
+ * <p>
+ * Note that in this example we cannot guarantee order in which nodes return results of intermediate
+ * computations and therefore algorithm can return different results.</p>
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.</p>
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.</p>
+ */
+public class KNNRegressionExample {
+ /** Separator. */
+ private static final String SEPARATOR = ",";
+
+ /** */
+ private static final String KNN_CLEARED_MACHINES_TXT = "../datasets/cleared_machines.txt";
+
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) throws InterruptedException {
+ System.out.println(">>> kNN regression example started.");
+ // Start ignite grid.
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println(">>> Ignite grid started.");
+
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ KNNRegressionExample.class.getSimpleName(), () -> {
+
+ try {
+ // Prepare path to read
+ URL url = KNNClassificationExample.class.getResource(KNN_CLEARED_MACHINES_TXT);
+ if (url == null)
+ throw new RuntimeException("Can't get URL for: " + KNN_CLEARED_MACHINES_TXT);
+
+ Path path = Paths.get(url.toURI());
+
+ // Read dataset from file
+ LabeledDataset dataset = LabeledDatasetLoader.loadFromTxtFile(path, SEPARATOR, false, false);
+
+ // Normalize dataset
+ Normalizer.normalizeWithMiniMax(dataset);
+
+ // Random splitting of iris data as 80% train and 20% test datasets
+ LabeledDatasetTestTrainPair split = new LabeledDatasetTestTrainPair(dataset, 0.2);
+
+ System.out.println("\n>>> Amount of observations in train dataset: " + split.train().rowSize());
+ System.out.println("\n>>> Amount of observations in test dataset: " + split.test().rowSize());
+
+ LabeledDataset test = split.test();
+ LabeledDataset train = split.train();
+
+ // Builds weighted kNN-regression with Manhattan Distance
+ KNNMultipleLinearRegression knnMdl = new KNNMultipleLinearRegression(7, new ManhattanDistance(),
+ KNNStrategy.WEIGHTED, train);
+
+ // Clone labels
+ final double[] labels = test.labels();
+
+ // Save predicted classes to test dataset
+ LabellingMachine.assignLabels(test, knnMdl);
+
+ // Calculate mean squared error (MSE)
+ double mse = 0.0;
+
+ for (int i = 0; i < test.rowSize(); i++)
+ mse += Math.pow(test.label(i) - labels[i], 2.0);
+ mse = mse / test.rowSize();
+
+ System.out.println("\n>>> Mean squared error (MSE) " + mse);
+
+ // Calculate mean absolute error (MAE)
+ double mae = 0.0;
+
+ for (int i = 0; i < test.rowSize(); i++)
+ mae += Math.abs(test.label(i) - labels[i]);
+ mae = mae / test.rowSize();
+
+ System.out.println("\n>>> Mean absolute error (MAE) " + mae);
+
+ // Calculate R^2 as 1 - RSS/TSS
+ double avg = 0.0;
+
+ for (int i = 0; i < test.rowSize(); i++)
+ avg += test.label(i);
+
+ avg = avg / test.rowSize();
+
+ double detCf = 0.0;
+ double tss = 0.0;
+
+ for (int i = 0; i < test.rowSize(); i++) {
+ detCf += Math.pow(test.label(i) - labels[i], 2.0);
+ tss += Math.pow(test.label(i) - avg, 2.0);
+ }
+
+ detCf = 1 - detCf / tss;
+
+ System.out.println("\n>>> R^2 " + detCf);
+ }
+ catch (URISyntaxException | IOException e) {
+ e.printStackTrace();
+ System.out.println("\n>>> Unexpected exception, check resources: " + e);
+ }
+ finally {
+ System.out.println("\n>>> kNN regression example completed.");
+ }
+ });
+
+ igniteThread.start();
+ igniteThread.join();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/knn/regression/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/regression/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/knn/regression/package-info.java
new file mode 100644
index 0000000..e7ac336
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/knn/regression/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. -->
+ * kNN regression examples.
+ */
+package org.apache.ignite.examples.ml.knn.regression;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/CholeskyDecompositionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/CholeskyDecompositionExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/CholeskyDecompositionExample.java
new file mode 100644
index 0000000..ebac2b1
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/CholeskyDecompositionExample.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.ml.math.decompositions;
+
+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}.
+ */
+public class CholeskyDecompositionExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println(">>> Cholesky decomposition example started.");
+ // Let's compute a Cholesky decomposition of Hermitian matrix m:
+ // m = l l^{*}, where
+ // l is a lower triangular matrix
+ // l^{*} is its conjugate transpose
+
+ DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(new double[][] {
+ {2.0d, -1.0d, 0.0d},
+ {-1.0d, 2.0d, -1.0d},
+ {0.0d, -1.0d, 2.0d}
+ });
+ System.out.println("\n>>> Matrix m for decomposition: ");
+ Tracer.showAscii(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);
+ System.out.println("\n>>> Made decomposition m = l * l^{*}.");
+ System.out.println(">>> Matrix l is ");
+ Tracer.showAscii(dec.getL());
+ System.out.println(">>> Matrix l^{*} is ");
+ Tracer.showAscii(dec.getLT());
+
+ Matrix bs = new DenseLocalOnHeapMatrix(new double[][] {
+ {4.0, -6.0, 7.0},
+ {1.0, 1.0, 1.0}
+ }).transpose();
+ System.out.println("\n>>> Solving systems of linear equations of the form m x = b for various bs represented by columns of matrix");
+ Tracer.showAscii(bs);
+ Matrix sol = dec.solve(bs);
+
+ System.out.println("\n>>> List of solutions: ");
+ for (int i = 0; i < sol.columnSize(); i++)
+ Tracer.showAscii(sol.viewColumn(i));
+
+ System.out.println("\n>>> Cholesky decomposition example completed.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/EigenDecompositionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/EigenDecompositionExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/EigenDecompositionExample.java
new file mode 100644
index 0000000..cda37f4
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/EigenDecompositionExample.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.examples.ml.math.decompositions;
+
+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}.
+ */
+public class EigenDecompositionExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println(">>> Eigen decomposition example started.");
+
+ // Let's compute EigenDecomposition for some square (n x n) matrix m with real eigenvalues:
+ // m = v d v^{-1}, where d is diagonal matrix having eigenvalues of m on diagonal
+ // and v is matrix where i-th column is eigenvector for i-th eigenvalue (i from 0 to n - 1)
+ DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(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}
+ });
+ System.out.println("\n>>> Matrix m for decomposition: ");
+ Tracer.showAscii(m);
+
+ EigenDecomposition dec = new EigenDecomposition(m);
+ System.out.println("\n>>> Made decomposition.");
+ System.out.println(">>> Matrix getV is ");
+ Tracer.showAscii(dec.getV());
+ System.out.println(">>> Matrix getD is ");
+ Tracer.showAscii(dec.getD());
+
+ // From this decomposition we, for example, can easily compute determinant of matrix m
+ // det (m) = det (v d v^{-1}) =
+ // det(v) det (d) det(v^{-1}) =
+ // det(v) det(v)^{-1} det(d) =
+ // det (d) =
+ // product of diagonal elements of d =
+ // product of eigenvalues
+ double det = dec.getRealEigenValues().foldMap(Functions.MULT, Functions.IDENTITY, 1.0);
+ System.out.println("\n>>> Determinant is " + det);
+
+ System.out.println("\n>>> Eigen decomposition example completed.");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/LUDecompositionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/LUDecompositionExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/LUDecompositionExample.java
new file mode 100644
index 0000000..a815047
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/LUDecompositionExample.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.ml.math.decompositions;
+
+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}.
+ */
+public class LUDecompositionExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println(">>> LU decomposition example started.");
+ // Let's compute a LU decomposition for some (n x n) matrix m:
+ // m = p l u, where
+ // p is an (n x n) is a row-permutation matrix
+ // l is a (n x n) lower triangular matrix
+ // u is a (n x n) upper triangular matrix
+
+ DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(new double[][] {
+ {1.0d, 1.0d, -1.0d},
+ {1.0d, -2.0d, 3.0d},
+ {2.0d, 3.0d, 1.0d}
+ });
+ System.out.println("\n>>> Matrix m for decomposition: ");
+ Tracer.showAscii(m);
+
+ // This decomposition is useful when dealing with systems of linear equations.
+ // (see https://en.wikipedia.org/wiki/LU_decomposition)
+ // suppose we want to solve system
+ // m x = b for various bs. Then after we computed LU decomposition, we can feed various bs
+ // as a matrix of the form
+ // (b1, b2, ..., bm)
+ // to the method LUDecomposition::solve which returns solutions in the form
+ // (sol1, sol2, ..., solm)
+
+ LUDecomposition dec = new LUDecomposition(m);
+ System.out.println("\n>>> Made decomposition.");
+ System.out.println(">>> Matrix getL is ");
+ Tracer.showAscii(dec.getL());
+ System.out.println(">>> Matrix getU is ");
+ Tracer.showAscii(dec.getU());
+ System.out.println(">>> Matrix getP is ");
+ Tracer.showAscii(dec.getP());
+
+ Matrix bs = new DenseLocalOnHeapMatrix(new double[][] {
+ {4.0, -6.0, 7.0},
+ {1.0, 1.0, 1.0}
+ });
+ System.out.println("\n>>> Matrix to solve: ");
+ Tracer.showAscii(bs);
+
+ Matrix sol = dec.solve(bs.transpose());
+
+ System.out.println("\n>>> List of solutions: ");
+ for (int i = 0; i < sol.columnSize(); i++)
+ Tracer.showAscii(sol.viewColumn(i));
+
+ System.out.println("\n>>> LU decomposition example completed.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/QRDecompositionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/QRDecompositionExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/QRDecompositionExample.java
new file mode 100644
index 0000000..bed99d1
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/QRDecompositionExample.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.ml.math.decompositions;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Tracer;
+import org.apache.ignite.ml.math.decompositions.QRDecomposition;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+
+/**
+ * Example of using {@link QRDecomposition}.
+ */
+public class QRDecompositionExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println(">>> QR decomposition example started.");
+ Matrix m = new DenseLocalOnHeapMatrix(new double[][] {
+ {2.0d, -1.0d, 0.0d},
+ {-1.0d, 2.0d, -1.0d},
+ {0.0d, -1.0d, 2.0d}
+ });
+
+ System.out.println("\n>>> Input matrix:");
+ Tracer.showAscii(m);
+
+ QRDecomposition dec = new QRDecomposition(m);
+ System.out.println("\n>>> Value for full rank in decomposition: [" + dec.hasFullRank() + "].");
+
+ Matrix q = dec.getQ();
+ Matrix r = dec.getR();
+
+ System.out.println("\n>>> Orthogonal matrix Q:");
+ Tracer.showAscii(q);
+ System.out.println("\n>>> Upper triangular matrix R:");
+ Tracer.showAscii(r);
+
+ Matrix qSafeCp = safeCopy(q);
+
+ Matrix identity = qSafeCp.times(qSafeCp.transpose());
+
+ System.out.println("\n>>> Identity matrix obtained from Q:");
+ Tracer.showAscii(identity);
+
+ Matrix recomposed = qSafeCp.times(r);
+
+ System.out.println("\n>>> Recomposed input matrix:");
+ Tracer.showAscii(recomposed);
+
+ Matrix sol = dec.solve(new DenseLocalOnHeapMatrix(3, 10));
+
+ System.out.println("\n>>> Solved matrix:");
+ Tracer.showAscii(sol);
+
+ dec.destroy();
+
+ System.out.println("\n>>> QR decomposition example completed.");
+ }
+
+ /** */
+ private static Matrix safeCopy(Matrix orig) {
+ return new DenseLocalOnHeapMatrix(orig.rowSize(), orig.columnSize()).assign(orig);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/SingularValueDecompositionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/SingularValueDecompositionExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/SingularValueDecompositionExample.java
new file mode 100644
index 0000000..81406ae
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/SingularValueDecompositionExample.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.ml.math.decompositions;
+
+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}.
+ */
+public class SingularValueDecompositionExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ System.out.println(">>> Singular value decomposition (SVD) example started.");
+
+ // Let's compute a SVD of (l x k) matrix m. This decomposition can be thought as extension of EigenDecomposition to
+ // rectangular matrices. The factorization we get is following:
+ // m = u * s * v^{*}, where
+ // u is a real or complex unitary matrix
+ // s is a rectangular diagonal matrix with non-negative real numbers on diagonal (this numbers are singular values of m)
+ // v is a real or complex unitary matrix
+ // If m is real then u and v are also real.
+ // Complex case is not supported for the moment.
+ DenseLocalOnHeapMatrix m = new DenseLocalOnHeapMatrix(new double[][] {
+ {1.0d, 0.0d, 0.0d, 0.0d, 2.0d},
+ {0.0d, 0.0d, 3.0d, 0.0d, 0.0d},
+ {0.0d, 0.0d, 0.0d, 0.0d, 0.0d},
+ {0.0d, 2.0d, 0.0d, 0.0d, 0.0d}
+ });
+ System.out.println("\n>>> Matrix m for decomposition: ");
+ Tracer.showAscii(m);
+
+ SingularValueDecomposition dec = new SingularValueDecomposition(m);
+ System.out.println("\n>>> Made decomposition m = u * s * v^{*}.");
+ System.out.println(">>> Matrix u is ");
+ Tracer.showAscii(dec.getU());
+ System.out.println(">>> Matrix s is ");
+ Tracer.showAscii(dec.getS());
+ System.out.println(">>> Matrix v is ");
+ Tracer.showAscii(dec.getV());
+
+ // This decomposition can in particular help with solving problem of finding x minimizing 2-norm of m x such
+ // that 2-norm of x is 1. It appears that it is the right singular vector corresponding to minimal singular
+ // value, which is always last.
+ System.out.println("\n>>> Vector x minimizing 2-norm of m x such that 2 norm of x is 1: ");
+ Tracer.showAscii(dec.getV().viewColumn(dec.getSingularValues().length - 1));
+
+ System.out.println("\n>>> Singular value decomposition (SVD) example completed.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/decompositions/package-info.java
new file mode 100644
index 0000000..644f8ba
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/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. -->
+ * Core algebra decomposition examples.
+ */
+package org.apache.ignite.examples.ml.math.decompositions;
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/CacheMatrixExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/CacheMatrixExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/CacheMatrixExample.java
new file mode 100644
index 0000000..a7cbaab
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/CacheMatrixExample.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.examples.ml.math.matrix;
+
+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.examples.ml.math.vector.CacheVectorExample;
+import org.apache.ignite.ml.math.IdentityValueMapper;
+import org.apache.ignite.ml.math.Tracer;
+import org.apache.ignite.ml.math.distributed.MatrixKeyMapper;
+import org.apache.ignite.ml.math.distributed.ValueMapper;
+import org.apache.ignite.ml.math.functions.Functions;
+import org.apache.ignite.ml.math.impls.matrix.CacheMatrix;
+
+/**
+ * Example that demonstrates how to use {@link CacheMatrix}.
+ *
+ * Basically CacheMatrix is view over existing data in cache. So we have {@link MatrixKeyMapper} and {@link ValueMapper}
+ * for this purpose. A {@link MatrixKeyMapper} allows us to map matrix indices to cache keys. And a {@link ValueMapper}
+ * allows us map cache object to matrix elements - doubles.
+ *
+ * In this example we use simple flat mapping for keys and {@link IdentityValueMapper} for cache objects
+ * because they are Doubles.
+ *
+ * @see CacheVectorExample
+ */
+public class CacheMatrixExample {
+ /** */ private static final String CACHE_NAME = CacheMatrixExample.class.getSimpleName();
+ /** */ private static final int ROWS = 3;
+ /** */ private static final int COLS = 3;
+
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println();
+ System.out.println(">>> CacheMatrix example started.");
+
+ CacheConfiguration<Integer, Double> cfg = new CacheConfiguration<>();
+
+ cfg.setName(CACHE_NAME);
+
+ try (IgniteCache<Integer, Double> cache = ignite.getOrCreateCache(cfg)) {
+ double[][] testValues = {{1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {1.0, 1.0, 1.0}};
+
+ ValueMapper valMapper = new IdentityValueMapper();
+
+ // Map matrix element indices to cache keys.
+ MatrixKeyMapper<Integer> keyMapper = new MatrixKeyMapper<Integer>() {
+ @Override public Integer apply(int x, int y) {
+ return x * COLS + y;
+ }
+
+ @Override public boolean isValid(Integer integer) {
+ return integer >= 0 && integer < COLS * ROWS;
+ }
+ };
+
+ // Create cache matrix.
+ CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(ROWS, COLS, cache, keyMapper, valMapper);
+
+ cacheMatrix.assign(testValues);
+
+ Tracer.showAscii(cacheMatrix);
+
+ // Find all positive elements.
+ Integer nonZeroes = cacheMatrix.foldMap((o, aDouble) -> {
+ if (aDouble > 0)
+ return o + 1;
+ return o;
+ }, Functions.IDENTITY, 0);
+
+ System.out.println("Quantity of non zeroes elements is " + nonZeroes.intValue());
+
+ System.out.println(">>>");
+ System.out.println(">>> Finished executing Ignite \"CacheMatrix\" example.");
+ System.out.println(">>> Lower triangular matrix 3x3 have only 6 positive elements.");
+ System.out.println(">>>");
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.java b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.java
new file mode 100644
index 0000000..542fbdc
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.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.examples.ml.math.matrix;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Arrays;
+import org.apache.ignite.ml.math.MatrixStorage;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.impls.storage.matrix.ArrayMatrixStorage;
+import org.apache.ignite.ml.math.util.MatrixUtil;
+
+/**
+ * Example matrix storage implementation, modeled after {@link ArrayMatrixStorage}.
+ */
+class ExampleMatrixStorage implements MatrixStorage {
+ /** Backing data array. */
+ private double[][] data;
+ /** Amount of rows in a matrix storage. */
+ private int rows;
+ /** Amount of columns in a matrix storage. */
+ private int cols;
+
+ /**
+ *
+ */
+ public ExampleMatrixStorage() {
+ // No-op.
+ }
+
+ /**
+ * @param rows Amount of rows in a matrix storage.
+ * @param cols Amount of columns in a matrix storage.
+ */
+ ExampleMatrixStorage(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.
+ */
+ ExampleMatrixStorage(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 int storageMode() {
+ // This value indicate that we store matrix data by rows.
+ return StorageConstants.ROW_STORAGE_MODE;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int accessMode() {
+ return StorageConstants.RANDOM_ACCESS_MODE;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isArrayBased() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public double[] data() {
+ return MatrixUtil.flatten(data, StorageConstants.ROW_STORAGE_MODE);
+ }
+
+ /** {@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;
+
+ ExampleMatrixStorage that = (ExampleMatrixStorage)o;
+
+ return Arrays.deepEquals(data, that.data);
+ }
+}
[04/11] ignite git commit: IGNITE-7203 Java 8 by default
Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/LifecycleExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/LifecycleExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/LifecycleExamplesSelfTest.java
index 2bd4a1f..b89a8f7 100644
--- a/examples/src/test/java/org/apache/ignite/examples/LifecycleExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/LifecycleExamplesSelfTest.java
@@ -17,7 +17,8 @@
package org.apache.ignite.examples;
-import org.apache.ignite.examples.misc.lifecycle.LifecycleExample;
+//import org.apache.ignite.examples.misc.lifecycle.*;
+
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
/**
@@ -25,9 +26,12 @@ import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
*/
public class LifecycleExamplesSelfTest extends GridAbstractExamplesTest {
/**
+ * TODO: IGNITE-711 next example(s) should be implemented for java 8
+ * or testing method(s) should be removed if example(s) does not applicable for java 8.
+ *
* @throws Exception If failed.
*/
- public void testLifecycleExample() throws Exception {
- LifecycleExample.main(EMPTY_ARGS);
- }
-}
\ No newline at end of file
+// public void testLifecycleExample() throws Exception {
+// LifecycleExample.main(EMPTY_ARGS);
+// }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesMultiNodeSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesMultiNodeSelfTest.java
index 82a69e3..fd57fbb 100644
--- a/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesMultiNodeSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesMultiNodeSelfTest.java
@@ -17,15 +17,17 @@
package org.apache.ignite.examples;
-import org.apache.ignite.examples.misc.client.memcache.MemcacheRestExampleNodeStartup;
+//import org.apache.ignite.examples.misc.client.memcache.*;
/**
* MemcacheRestExample multi-node self test.
*/
public class MemcacheRestExamplesMultiNodeSelfTest extends MemcacheRestExamplesSelfTest {
+ // TODO: IGNITE-711 next example(s) should be implemented for java 8
+ // or testing method(s) should be removed if example(s) does not applicable for java 8.
/** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- for (int i = 0; i < RMT_NODES_CNT; i++)
- startGrid("memcache-rest-examples-" + i, MemcacheRestExampleNodeStartup.configuration());
- }
+// @Override protected void beforeTest() throws Exception {
+// for (int i = 0; i < RMT_NODES_CNT; i++)
+// startGrid("memcache-rest-examples-" + i, MemcacheRestExampleNodeStartup.configuration());
+// }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesSelfTest.java
index 459ddea..762343d 100644
--- a/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesSelfTest.java
@@ -17,26 +17,28 @@
package org.apache.ignite.examples;
-import org.apache.ignite.examples.misc.client.memcache.MemcacheRestExample;
-import org.apache.ignite.examples.misc.client.memcache.MemcacheRestExampleNodeStartup;
+//import org.apache.ignite.examples.misc.client.memcache.*;
+
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
/**
* MemcacheRestExample self test.
*/
public class MemcacheRestExamplesSelfTest extends GridAbstractExamplesTest {
- /**
- * @throws Exception If failed.
- */
- @Override protected void beforeTest() throws Exception {
- // Start up a cluster node.
- startGrid("memcache-rest-examples", MemcacheRestExampleNodeStartup.configuration());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMemcacheRestExample() throws Exception {
- MemcacheRestExample.main(EMPTY_ARGS);
- }
-}
\ No newline at end of file
+// TODO: IGNITE-711 next example(s) should be implemented for java 8
+// or testing method(s) should be removed if example(s) does not applicable for java 8.
+// /**
+// * @throws Exception If failed.
+// */
+// @Override protected void beforeTest() throws Exception {
+// // Start up a cluster node.
+// startGrid("memcache-rest-examples", MemcacheRestExampleNodeStartup.configuration());
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testMemcacheRestExample() throws Exception {
+// MemcacheRestExample.main(EMPTY_ARGS);
+// }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/MessagingExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/MessagingExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/MessagingExamplesSelfTest.java
index 66cddb4..3c94d3b 100644
--- a/examples/src/test/java/org/apache/ignite/examples/MessagingExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/MessagingExamplesSelfTest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.examples;
import org.apache.ignite.examples.messaging.MessagingExample;
import org.apache.ignite.examples.messaging.MessagingPingPongExample;
-import org.apache.ignite.examples.messaging.MessagingPingPongListenActorExample;
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
/**
@@ -45,10 +44,12 @@ public class MessagingExamplesSelfTest extends GridAbstractExamplesTest {
MessagingPingPongExample.main(EMPTY_ARGS);
}
- /**
- * @throws Exception If failed.
- */
- public void testMessagingPingPongListenActorExample() throws Exception {
- MessagingPingPongListenActorExample.main(EMPTY_ARGS);
- }
+// TODO: IGNITE-711 next example(s) should be implemented for java 8
+// or testing method(s) should be removed if example(s) does not applicable for java 8.
+// /**
+// * @throws Exception If failed.
+// */
+// public void testMessagingPingPongListenActorExample() throws Exception {
+// MessagingPingPongListenActorExample.main(EMPTY_ARGS);
+// }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/MonteCarloExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/MonteCarloExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/MonteCarloExamplesSelfTest.java
index f98b481..beba341 100644
--- a/examples/src/test/java/org/apache/ignite/examples/MonteCarloExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/MonteCarloExamplesSelfTest.java
@@ -17,7 +17,8 @@
package org.apache.ignite.examples;
-import org.apache.ignite.examples.computegrid.montecarlo.CreditRiskExample;
+//import org.apache.ignite.examples.computegrid.montecarlo.*;
+
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
/**
@@ -66,9 +67,12 @@ import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
*/
public class MonteCarloExamplesSelfTest extends GridAbstractExamplesTest {
/**
+ * TODO: IGNITE-711 next example(s) should be implemented for java 8
+ * or testing method(s) should be removed if example(s) does not applicable for java 8.
+ *
* @throws Exception If failed.
*/
- public void testCreditRiskExample() throws Exception {
- CreditRiskExample.main(EMPTY_ARGS);
- }
-}
\ No newline at end of file
+// public void testCreditRiskExample() throws Exception {
+// CreditRiskExample.main(EMPTY_ARGS);
+// }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/SpringBeanExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/SpringBeanExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/SpringBeanExamplesSelfTest.java
index 9819072..4cc209f 100644
--- a/examples/src/test/java/org/apache/ignite/examples/SpringBeanExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/SpringBeanExamplesSelfTest.java
@@ -17,7 +17,8 @@
package org.apache.ignite.examples;
-import org.apache.ignite.examples.misc.springbean.SpringBeanExample;
+//import org.apache.ignite.examples.misc.springbean.*;
+
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
/**
@@ -25,9 +26,12 @@ import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
*/
public class SpringBeanExamplesSelfTest extends GridAbstractExamplesTest {
/**
+ * TODO: IGNITE-711 next example(s) should be implemented for java 8
+ * or testing method(s) should be removed if example(s) does not applicable for java 8.
+ *
* @throws Exception If failed.
*/
- public void testSpringBeanHelloWorldExample() throws Exception {
- SpringBeanExample.main(EMPTY_ARGS);
- }
-}
\ No newline at end of file
+// public void testSpringBeanHelloWorldExample() throws Exception {
+// SpringBeanExample.main(EMPTY_ARGS);
+// }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/examples/TaskExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/TaskExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/TaskExamplesSelfTest.java
index c31787a..72ad3c7 100644
--- a/examples/src/test/java/org/apache/ignite/examples/TaskExamplesSelfTest.java
+++ b/examples/src/test/java/org/apache/ignite/examples/TaskExamplesSelfTest.java
@@ -17,25 +17,27 @@
package org.apache.ignite.examples;
-import org.apache.ignite.examples.computegrid.ComputeTaskMapExample;
-import org.apache.ignite.examples.computegrid.ComputeTaskSplitExample;
+//import org.apache.ignite.examples.computegrid.*;
+
import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
/**
* Hello world examples self test.
*/
public class TaskExamplesSelfTest extends GridAbstractExamplesTest {
- /**
- * @throws Exception If failed.
- */
- public void testTaskSplitExample() throws Exception {
- ComputeTaskSplitExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTaskMapExample() throws Exception {
- ComputeTaskMapExample.main(EMPTY_ARGS);
- }
-}
\ No newline at end of file
+// TODO: IGNITE-711 next example(s) should be implemented for java 8
+// or testing method(s) should be removed if example(s) does not applicable for java 8.
+// /**
+// * @throws Exception If failed.
+// */
+// public void testTaskSplitExample() throws Exception {
+// ComputeTaskSplitExample.main(EMPTY_ARGS);
+// }
+//
+// /**
+// * @throws Exception If failed.
+// */
+// public void testTaskMapExample() throws Exception {
+// ComputeTaskMapExample.main(EMPTY_ARGS);
+// }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesJ8SelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesJ8SelfTestSuite.java b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesJ8SelfTestSuite.java
new file mode 100644
index 0000000..f73d977
--- /dev/null
+++ b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesJ8SelfTestSuite.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.examples.BasicExamplesMultiNodeSelfTest;
+import org.apache.ignite.examples.BasicExamplesSelfTest;
+import org.apache.ignite.examples.CacheExamplesMultiNodeSelfTest;
+import org.apache.ignite.examples.CacheExamplesSelfTest;
+import org.apache.ignite.examples.EventsExamplesMultiNodeSelfTest;
+import org.apache.ignite.examples.EventsExamplesSelfTest;
+import org.apache.ignite.examples.MessagingExamplesSelfTest;
+import org.apache.ignite.testframework.GridTestUtils;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP;
+
+/**
+ * Examples test suite.
+ * <p>
+ * Contains only Spring ignite examples tests.
+ */
+public class IgniteExamplesJ8SelfTestSuite extends TestSuite {
+ /**
+ * @return Suite.
+ * @throws Exception If failed.
+ */
+ public static TestSuite suite() throws Exception {
+ System.setProperty(IGNITE_OVERRIDE_MCAST_GRP,
+ GridTestUtils.getNextMulticastGroup(IgniteExamplesJ8SelfTestSuite.class));
+
+ TestSuite suite = new TestSuite("Ignite Examples Test Suite");
+
+ suite.addTest(new TestSuite(CacheExamplesSelfTest.class));
+ suite.addTest(new TestSuite(BasicExamplesSelfTest.class));
+
+// suite.addTest(new TestSuite(ContinuationExamplesSelfTest.class));
+// suite.addTest(new TestSuite(ContinuousMapperExamplesSelfTest.class));
+// suite.addTest(new TestSuite(DeploymentExamplesSelfTest.class));
+ suite.addTest(new TestSuite(EventsExamplesSelfTest.class));
+// suite.addTest(new TestSuite(LifecycleExamplesSelfTest.class));
+ suite.addTest(new TestSuite(MessagingExamplesSelfTest.class));
+// suite.addTest(new TestSuite(MemcacheRestExamplesSelfTest.class));
+// suite.addTest(new TestSuite(MonteCarloExamplesSelfTest.class));
+// suite.addTest(new TestSuite(TaskExamplesSelfTest.class));
+// suite.addTest(new TestSuite(SpringBeanExamplesSelfTest.class));
+// suite.addTest(new TestSuite(IgfsExamplesSelfTest.class));
+// suite.addTest(new TestSuite(CheckpointExamplesSelfTest.class));
+// suite.addTest(new TestSuite(HibernateL2CacheExampleSelfTest.class));
+// suite.addTest(new TestSuite(ClusterGroupExampleSelfTest.class));
+
+ // Multi-node.
+ suite.addTest(new TestSuite(CacheExamplesMultiNodeSelfTest.class));
+ suite.addTest(new TestSuite(BasicExamplesMultiNodeSelfTest.class));
+// suite.addTest(new TestSuite(ContinuationExamplesMultiNodeSelfTest.class));
+// suite.addTest(new TestSuite(ContinuousMapperExamplesMultiNodeSelfTest.class));
+// suite.addTest(new TestSuite(DeploymentExamplesMultiNodeSelfTest.class));
+ suite.addTest(new TestSuite(EventsExamplesMultiNodeSelfTest.class));
+// suite.addTest(new TestSuite(TaskExamplesMultiNodeSelfTest.class));
+// suite.addTest(new TestSuite(MemcacheRestExamplesMultiNodeSelfTest.class));
+// suite.addTest(new TestSuite(MonteCarloExamplesMultiNodeSelfTest.class));
+// suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class));
+
+ return suite;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesMLTestSuite.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesMLTestSuite.java b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesMLTestSuite.java
new file mode 100644
index 0000000..bc917b9
--- /dev/null
+++ b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesMLTestSuite.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.testsuites;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import javassist.CannotCompileException;
+import javassist.ClassClassPath;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtNewMethod;
+import javassist.NotFoundException;
+import junit.framework.TestSuite;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP;
+
+/**
+ * Examples test suite.
+ * <p>
+ * Contains only Spring ignite examples tests.
+ */
+public class IgniteExamplesMLTestSuite extends TestSuite {
+ /**
+ * @return Suite.
+ * @throws Exception If failed.
+ */
+ public static TestSuite suite() throws Exception {
+ System.setProperty(IGNITE_OVERRIDE_MCAST_GRP,
+ GridTestUtils.getNextMulticastGroup(IgniteExamplesMLTestSuite.class));
+
+ TestSuite suite = new TestSuite("Ignite ML Examples Test Suite");
+
+ for (Class clazz : getClasses("org.apache.ignite.examples.ml", ".*Example$"))
+ suite.addTest(new TestSuite(makeTestClass(clazz, "org.apache.ignite.ml.examples")));
+
+ return suite;
+ }
+
+ /**
+ * Creates test class for given example.
+ *
+ * @param exampleCls Class of the example to be tested
+ * @param basePkgForTests Base package to create test classes in
+ * @return Test class
+ * @throws NotFoundException if class not found
+ * @throws CannotCompileException if test class cannot be compiled
+ */
+ private static Class makeTestClass(Class<?> exampleCls, String basePkgForTests)
+ throws NotFoundException, CannotCompileException {
+ ClassPool cp = ClassPool.getDefault();
+ cp.insertClassPath(new ClassClassPath(IgniteExamplesMLTestSuite.class));
+
+ CtClass cl = cp.makeClass(basePkgForTests + "." + exampleCls.getSimpleName() + "SelfName");
+
+ cl.setSuperclass(cp.get(GridAbstractExamplesTest.class.getName()));
+
+ cl.addMethod(CtNewMethod.make("public void testExample() { "
+ + exampleCls.getCanonicalName()
+ + ".main("
+ + GridAbstractExamplesTest.class.getName()
+ + ".EMPTY_ARGS); }", cl));
+
+ return cl.toClass();
+ }
+
+ /**
+ * Scans all classes accessible from the context class loader which belong to the given package and subpackages.
+ *
+ * @param pkgName The base package
+ * @return The classes
+ * @throws ClassNotFoundException if some classes not found
+ * @throws IOException if some resources unavailable
+ */
+ private static List<Class> getClasses(String pkgName, String clsNamePtrn) throws ClassNotFoundException, IOException {
+ String path = pkgName.replace('.', '/');
+
+ Enumeration<URL> resources = Thread.currentThread()
+ .getContextClassLoader()
+ .getResources(path);
+
+ List<File> dirs = new ArrayList<>();
+ while (resources.hasMoreElements())
+ dirs.add(new File(resources.nextElement().getFile()));
+
+ List<Class> classes = new ArrayList<>();
+ for (File directory : dirs)
+ classes.addAll(findClasses(directory, pkgName, clsNamePtrn));
+
+ return classes;
+ }
+
+ /**
+ * Recursive method used to find all classes in a given directory and subdirs.
+ *
+ * @param dir The base directory
+ * @param pkgName The package name for classes found inside the base directory
+ * @return The classes
+ * @throws ClassNotFoundException if class not found
+ */
+ private static List<Class> findClasses(File dir, String pkgName, String clsNamePtrn) throws ClassNotFoundException {
+ List<Class> classes = new ArrayList<>();
+ if (!dir.exists())
+ return classes;
+
+ File[] files = dir.listFiles();
+ if (files != null)
+ for (File file : files) {
+ if (file.isDirectory())
+ classes.addAll(findClasses(file, pkgName + "." + file.getName(), clsNamePtrn));
+ else if (file.getName().endsWith(".class")) {
+ String clsName = pkgName + '.' + file.getName().substring(0, file.getName().length() - 6);
+ if (clsName.matches(clsNamePtrn))
+ classes.add(Class.forName(clsName));
+ }
+ }
+
+ return classes;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/BasicExamplesMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/BasicExamplesMultiNodeSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/BasicExamplesMultiNodeSelfTest.java
deleted file mode 100644
index 127ba0d..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/BasicExamplesMultiNodeSelfTest.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.java8.examples;
-
-/**
- * Closure examples multi-node self test.
- */
-public class BasicExamplesMultiNodeSelfTest extends BasicExamplesSelfTest {
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- startRemoteNodes();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/BasicExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/BasicExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/BasicExamplesSelfTest.java
deleted file mode 100644
index cc74cef..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/BasicExamplesSelfTest.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.java8.examples;
-
-import org.apache.ignite.examples.java8.computegrid.ComputeBroadcastExample;
-import org.apache.ignite.examples.java8.computegrid.ComputeCallableExample;
-import org.apache.ignite.examples.java8.computegrid.ComputeClosureExample;
-import org.apache.ignite.examples.java8.computegrid.ComputeRunnableExample;
-import org.apache.ignite.examples.java8.datastructures.IgniteExecutorServiceExample;
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * Closure examples self test.
- */
-public class BasicExamplesSelfTest extends GridAbstractExamplesTest {
- /**
- * @throws Exception If failed.
- */
- public void testBroadcastExample() throws Exception {
- ComputeBroadcastExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCallableExample() throws Exception {
- ComputeCallableExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testClosureExample() throws Exception {
- ComputeClosureExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testExecutorExample() throws Exception {
- IgniteExecutorServiceExample.main(EMPTY_ARGS);
- }
-
-// TODO: IGNITE-711 next example(s) should be implemented for java 8 or testing method(s) should be removed if example(s) does not applicable for java 8.
-// /**
-// * @throws Exception If failed.
-// */
-// public void testReducerExample() throws Exception {
-// ComputeReducerExample.main(EMPTY_ARGS);
-// }
-
- /**
- * @throws Exception If failed.
- */
- public void testRunnableExample() throws Exception {
- ComputeRunnableExample.main(EMPTY_ARGS);
- }
-
-// TODO: IGNITE-711 next example(s) should be implemented for java 8
-// or testing method(s) should be removed if example(s) does not applicable for java 8.
-// /**
-// * @throws Exception If failed.
-// */
-// public void testTaskMapExample() throws Exception {
-// ComputeTaskMapExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testTaskSplitExample() throws Exception {
-// ComputeTaskSplitExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/CacheExamplesMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/CacheExamplesMultiNodeSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/CacheExamplesMultiNodeSelfTest.java
deleted file mode 100644
index 8056eef..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/CacheExamplesMultiNodeSelfTest.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.java8.examples;
-
-/**
- * Cache examples multi-node self test.
- */
-public class CacheExamplesMultiNodeSelfTest extends CacheExamplesSelfTest {
- /** {@inheritDoc} */
- @Override protected String defaultConfig() {
- return "examples/config/example-ignite.xml";
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- startRemoteNodes();
- }
-
- /** {@inheritDoc} */
- @Override protected long getTestTimeout() {
- return 10 * 60 * 1000;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/CacheExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/CacheExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/CacheExamplesSelfTest.java
deleted file mode 100644
index e44fec3..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/CacheExamplesSelfTest.java
+++ /dev/null
@@ -1,155 +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.java8.examples;
-
-import org.apache.ignite.examples.java8.datagrid.CacheAffinityExample;
-import org.apache.ignite.examples.java8.datagrid.CacheEntryProcessorExample;
-import org.apache.ignite.examples.java8.datagrid.CacheApiExample;
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-//import org.apache.ignite.examples.java8.datagrid.starschema.*;
-//import org.apache.ignite.examples.java8.datagrid.store.dummy.*;
-//import org.apache.ignite.examples.java8.datastructures.*;
-
-/**
- * Cache examples self test.
- */
-public class CacheExamplesSelfTest extends GridAbstractExamplesTest {
- /**
- * @throws Exception If failed.
- */
- public void testCacheAffinityExample() throws Exception {
- CacheAffinityExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheEntryProcessorExample() throws Exception {
- CacheEntryProcessorExample.main(EMPTY_ARGS);
- }
-
-// TODO: IGNITE-711 next example(s) should be implemented for java 8
-// or testing method(s) should be removed if example(s) does not applicable for java 8.
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCacheAtomicLongExample() throws Exception {
-// IgniteAtomicLongExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCacheAtomicReferenceExample() throws Exception {
-// IgniteAtomicReferenceExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCacheAtomicSequenceExample() throws Exception {
-// IgniteAtomicSequenceExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCacheAtomicStampedExample() throws Exception {
-// IgniteAtomicStampedExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCacheCountDownLatchExample() throws Exception {
-// IgniteCountDownLatchExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCacheQueueExample() throws Exception {
-// IgniteQueueExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCacheSetExample() throws Exception {
-// IgniteSetExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCacheDummyStoreExample() throws Exception {
-// CacheDummyStoreExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCacheQueryExample() throws Exception {
-// CacheQueryExample.main(EMPTY_ARGS);
-// }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheApiExample() throws Exception {
- CacheApiExample.main(EMPTY_ARGS);
- }
-
-// TODO: IGNITE-711 next example(s) should be implemented for java 8
-// or testing method(s) should be removed if example(s) does not applicable for java 8.
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCacheTransactionExample() throws Exception {
-// CacheTransactionExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCacheDataStreamerExample() throws Exception {
-// CacheDataStreamerExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCachePutGetExample() throws Exception {
-// CachePutGetExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testSnowflakeSchemaExample() throws Exception {
-// CacheStarSchemaExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCacheContinuousQueryExample() throws Exception {
-// CacheContinuousQueryExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/CheckpointExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/CheckpointExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/CheckpointExamplesSelfTest.java
deleted file mode 100644
index b39fe7f..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/CheckpointExamplesSelfTest.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.java8.examples;
-
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * Checkpoint examples self test.
- */
-public class CheckpointExamplesSelfTest extends GridAbstractExamplesTest {
- /**
- * TODO: IGNITE-711 next example(s) should be implemented for java 8
- * or testing method(s) should be removed if example(s) does not applicable for java 8.
- *
- * Starts remote nodes before each test.
- *
- * Note: using beforeTestsStarted() to start nodes only once won't work.
- *
- * @throws Exception If remote nodes start failed.
- */
-// @Override protected void beforeTest() throws Exception {
-// for (int i = 0; i < RMT_NODES_CNT; i++)
-// startGrid("node-" + i, ComputeFailoverNodeStartup.configuration());
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testCheckpointExample() throws Exception {
-// ComputeFailoverExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/ClusterGroupExampleSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/ClusterGroupExampleSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/ClusterGroupExampleSelfTest.java
deleted file mode 100644
index 34ef68d..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/ClusterGroupExampleSelfTest.java
+++ /dev/null
@@ -1,40 +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.java8.examples;
-
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- *
- */
-public class ClusterGroupExampleSelfTest extends GridAbstractExamplesTest {
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- // Start up a node.
- startGrid("ignite-cluster-groups-example", DFLT_CFG);
- }
-
-// TODO: IGNITE-711 next example(s) should be implemented for java 8
-// or testing method(s) should be removed if example(s) does not applicable for java 8.
-// /**
-// * @throws Exception If failed.
-// */
-// public void testComputeClusterGroupsExample() throws Exception {
-// ClusterGroupExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuationExamplesMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuationExamplesMultiNodeSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuationExamplesMultiNodeSelfTest.java
deleted file mode 100644
index 8e9aa48..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuationExamplesMultiNodeSelfTest.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.java8.examples;
-
-/**
- * Continuation example multi-node self test.
- */
-public class ContinuationExamplesMultiNodeSelfTest extends ContinuationExamplesSelfTest {
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- startRemoteNodes();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuationExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuationExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuationExamplesSelfTest.java
deleted file mode 100644
index bea6bb6..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuationExamplesSelfTest.java
+++ /dev/null
@@ -1,37 +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.java8.examples;
-
-//import org.apache.ignite.examples.java8.computegrid.*;
-
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * Continuation example self test.
- */
-public class ContinuationExamplesSelfTest extends GridAbstractExamplesTest {
- /**
- * TODO: IGNITE-711 next example(s) should be implemented for java 8
- * or testing method(s) should be removed if example(s) does not applicable for java 8.
- *
- * @throws Exception If failed.
- */
-// public void testContinuationExample() throws Exception {
-// ComputeFibonacciContinuationExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuousMapperExamplesMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuousMapperExamplesMultiNodeSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuousMapperExamplesMultiNodeSelfTest.java
deleted file mode 100644
index b570947..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuousMapperExamplesMultiNodeSelfTest.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.java8.examples;
-
-/**
- * ContinuousMapperExample multi-node self test.
- */
-public class ContinuousMapperExamplesMultiNodeSelfTest extends ContinuationExamplesSelfTest {
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- startRemoteNodes();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuousMapperExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuousMapperExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuousMapperExamplesSelfTest.java
deleted file mode 100644
index f23b6fa..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuousMapperExamplesSelfTest.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.java8.examples;
-
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * ContinuousMapperExample self test.
- */
-public class ContinuousMapperExamplesSelfTest extends GridAbstractExamplesTest {
- /**
- * TODO: IGNITE-711 next example(s) should be implemented for java 8
- * or testing method(s) should be removed if example(s) does not applicable for java 8.
- *
- * @throws Exception If failed.
- */
-// public void testContinuousMapperExample() throws Exception {
-// ComputeContinuousMapperExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/DeploymentExamplesMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/DeploymentExamplesMultiNodeSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/DeploymentExamplesMultiNodeSelfTest.java
deleted file mode 100644
index 3ad9837..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/DeploymentExamplesMultiNodeSelfTest.java
+++ /dev/null
@@ -1,32 +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.java8.examples;
-
-/**
- * Deployment examples multi-node self test.
- */
-public class DeploymentExamplesMultiNodeSelfTest extends DeploymentExamplesSelfTest {
- // TODO: IGNITE-711 next example(s) should be implemented for java 8
- // or testing method(s) should be removed if example(s) does not applicable for java 8.
- /** {@inheritDoc} */
-// @Override public void testDeploymentExample() throws Exception {
-// startRemoteNodes();
-//
-// super.testDeploymentExample();
-// }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/DeploymentExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/DeploymentExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/DeploymentExamplesSelfTest.java
deleted file mode 100644
index 70bddd5..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/DeploymentExamplesSelfTest.java
+++ /dev/null
@@ -1,36 +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.java8.examples;
-
-//import org.apache.ignite.examples.java8.misc.deployment.*;
-
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * Deployment examples self test.
- */
-public class DeploymentExamplesSelfTest extends GridAbstractExamplesTest {
- // TODO: IGNITE-711 next example(s) should be implemented for java 8
- // or testing method(s) should be removed if example(s) does not applicable for java 8.
- /**
- * @throws Exception If failed.
- */
-// public void testDeploymentExample() throws Exception {
-// DeploymentExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/EventsExamplesMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/EventsExamplesMultiNodeSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/EventsExamplesMultiNodeSelfTest.java
deleted file mode 100644
index 1b71382..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/EventsExamplesMultiNodeSelfTest.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.java8.examples;
-
-/**
- * Events examples multi-node self test.
- */
-public class EventsExamplesMultiNodeSelfTest extends EventsExamplesSelfTest {
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- startRemoteNodes();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/EventsExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/EventsExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/EventsExamplesSelfTest.java
deleted file mode 100644
index 09784fe..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/EventsExamplesSelfTest.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.java8.examples;
-
-import org.apache.ignite.examples.java8.events.EventsExample;
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * Events examples self test.
- */
-public class EventsExamplesSelfTest extends GridAbstractExamplesTest {
- /**
- * @throws Exception If failed.
- */
- public void testEventsExample() throws Exception {
- EventsExample.main(EMPTY_ARGS);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/IgfsExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/IgfsExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/IgfsExamplesSelfTest.java
deleted file mode 100644
index aed11b3..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/IgfsExamplesSelfTest.java
+++ /dev/null
@@ -1,55 +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.java8.examples;
-
-//import org.apache.ignite.examples.java8.igfs.*;
-//import org.apache.ignite.internal.util.typedef.internal.*;
-
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * IGFS examples self test.
- */
-public class IgfsExamplesSelfTest extends GridAbstractExamplesTest {
- /** IGFS config with shared memory IPC. */
- private static final String IGFS_SHMEM_CFG = "modules/core/src/test/config/igfs-shmem.xml";
-
- /** IGFS config with loopback IPC. */
- private static final String IGFS_LOOPBACK_CFG = "modules/core/src/test/config/igfs-loopback.xml";
-
- /**
- * TODO: IGNITE-711 next example(s) should be implemented for java 8
- * or testing method(s) should be removed if example(s) does not applicable for java 8.
- *
- * @throws Exception If failed.
- */
-// public void testIgniteFsApiExample() throws Exception {
-// String configPath = U.isWindows() ? IGFS_LOOPBACK_CFG : IGFS_SHMEM_CFG;
-//
-// try {
-// startGrid("test1", configPath);
-// startGrid("test2", configPath);
-// startGrid("test3", configPath);
-//
-// IgfsExample.main(EMPTY_ARGS);
-// }
-// finally {
-// stopAllGrids();
-// }
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/LifecycleExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/LifecycleExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/LifecycleExamplesSelfTest.java
deleted file mode 100644
index ac60659..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/LifecycleExamplesSelfTest.java
+++ /dev/null
@@ -1,37 +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.java8.examples;
-
-//import org.apache.ignite.examples.java8.misc.lifecycle.*;
-
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * LifecycleExample self test.
- */
-public class LifecycleExamplesSelfTest extends GridAbstractExamplesTest {
- /**
- * TODO: IGNITE-711 next example(s) should be implemented for java 8
- * or testing method(s) should be removed if example(s) does not applicable for java 8.
- *
- * @throws Exception If failed.
- */
-// public void testLifecycleExample() throws Exception {
-// LifecycleExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/MemcacheRestExamplesMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/MemcacheRestExamplesMultiNodeSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/MemcacheRestExamplesMultiNodeSelfTest.java
deleted file mode 100644
index 52b79d8..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/MemcacheRestExamplesMultiNodeSelfTest.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.java8.examples;
-
-//import org.apache.ignite.examples.java8.misc.client.memcache.*;
-
-/**
- * MemcacheRestExample multi-node self test.
- */
-public class MemcacheRestExamplesMultiNodeSelfTest extends MemcacheRestExamplesSelfTest {
- // TODO: IGNITE-711 next example(s) should be implemented for java 8
- // or testing method(s) should be removed if example(s) does not applicable for java 8.
- /** {@inheritDoc} */
-// @Override protected void beforeTest() throws Exception {
-// for (int i = 0; i < RMT_NODES_CNT; i++)
-// startGrid("memcache-rest-examples-" + i, MemcacheRestExampleNodeStartup.configuration());
-// }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/MemcacheRestExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/MemcacheRestExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/MemcacheRestExamplesSelfTest.java
deleted file mode 100644
index 80caf1f..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/MemcacheRestExamplesSelfTest.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.java8.examples;
-
-//import org.apache.ignite.examples.java8.misc.client.memcache.*;
-
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * MemcacheRestExample self test.
- */
-public class MemcacheRestExamplesSelfTest extends GridAbstractExamplesTest {
-// TODO: IGNITE-711 next example(s) should be implemented for java 8
-// or testing method(s) should be removed if example(s) does not applicable for java 8.
-// /**
-// * @throws Exception If failed.
-// */
-// @Override protected void beforeTest() throws Exception {
-// // Start up a cluster node.
-// startGrid("memcache-rest-examples", MemcacheRestExampleNodeStartup.configuration());
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testMemcacheRestExample() throws Exception {
-// MemcacheRestExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/MessagingExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/MessagingExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/MessagingExamplesSelfTest.java
deleted file mode 100644
index e15159d..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/MessagingExamplesSelfTest.java
+++ /dev/null
@@ -1,55 +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.java8.examples;
-
-import org.apache.ignite.examples.java8.messaging.MessagingExample;
-import org.apache.ignite.examples.java8.messaging.MessagingPingPongExample;
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * Messaging examples self test.
- */
-public class MessagingExamplesSelfTest extends GridAbstractExamplesTest {
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- startGrid("companion", DFLT_CFG);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMessagingExample() throws Exception {
- MessagingExample.main(EMPTY_ARGS);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMessagingPingPongExample() throws Exception {
- MessagingPingPongExample.main(EMPTY_ARGS);
- }
-
-// TODO: IGNITE-711 next example(s) should be implemented for java 8
-// or testing method(s) should be removed if example(s) does not applicable for java 8.
-// /**
-// * @throws Exception If failed.
-// */
-// public void testMessagingPingPongListenActorExample() throws Exception {
-// MessagingPingPongListenActorExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/MonteCarloExamplesMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/MonteCarloExamplesMultiNodeSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/MonteCarloExamplesMultiNodeSelfTest.java
deleted file mode 100644
index dee7560..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/MonteCarloExamplesMultiNodeSelfTest.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.java8.examples;
-
-/**
- * PrimeExample multi-node self test.
- */
-public class MonteCarloExamplesMultiNodeSelfTest extends MonteCarloExamplesSelfTest {
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- startRemoteNodes();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/MonteCarloExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/MonteCarloExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/MonteCarloExamplesSelfTest.java
deleted file mode 100644
index c6161de..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/MonteCarloExamplesSelfTest.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.java8.examples;
-
-//import org.apache.ignite.examples.java8.computegrid.montecarlo.*;
-
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * Ignite examples self test. Excludes Ignite Spring tests.
- *
- * <h1 class="header">AOP Configuration</h1>
- * In order for this test to execute, any of the following
- * AOP configurations must be provided.
- * <h2 class="header">Jboss AOP</h2>
- * The following configuration needs to be applied to enable JBoss byte code
- * weaving. Note that Ignite is not shipped with JBoss and necessary
- * libraries will have to be downloaded separately (they come standard
- * if you have JBoss installed already):
- * <ul>
- * <li>
- * The following JVM configuration must be present:
- * <ul>
- * <li>{@code -javaagent:[path to jboss-aop-jdk50-4.x.x.jar]}</li>
- * <li>{@code -Djboss.aop.class.path=[path to ignite.jar]}</li>
- * <li>{@code -Djboss.aop.exclude=org,com -Djboss.aop.include=org.apache.ignite.examples}</li>
- * </ul>
- * </li>
- * <li>
- * The following JARs should be in a classpath:
- * <ul>
- * <li>{@code javassist-3.x.x.jar}</li>
- * <li>{@code jboss-aop-jdk50-4.x.x.jar}</li>
- * <li>{@code jboss-aspect-library-jdk50-4.x.x.jar}</li>
- * <li>{@code jboss-common-4.x.x.jar}</li>
- * <li>{@code trove-1.0.2.jar}</li>
- * </ul>
- * </li>
- * </ul>
- * <p>
- * <h2 class="header">AspectJ AOP</h2>
- * The following configuration needs to be applied to enable AspectJ byte code
- * weaving.
- * <ul>
- * <li>
- * JVM configuration should include:
- * {@code -javaagent:${IGNITE_HOME}/libs/aspectjweaver-1.7.2.jar}
- * </li>
- * <li>
- * Classpath should contain the {@code ${IGNITE_HOME}/modules/tests/config/aop/aspectj} folder.
- * </li>
- */
-public class MonteCarloExamplesSelfTest extends GridAbstractExamplesTest {
- /**
- * TODO: IGNITE-711 next example(s) should be implemented for java 8
- * or testing method(s) should be removed if example(s) does not applicable for java 8.
- *
- * @throws Exception If failed.
- */
-// public void testCreditRiskExample() throws Exception {
-// CreditRiskExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/SpringBeanExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/SpringBeanExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/SpringBeanExamplesSelfTest.java
deleted file mode 100644
index 1ea2e22..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/SpringBeanExamplesSelfTest.java
+++ /dev/null
@@ -1,37 +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.java8.examples;
-
-//import org.apache.ignite.examples.java8.misc.springbean.*;
-
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * Spring bean examples self test.
- */
-public class SpringBeanExamplesSelfTest extends GridAbstractExamplesTest {
- /**
- * TODO: IGNITE-711 next example(s) should be implemented for java 8
- * or testing method(s) should be removed if example(s) does not applicable for java 8.
- *
- * @throws Exception If failed.
- */
-// public void testSpringBeanHelloWorldExample() throws Exception {
-// SpringBeanExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/TaskExamplesMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/TaskExamplesMultiNodeSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/TaskExamplesMultiNodeSelfTest.java
deleted file mode 100644
index 2db3906..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/TaskExamplesMultiNodeSelfTest.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.java8.examples;
-
-/**
- * Hello world examples multi-node self test.
- */
-public class TaskExamplesMultiNodeSelfTest extends TaskExamplesSelfTest {
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- startRemoteNodes();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/examples/TaskExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/TaskExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/TaskExamplesSelfTest.java
deleted file mode 100644
index 37520c1..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/TaskExamplesSelfTest.java
+++ /dev/null
@@ -1,43 +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.java8.examples;
-
-//import org.apache.ignite.examples.java8.computegrid.*;
-
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * Hello world examples self test.
- */
-public class TaskExamplesSelfTest extends GridAbstractExamplesTest {
-// TODO: IGNITE-711 next example(s) should be implemented for java 8
-// or testing method(s) should be removed if example(s) does not applicable for java 8.
-// /**
-// * @throws Exception If failed.
-// */
-// public void testTaskSplitExample() throws Exception {
-// ComputeTaskSplitExample.main(EMPTY_ARGS);
-// }
-//
-// /**
-// * @throws Exception If failed.
-// */
-// public void testTaskMapExample() throws Exception {
-// ComputeTaskMapExample.main(EMPTY_ARGS);
-// }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java b/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
deleted file mode 100644
index 9a5f36a..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
+++ /dev/null
@@ -1,80 +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.java8.testsuites;
-
-import junit.framework.TestSuite;
-import org.apache.ignite.java8.examples.BasicExamplesMultiNodeSelfTest;
-import org.apache.ignite.java8.examples.BasicExamplesSelfTest;
-import org.apache.ignite.java8.examples.CacheExamplesMultiNodeSelfTest;
-import org.apache.ignite.java8.examples.CacheExamplesSelfTest;
-import org.apache.ignite.java8.examples.EventsExamplesMultiNodeSelfTest;
-import org.apache.ignite.java8.examples.EventsExamplesSelfTest;
-import org.apache.ignite.java8.examples.MessagingExamplesSelfTest;
-import org.apache.ignite.testframework.GridTestUtils;
-
-import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP;
-
-/**
- * Examples test suite.
- * <p>
- * Contains only Spring ignite examples tests.
- */
-public class IgniteExamplesJ8SelfTestSuite extends TestSuite {
- /**
- * @return Suite.
- * @throws Exception If failed.
- */
- public static TestSuite suite() throws Exception {
- System.setProperty(IGNITE_OVERRIDE_MCAST_GRP,
- GridTestUtils.getNextMulticastGroup(IgniteExamplesJ8SelfTestSuite.class));
-
- TestSuite suite = new TestSuite("Ignite Examples Test Suite");
-
- suite.addTest(new TestSuite(CacheExamplesSelfTest.class));
- suite.addTest(new TestSuite(BasicExamplesSelfTest.class));
-
-// suite.addTest(new TestSuite(ContinuationExamplesSelfTest.class));
-// suite.addTest(new TestSuite(ContinuousMapperExamplesSelfTest.class));
-// suite.addTest(new TestSuite(DeploymentExamplesSelfTest.class));
- suite.addTest(new TestSuite(EventsExamplesSelfTest.class));
-// suite.addTest(new TestSuite(LifecycleExamplesSelfTest.class));
- suite.addTest(new TestSuite(MessagingExamplesSelfTest.class));
-// suite.addTest(new TestSuite(MemcacheRestExamplesSelfTest.class));
-// suite.addTest(new TestSuite(MonteCarloExamplesSelfTest.class));
-// suite.addTest(new TestSuite(TaskExamplesSelfTest.class));
-// suite.addTest(new TestSuite(SpringBeanExamplesSelfTest.class));
-// suite.addTest(new TestSuite(IgfsExamplesSelfTest.class));
-// suite.addTest(new TestSuite(CheckpointExamplesSelfTest.class));
-// suite.addTest(new TestSuite(HibernateL2CacheExampleSelfTest.class));
-// suite.addTest(new TestSuite(ClusterGroupExampleSelfTest.class));
-
- // Multi-node.
- suite.addTest(new TestSuite(CacheExamplesMultiNodeSelfTest.class));
- suite.addTest(new TestSuite(BasicExamplesMultiNodeSelfTest.class));
-// suite.addTest(new TestSuite(ContinuationExamplesMultiNodeSelfTest.class));
-// suite.addTest(new TestSuite(ContinuousMapperExamplesMultiNodeSelfTest.class));
-// suite.addTest(new TestSuite(DeploymentExamplesMultiNodeSelfTest.class));
- suite.addTest(new TestSuite(EventsExamplesMultiNodeSelfTest.class));
-// suite.addTest(new TestSuite(TaskExamplesMultiNodeSelfTest.class));
-// suite.addTest(new TestSuite(MemcacheRestExamplesMultiNodeSelfTest.class));
-// suite.addTest(new TestSuite(MonteCarloExamplesMultiNodeSelfTest.class));
-// suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class));
-
- return suite;
- }
-}
[11/11] ignite git commit: IGNITE-7203 Java 8 by default
Posted by av...@apache.org.
IGNITE-7203 Java 8 by default
Signed-off-by: Anton Vinogradov <av...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/43a62cdb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/43a62cdb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/43a62cdb
Branch: refs/heads/master
Commit: 43a62cdbabdaf4d39a3ebdb0c15d015bfa4cf309
Parents: e02a8d2
Author: Ivanov Petr <pi...@gridgain.com>
Authored: Wed Jan 17 13:15:27 2018 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Jan 17 13:15:30 2018 +0300
----------------------------------------------------------------------
examples/README-LGPL.txt | 7 -
examples/README.txt | 17 -
examples/pom-standalone-lgpl.xml | 66 +--
examples/pom-standalone.xml | 66 +--
examples/pom.xml | 89 +---
.../examples/cluster/ClusterGroupExample.java | 86 ++++
.../ignite/examples/cluster/package-info.java | 22 +
.../computegrid/ComputeAsyncExample.java | 17 +-
.../computegrid/ComputeBroadcastExample.java | 44 +-
.../computegrid/ComputeCallableExample.java | 18 +-
.../computegrid/ComputeClosureExample.java | 22 +-
.../computegrid/ComputeRunnableExample.java | 10 +-
.../examples/datagrid/CacheAffinityExample.java | 38 +-
.../examples/datagrid/CacheApiExample.java | 26 +-
.../examples/datagrid/CacheAsyncApiExample.java | 37 +-
.../datagrid/CacheEntryProcessorExample.java | 46 +-
.../ignite/examples/datagrid/package-info.java | 2 +-
.../IgniteExecutorServiceExample.java | 8 +-
.../ignite/examples/events/EventsExample.java | 32 +-
.../examples/messaging/MessagingExample.java | 95 ++---
.../messaging/MessagingPingPongExample.java | 46 +-
.../clustering/DatasetWithObviousStructure.java | 105 +++++
.../ml/clustering/FuzzyCMeansExample.java | 134 ++++++
.../ml/clustering/FuzzyCMeansLocalExample.java | 95 +++++
.../KMeansDistributedClustererExample.java | 97 +++++
.../clustering/KMeansLocalClustererExample.java | 106 +++++
.../examples/ml/clustering/package-info.java | 22 +
.../KNNClassificationExample.java | 155 +++++++
.../ml/knn/classification/package-info.java | 22 +
.../ignite/examples/ml/knn/datasets/README.md | 2 +
.../ml/knn/datasets/cleared_machines.txt | 209 +++++++++
.../ignite/examples/ml/knn/datasets/iris.txt | 150 +++++++
.../ignite/examples/ml/knn/package-info.java | 22 +
.../ml/knn/regression/KNNRegressionExample.java | 157 +++++++
.../ml/knn/regression/package-info.java | 22 +
.../CholeskyDecompositionExample.java | 80 ++++
.../EigenDecompositionExample.java | 69 +++
.../decompositions/LUDecompositionExample.java | 83 ++++
.../decompositions/QRDecompositionExample.java | 82 ++++
.../SingularValueDecompositionExample.java | 70 +++
.../ml/math/decompositions/package-info.java | 22 +
.../ml/math/matrix/CacheMatrixExample.java | 102 +++++
.../ml/math/matrix/ExampleMatrixStorage.java | 175 ++++++++
.../math/matrix/MatrixCustomStorageExample.java | 141 ++++++
.../examples/ml/math/matrix/MatrixExample.java | 79 ++++
.../ml/math/matrix/MatrixExampleUtil.java | 52 +++
.../ml/math/matrix/OffHeapMatrixExample.java | 84 ++++
.../matrix/SparseDistributedMatrixExample.java | 70 +++
.../ml/math/matrix/SparseMatrixExample.java | 84 ++++
.../examples/ml/math/matrix/package-info.java | 22 +
.../ignite/examples/ml/math/package-info.java | 22 +
.../examples/ml/math/tracer/TracerExample.java | 63 +++
.../examples/ml/math/tracer/package-info.java | 22 +
.../ml/math/vector/CacheVectorExample.java | 109 +++++
.../ml/math/vector/ExampleVectorStorage.java | 127 ++++++
.../ml/math/vector/OffHeapVectorExample.java | 78 ++++
.../ml/math/vector/SparseVectorExample.java | 76 ++++
.../math/vector/VectorCustomStorageExample.java | 120 ++++++
.../examples/ml/math/vector/VectorExample.java | 73 ++++
.../examples/ml/math/vector/package-info.java | 22 +
.../examples/ml/nn/MLPGroupTrainerExample.java | 141 ++++++
.../examples/ml/nn/MLPLocalTrainerExample.java | 161 +++++++
.../ignite/examples/ml/nn/package-info.java | 22 +
.../apache/ignite/examples/ml/package-info.java | 22 +
...tedLinearRegressionExampleWithQRTrainer.java | 136 ++++++
...edLinearRegressionExampleWithSGDTrainer.java | 137 ++++++
.../ml/regression/linear/package-info.java | 22 +
.../examples/ml/regression/package-info.java | 22 +
.../ignite/examples/ml/trees/MNISTExample.java | 261 ++++++++++++
.../ignite/examples/ml/trees/package-info.java | 22 +
.../streaming/StreamTransformerExample.java | 28 +-
.../streaming/StreamVisitorExample.java | 84 ++--
.../ignite/examples/streaming/package-info.java | 1 +
.../java8/cluster/ClusterGroupExample.java | 86 ----
.../examples/java8/cluster/package-info.java | 22 -
.../java8/computegrid/ComputeAsyncExample.java | 75 ----
.../computegrid/ComputeBroadcastExample.java | 102 -----
.../computegrid/ComputeCallableExample.java | 75 ----
.../computegrid/ComputeClosureExample.java | 71 ----
.../computegrid/ComputeRunnableExample.java | 64 ---
.../java8/computegrid/package-info.java | 22 -
.../java8/datagrid/CacheAffinityExample.java | 142 -------
.../java8/datagrid/CacheApiExample.java | 110 -----
.../java8/datagrid/CacheAsyncApiExample.java | 90 ----
.../datagrid/CacheEntryProcessorExample.java | 152 -------
.../examples/java8/datagrid/package-info.java | 22 -
.../IgniteExecutorServiceExample.java | 70 ---
.../java8/datastructures/package-info.java | 22 -
.../examples/java8/events/EventsExample.java | 135 ------
.../examples/java8/events/package-info.java | 22 -
.../java8/messaging/MessagingExample.java | 161 -------
.../messaging/MessagingPingPongExample.java | 113 -----
.../examples/java8/messaging/package-info.java | 22 -
.../ignite/examples/java8/package-info.java | 23 -
.../streaming/StreamTransformerExample.java | 108 -----
.../java8/streaming/StreamVisitorExample.java | 177 --------
.../examples/java8/streaming/package-info.java | 22 -
.../clustering/DatasetWithObviousStructure.java | 105 -----
.../ml/clustering/FuzzyCMeansExample.java | 134 ------
.../ml/clustering/FuzzyCMeansLocalExample.java | 95 -----
.../KMeansDistributedClustererExample.java | 97 -----
.../clustering/KMeansLocalClustererExample.java | 106 -----
.../examples/ml/clustering/package-info.java | 22 -
.../KNNClassificationExample.java | 155 -------
.../ml/knn/classification/package-info.java | 22 -
.../ignite/examples/ml/knn/datasets/README.md | 2 -
.../ml/knn/datasets/cleared_machines.txt | 209 ---------
.../ignite/examples/ml/knn/datasets/iris.txt | 150 -------
.../ignite/examples/ml/knn/package-info.java | 22 -
.../ml/knn/regression/KNNRegressionExample.java | 157 -------
.../ml/knn/regression/package-info.java | 22 -
.../CholeskyDecompositionExample.java | 80 ----
.../EigenDecompositionExample.java | 69 ---
.../decompositions/LUDecompositionExample.java | 83 ----
.../decompositions/QRDecompositionExample.java | 82 ----
.../SingularValueDecompositionExample.java | 70 ---
.../ml/math/decompositions/package-info.java | 22 -
.../ml/math/matrix/CacheMatrixExample.java | 102 -----
.../ml/math/matrix/ExampleMatrixStorage.java | 175 --------
.../math/matrix/MatrixCustomStorageExample.java | 141 ------
.../examples/ml/math/matrix/MatrixExample.java | 79 ----
.../ml/math/matrix/MatrixExampleUtil.java | 52 ---
.../ml/math/matrix/OffHeapMatrixExample.java | 84 ----
.../matrix/SparseDistributedMatrixExample.java | 70 ---
.../ml/math/matrix/SparseMatrixExample.java | 84 ----
.../examples/ml/math/matrix/package-info.java | 22 -
.../ignite/examples/ml/math/package-info.java | 22 -
.../examples/ml/math/tracer/TracerExample.java | 63 ---
.../examples/ml/math/tracer/package-info.java | 22 -
.../ml/math/vector/CacheVectorExample.java | 109 -----
.../ml/math/vector/ExampleVectorStorage.java | 127 ------
.../ml/math/vector/OffHeapVectorExample.java | 78 ----
.../ml/math/vector/SparseVectorExample.java | 76 ----
.../math/vector/VectorCustomStorageExample.java | 120 ------
.../examples/ml/math/vector/VectorExample.java | 73 ----
.../examples/ml/math/vector/package-info.java | 22 -
.../examples/ml/nn/MLPGroupTrainerExample.java | 141 ------
.../examples/ml/nn/MLPLocalTrainerExample.java | 161 -------
.../ignite/examples/ml/nn/package-info.java | 22 -
.../apache/ignite/examples/ml/package-info.java | 22 -
...tedLinearRegressionExampleWithQRTrainer.java | 136 ------
...edLinearRegressionExampleWithSGDTrainer.java | 137 ------
.../ml/regression/linear/package-info.java | 22 -
.../examples/ml/regression/package-info.java | 22 -
.../ignite/examples/ml/trees/MNISTExample.java | 261 ------------
.../ignite/examples/ml/trees/package-info.java | 22 -
.../ignite/examples/BasicExamplesSelfTest.java | 46 +-
.../CacheExamplesMultiNodeSelfTest.java | 16 -
.../ignite/examples/CacheExamplesSelfTest.java | 254 +++++------
.../examples/CheckpointExamplesSelfTest.java | 29 +-
.../examples/ClusterGroupExampleSelfTest.java | 17 +-
.../examples/ContinuationExamplesSelfTest.java | 14 +-
.../ContinuousMapperExamplesSelfTest.java | 12 +-
.../DeploymentExamplesMultiNodeSelfTest.java | 12 +-
.../examples/DeploymentExamplesSelfTest.java | 13 +-
.../ignite/examples/EventsExamplesSelfTest.java | 2 +-
.../ignite/examples/IgfsExamplesSelfTest.java | 38 +-
.../examples/LifecycleExamplesSelfTest.java | 14 +-
.../MemcacheRestExamplesMultiNodeSelfTest.java | 12 +-
.../examples/MemcacheRestExamplesSelfTest.java | 36 +-
.../examples/MessagingExamplesSelfTest.java | 15 +-
.../examples/MonteCarloExamplesSelfTest.java | 14 +-
.../examples/SpringBeanExamplesSelfTest.java | 14 +-
.../ignite/examples/TaskExamplesSelfTest.java | 34 +-
.../IgniteExamplesJ8SelfTestSuite.java | 80 ++++
.../testsuites/IgniteExamplesMLTestSuite.java | 140 ++++++
.../BasicExamplesMultiNodeSelfTest.java | 28 --
.../java8/examples/BasicExamplesSelfTest.java | 89 ----
.../CacheExamplesMultiNodeSelfTest.java | 38 --
.../java8/examples/CacheExamplesSelfTest.java | 155 -------
.../examples/CheckpointExamplesSelfTest.java | 47 --
.../examples/ClusterGroupExampleSelfTest.java | 40 --
.../ContinuationExamplesMultiNodeSelfTest.java | 28 --
.../examples/ContinuationExamplesSelfTest.java | 37 --
...ntinuousMapperExamplesMultiNodeSelfTest.java | 28 --
.../ContinuousMapperExamplesSelfTest.java | 35 --
.../DeploymentExamplesMultiNodeSelfTest.java | 32 --
.../examples/DeploymentExamplesSelfTest.java | 36 --
.../EventsExamplesMultiNodeSelfTest.java | 28 --
.../java8/examples/EventsExamplesSelfTest.java | 33 --
.../java8/examples/IgfsExamplesSelfTest.java | 55 ---
.../examples/LifecycleExamplesSelfTest.java | 37 --
.../MemcacheRestExamplesMultiNodeSelfTest.java | 33 --
.../examples/MemcacheRestExamplesSelfTest.java | 44 --
.../examples/MessagingExamplesSelfTest.java | 55 ---
.../MonteCarloExamplesMultiNodeSelfTest.java | 28 --
.../examples/MonteCarloExamplesSelfTest.java | 78 ----
.../examples/SpringBeanExamplesSelfTest.java | 37 --
.../examples/TaskExamplesMultiNodeSelfTest.java | 28 --
.../java8/examples/TaskExamplesSelfTest.java | 43 --
.../IgniteExamplesJ8SelfTestSuite.java | 80 ----
.../testsuites/IgniteExamplesMLTestSuite.java | 140 ------
modules/aop/pom.xml | 11 +
.../apache/ignite/gridify/BasicAopSelfTest.java | 26 +-
.../testsuites/IgniteAopSelfTestSuite.java | 12 +-
modules/benchmarks/pom.xml | 13 -
modules/cassandra/serializers/pom.xml | 3 -
modules/cassandra/store/pom.xml | 3 -
modules/codegen/pom.xml | 9 +-
modules/core/pom.xml | 4 +-
modules/indexing/pom.xml | 48 ---
modules/mesos/pom.xml | 11 -
modules/ml/pom.xml | 18 -
.../DataStorageConfigurationParityTest.cs | 2 +-
.../ApiParity/DataStorageMetricsParityTest.cs | 2 +-
.../QueryEntityConfigurationParityTest.cs | 2 +-
.../Cache/CacheConfigurationTest.cs | 2 +-
.../Cache/PersistenceTest.cs | 2 +-
.../Cache/PersistentStoreTestObsolete.cs | 2 +-
.../Cache/Query/CacheDmlQueriesTest.cs | 2 +-
.../Cache/ClientCacheConfigurationTest.cs | 2 +-
.../Client/Cache/CreateCacheTest.cs | 2 +-
.../Client/ClientConnectionTest.cs | 2 +-
.../Client/ClientTestBase.cs | 2 +-
.../Config/Apache.Ignite.exe.config.test | 4 +-
.../Config/Apache.Ignite.exe.config.test2 | 2 +-
.../Config/full-config.xml | 2 +-
.../Apache.Ignite.Core.Tests/ExecutableTest.cs | 20 +-
.../IgniteConfigurationSerializerTest.cs | 2 +-
.../IgniteConfigurationTest.cs | 2 +-
.../WindowsServiceTest.cs | 58 ++-
.../Cache/Configuration/QueryEntity.cs | 2 +-
.../Cache/Configuration/QueryField.cs | 2 +-
.../Configuration/QuerySqlFieldAttribute.cs | 2 +-
.../Client/Cache/CacheClientConfiguration.cs | 2 +-
.../ClientConnectorConfiguration.cs | 2 +-
.../IgniteConfigurationSection.xsd | 2 +-
.../Cache/ClientCacheConfigurationSerializer.cs | 2 +-
.../Impl/Unmanaged/Jni/Env.cs | 7 +-
.../dotnet/Apache.Ignite/IgniteRunner.cs | 2 +-
.../Apache.Ignite/Service/IgniteService.cs | 13 +-
modules/sqlline/pom.xml | 4 -
modules/tools/pom.xml | 6 -
modules/yardstick/pom-standalone.xml | 56 ---
modules/yardstick/pom.xml | 78 +---
.../apache/ignite/yardstick/ml/DataChanger.java | 65 +++
...niteKMeansDistributedClustererBenchmark.java | 75 ++++
.../IgniteKMeansLocalClustererBenchmark.java | 50 +++
.../yardstick/ml/clustering/package-info.java | 22 +
.../IgniteCholeskyDecompositionBenchmark.java | 69 +++
.../IgniteEigenDecompositionBenchmark.java | 69 +++
.../IgniteLUDecompositionBenchmark.java | 75 ++++
...niteSingularValueDecompositionBenchmark.java | 59 +++
.../ml/decomposition/package-info.java | 22 +
.../math/IgniteAbstractMatrixMulBenchmark.java | 120 ++++++
...niteDenseLocalOffHeapMatrixMulBenchmark.java | 32 ++
...gniteDenseLocalOnHeapMatrixMulBenchmark.java | 32 ++
...parseBlockDistributedMatrixMulBenchmark.java | 32 ++
...niteSparseDistributedMatrixMulBenchmark.java | 49 +++
.../IgniteSparseLocalMatrixMulBenchmark.java | 32 ++
.../ignite/yardstick/ml/math/package-info.java | 22 +
.../ignite/yardstick/ml/package-info.java | 22 +
...iteOLSMultipleLinearRegressionBenchmark.java | 69 +++
.../yardstick/ml/regression/package-info.java | 22 +
.../IgniteColumnDecisionTreeGiniBenchmark.java | 70 +++
...niteColumnDecisionTreeVarianceBenchmark.java | 71 ++++
.../yardstick/ml/trees/SplitDataGenerator.java | 426 +++++++++++++++++++
.../ignite/yardstick/ml/trees/package-info.java | 22 +
.../apache/ignite/yardstick/ml/DataChanger.java | 65 ---
...niteKMeansDistributedClustererBenchmark.java | 75 ----
.../IgniteKMeansLocalClustererBenchmark.java | 50 ---
.../yardstick/ml/clustering/package-info.java | 22 -
.../IgniteCholeskyDecompositionBenchmark.java | 69 ---
.../IgniteEigenDecompositionBenchmark.java | 69 ---
.../IgniteLUDecompositionBenchmark.java | 75 ----
...niteSingularValueDecompositionBenchmark.java | 59 ---
.../ml/decomposition/package-info.java | 22 -
.../math/IgniteAbstractMatrixMulBenchmark.java | 120 ------
...niteDenseLocalOffHeapMatrixMulBenchmark.java | 32 --
...gniteDenseLocalOnHeapMatrixMulBenchmark.java | 32 --
...parseBlockDistributedMatrixMulBenchmark.java | 32 --
...niteSparseDistributedMatrixMulBenchmark.java | 49 ---
.../IgniteSparseLocalMatrixMulBenchmark.java | 32 --
.../ignite/yardstick/ml/math/package-info.java | 22 -
.../ignite/yardstick/ml/package-info.java | 22 -
...iteOLSMultipleLinearRegressionBenchmark.java | 69 ---
.../yardstick/ml/regression/package-info.java | 22 -
.../IgniteColumnDecisionTreeGiniBenchmark.java | 70 ---
...niteColumnDecisionTreeVarianceBenchmark.java | 71 ----
.../yardstick/ml/trees/SplitDataGenerator.java | 426 -------------------
.../ignite/yardstick/ml/trees/package-info.java | 22 -
modules/yarn/pom.xml | 11 -
parent/pom.xml | 65 +--
pom.xml | 9 +-
284 files changed, 6758 insertions(+), 10112 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/README-LGPL.txt
----------------------------------------------------------------------
diff --git a/examples/README-LGPL.txt b/examples/README-LGPL.txt
index f8ca0d8..2db50c1 100644
--- a/examples/README-LGPL.txt
+++ b/examples/README-LGPL.txt
@@ -12,8 +12,6 @@ The examples folder contains he following subfolders:
- `memcached` - contains PHP script demonstrating how Ignite Cache can be accessed using Memcached client.
- `rest` - contains PHP script demonstrating how Ignite Cache can be accessed via HTTP API.
- `src/main/java` - contains Java examples for different Ignite modules and features.
-- `src/main/java8` - contains additional set of Java examples utilizing Java 8 lambdas. These examples
- are excluded by default, enable `java8` Maven profile to include them (JDK8 is required).
- `src/main/scala` - contains examples demonstrating usage of API provided by Scalar.
- `src/main/java-lgpl` - contains lgpl-based examples for different Ignite modules and features.
@@ -24,8 +22,3 @@ Starting Remote Nodes
Remote nodes for examples should always be started with special configuration file which enables P2P
class loading: `examples/config/example-ignite.xml`. To run a remote node in IDE use `ExampleNodeStartup` class.
-
-Java7 vs Java8
-===============
-Some examples (not all) which can benefit from Java8 Lambda support were re-written with Java8 lambdas.
-For full set of examples, look at both Java7 and Java8 packages.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/README.txt
----------------------------------------------------------------------
diff --git a/examples/README.txt b/examples/README.txt
index 6f69481..7aec87f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -12,11 +12,8 @@ The examples folder contains he following subfolders:
- `memcached` - contains PHP script demonstrating how Ignite Cache can be accessed using Memcached client.
- `rest` - contains PHP script demonstrating how Ignite Cache can be accessed via HTTP API.
- `src/main/java` - contains Java examples for different Ignite modules and features.
-- `src/main/java8` - contains additional set of Java examples utilizing Java 8 lambdas. These examples
- are excluded by default, enable `java8` Maven profile to include them (JDK8 is required).
- `src/main/scala` - contains examples demonstrating usage of API provided by Scalar.
- `src/main/java-lgpl` - contains lgpl-based examples for different Ignite modules and features.
-- `src/main/ml` - contains Java examples for Ignite-ML module.
Starting Remote Nodes
=====================
@@ -25,12 +22,6 @@ Remote nodes for examples should always be started with special configuration fi
class loading: `examples/config/example-ignite.xml`. To run a remote node in IDE use `ExampleNodeStartup` class.
-Java7 vs Java8
-===============
-Some examples (not all) which can benefit from Java8 Lambda support were re-written with Java8 lambdas.
-For full set of examples, look at both Java7 and Java8 packages.
-
-
LGPL
=====
LGPL examples can be activated by turning lgpl profile on.
@@ -47,11 +38,3 @@ This case will install lgpl-based libs to local maven repository.
2) Run "mvn clean package -DskipTests -Prelease,lgpl -Dignite.edition=fabric-lgpl" at Apache Ignite sources.
Required libs will appear at /target/release-package/libs/optional subfolders.
Found libs should be copied to global or project's classpath.
-
-ML
-==
-Math/Machine Learning examples can be activated by turning ml profile on.
-
-This module also required java8 and ignite-ml module.
-
-Like the lgpl examples we could build required module running "mvn clean install -Pml -DskipTests -pl modules/ml -am".
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/pom-standalone-lgpl.xml
----------------------------------------------------------------------
diff --git a/examples/pom-standalone-lgpl.xml b/examples/pom-standalone-lgpl.xml
index 2f6ff9c..09698de 100644
--- a/examples/pom-standalone-lgpl.xml
+++ b/examples/pom-standalone-lgpl.xml
@@ -27,14 +27,14 @@
<modelVersion>4.0.0</modelVersion>
<properties>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- will be changed by profile activation. allows to combine profiles. -->
- <lgpl.folder>src/main/java</lgpl.folder>
- <java8.folder>src/main/java</java8.folder>
<spark.folder>src/main/java</spark.folder>
- <ml.folder>src/main/java</ml.folder>
- <java.ver>1.7</java.ver>
+ <lgpl.folder>src/main/java</lgpl.folder>
</properties>
<groupId>org.apache.ignite</groupId>
@@ -79,6 +79,18 @@
</dependency>
<dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-ml</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
<groupId>com.google.code.simple-spring-memcached</groupId>
<artifactId>spymemcached</artifactId>
<version>2.8.4</version>
@@ -87,19 +99,6 @@
<profiles>
<profile>
- <id>java8</id>
-
- <properties>
- <java8.folder>src/main/java8</java8.folder>
- <java.ver>1.8</java.ver>
- </properties>
-
- <activation>
- <jdk>[1.8,)</jdk>
- </activation>
- </profile>
-
- <profile>
<id>scala</id>
<properties>
@@ -155,28 +154,6 @@
</profile>
<profile>
- <id>ml</id>
-
- <properties>
- <ml.folder>src/main/ml</ml.folder>
- <java.ver>1.8</java.ver>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-ml</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- <version>1.2</version>
- </dependency>
- </dependencies>
- </profile>
-
- <profile>
<id>lgpl</id>
<activation>
@@ -224,15 +201,6 @@
<plugins>
<plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <source>${java.ver}</source>
- <target>${java.ver}</target>
- </configuration>
- </plugin>
-
- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
@@ -245,9 +213,7 @@
<configuration>
<sources>
<source>${lgpl.folder}</source>
- <source>${java8.folder}</source>
<source>${spark.folder}</source>
- <source>${ml.folder}</source>
</sources>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/pom-standalone.xml
----------------------------------------------------------------------
diff --git a/examples/pom-standalone.xml b/examples/pom-standalone.xml
index bf2117a..385c2cf 100644
--- a/examples/pom-standalone.xml
+++ b/examples/pom-standalone.xml
@@ -27,14 +27,14 @@
<modelVersion>4.0.0</modelVersion>
<properties>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- will be changed by profile activation. allows to combine profiles. -->
- <lgpl.folder>src/main/java</lgpl.folder>
- <java8.folder>src/main/java</java8.folder>
<spark.folder>src/main/java</spark.folder>
- <ml.folder>src/main/java</ml.folder>
- <java.ver>1.7</java.ver>
+ <lgpl.folder>src/main/java</lgpl.folder>
</properties>
<groupId>org.apache.ignite</groupId>
@@ -79,6 +79,18 @@
</dependency>
<dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-ml</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
<groupId>com.google.code.simple-spring-memcached</groupId>
<artifactId>spymemcached</artifactId>
<version>2.8.4</version>
@@ -87,19 +99,6 @@
<profiles>
<profile>
- <id>java8</id>
-
- <properties>
- <java8.folder>src/main/java8</java8.folder>
- <java.ver>1.8</java.ver>
- </properties>
-
- <activation>
- <jdk>[1.8,)</jdk>
- </activation>
- </profile>
-
- <profile>
<id>scala</id>
<properties>
@@ -155,28 +154,6 @@
</profile>
<profile>
- <id>ml</id>
-
- <properties>
- <ml.folder>src/main/ml</ml.folder>
- <java.ver>1.8</java.ver>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-ml</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- <version>1.2</version>
- </dependency>
- </dependencies>
- </profile>
-
- <profile>
<!-- See README.txt for details -->
<id>lgpl</id>
@@ -225,15 +202,6 @@
<plugins>
<plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <source>${java.ver}</source>
- <target>${java.ver}</target>
- </configuration>
- </plugin>
-
- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
@@ -246,9 +214,7 @@
<configuration>
<sources>
<source>${lgpl.folder}</source>
- <source>${java8.folder}</source>
<source>${spark.folder}</source>
- <source>${ml.folder}</source>
</sources>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 7ae0187..f977ebd 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -17,7 +17,8 @@
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>
@@ -68,6 +69,18 @@
</dependency>
<dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-ml</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
<groupId>com.google.code.simple-spring-memcached</groupId>
<artifactId>spymemcached</artifactId>
<version>2.8.4</version>
@@ -87,18 +100,21 @@
<version>1.0.0</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>${javassist.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<properties>
<!-- will be changed by profile activation. allows to combine profiles. -->
<lgpl.folder>src/main/java</lgpl.folder>
- <java8.folder>src/main/java</java8.folder>
+ <lgpl.test.folder>src/test/java</lgpl.test.folder>
<spark.folder>src/main/java</spark.folder>
<spark.test.folder>src/test/java</spark.test.folder>
- <lgpl.test.folder>src/test/java</lgpl.test.folder>
- <java8.test.folder>src/test/java</java8.test.folder>
- <ml.folder>src/main/java</ml.folder>
- <ml.test.folder>src/test/java</ml.test.folder>
</properties>
<profiles>
@@ -193,62 +209,6 @@
</profile>
<profile>
- <id>java8</id>
-
- <properties>
- <java8.folder>src/main/java8</java8.folder>
- <java8.test.folder>src/test/java8</java8.test.folder>
- </properties>
-
- <activation>
- <jdk>[1.8,)</jdk>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>ml</id>
-
- <properties>
- <ml.folder>src/main/ml</ml.folder>
- <ml.test.folder>src/test/ml</ml.test.folder>
- <java.ver>1.8</java.ver>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-ml</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- <version>1.2</version>
- </dependency>
-
- <dependency>
- <groupId>org.javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>${javassist.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </profile>
-
- <profile>
<id>lgpl</id>
<properties>
@@ -305,9 +265,7 @@
<configuration>
<sources>
<source>${lgpl.folder}</source>
- <source>${java8.folder}</source>
<source>${spark.folder}</source>
- <source>${ml.folder}</source>
</sources>
</configuration>
</execution>
@@ -322,13 +280,12 @@
<sources>
<source>${lgpl.test.folder}</source>
<source>${spark.test.folder}</source>
- <source>${java8.test.folder}</source>
- <source>${ml.test.folder}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/cluster/ClusterGroupExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/cluster/ClusterGroupExample.java b/examples/src/main/java/org/apache/ignite/examples/cluster/ClusterGroupExample.java
new file mode 100644
index 0000000..1d0bff5
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/cluster/ClusterGroupExample.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.examples.cluster;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCluster;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+
+/**
+ * Demonstrates new functional APIs.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ClusterGroupExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If example execution failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
+ return;
+
+ System.out.println();
+ System.out.println("Compute example started.");
+
+ IgniteCluster cluster = ignite.cluster();
+
+ // Say hello to all nodes in the cluster, including local node.
+ sayHello(ignite, cluster);
+
+ // Say hello to all remote nodes.
+ sayHello(ignite, cluster.forRemotes());
+
+ // Pick random node out of remote nodes.
+ ClusterGroup randomNode = cluster.forRemotes().forRandom();
+
+ // Say hello to a random node.
+ sayHello(ignite, randomNode);
+
+ // Say hello to all nodes residing on the same host with random node.
+ sayHello(ignite, cluster.forHost(randomNode.node()));
+
+ // Say hello to all nodes that have current CPU load less than 50%.
+ sayHello(ignite, cluster.forPredicate(n -> n.metrics().getCurrentCpuLoad() < 0.5));
+ }
+ }
+
+ /**
+ * Print 'Hello' message on remote nodes.
+ *
+ * @param ignite Ignite.
+ * @param grp Cluster group.
+ * @throws IgniteException If failed.
+ */
+ private static void sayHello(Ignite ignite, final ClusterGroup grp) throws IgniteException {
+ // Print out hello message on all cluster nodes.
+ ignite.compute(grp).broadcast(
+ () -> System.out.println(">>> Hello Node: " + grp.ignite().cluster().localNode().id()));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/cluster/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/cluster/package-info.java b/examples/src/main/java/org/apache/ignite/examples/cluster/package-info.java
new file mode 100644
index 0000000..3fbf7d7
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/cluster/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. -->
+ * Cluster group example.
+ */
+package org.apache.ignite.examples.cluster;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeAsyncExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeAsyncExample.java b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeAsyncExample.java
index 8064ace..e58b992 100644
--- a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeAsyncExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeAsyncExample.java
@@ -49,24 +49,23 @@ public class ComputeAsyncExample {
System.out.println("Compute asynchronous example started.");
// Enable asynchronous mode.
- IgniteCompute compute = ignite.compute();
+ IgniteCompute compute = ignite.compute().withAsync();
Collection<IgniteFuture<?>> futs = new ArrayList<>();
// Iterate through all words in the sentence and create runnable jobs.
for (final String word : "Print words using runnable".split(" ")) {
// Execute runnable on some node.
- futs.add(compute.runAsync(new IgniteRunnable() {
- @Override public void run() {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
- }
- }));
+ compute.run(() -> {
+ System.out.println();
+ System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
+ });
+
+ futs.add(compute.future());
}
// Wait for completion of all futures.
- for (IgniteFuture<?> fut : futs)
- fut.get();
+ futs.forEach(IgniteFuture::get);
System.out.println();
System.out.println(">>> Finished printing words using runnable execution.");
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeBroadcastExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeBroadcastExample.java b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeBroadcastExample.java
index 783b102..af0d421 100644
--- a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeBroadcastExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeBroadcastExample.java
@@ -22,9 +22,6 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;
import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteCallable;
-import org.apache.ignite.lang.IgniteRunnable;
-import org.apache.ignite.resources.IgniteInstanceResource;
/**
* Demonstrates broadcasting computations within cluster.
@@ -63,14 +60,10 @@ public class ComputeBroadcastExample {
*/
private static void hello(Ignite ignite) throws IgniteException {
// Print out hello message on all nodes.
- ignite.compute().broadcast(
- new IgniteRunnable() {
- @Override public void run() {
- System.out.println();
- System.out.println(">>> Hello Node! :)");
- }
- }
- );
+ ignite.compute().broadcast(() -> {
+ System.out.println();
+ System.out.println(">>> Hello Node! :)");
+ });
System.out.println();
System.out.println(">>> Check all nodes for hello message output.");
@@ -84,23 +77,16 @@ public class ComputeBroadcastExample {
*/
private static void gatherSystemInfo(Ignite ignite) throws IgniteException {
// Gather system info from all nodes.
- Collection<String> res = ignite.compute().broadcast(
- new IgniteCallable<String>() {
- // Automatically inject ignite instance.
- @IgniteInstanceResource
- private Ignite ignite;
-
- @Override public String call() {
- System.out.println();
- System.out.println("Executing task on node: " + ignite.cluster().localNode().id());
+ Collection<String> res = ignite.compute().broadcast(() -> {
+ System.out.println();
+ System.out.println("Executing task on node: " + ignite.cluster().localNode().id());
- return "Node ID: " + ignite.cluster().localNode().id() + "\n" +
- "OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " +
- System.getProperty("os.arch") + "\n" +
- "User: " + System.getProperty("user.name") + "\n" +
- "JRE: " + System.getProperty("java.runtime.name") + " " +
- System.getProperty("java.runtime.version");
- }
+ return "Node ID: " + ignite.cluster().localNode().id() + "\n" +
+ "OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " +
+ System.getProperty("os.arch") + "\n" +
+ "User: " + System.getProperty("user.name") + "\n" +
+ "JRE: " + System.getProperty("java.runtime.name") + " " +
+ System.getProperty("java.runtime.version");
});
// Print result.
@@ -108,9 +94,9 @@ public class ComputeBroadcastExample {
System.out.println("Nodes system information:");
System.out.println();
- for (String r : res) {
+ res.forEach(r -> {
System.out.println(r);
System.out.println();
- }
+ });
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeCallableExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeCallableExample.java b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeCallableExample.java
index aceca17..81eb5f6 100644
--- a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeCallableExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeCallableExample.java
@@ -53,25 +53,19 @@ public class ComputeCallableExample {
Collection<IgniteCallable<Integer>> calls = new ArrayList<>();
// Iterate through all words in the sentence and create callable jobs.
- for (final String word : "Count characters using callable".split(" ")) {
- calls.add(new IgniteCallable<Integer>() {
- @Override public Integer call() throws Exception {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
+ for (String word : "Count characters using callable".split(" ")) {
+ calls.add(() -> {
+ System.out.println();
+ System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
- return word.length();
- }
+ return word.length();
});
}
// Execute collection of callables on the ignite.
Collection<Integer> res = ignite.compute().call(calls);
- int sum = 0;
-
- // Add up individual word lengths received from remote nodes.
- for (int len : res)
- sum += len;
+ int sum = res.stream().mapToInt(i -> i).sum();
System.out.println();
System.out.println(">>> Total number of characters in the phrase is '" + sum + "'.");
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClosureExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClosureExample.java b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClosureExample.java
index 43a18e2..fc79c84 100644
--- a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClosureExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClosureExample.java
@@ -23,7 +23,6 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;
import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteClosure;
/**
* Demonstrates a simple use of Ignite with reduce closure.
@@ -51,29 +50,22 @@ public class ComputeClosureExample {
// Execute closure on all cluster nodes.
Collection<Integer> res = ignite.compute().apply(
- new IgniteClosure<String, Integer>() {
- @Override public Integer apply(String word) {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
+ (String word) -> {
+ System.out.println();
+ System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
- // Return number of letters in the word.
- return word.length();
- }
+ // Return number of letters in the word.
+ return word.length();
},
-
// Job parameters. Ignite will create as many jobs as there are parameters.
Arrays.asList("Count characters using closure".split(" "))
);
- int sum = 0;
-
- // Add up individual word lengths received from remote nodes
- for (int len : res)
- sum += len;
+ int sum = res.stream().mapToInt(i -> i).sum();
System.out.println();
System.out.println(">>> Total number of characters in the phrase is '" + sum + "'.");
System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
}
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeRunnableExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeRunnableExample.java b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeRunnableExample.java
index 5a6f9e8..d1e5825 100644
--- a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeRunnableExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeRunnableExample.java
@@ -27,7 +27,7 @@ import org.apache.ignite.lang.IgniteRunnable;
/**
* Demonstrates a simple use of {@link IgniteRunnable}.
* <p>
- * Remote nodes should always be started with special configuration file which
+ * Remote nodes should always be 0started with special configuration file which
* enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
* <p>
* Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
@@ -50,11 +50,9 @@ public class ComputeRunnableExample {
// Iterate through all words in the sentence and create runnable jobs.
for (final String word : "Print words using runnable".split(" ")) {
// Execute runnable on some node.
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
- }
+ compute.run(() -> {
+ System.out.println();
+ System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
});
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java
index c059ced..edd104e 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java
@@ -25,8 +25,10 @@ import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.examples.ExampleNodeStartup;
import org.apache.ignite.lang.IgniteRunnable;
@@ -59,8 +61,13 @@ public final class CacheAffinityExample {
System.out.println();
System.out.println(">>> Cache affinity example started.");
+ CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+ cfg.setCacheMode(CacheMode.PARTITIONED);
+ cfg.setName(CACHE_NAME);
+
// Auto-close cache at the end of the example.
- try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(CACHE_NAME)) {
+ try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
for (int i = 0; i < KEY_CNT; i++)
cache.put(i, Integer.toString(i));
@@ -87,18 +94,13 @@ public final class CacheAffinityExample {
final IgniteCache<Integer, String> cache = ignite.cache(CACHE_NAME);
for (int i = 0; i < KEY_CNT; i++) {
- final int key = i;
+ int key = i;
// This runnable will execute on the remote node where
// data with the given key is located. Since it will be co-located
// we can use local 'peek' operation safely.
- ignite.compute().affinityRun(CACHE_NAME, key, new IgniteRunnable() {
- @Override public void run() {
- // Peek is a local memory lookup, however, value should never be 'null'
- // as we are co-located with node that has a given key.
- System.out.println("Co-located using affinityRun [key= " + key + ", value=" + cache.localPeek(key) + ']');
- }
- });
+ ignite.compute().affinityRun(CACHE_NAME, key,
+ () -> System.out.println("Co-located using affinityRun [key= " + key + ", value=" + cache.localPeek(key) + ']'));
}
}
@@ -125,16 +127,14 @@ public final class CacheAffinityExample {
if (node != null) {
// Bring computations to the nodes where the data resides (i.e. collocation).
- ignite.compute(ignite.cluster().forNode(node)).run(new IgniteRunnable() {
- @Override public void run() {
- IgniteCache<Integer, String> cache = ignite.cache(CACHE_NAME);
-
- // Peek is a local memory lookup, however, value should never be 'null'
- // as we are co-located with node that has a given key.
- for (Integer key : mappedKeys)
- System.out.println("Co-located using mapKeysToNodes [key= " + key +
- ", value=" + cache.localPeek(key) + ']');
- }
+ ignite.compute(ignite.cluster().forNode(node)).run(() -> {
+ IgniteCache<Integer, String> cache = ignite.cache(CACHE_NAME);
+
+ // Peek is a local memory lookup, however, value should never be 'null'
+ // as we are co-located with node that has a given key.
+ for (Integer key : mappedKeys)
+ System.out.println("Co-located using mapKeysToNodes [key= " + key +
+ ", value=" + cache.localPeek(key) + ']');
});
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java
index a20ef16..69437ea 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java
@@ -18,12 +18,12 @@
package org.apache.ignite.examples.datagrid;
import java.util.concurrent.ConcurrentMap;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.MutableEntry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.examples.ExampleNodeStartup;
/**
@@ -50,8 +50,13 @@ public class CacheApiExample {
System.out.println();
System.out.println(">>> Cache API example started.");
+ CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+ cfg.setCacheMode(CacheMode.PARTITIONED);
+ cfg.setName(CACHE_NAME);
+
// Auto-close cache at the end of the example.
- try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(CACHE_NAME)) {
+ try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
// Demonstrate atomic map operations.
atomicMapOperations(cache);
}
@@ -76,7 +81,7 @@ public class CacheApiExample {
String v = cache.getAndPut(1, "1");
assert v == null;
- // Put and do not return previous value.
+ // Put and do not return previous value (all methods ending with 'x' return boolean).
// Performs better when previous value is not needed.
cache.put(2, "2");
@@ -87,14 +92,13 @@ public class CacheApiExample {
// Invoke - assign new value based on previous value.
cache.put(6, "6");
- cache.invoke(6, new EntryProcessor<Integer, String, Object>() {
- @Override public Object process(MutableEntry<Integer, String> entry, Object... args) {
- String v = entry.getValue();
- entry.setValue(v + "6"); // Set new value based on previous value.
+ cache.invoke(6, (entry, args) -> {
+ String val = entry.getValue();
- return null;
- }
+ entry.setValue(val + "6"); // Set new value based on previous value.
+
+ return null;
});
// Replace.
@@ -103,4 +107,4 @@ public class CacheApiExample {
b2 = cache.replace(7, "7", "777");
assert b1 & !b2;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java
index 69b23e7..951b877 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java
@@ -23,9 +23,10 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.examples.ExampleNodeStartup;
import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgniteInClosure;
/**
* This example demonstrates some of the cache rich API capabilities.
@@ -51,24 +52,34 @@ public class CacheAsyncApiExample {
System.out.println();
System.out.println(">>> Cache asynchronous API example started.");
+ CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+ cfg.setCacheMode(CacheMode.PARTITIONED);
+ cfg.setName(CACHE_NAME);
+
// Auto-close cache at the end of the example.
- try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(CACHE_NAME)) {
+ try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
+ // Enable asynchronous mode.
+ IgniteCache<Integer, String> asyncCache = cache.withAsync();
+
Collection<IgniteFuture<?>> futs = new ArrayList<>();
// Execute several puts asynchronously.
- for (int i = 0; i < 10; i++)
- futs.add(cache.putAsync(i, String.valueOf(i)));
+ for (int i = 0; i < 10; i++) {
+ asyncCache.put(i, String.valueOf(i));
+
+ futs.add(asyncCache.future());
+ }
// Wait for completion of all futures.
- for (IgniteFuture<?> fut : futs)
- fut.get();
+ futs.forEach(IgniteFuture::get);
+
+ // Execute get operation asynchronously.
+ asyncCache.get(1);
- // Execute get operation asynchronously and wait for result.
- cache.getAsync(1).listen(new IgniteInClosure<IgniteFuture<String>>() {
- @Override public void apply(IgniteFuture<String> fut) {
- System.out.println("Get operation completed [value=" + fut.get() + ']');
- }
- });
+ // Asynchronously wait for result.
+ asyncCache.<String>future().listen(fut ->
+ System.out.println("Get operation completed [value=" + fut.get() + ']'));
}
finally {
// Distributed cache could be removed from cluster only by #destroyCache() call.
@@ -76,4 +87,4 @@ public class CacheAsyncApiExample {
}
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEntryProcessorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEntryProcessorExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEntryProcessorExample.java
index 04c4811..521e144 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEntryProcessorExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEntryProcessorExample.java
@@ -21,8 +21,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.EntryProcessorException;
-import javax.cache.processor.MutableEntry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteException;
@@ -30,15 +28,15 @@ import org.apache.ignite.Ignition;
import org.apache.ignite.examples.ExampleNodeStartup;
/**
- * This example demonstrates the simplest code that populates the distributed cache
- * and co-locates simple closure execution with each key. The goal of this particular
- * example is to provide the simplest code example of this logic using EntryProcessor.
+ * This example demonstrates the simplest code that populates the distributed cache and co-locates simple closure
+ * execution with each key. The goal of this particular example is to provide the simplest code example of this logic
+ * using EntryProcessor.
* <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * Remote nodes should always be started with special configuration file which enables P2P
+ * class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
* <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node with
+ * {@code examples/config/example-ignite.xml} configuration.
*/
public class CacheEntryProcessorExample {
/** Cache name. */
@@ -47,7 +45,7 @@ public class CacheEntryProcessorExample {
/** Number of keys. */
private static final int KEY_CNT = 20;
- /** Keys predefined set. */
+ /** Set of predefined keys. */
private static final Set<Integer> KEYS_SET;
/**
@@ -100,15 +98,11 @@ public class CacheEntryProcessorExample {
// Invokes EntryProcessor for every key sequentially.
for (int i = 0; i < KEY_CNT; i++) {
- cache.invoke(i, new EntryProcessor<Integer, Integer, Object>() {
- @Override public Object process(MutableEntry<Integer, Integer> entry,
- Object... objects) throws EntryProcessorException {
- // Initializes entry's value if it's not set.
- if (entry.getValue() == null)
- entry.setValue((entry.getKey() + 1) * 10);
-
- return null;
- }
+ cache.invoke(i, (entry, object) -> {
+ // Initializes entry's value if it's not set.
+ if (entry.getValue() == null)
+ entry.setValue((entry.getKey() + 1) * 10);
+ return null;
});
}
@@ -117,8 +111,8 @@ public class CacheEntryProcessorExample {
}
/**
- * Increments values of entries stored in the cache using
- * {@link IgniteCache#invokeAll(Set, EntryProcessor, Object...)} method.
+ * Increments values of entries stored in the cache using {@link IgniteCache#invokeAll(Set, EntryProcessor,
+ * Object...)} method.
*
* @param cache Cache instance.
*/
@@ -127,14 +121,10 @@ public class CacheEntryProcessorExample {
System.out.println(">> Incrementing values in the cache using EntryProcessor.");
// Using EntryProcessor.invokeAll to increment every value in place.
- cache.invokeAll(KEYS_SET, new EntryProcessor<Integer, Integer, Object>() {
- @Override public Object process(MutableEntry<Integer, Integer> entry,
- Object... arguments) throws EntryProcessorException {
-
- entry.setValue(entry.getValue() + 5);
+ cache.invokeAll(KEYS_SET, (entry, object) -> {
+ entry.setValue(entry.getValue() + 5);
- return null;
- }
+ return null;
});
// Print outs entries that are incremented using the EntryProcessor above.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/datagrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/package-info.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/package-info.java
index e060581..e8c54ac 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/package-info.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/package-info.java
@@ -19,4 +19,4 @@
* <!-- Package description. -->
* Demonstrates data ignite cache usage.
*/
-package org.apache.ignite.examples.datagrid;
\ No newline at end of file
+package org.apache.ignite.examples.jav.datagrid;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteExecutorServiceExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteExecutorServiceExample.java b/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteExecutorServiceExample.java
index e840650..fa1c1b1 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteExecutorServiceExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteExecutorServiceExample.java
@@ -52,11 +52,9 @@ public final class IgniteExecutorServiceExample {
// Iterate through all words in the sentence and create callable jobs.
for (final String word : "Print words using runnable".split(" ")) {
// Execute runnable on some node.
- exec.submit(new IgniteRunnable() {
- @Override public void run() {
- System.out.println();
- System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
- }
+ exec.submit((IgniteRunnable)() -> {
+ System.out.println();
+ System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
});
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java b/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java
index 6cc6659..7e306e5 100644
--- a/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java
@@ -75,23 +75,17 @@ public class EventsExample {
Ignite ignite = Ignition.ignite();
- IgnitePredicate<TaskEvent> lsnr = new IgnitePredicate<TaskEvent>() {
- @Override public boolean apply(TaskEvent evt) {
- System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName() + ']');
+ IgnitePredicate<TaskEvent> lsnr = evt -> {
+ System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName() + ']');
- return true; // Return true to continue listening.
- }
+ return true; // Return true to continue listening.
};
// Register event listener for all local task execution events.
ignite.events().localListen(lsnr, EVTS_TASK_EXECUTION);
// Generate task events.
- ignite.compute().withName("example-event-task").run(new IgniteRunnable() {
- @Override public void run() {
- System.out.println("Executing sample job.");
- }
- });
+ ignite.compute().withName("example-event-task").run(() -> System.out.println("Executing sample job."));
// Unsubscribe local task event listener.
ignite.events().stopLocalListen(lsnr);
@@ -108,23 +102,17 @@ public class EventsExample {
// This optional local callback is called for each event notification
// that passed remote predicate listener.
- IgniteBiPredicate<UUID, TaskEvent> locLsnr = new IgniteBiPredicate<UUID, TaskEvent>() {
- @Override public boolean apply(UUID nodeId, TaskEvent evt) {
- // Remote filter only accepts tasks whose name being with "good-task" prefix.
- assert evt.taskName().startsWith("good-task");
+ IgniteBiPredicate<UUID, TaskEvent> locLsnr = (nodeId, evt) -> {
+ // Remote filter only accepts tasks whose name being with "good-task" prefix.
+ assert evt.taskName().startsWith("good-task");
- System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName());
+ System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName());
- return true; // Return true to continue listening.
- }
+ return true; // Return true to continue listening.
};
// Remote filter which only accepts tasks whose name begins with "good-task" prefix.
- IgnitePredicate<TaskEvent> rmtLsnr = new IgnitePredicate<TaskEvent>() {
- @Override public boolean apply(TaskEvent evt) {
- return evt.taskName().startsWith("good-task");
- }
- };
+ IgnitePredicate<TaskEvent> rmtLsnr = evt -> evt.taskName().startsWith("good-task");
Ignite ignite = Ignition.ignite();
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingExample.java b/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingExample.java
index a810e02..715ffeb 100644
--- a/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingExample.java
@@ -17,7 +17,6 @@
package org.apache.ignite.examples.messaging;
-import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteException;
@@ -26,8 +25,6 @@ import org.apache.ignite.Ignition;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.examples.ExampleNodeStartup;
import org.apache.ignite.examples.ExamplesUtils;
-import org.apache.ignite.lang.IgniteBiPredicate;
-import org.apache.ignite.resources.IgniteInstanceResource;
/**
* Example that demonstrates how to exchange messages between nodes. Use such
@@ -47,13 +44,13 @@ public final class MessagingExample {
private static final int MESSAGES_NUM = 10;
/** Message topics. */
- private enum EXAMPLE_TOPIC { ORDERED, UNORDERED }
+ private enum TOPIC { ORDERED, UNORDERED }
/**
* Executes example.
*
* @param args Command line arguments, none required.
- * @throws Exception If example execution failed.
+ * @throws IgniteException If example execution failed.
*/
public static void main(String[] args) throws Exception {
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
@@ -64,10 +61,10 @@ public final class MessagingExample {
System.out.println(">>> Messaging example started.");
// Group for remote nodes.
- ClusterGroup rmts = ignite.cluster().forRemotes();
+ ClusterGroup rmtGrp = ignite.cluster().forRemotes();
// Listen for messages from remote nodes to make sure that they received all the messages.
- int msgCnt = rmts.nodes().size() * MESSAGES_NUM;
+ int msgCnt = rmtGrp.nodes().size() * MESSAGES_NUM;
CountDownLatch orderedLatch = new CountDownLatch(msgCnt);
CountDownLatch unorderedLatch = new CountDownLatch(msgCnt);
@@ -75,17 +72,17 @@ public final class MessagingExample {
localListen(ignite.message(ignite.cluster().forLocal()), orderedLatch, unorderedLatch);
// Register listeners on all cluster nodes.
- startListening(ignite.message(rmts));
+ startListening(ignite, ignite.message(rmtGrp));
// Send unordered messages to all remote nodes.
for (int i = 0; i < MESSAGES_NUM; i++)
- ignite.message(rmts).send(EXAMPLE_TOPIC.UNORDERED, Integer.toString(i));
+ ignite.message(rmtGrp).send(TOPIC.UNORDERED, Integer.toString(i));
System.out.println(">>> Finished sending unordered messages.");
// Send ordered messages to all remote nodes.
for (int i = 0; i < MESSAGES_NUM; i++)
- ignite.message(rmts).sendOrdered(EXAMPLE_TOPIC.ORDERED, Integer.toString(i), 0);
+ ignite.message(rmtGrp).sendOrdered(TOPIC.ORDERED, Integer.toString(i), 0);
System.out.println(">>> Finished sending ordered messages.");
System.out.println(">>> Check output on all nodes for message printouts.");
@@ -101,76 +98,64 @@ public final class MessagingExample {
/**
* Start listening to messages on remote cluster nodes.
*
- * @param msg Ignite messaging.
+ * @param ignite Ignite.
+ * @param imsg Ignite messaging.
+ * @throws IgniteException If failed.
*/
- private static void startListening(IgniteMessaging msg) {
+ private static void startListening(final Ignite ignite, IgniteMessaging imsg) throws IgniteException {
// Add ordered message listener.
- msg.remoteListen(EXAMPLE_TOPIC.ORDERED, new IgniteBiPredicate<UUID, String>() {
- @IgniteInstanceResource
- private Ignite ignite;
+ imsg.remoteListen(TOPIC.ORDERED, (nodeId, msg) -> {
+ System.out.println("Received ordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
- @Override public boolean apply(UUID nodeId, String msg) {
- System.out.println("Received ordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
-
- try {
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(EXAMPLE_TOPIC.ORDERED, msg);
- }
- catch (IgniteException e) {
- e.printStackTrace();
- }
-
- return true; // Return true to continue listening.
+ try {
+ ignite.message(ignite.cluster().forNodeId(nodeId)).send(TOPIC.ORDERED, msg);
+ }
+ catch (IgniteException e) {
+ e.printStackTrace();
}
+
+ return true; // Return true to continue listening.
});
// Add unordered message listener.
- msg.remoteListen(EXAMPLE_TOPIC.UNORDERED, new IgniteBiPredicate<UUID, String>() {
- @IgniteInstanceResource
- private Ignite ignite;
-
- @Override public boolean apply(UUID nodeId, String msg) {
- System.out.println("Received unordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
+ imsg.remoteListen(TOPIC.UNORDERED, (nodeId, msg) -> {
+ System.out.println("Received unordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
- try {
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(EXAMPLE_TOPIC.UNORDERED, msg);
- }
- catch (IgniteException e) {
- e.printStackTrace();
- }
-
- return true; // Return true to continue listening.
+ try {
+ ignite.message(ignite.cluster().forNodeId(nodeId)).send(TOPIC.UNORDERED, msg);
+ }
+ catch (IgniteException e) {
+ e.printStackTrace();
}
+
+ return true; // Return true to continue listening.
});
}
/**
* Listen for messages from remote nodes.
*
- * @param msg Ignite messaging.
+ * @param imsg Ignite messaging.
* @param orderedLatch Latch for ordered messages acks.
* @param unorderedLatch Latch for unordered messages acks.
*/
private static void localListen(
- IgniteMessaging msg,
+ IgniteMessaging imsg,
final CountDownLatch orderedLatch,
final CountDownLatch unorderedLatch
) {
- msg.localListen(EXAMPLE_TOPIC.ORDERED, new IgniteBiPredicate<UUID, String>() {
- @Override public boolean apply(UUID nodeId, String msg) {
- orderedLatch.countDown();
+ imsg.localListen(TOPIC.ORDERED, (nodeId, msg) -> {
+ orderedLatch.countDown();
- // Return true to continue listening, false to stop.
- return orderedLatch.getCount() > 0;
- }
+ // Return true to continue listening, false to stop.
+ return orderedLatch.getCount() > 0;
});
- msg.localListen(EXAMPLE_TOPIC.UNORDERED, new IgniteBiPredicate<UUID, String>() {
- @Override public boolean apply(UUID nodeId, String msg) {
- unorderedLatch.countDown();
+ imsg.localListen(TOPIC.UNORDERED, (nodeId, msg) -> {
+ unorderedLatch.countDown();
- // Return true to continue listening, false to stop.
- return unorderedLatch.getCount() > 0;
- }
+ // Return true to continue listening, false to stop.
+ return unorderedLatch.getCount() > 0;
});
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingPingPongExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingPingPongExample.java b/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingPingPongExample.java
index 8571f66..f5d4664 100644
--- a/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingPingPongExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingPingPongExample.java
@@ -17,7 +17,6 @@
package org.apache.ignite.examples.messaging;
-import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteException;
@@ -25,7 +24,6 @@ import org.apache.ignite.Ignition;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.examples.ExampleNodeStartup;
import org.apache.ignite.examples.ExamplesUtils;
-import org.apache.ignite.lang.IgniteBiPredicate;
/**
* Demonstrates simple message exchange between local and remote nodes.
@@ -63,18 +61,16 @@ public class MessagingPingPongExample {
// anonymous closure's state during its remote execution.
// Set up remote player.
- ignite.message(nodeB).remoteListen(null, new IgniteBiPredicate<UUID, String>() {
- @Override public boolean apply(UUID nodeId, String rcvMsg) {
- System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
+ ignite.message(nodeB).remoteListen(null, (nodeId, rcvMsg) -> {
+ System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
- if ("PING".equals(rcvMsg)) {
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PONG");
+ if ("PING".equals(rcvMsg)) {
+ ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PONG");
- return true; // Continue listening.
- }
-
- return false; // Unsubscribe.
+ return true; // Continue listening.
}
+
+ return false; // Unsubscribe.
});
int MAX_PLAYS = 10;
@@ -82,26 +78,24 @@ public class MessagingPingPongExample {
final CountDownLatch cnt = new CountDownLatch(MAX_PLAYS);
// Set up local player.
- ignite.message().localListen(null, new IgniteBiPredicate<UUID, String>() {
- @Override public boolean apply(UUID nodeId, String rcvMsg) {
- System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
-
- if (cnt.getCount() == 1) {
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "STOP");
+ ignite.message().localListen(null, (nodeId, rcvMsg) -> {
+ System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
- cnt.countDown();
-
- return false; // Stop listening.
- }
- else if ("PONG".equals(rcvMsg))
- ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PING");
- else
- throw new IgniteException("Received unexpected message: " + rcvMsg);
+ if (cnt.getCount() == 1) {
+ ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "STOP");
cnt.countDown();
- return true; // Continue listening.
+ return false; // Stop listening.
}
+ else if ("PONG".equals(rcvMsg))
+ ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PING");
+ else
+ throw new IgniteException("Received unexpected message: " + rcvMsg);
+
+ cnt.countDown();
+
+ return true; // Continue listening.
});
// Serve!