ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [6/8] ignite git commit: IGNITE-2263: Moved cache-related methods to GridCacheUtils.
Date Wed, 30 Dec 2015 09:52:25 GMT
IGNITE-2263: Moved cache-related methods to GridCacheUtils.


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

Branch: refs/heads/ignite-2263
Commit: 94cf22b3fdd140a85b239a1e3a5e335d995b1ebb
Parents: 5f780be
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Wed Dec 30 12:46:45 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Wed Dec 30 12:46:45 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheKeySet.java       |  2 +-
 .../processors/cache/GridCacheUtils.java        | 72 +++++++++++++++++++
 .../cache/GridCacheValueCollection.java         |  5 +-
 .../distributed/near/GridNearCacheAdapter.java  |  3 +-
 .../ignite/internal/util/lang/GridFunc.java     | 75 +-------------------
 5 files changed, 79 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/94cf22b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
index 6d18b7d..af0c704 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
@@ -66,7 +66,7 @@ public class GridCacheKeySet<K, V> extends GridSerializableSet<K>
{
 
     /** {@inheritDoc} */
     @Override public Iterator<K> iterator() {
-        return new GridCacheIterator<>(ctx, map.values(), F.<K, V>cacheEntry2Key(),
filter);
+        return new GridCacheIterator<>(ctx, map.values(), CU.<K, V>cacheEntry2Key(),
filter);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/94cf22b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index ff07ac5..b7baf7e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -286,6 +286,41 @@ public class GridCacheUtils {
         }
     };
 
+    /** */
+    private static final IgniteClosure CACHE_ENTRY_KEY = new IgniteClosure() {
+        @Override public Object apply(Object o) {
+            return ((Cache.Entry)o).getKey();
+        }
+
+        @Override public String toString() {
+            return "Map entry to key transformer closure.";
+        }
+    };
+
+    /** */
+    private static final IgniteClosure CACHE_ENTRY_VAL_GET = new IgniteClosure() {
+        @SuppressWarnings({"unchecked"})
+        @Nullable @Override public Object apply(Object o) {
+            return ((Cache.Entry)o).getValue();
+        }
+
+        @Override public String toString() {
+            return "Cache entry to get-value transformer closure.";
+        }
+    };
+
+    /** */
+    private static final IgnitePredicate CACHE_ENTRY_HAS_PEEK_VAL = new IgnitePredicate()
{
+        @SuppressWarnings({"unchecked"})
+        @Override public boolean apply(Object o) {
+            return ((Cache.Entry)o).getValue() != null;
+        }
+
+        @Override public String toString() {
+            return "Cache entry has-peek-value predicate.";
+        }
+    };
+
     /**
      * Ensure singleton.
      */
@@ -1883,4 +1918,41 @@ public class GridCacheUtils {
                 }
             });
     }
