You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/12/29 14:55:58 UTC

[1/3] ignite git commit: IGNITE-2263: Removing unused stuff.

Repository: ignite
Updated Branches:
  refs/heads/ignite-2263 c34453622 -> 597ef1d6e


IGNITE-2263: Removing unused stuff.


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

Branch: refs/heads/ignite-2263
Commit: 2a66f56cb52ede991a364149c5ced877b92c45b8
Parents: c344536
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Dec 29 16:27:56 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Dec 29 16:27:56 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/util/lang/GridFunc.java     | 227 +------------------
 .../ignite/internal/util/lang/GridTuple3.java   |   1 -
 .../ignite/internal/util/lang/GridTuple4.java   |   1 -
 .../ignite/internal/util/lang/GridTuple5.java   |   1 -
 .../ignite/internal/util/lang/GridTuple6.java   |   1 -
 .../ignite/internal/util/lang/GridTupleV.java   |   1 -
 6 files changed, 1 insertion(+), 231 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2a66f56c/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index 0678657..525269b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -382,23 +382,6 @@ public class GridFunc {
     }
 
     /**
-     * Creates new collection by removing duplicates from the given collection.
-     *
-     * @param c Collection to remove duplicates from.
-     * @param <T> Type of the collection.
-     * @return De-duped collection.
-     */
-    public static <T> Collection<T> dedup(Collection<? extends T> c) {
-        A.notNull(c, "c");
-
-        Collection<T> set = new GridLeanSet<>();
-
-        set.addAll(c);
-
-        return set;
-    }
-
-    /**
      * Calculates sum of all elements.
      * <p>
      * <img src="{@docRoot}/img/sum.png">
@@ -1026,94 +1009,6 @@ public class GridFunc {
     }
 
     /**
-     * Loses all entries in input map that are evaluated to {@code true} by all given predicates.
-     *
-     * @param m Map to filter.
-     * @param cp If {@code true} method creates new map not modifying input, otherwise does
-     *      <tt>in-place</tt> modifications.
-     * @param p Optional set of predicates to use for filtration. If none provided - original map
-     *  will (or its copy) be returned.
-     * @param <K> Type of the free variable for the predicate and type of map's keys.
-     * @param <V> Type of the free variable for the predicate and type of map's values.
-     * @return Filtered map.
-     */
-    @SuppressWarnings({"unchecked"})
-    public static <K, V> Map<K, V> lose(Map<K, V> m, boolean cp,
-        @Nullable IgnitePredicate<? super Map.Entry<K, V>>... p) {
-        A.notNull(m, "m");
-
-        Map<K, V> res;
-
-        if (!cp) {
-            res = m;
-
-            if (isEmpty(p))
-                res.clear();
-            else if (!isAlwaysFalse(p))
-                for (Iterator<Map.Entry<K, V>> iter = m.entrySet().iterator(); iter.hasNext();)
-                    if (isAll(iter.next(), p))
-                        iter.remove();
-        }
-        else {
-            res = U.newHashMap(m.size());
-
-            if (!isEmpty(p) && !isAlwaysTrue(p))
-                for (Map.Entry<K, V> e : m.entrySet())
-                    if (!F.isAll(e, p))
-                        res.put(e.getKey(), e.getValue());
-        }
-
-        return res;
-    }
-
-    /**
-     * Loses all entries in input map which keys are evaluated to {@code true} by all
-     * given predicates.
-     *
-     * @param m Map to filter.
-     * @param cp If {@code true} method creates new map not modifying input, otherwise does
-     *      <tt>in-place</tt> modifications.
-     * @param p Optional set of predicates to use for filtration. If none provided - original
-     *      map (or its copy) will be returned.
-     * @param <K> Type of the free variable for the predicate and type of map's keys.
-     * @param <V> Type of map's values.
-     * @return Filtered map.
-     */
-    public static <K, V> Map<K, V> loseKeys(
-        Map<K, V> m,
-        boolean cp,
-        @Nullable final IgnitePredicate<? super K>... p
-    ) {
-        return lose(m, cp, new P1<Map.Entry<K, V>>() {
-            @Override public boolean apply(Map.Entry<K, V> e) {
-                return isAll(e.getKey(), p);
-            }
-        });
-    }
-
-    /**
-     * Loses all entries in input map which values are evaluated to {@code true} by all
-     * given predicates.
-     *
-     * @param m Map to filter.
-     * @param cp If {@code true} method creates new map not modifying input, otherwise does
-     *      <tt>in-place</tt> modifications.
-     * @param p Optional set of predicates to use for filtration. If none provided - original
-     *      map (or its copy) will be returned.
-     * @param <K> Type of the free variable for the predicate and type of map's keys.
-     * @param <V> Type of map's values.
-     * @return Filtered map.
-     */
-    public static <K, V> Map<K, V> loseValues(Map<K, V> m, boolean cp,
-        @Nullable final IgnitePredicate<? super V>... p) {
-        return lose(m, cp, new P1<Map.Entry<K, V>>() {
-            @Override public boolean apply(Map.Entry<K, V> e) {
-                return isAll(e.getValue(), p);
-            }
-        });
-    }
-
-    /**
      * Loses all elements in input list that are contained in {@code filter} collection.
      *
      * @param c Input list.
@@ -1148,40 +1043,6 @@ public class GridFunc {
     }
 
     /**
-     * Loses all elements in input list for which any of the predicates evaluate to {@code true}.
-     *
-     * @param c Input list.
-     * @param cp If {@code true} method creates new list not modifying input,
-     *      otherwise does <tt>in-place</tt> modifications.
-     * @param p Looses all elements for which any of the predicates evaluate to {@code true}.
-     * @param <T> Type of list.
-     * @return List of remaining elements
-     */
-    public static <T> List<T> filterList(List<T> c, boolean cp, @Nullable IgnitePredicate<T>... p) {
-        A.notNull(c, "c");
-
-        List<T> res;
-
-        if (!cp) {
-            res = c;
-
-            if (p != null)
-                for (Iterator<T> it = c.iterator(); it.hasNext();)
-                    if (isAny(it.next(), p))
-                        it.remove();
-        }
-        else {
-            res = new ArrayList<>(c.size());
-
-            for (T t : c)
-                if (!isAny(t, p))
-                    res.add(t);
-        }
-
-        return res;
-    }
-
-    /**
      * Gets closure which converts node to node ID.
      *
      * @return Closure which converts node to node ID.
@@ -1738,27 +1599,6 @@ public class GridFunc {
     }
 
     /**
-     * Creates a view on given list with provided transformer and predicates.
-     * Resulting list will only "have" elements for which all provided predicates, if any,
-     * evaluate to {@code true}. Note that a new collection will be created and data will
-     * be copied.
-     *
-     * @param c Input list that serves as a base for the view.
-     * @param trans Transforming closure from T1 to T2.
-     * @param p Optional predicates. If predicates are not provided - all elements will be in the view.
-     * @return View on given list with provided predicate.
-     */
-    public static <T1, T2> List<T2> transformList(Collection<? extends T1> c,
-        IgniteClosure<? super T1, T2> trans, @Nullable IgnitePredicate<? super T1>... p) {
-        A.notNull(c, "c", trans, "trans");
-
-        if (isAlwaysFalse(p))
-            return Collections.emptyList();
-
-        return new ArrayList<>(transform(retain(c, true, p), trans));
-    }
-
-    /**
      * Creates light-weight view on given map with provided predicates. Resulting map will
      * only "have" keys for which all provided predicates, if any, evaluates to {@code true}.
      * Note that only wrapping map will be created and no duplication of data will occur.
@@ -2838,6 +2678,7 @@ public class GridFunc {
      * @param <T> Type of the collection.
      * @return Collections' first element or {@code null} in case if the collection is empty.
      */
