ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [09/22] ignite git commit: Reworked "removeAsync".
Date Fri, 01 Apr 2016 08:24:54 GMT
Reworked "removeAsync".


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

Branch: refs/heads/ignite-2931
Commit: 8dc2addc02ea307737d6333b6e75999f46555b83
Parents: 0cb0d5f
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Thu Mar 31 18:01:45 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Thu Mar 31 18:01:45 2016 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/cache/GridCacheAdapter.java  | 8 ++++----
 .../ignite/internal/processors/cache/GridCacheContext.java  | 8 ++++++++
 .../cache/distributed/dht/atomic/GridDhtAtomicCache.java    | 9 +++++----
 .../cache/distributed/near/GridNearAtomicCache.java         | 2 +-
 .../processors/cache/local/atomic/GridLocalAtomicCache.java | 7 ++++---
 5 files changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8dc2addc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 75996f9..5ab9e9a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -2986,7 +2986,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
     @Override public IgniteInternalFuture<Boolean> removeAsync(K key) {
         A.notNull(key, "key");
 
-        return removeAsync(key, CU.empty0());
+        return removeAsync(key, (CacheEntryPredicate)null);
     }
 
     /**
@@ -2994,7 +2994,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
      * @param filter Optional filter.
      * @return Putx operation future.
      */
-    public IgniteInternalFuture<Boolean> removeAsync(final K key, @Nullable final CacheEntryPredicate...
filter) {
+    public IgniteInternalFuture<Boolean> removeAsync(final K key, @Nullable final CacheEntryPredicate
filter) {
         final boolean statsEnabled = ctx.config().isStatisticsEnabled();
 
         final long start = statsEnabled ? System.nanoTime() : 0L;
@@ -3009,13 +3009,13 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
                 return tx.removeAllAsync(ctx,
                     Collections.singletonList(key),
                     /*retval*/false,
-                    filter,
+                    filter != null ? new CacheEntryPredicate[] { filter } : null,
                     /*singleRmv*/true).chain(
                     (IgniteClosure<IgniteInternalFuture<GridCacheReturn>, Boolean>)RET2FLAG);
             }
 
             @Override public String toString() {
-                return "removeAsync [key=" + key + ", filter=" + Arrays.toString(filter)
+ ']';
+                return "removeAsync [key=" + key + ", filter=" + filter + ']';
             }
         });
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/8dc2addc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 996a125..da51995 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -1134,6 +1134,14 @@ public class GridCacheContext<K, V> implements Externalizable
{
 
     /**
      * @param val Value to check.
+     * @return Predicate that checks for value.
+     */
+    public CacheEntryPredicate equalsVal(V val) {
+        return new CacheEntryPredicateContainsValue(toCacheObject(val));
+    }
+
+    /**
+     * @param val Value to check.
      * @return Predicate array that checks for value.
      */
     public CacheEntryPredicate[] equalsValArray(V val) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/8dc2addc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index e4a9f39..fd69018 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -651,15 +651,16 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
 
     /** {@inheritDoc} */
     @Override public boolean remove(K key) throws IgniteCheckedException {
-        return removeAsync(key, CU.empty0()).get();
+        return removeAsync(key, (CacheEntryPredicate)null).get();
     }
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Override public IgniteInternalFuture<Boolean> removeAsync(K key, @Nullable CacheEntryPredicate...
filter) {
+    @Override public IgniteInternalFuture<Boolean> removeAsync(K key, @Nullable CacheEntryPredicate
filter) {
         A.notNull(key, "key");
 
-        return removeAllAsync0(Collections.singletonList(key), null, false, false, filter);
+        return removeAllAsync0(Collections.singletonList(key), null, false, false,
+            filter != null ? new CacheEntryPredicate[] { filter } : null);
     }
 
     /** {@inheritDoc} */
@@ -671,7 +672,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
     @Override public IgniteInternalFuture<Boolean> removeAsync(K key, V val) {
         A.notNull(key, "key", val, "val");
 
-        return removeAsync(key, ctx.equalsValArray(val));
+        return removeAsync(key, ctx.equalsVal(val));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/8dc2addc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
index f8fd984..a97c2ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
@@ -620,7 +620,7 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K,
V> {
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Override public IgniteInternalFuture<Boolean> removeAsync(K key, @Nullable CacheEntryPredicate...
filter) {
+    @Override public IgniteInternalFuture<Boolean> removeAsync(K key, @Nullable CacheEntryPredicate
filter) {
         return dht.removeAsync(key, filter);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/8dc2addc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index f1aa7de..67ec606 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -430,10 +430,11 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K,
V> {
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Override public IgniteInternalFuture<Boolean> removeAsync(K key, @Nullable CacheEntryPredicate...
filter) {
+    @Override public IgniteInternalFuture<Boolean> removeAsync(K key, @Nullable CacheEntryPredicate
filter) {
         A.notNull(key, "key");
 
-        return removeAllAsync0(Collections.singletonList(key), false, false, filter);
+        return removeAllAsync0(Collections.singletonList(key), false, false,
+            filter != null ? new CacheEntryPredicate[] { filter } : null);
     }
 
     /** {@inheritDoc} */
@@ -457,7 +458,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K,
V> {
 
     /** {@inheritDoc} */
     @Override public IgniteInternalFuture<Boolean> removeAsync(K key, V val) {
-        return removeAsync(key, ctx.equalsValArray(val));
+        return removeAsync(key, ctx.equalsVal(val));
     }
 
     /** {@inheritDoc} */


Mime
View raw message