+
+    /**
+     * Gets closure that returns key for cache entry. The closure internally
+     * delegates to {@link javax.cache.Cache.Entry#getKey()} method.
+     *
+     * @param <K> Key type.
+     * @return Closure that returns key for an entry.
+     */
+    @SuppressWarnings({"unchecked"})
+    public static <K, V> IgniteClosure<Cache.Entry<K, V>, K> cacheEntry2Key()
{
+        return (IgniteClosure<Cache.Entry<K, V>, K>)CACHE_ENTRY_KEY;
+    }
+
+    /**
+     * Gets closure that returns value for an entry. The closure internally
+     * delegates to {@link javax.cache.Cache.Entry#get(Object)} method.
+     *
+     * @param <K> Key type.
+     * @param <V> Value type.
+     * @return Closure that returns value for an entry.
+     */
+    @SuppressWarnings({"unchecked"})
+    public static <K, V> IgniteClosure<Cache.Entry<K, V>, V> cacheEntry2Get()
{
+        return (IgniteClosure<Cache.Entry<K, V>, V>)CACHE_ENTRY_VAL_GET;
+    }
+
+    /**
+     * Gets predicate which returns {@code true} if entry has peek value.
+     *
+     * @param <K> Cache key type.
+     * @param <V> Cache value type.
+     * @return Predicate which returns {@code true} if entry has peek value.
+     */
+    @SuppressWarnings({"unchecked"})
+    public static <K, V> IgnitePredicate<Cache.Entry<K, V>> cacheHasPeekValue()
{
+        return (IgnitePredicate<Cache.Entry<K, V>>)CACHE_ENTRY_HAS_PEEK_VAL;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/94cf22b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java
index 2d1686e..68b54b3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridSerializableCollection;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.jetbrains.annotations.Nullable;
 
@@ -72,8 +73,8 @@ public class GridCacheValueCollection<K, V> extends GridSerializableCollection<V
         return new GridCacheIterator<K, V, V>(
             ctx,
             map.values(),
-            F.<K, V>cacheEntry2Get(),
-            ctx.vararg(F0.and(filter, F.<K, V>cacheHasPeekValue()))
+            CU.<K, V>cacheEntry2Get(),
+            ctx.vararg(F0.and(filter, CU.<K, V>cacheHasPeekValue()))
         ) {
             {
                 advance();

http://git-wip-us.apache.org/repos/asf/ignite/blob/94cf22b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
index 5bf18d9..ce17d03 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@ -64,6 +64,7 @@ import org.apache.ignite.internal.util.typedef.C1;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.P1;
 import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteBiPredicate;
 import org.jetbrains.annotations.NotNull;
@@ -416,7 +417,7 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
 
     /** {@inheritDoc} */
     @Override public Collection<V> values(CacheEntryPredicate... filter) {
-        return new GridCacheValueCollection<>(ctx, entrySet(filter), ctx.vararg(F.<K,
V>cacheHasPeekValue()));
+        return new GridCacheValueCollection<>(ctx, entrySet(filter), ctx.vararg(CU.<K,
V>cacheHasPeekValue()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/94cf22b3/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 58b9a91..47c90c3 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
@@ -194,42 +194,6 @@ public class GridFunc {
     };
 
     /** */
-    private static final IgniteClosure CACHE_ENTRY_KEY = new IgniteClosure() {
-        @Override public Object apply(Object o) {
-            return ((Cache.Entry)o).getKey();
-        }
-
-        @Override public String toString() {
-            return "Map entry to key transformer closure.";
-        }
-    };
-
-
-    /** */
-    private static final IgniteClosure CACHE_ENTRY_VAL_GET = new IgniteClosure() {
-        @SuppressWarnings({"unchecked"})
-        @Nullable @Override public Object apply(Object o) {
-            return ((Cache.Entry)o).getValue();
-        }
-
-        @Override public String toString() {
-            return "Cache entry to get-value transformer closure.";
-        }
-    };
-
-    /** */
-    private static final IgnitePredicate CACHE_ENTRY_HAS_PEEK_VAL = new IgnitePredicate()
{
-        @SuppressWarnings({"unchecked"})
-        @Override public boolean apply(Object o) {
-            return ((Cache.Entry)o).getValue() != null;
-        }
-
-        @Override public String toString() {
-            return "Cache entry has-peek-value predicate.";
-        }
-    };
-
-    /** */
     private static final IgniteClosure<ClusterNode, UUID> NODE2ID = new IgniteClosure<ClusterNode,
UUID>() {
         @Override public UUID apply(ClusterNode n) {
             return n.id();
@@ -3513,7 +3477,7 @@ public class GridFunc {
      * @param <T> Element's type.
      * @return Created set.
      */
-    @SuppressWarnings( {"RedundantTypeArguments"})
+    @SuppressWarnings({"RedundantTypeArguments", "unchecked"})
     public static <T> Set<T> asSet(@Nullable T... t) {
         if (t == null || t.length == 0)
             return Collections.<T>emptySet();
@@ -3781,43 +3745,6 @@ public class GridFunc {
     }
 
     /**
-     * Gets closure that returns key for cache entry. The closure internally
-     * delegates to {@link javax.cache.Cache.Entry#getKey()} method.
-     *
-     * @param <K> Key type.
-     * @return Closure that returns key for an entry.
-     */
-    @SuppressWarnings({"unchecked"})
-    public static <K, V> IgniteClosure<Cache.Entry<K, V>, K> cacheEntry2Key()
{
-        return (IgniteClosure<Cache.Entry<K, V>, K>)CACHE_ENTRY_KEY;
-    }
-
-    /**
-     * Gets closure that returns value for an entry. The closure internally
-     * delegates to {@link javax.cache.Cache.Entry#get(Object)} method.
-     *
-     * @param <K> Key type.
-     * @param <V> Value type.
-     * @return Closure that returns value for an entry.
-     */
-    @SuppressWarnings({"unchecked"})
-    public static <K, V> IgniteClosure<Cache.Entry<K, V>, V> cacheEntry2Get()
{
-        return (IgniteClosure<Cache.Entry<K, V>, V>)CACHE_ENTRY_VAL_GET;
-    }
-
-    /**
-     * Gets predicate which returns {@code true} if entry has peek value.
-     *
-     * @param <K> Cache key type.
-     * @param <V> Cache value type.
-     * @return Predicate which returns {@code true} if entry has peek value.
-     */
-    @SuppressWarnings({"unchecked"})
-    public static <K, V> IgnitePredicate<Cache.Entry<K, V>> cacheHasPeekValue()
{
-        return (IgnitePredicate<Cache.Entry<K, V>>)CACHE_ENTRY_HAS_PEEK_VAL;
-    }
-
-    /**
      * Shortcut method that creates an instance of {@link GridClosureException}.
      *
      * @param e Exception to wrap.


Mime
View raw message