+    @SuppressWarnings("unchecked")
     public static <T> T first(@Nullable Iterable<? extends T> c) {
         if (c == null)
             return null;
@@ -3832,72 +3673,6 @@ public class GridFunc {
     }
 
     /**
-     * Creates vararg tuple with given values.
-     *
-     * @param objs Values for vararg tuple.
-     * @return Vararg tuple with given values.
-     */
-    public static GridTupleV tv(Object... objs) {
-        assert objs != null;
-
-        return new GridTupleV(objs);
-    }
-
-    /**
-     * Factory method returning new empty tuple.
-     *
-     * @param <V1> Type of the 1st tuple parameter.
-     * @param <V2> Type of the 2nd tuple parameter.
-     * @param <V3> Type of the 3rd tuple parameter.
-     * @return Newly created empty tuple.
-     */
-    public static <V1, V2, V3> GridTuple3<V1, V2, V3> t3() {
-        return new GridTuple3<>();
-    }
-
-    /**
-     * Factory method returning new empty tuple.
-     *
-     * @param <V1> Type of the 1st tuple parameter.
-     * @param <V2> Type of the 2nd tuple parameter.
-     * @param <V3> Type of the 3rd tuple parameter.
-     * @param <V4> Type of the 4th tuple parameter.
-     * @return Newly created empty tuple.
-     */
-    public static <V1, V2, V3, V4> GridTuple4<V1, V2, V3, V4> t4() {
-        return new GridTuple4<>();
-    }
-
-    /**
-     * Factory method returning new empty tuple.
-     *
-     * @param <V1> Type of the 1st tuple parameter.
-     * @param <V2> Type of the 2nd tuple parameter.
-     * @param <V3> Type of the 3rd tuple parameter.
-     * @param <V4> Type of the 4th tuple parameter.
-     * @param <V5> Type of the 5th tuple parameter.
-     * @return Newly created empty tuple.
-     */
-    public static <V1, V2, V3, V4, V5> GridTuple5<V1, V2, V3, V4, V5> t5() {
-        return new GridTuple5<>();
-    }
-
-    /**
-     * Factory method returning new empty tuple.
-     *
-     * @param <V1> Type of the 1st tuple parameter.
-     * @param <V2> Type of the 2nd tuple parameter.
-     * @param <V3> Type of the 3rd tuple parameter.
-     * @param <V4> Type of the 4th tuple parameter.
-     * @param <V5> Type of the 5th tuple parameter.
-     * @param <V6> Type of the 6th tuple parameter.
-     * @return Newly created empty tuple.
-     */
-    public static <V1, V2, V3, V4, V5, V6> GridTuple6<V1, V2, V3, V4, V5, V6> t6() {
-        return new GridTuple6<>();
-    }
-
-    /**
      * Converts collection to map using collection values as keys and
      * passed in default value as values.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a66f56c/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple3.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple3.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple3.java
index b999e2a..e5d247a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple3.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple3.java
@@ -34,7 +34,6 @@ import org.jetbrains.annotations.Nullable;
  * This class doesn't provide any synchronization for multi-threaded access
  * and it is responsibility of the user of this class to provide outside
  * synchronization, if needed.
- * @see GridFunc#t3()
  * @see GridFunc#t(Object, Object, Object)
  */
 public class GridTuple3<V1, V2, V3> implements Iterable<Object>, Externalizable, Cloneable {

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a66f56c/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java
index c95a859..d1e69b5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java
@@ -34,7 +34,6 @@ import org.jetbrains.annotations.Nullable;
  * This class doesn't provide any synchronization for multi-threaded access
  * and it is responsibility of the user of this class to provide outside
  * synchronization, if needed.
- * @see GridFunc#t4()
  * @see GridFunc#t(Object, Object, Object, Object)
  */
 public class GridTuple4<V1, V2, V3, V4> implements Iterable<Object>, Externalizable, Cloneable {

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a66f56c/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple5.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple5.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple5.java
index 9790f48..7d25996 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple5.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple5.java
@@ -34,7 +34,6 @@ import org.jetbrains.annotations.Nullable;
  * This class doesn't provide any synchronization for multi-threaded access
  * and it is responsibility of the user of this class to provide outside
  * synchronization, if needed.
- * @see GridFunc#t5()
  * @see GridFunc#t(Object, Object, Object, Object, Object)
  */
 public class GridTuple5<V1, V2, V3, V4, V5> implements Iterable<Object>, Externalizable, Cloneable {

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a66f56c/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple6.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple6.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple6.java
index 044944b..c904587 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple6.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple6.java
@@ -34,7 +34,6 @@ import org.jetbrains.annotations.Nullable;
  * This class doesn't provide any synchronization for multi-threaded access
  * and it is responsibility of the user of this class to provide outside
  * synchronization, if needed.
- * @see GridFunc#t5()
  * @see GridFunc#t(Object, Object, Object, Object, Object)
  */
 public class GridTuple6<V1, V2, V3, V4, V5, V6> implements Iterable<Object>, Externalizable,

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a66f56c/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTupleV.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTupleV.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTupleV.java
index 225366a..58e18aa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTupleV.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTupleV.java
@@ -35,7 +35,6 @@ import org.apache.ignite.internal.util.typedef.internal.U;
  * This class doesn't provide any synchronization for multi-threaded access
  * and it is responsibility of the user of this class to provide outside
  * synchronization, if needed.
- * @see GridFunc#tv(Object...)
  */
 public class GridTupleV implements Iterable<Object>, Externalizable, Cloneable {
     /** */


[3/3] ignite git commit: IGNITE-2263: Further simplification of GridFunc.

Posted by vo...@apache.org.
IGNITE-2263: Further simplification of GridFunc.


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

Branch: refs/heads/ignite-2263
Commit: 597ef1d6edd6650a8975b079549d6dc2d06a3a33
Parents: e91d6e6
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Dec 29 16:56:53 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Dec 29 16:56:53 2015 +0300

----------------------------------------------------------------------
 .../GridCachePartitionExchangeManager.java      |  12 +-
 .../ignite/internal/util/lang/GridFunc.java     | 131 -------------------
 .../ignite/lang/GridBasicPerformanceTest.java   |  10 +-
 3 files changed, 18 insertions(+), 135 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/597ef1d6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index a0f7f93..4732597 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -80,6 +80,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.util.worker.GridWorker;
 import org.apache.ignite.lang.IgniteBiInClosure;
+import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.lang.IgniteProductVersion;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.thread.IgniteThread;
@@ -1270,9 +1271,16 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
                     }
 
                     // After workers line up and before preloading starts we initialize all futures.
-                    if (log.isDebugEnabled())
+                    if (log.isDebugEnabled()) {
+                        IgnitePredicate p = new IgnitePredicate<IgniteInternalFuture<?>>() {
+                            @Override public boolean apply(IgniteInternalFuture<?> f) {
+                                return !f.isDone();
+                            }
+                        };
+
                         log.debug("Before waiting for exchange futures [futs" +
-                            F.view(exchFuts.values(), F.unfinishedFutures()) + ", worker=" + this + ']');
+                            F.view(exchFuts.values(), p) + ", worker=" + this + ']');
+                    }
 
                     // Take next exchange future.
                     exchFut = poll(futQ, timeout, this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/597ef1d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index 3e7b122..4cba715 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -38,12 +38,9 @@ import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
 import javax.cache.Cache;
-import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.compute.ComputeJobResult;
-import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridConcurrentHashSet;
@@ -333,13 +330,6 @@ public class GridFunc {
         }
     };
 
-    /** */
-    private static final IgnitePredicate<IgniteInternalFuture<?>> UNFINISHED_FUTURE = new IgnitePredicate<IgniteInternalFuture<?>>() {
-        @Override public boolean apply(IgniteInternalFuture<?> f) {
-            return !f.isDone();
-        }
-    };
-
     /**
      * Gets predicate that evaluates to {@code true} only for given local node ID.
      *
@@ -1409,21 +1399,6 @@ public class GridFunc {
     }
 
     /**
-     * Converts given runnable to an absolute closure.
-     *
-     * @param r Runnable to convert to closure. If {@code null} - no-op closure is returned.
-     * @return Closure that wraps given runnable. Note that wrapping closure always returns {@code null}.
-     */
-    public static GridAbsClosure as(@Nullable final Runnable r) {
-        return new CA() {
-            @Override public void apply() {
-                if (r != null)
-                    r.run();
-            }
-        };
-    }
-
-    /**
      * Gets size of the given collection with provided optional predicates.
      *
      * @param c Collection to size.
@@ -3817,35 +3792,6 @@ public class GridFunc {
     }
 
     /**
-     * @param arr Array.
-     * @param val Value to find.
-     * @return {@code True} if array contains given value.
-     */
-    public static boolean contains(Integer[] arr, int val) {
-        for (Integer el : arr) {
-            if (el == val)
-                return true;
-        }
-
-        return false;
-    }
-
-    /**
-     * @param arr Array.
-     * @param val Value to find.
-     * @return {@code True} if array contains given value.
-     */
-    @SuppressWarnings("ForLoopReplaceableByForEach")
-    public static boolean contains(long[] arr, long val) {
-        for (int i = 0; i < arr.length; i++) {
-            if (arr[i] == val)
-                return true;
-        }
-
-        return false;
-    }
-
-    /**
      * Tests whether specified arguments are equal, or both {@code null}.
      *
      * @param o1 Object to compare.
@@ -4017,74 +3963,6 @@ public class GridFunc {
     }
 
     /**
-     * Compares two arrays. Unlike {@code Arrays#equals(...)} method this implementation
-     * checks two arrays as sets allowing the same elements to be in different indexes.
-     *
-     * @param a1 First array to check.
-     * @param a2 Second array to check.
-     * @param sorted Tells whether or not both arrays are pre-sorted so that binary
-     *      search could be used instead of iteration.
-     * @param dups Tells whether or not arrays can contain duplicates. If arrays contain
-     *      duplicate the implementation will have to do double work.
-     * @return {@code True} if arrays are equal, {@code false} otherwise.
-     */
-    public static boolean eqArray(Object[] a1, Object[] a2, boolean sorted, boolean dups) {
-        if (a1 == a2)
-            return true;
-
-        if (a1 == null || a2 == null || a1.length != a2.length)
-            return false;
-
-        // Short circuit.
-        if (a1.length == 1)
-            return eq(a1[0], a2[0]);
-
-        for (Object o1 : a1) {
-            boolean found = false;
-
-            if (sorted)
-                found = Arrays.binarySearch(a2, o1) >= 0;
-            else {
-                for (Object o2 : a2) {
-                    if (eq(o1, o2)) {
-                        found = true;
-
-                        break;
-                    }
-                }
-            }
-
-            if (!found)
-                return false;
-        }
-
-        // If there are no dups - we can't skip checking seconds array
-        // against first one.
-        if (dups) {
-            for (Object o2 : a2) {
-                boolean found = false;
-
-                if (sorted)
-                    found = Arrays.binarySearch(a1, o2) >= 0;
-                else {
-                    for (Object o1 : a1) {
-                        if (eq(o2, o1)) {
-                            found = true;
-
-                            break;
-                        }
-                    }
-                }
-
-                if (!found)
-                    return false;
-            }
-        }
-
-        return true;
-    }
-
-    /**
      * Compares two {@link org.apache.ignite.cluster.ClusterNode} instances for equality.
      * <p>
      * Since introduction of {@link org.apache.ignite.cluster.ClusterNode} in Apache Ignite 3.0 the semantic of equality between
@@ -4152,13 +4030,4 @@ public class GridFunc {
     public static GridClosureException wrap(Throwable e) {
         return new GridClosureException(e);
     }
-
-    /**
-     * Returns predicate for filtering unfinished futures.
-     *
-     * @return Predicate for filtering unfinished futures.
-     */
-    public static IgnitePredicate<IgniteInternalFuture<?>> unfinishedFutures() {
-        return UNFINISHED_FUTURE;
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/597ef1d6/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
index 37e7afe..353367e 100644
--- a/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
@@ -748,8 +748,14 @@ public class GridBasicPerformanceTest {
         for (int i = 0; i < MAX; i++) {
             if (sort)
                 Arrays.binarySearch(arr, ThreadLocalRandom8.current().nextInt(lim));
-            else
-                F.contains(arr, ThreadLocalRandom8.current().nextInt(lim));
+            else {
+                int val = ThreadLocalRandom8.current().nextInt(lim);
+
+                for (long arrItem : arr) {
+                    if (arrItem == val)
+                        break;
+                }
+            }
         }
 
         long time =  System.currentTimeMillis() - start;


[2/3] ignite git commit: IGNITE-2263: Removing unused stuff.

Posted by vo...@apache.org.
IGNITE-2263: Removing unused stuff.


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

Branch: refs/heads/ignite-2263
Commit: e91d6e614c20da3a2fe6a6163e059f40ce772e7e
Parents: 2a66f56
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Dec 29 16:39:59 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Dec 29 16:39:59 2015 +0300

----------------------------------------------------------------------
 .../internal/processors/igfs/IgfsProcessor.java |   8 +-
 .../ignite/internal/util/lang/GridFunc.java     | 195 -------------------
 2 files changed, 2 insertions(+), 201 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e91d6e61/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
index 5b8cf86..b313084 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
@@ -45,7 +45,6 @@ import org.apache.ignite.internal.IgniteNodeAttributes;
 import org.apache.ignite.internal.processors.query.GridQueryProcessor;
 import org.apache.ignite.internal.util.ipc.IpcServerEndpoint;
 import org.apache.ignite.internal.util.typedef.C1;
-import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -128,11 +127,8 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
 
         final Map<String, CacheConfiguration> cacheCfgs = new HashMap<>();
 
-        F.forEach(gridCfg.getCacheConfiguration(), new CI1<CacheConfiguration>() {
-            @Override public void apply(CacheConfiguration c) {
-                cacheCfgs.put(c.getName(), c);
-            }
-        });
+        for (CacheConfiguration c : gridCfg.getCacheConfiguration())
+            cacheCfgs.put(c.getName(), c);
 
         Collection<IgfsAttributes> attrVals = new ArrayList<>();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e91d6e61/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index 525269b..3e7b122 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -232,17 +232,6 @@ public class GridFunc {
     };
 
     /** */
-    private static final IgniteCallable<?> ATOMIC_REF_FACTORY = new IgniteCallable<AtomicReference>() {
-        @Override public AtomicReference call() {
-            return new AtomicReference();
-        }
-
-        @Override public String toString() {
-            return "Atomic reference factory.";
-        }
-    };
-
-    /** */
     private static final IgniteCallable<?> MAP_FACTORY = new IgniteCallable<Map>() {
         @Override public Map call() {
             return new HashMap();
@@ -2130,40 +2119,6 @@ public class GridFunc {
     }
 
     /**
-     * Utility map getter. This method analogous to {@link #addIfAbsent(Map, Object, Callable)}
-     * method but this one doesn't put the default value into the map when key is not found.
-     *
-     * @param map Map to get value from.
-     * @param key Map key (can be {@code null}).
-     * @param c Optional factory closure for the default value to be returned in
-     *      when {@code key} is not found. If closure is not provided - {@code null} will be returned.
-     * @param <K> Map key type.
-     * @param <V> Map value type.
-     * @return Value for the {@code key} or default value produced by {@code c} if key is not
-     *      found (or {@code null} if key is not found and closure is not provided).
-     * @throws GridClosureException Thrown in case when callable throws exception.
-     * @see #newLinkedList()
-     * @see #newList()
-     * @see #newSet()
-     * @see #newMap()
-     * @see #newAtomicLong()
-     * @see #newAtomicInt()
-     * @see #newAtomicRef()
-     * @see #newAtomicBoolean()
-     */
-    @Nullable public static <K, V> V returnIfAbsent(Map<? extends K, ? extends V> map, @Nullable K key,
-        @Nullable Callable<V> c) {
-        A.notNull(map, "map");
-
-        try {
-            return !map.containsKey(key) ? c == null ? null : c.call() : map.get(key);
-        }
-        catch (Exception e) {
-            throw wrap(e);
-        }
-    }
-
-    /**
      * Returns a factory closure that creates new {@link ConcurrentLinkedDeque8} instance.
      * Note that this method does not create a new closure but returns a static one.
      *
@@ -2214,45 +2169,6 @@ public class GridFunc {
     }
 
     /**
-     * Returns a factory closure that creates new {@link AtomicReference} instance
-     * initialized to {@code null}. Note that this method does not create a new closure
-     * but returns a static one.
-     *
-     * @param <T> Type of the atomic reference.
-     * @return Factory closure that creates new {@link AtomicReference} instance
-     *      initialized to {@code null} every time its {@link org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
-     */
-    @SuppressWarnings("unchecked")
-    public static <T> IgniteCallable<AtomicReference<T>> newAtomicRef() {
-        return (IgniteCallable<AtomicReference<T>>)ATOMIC_REF_FACTORY;
-    }
-
-    /**
-     * Returns a factory closure that creates new {@link AtomicBoolean} instance
-     * initialized to {@code false}. Note that this method does not create a new
-     * closure but returns a static one.
-     *
-     * @return Factory closure that creates new {@link AtomicBoolean} instance
-     *      initialized to {@code false} every time its {@link org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
-     */
-    public static IgniteCallable<AtomicBoolean> newAtomicBoolean() {
-        return ATOMIC_BOOL_FACTORY;
-    }
-
-    /**
-     * Returns a factory closure that creates new {@link LinkedList} instance.
-     * Note that this method does not create a new closure but returns a static one.
-     *
-     * @param <T> Type parameters for the created {@link LinkedList}.
-     * @return Factory closure that creates new {@link LinkedList} instance every time its {@link
-     *         org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
-     */
-    @SuppressWarnings("unchecked")
-    public static <T> IgniteCallable<LinkedList<T>> newLinkedList() {
-        return (IgniteCallable<LinkedList<T>>)LINKED_LIST_FACTORY;
-    }
-
-    /**
      * Returns a factory closure that creates new {@link Set} instance. Note that this
      * method does not create a new closure but returns a static one.
      *
@@ -2983,14 +2899,11 @@ public class GridFunc {
      *      found (or {@code null} if key is not found and closure is not provided). Note that
      *      in case when key is not found the default value will be put into the map.
      * @throws GridClosureException Thrown in case when callable throws exception.
-     * @see #newLinkedList()
      * @see #newList()
      * @see #newSet()
      * @see #newMap()
      * @see #newAtomicLong()
      * @see #newAtomicInt()
-     * @see #newAtomicRef()
-     * @see #newAtomicBoolean()
      */
     @Nullable public static <K, V> V addIfAbsent(Map<? super K, V> map, @Nullable K key,
         @Nullable Callable<? extends V> c) {
@@ -3085,25 +2998,6 @@ public class GridFunc {
     }
 
     /**
-     * Calls given {@code side-effect only} closure over the each element of the provided array.
-     *
-     * @param c Array to call closure over.
-     * @param f Side-effect only closure to call over the array.
-     * @param p Optional set of predicates. Only if collection element evaluates
-     *      to {@code true} for given predicates the closure will be applied to it.
-     *      If no predicates provided - closure will be applied to all collection
-     *      elements.
-     * @param <X> Type of the free variable for the closure and type of the array
-     *      elements.
-     */
-    @SuppressWarnings("RedundantTypeArguments")
-    public static <X> void forEach(X[] c, IgniteInClosure<? super X> f, @Nullable IgnitePredicate<? super X>... p) {
-        A.notNull(c, "c", f, "f");
-
-        F.<X>forEach(asList(c), f, p);
-    }
-
-    /**
      * Adds (copies) to given collection all elements in <tt>'from'</tt> array.
      *
      * @param to Collection to copy to.
@@ -4260,95 +4154,6 @@ public class GridFunc {
     }
 
     /**
-     * Checks if two collections passed in intersect.
-     *
-     * @param <E> Element type.
-     * @param s1 Set1.
-     * @param s2 Set2.
-     * @return {@code True} if there is an intersection, {@code false} otherwise.
-     */
-    public static <E> boolean intersects(Iterable<E> s1, Collection<E>... s2) {
-        for (E e1 : s1) {
-            for (Collection<E> s : s2) {
-                if (s.contains(e1))
-                    return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Waits until all passed futures will be executed.
-     *
-     * @param futs Futures. If none provided - this method is no-op.
-     * @throws IgniteCheckedException If any of the futures failed.
-     */
-    public static <T> void awaitAll(@Nullable Collection<IgniteInternalFuture<T>> futs) throws IgniteCheckedException {
-        awaitAll(0, null, futs);
-    }
-
-    /**
-     * Waits until all passed futures will be executed.
-     *
-     * @param timeout Timeout for waiting ({@code 0} for forever).
-     * @param futs Futures. If none provided - this method is no-op.
-     * @throws IgniteCheckedException If any of the futures failed.
-     */
-    public static <T> void awaitAll(long timeout, @Nullable Collection<IgniteInternalFuture<T>> futs) throws IgniteCheckedException {
-        awaitAll(timeout, null, futs);
-    }
-
-    /**
-     * Awaits for all futures to complete and optionally reduces all results into one.
-     *
-     * @param timeout Timeout for waiting ({@code 0} for forever).
-     * @param rdc Optional reducer. If not {@code null}, then results will be reduced into one.
-     * @param futs List of futures to wait for.
-     * @param <T> Return type of the futures.
-     * @param <R> Return type of the reducer.
-     * @return Reduced result if reducer is provided, {@code null} otherwise.
-     * @throws IgniteCheckedException If any of the futures failed.
-     */
-    @Nullable public static <T, R> R awaitAll(long timeout, @Nullable IgniteReducer<T, R> rdc,
-        @Nullable Collection<IgniteInternalFuture<T>> futs) throws IgniteCheckedException {
-        if (futs == null || futs.isEmpty())
-            return null;
-
-        long end = timeout == 0 ? Long.MAX_VALUE : U.currentTimeMillis() + timeout;
-
-        // Overflow.
-        if (end < 0)
-            end = Long.MAX_VALUE;
-
-        // Note that it is important to wait in the natural order of collection and
-        // not via listen method, because caller may actually add to this collection
-        // concurrently while this method is in progress.
-        for (IgniteInternalFuture<T> fut : futs) {
-            T t;
-
-            if (timeout > 0) {
-                long left = end - U.currentTimeMillis();
-
-                if (left <= 0 && !fut.isDone())
-                    throw new IgniteFutureTimeoutCheckedException("Timed out waiting for all futures: " + futs);
-
-                if (fut.isDone() && left < 0)
-                    left = 0;
-
-                t = fut.get(left);
-            }
-            else
-                t = fut.get();
-
-            if (rdc != null)
-                rdc.collect(t);
-        }
-
-        return rdc == null ? null : rdc.reduce();
-    }
-
-    /**
      * Returns predicate for filtering unfinished futures.
      *
      * @return Predicate for filtering unfinished futures.