ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [03/29] ignite git commit: Revert "IGNITE-2330: Simplified GridFunc."
Date Mon, 18 Jan 2016 08:23:49 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/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 e5d247a..b999e2a 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,6 +34,7 @@ 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/ddbe2d59/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 d1e69b5..c95a859 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,6 +34,7 @@ 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/ddbe2d59/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 7d25996..9790f48 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,6 +34,7 @@ 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/ddbe2d59/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 c904587..044944b 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,6 +34,7 @@ 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/ddbe2d59/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 58e18aa..225366a 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,6 +35,7 @@ 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 {
     /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java b/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java
index 44ca067..5c6bb9a 100644
--- a/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java
+++ b/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java
@@ -186,7 +186,7 @@ public final class IgniteUuid implements Comparable<IgniteUuid>,
Iterable<Ignite
 
     /** {@inheritDoc} */
     @Override public GridIterator<IgniteUuid> iterator() {
-        return F.identityIteratorReadOnly(Collections.singleton(this));
+        return F.iterator(Collections.singleton(this), F.<IgniteUuid>identity(), true);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/memory/MemoryEventStorageSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/memory/MemoryEventStorageSpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/memory/MemoryEventStorageSpi.java
index 56a627a..c7c635e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/memory/MemoryEventStorageSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/memory/MemoryEventStorageSpi.java
@@ -216,7 +216,6 @@ public class MemoryEventStorageSpi extends IgniteSpiAdapter implements
EventStor
     }
 
     /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
     @Override public <T extends Event> Collection<T> localEvents(IgnitePredicate<T>
p) {
         A.notNull(p, "p");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java
index 1e868b7..59a3eca 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java
@@ -21,7 +21,6 @@ import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
@@ -336,8 +335,7 @@ public class GridCacheLuceneQueryIndexTest extends GridCommonAbstractTest
{
                             map = new HashMap<>();
                         }
 
-                        map.put(new ObjectKey(String.valueOf(i)),
-                            vals[ThreadLocalRandom.current().nextInt(vals.length)]);
+                        map.put(new ObjectKey(String.valueOf(i)), F.rand(vals));
                     }
 
                     if (!map.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
index 52737e7..cb24e54 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
@@ -757,7 +757,7 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
             if (TEST_INFO)
                 X.println("Cache event: " + evt.shortDisplay());
 
-            AtomicInteger cntr = F.addIfAbsent(cntrs, evt.type(), new AtomicInteger());
+            AtomicInteger cntr = F.addIfAbsent(cntrs, evt.type(), F.newAtomicInt());
 
             assert cntr != null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java
index 3482fd6..1aae999 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java
@@ -517,16 +517,12 @@ public class IpcSharedMemoryCrashDetectionSelfTest extends GridCommonAbstractTes
          * @param shmemIds Shared memory IDs string.
          */
         public void shmemIds(String shmemIds) {
-            if (shmemIds == null)
-                this.shmemIds = null;
-            else {
-                String[] tokens = shmemIds.split(",");
-
-                this.shmemIds = new ArrayList<>(tokens.length);
-
-                for (String token : tokens)
-                    this.shmemIds.add(Long.valueOf(token).intValue());
-            }
+            this.shmemIds = (shmemIds == null) ? null :
+                F.transform(shmemIds.split(","), new C1<String, Integer>() {
+                    @Override public Integer apply(String s) {
+                        return Long.valueOf(s).intValue();
+                    }
+                });
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/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 353367e..37e7afe 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,14 +748,8 @@ public class GridBasicPerformanceTest {
         for (int i = 0; i < MAX; i++) {
             if (sort)
                 Arrays.binarySearch(arr, ThreadLocalRandom8.current().nextInt(lim));
-            else {
-                int val = ThreadLocalRandom8.current().nextInt(lim);
-
-                for (long arrItem : arr) {
-                    if (arrItem == val)
-                        break;
-                }
-            }
+            else
+                F.contains(arr, ThreadLocalRandom8.current().nextInt(lim));
         }
 
         long time =  System.currentTimeMillis() - start;

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/test/java/org/apache/ignite/lang/GridFuncPerformanceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridFuncPerformanceTest.java
b/modules/core/src/test/java/org/apache/ignite/lang/GridFuncPerformanceTest.java
new file mode 100644
index 0000000..5afd75f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/lang/GridFuncPerformanceTest.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.lang;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.apache.ignite.internal.util.lang.GridIterator;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.common.GridCommonTest;
+
+/**
+ * GridFunc performance test.
+ */
+@GridCommonTest(group = "Lang")
+public class GridFuncPerformanceTest extends GridCommonAbstractTest {
+    /**
+     *  Creates test.
+     */
+    public GridFuncPerformanceTest() {
+        super(/*start grid*/false);
+    }
+
+    /**
+     *
+     */
+    public void testTransformingIteratorPerformance() {
+        // Warmup.
+        testBody();
+        testBody();
+        testBody();
+
+        long r1 = testBody();
+        long r2 = testBody();
+        long r3 = testBody();
+
+        double r = (r1 + r2 + r3) / 3.f;
+
+        System.out.println("Average result is: " + Math.round(r) + "msec.");
+    }
+
+    /**
+     *
+     * @return Duration of the test.
+     */
+    @SuppressWarnings({"UnusedDeclaration"})
+    private long testBody() {
+        int MAX = 20000000;
+
+        Collection<Integer> l = new ArrayList<>(MAX);
+
+        for (int i = 0; i < MAX / 10; i++)
+            l.add(i);
+
+        IgniteClosure<Integer, Integer> c = new IgniteClosure<Integer, Integer>()
{
+            @Override public Integer apply(Integer e) {
+                return e;
+            }
+        };
+
+        IgnitePredicate<Integer> p1 = new IgnitePredicate<Integer>() {
+            @Override public boolean apply(Integer e) {
+                return e % 2 == 0;
+            }
+        };
+        IgnitePredicate<Integer> p2 = new IgnitePredicate<Integer>() {
+            @Override public boolean apply(Integer e) {
+                return e % 2 != 0;
+            }
+        };
+
+        GridIterator<Integer> iter = F.iterator(l, c, true, p1, p2);
+
+        long n = 0;
+
+        long start = System.currentTimeMillis();
+
+        for (Integer i : iter)
+            n += i;
+
+        long duration = System.currentTimeMillis() - start;
+
+        System.out.println("Duration: " + duration + "msec.");
+
+        return duration;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/test/java/org/apache/ignite/loadtest/GridLoadTestStatistics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtest/GridLoadTestStatistics.java
b/modules/core/src/test/java/org/apache/ignite/loadtest/GridLoadTestStatistics.java
index 10b140e..5d517a4 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtest/GridLoadTestStatistics.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtest/GridLoadTestStatistics.java
@@ -107,7 +107,7 @@ public class GridLoadTestStatistics {
                     AtomicInteger cnt;
 
                     synchronized (nodeCnts) {
-                        cnt = F.addIfAbsent(nodeCnts, id, new AtomicInteger());
+                        cnt = F.addIfAbsent(nodeCnts, id, F.newAtomicInt());
                     }
 
                     assert cnt != null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
index 9582df0..28adeee 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
@@ -24,10 +24,10 @@ import java.util.Iterator;
 import java.util.NavigableMap;
 import java.util.concurrent.ConcurrentNavigableMap;
 import java.util.concurrent.ConcurrentSkipListMap;
+import org.apache.ignite.internal.util.GridEmptyIterator;
 import org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSnapTreeMap;
 import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeGuard;
 import org.apache.ignite.internal.util.snaptree.SnapTreeMap;
-import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.spi.indexing.IndexingQueryFilter;
@@ -319,7 +319,7 @@ public class GridH2TreeIndex extends GridH2IndexBase implements Comparator<GridS
             comparable(last, 1));
 
         if (range == null)
-            return F.emptyIterator();
+            return new GridEmptyIterator<>();
 
         return filter(range.values().iterator());
     }


Mime
View raw message