#ignite-683: Remove filters from CacheProjection keySet.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/854e1981 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/854e1981 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/854e1981 Branch: refs/heads/ignite-683 Commit: 854e19814b580e55c3810b7ddb35169c9c9cd5b7 Parents: 8d70d11 Author: ivasilinets <ivasilin...@gridgain.com> Authored: Wed Apr 8 00:53:17 2015 +0300 Committer: ivasilinets <ivasilin...@gridgain.com> Committed: Wed Apr 8 00:53:17 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/CacheProjection.java | 22 +------------- .../processors/cache/GridCacheAdapter.java | 31 ++++++++++++++++++-- .../cache/GridCacheProjectionImpl.java | 12 ++------ .../processors/cache/GridCacheProxyImpl.java | 17 ++--------- 4 files changed, 35 insertions(+), 47 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/854e1981/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java index 751da4a..4e93018 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java @@ -830,23 +830,6 @@ public interface CacheProjection<K, V> extends Iterable<Cache.Entry<K, V>> { public Set<K> keySet(); /** - * Set of keys cached on this node. You can remove elements from this set, but you cannot add elements - * to this set. All removal operation will be reflected on the cache itself. - * <p> - * Iterator over this set will not fail if set was concurrently updated - * by another thread. This means that iterator may or may not return latest - * keys depending on whether they were added before or after current - * iterator position. - * <p> - * NOTE: this operation is not distributed and returns only the keys cached on this node. - * - * @param filter Optional filter to check prior to getting key form cache. Note - * that filter is checked atomically together with get operation. - * @return Key set for this cache projection. - */ - public Set<K> keySet(@Nullable CacheEntryPredicate... filter); - - /** * Set of keys for which this node is primary. * This set is dynamic and may change with grid topology changes. * Note that this set will contain mappings for all keys, even if their values are @@ -1240,15 +1223,12 @@ public interface CacheProjection<K, V> extends Iterable<Cache.Entry<K, V>> { * if there is one. * * @param key Key whose mapping is to be removed from cache. - * @param filter Optional filter to check prior to removing value form cache. Note - * that filter is checked atomically together with remove operation. * @return Future for the remove operation. The future will return {@code true} * if optional filters passed validation and remove did occur, {@code false} otherwise. * Note that if filter is not specified, this method will return {@code true}. * @throws NullPointerException if the key is {@code null}. */ - public IgniteInternalFuture<Boolean> removexAsync(K key, - @Nullable CacheEntryPredicate... filter); + public IgniteInternalFuture<Boolean> removexAsync(K key); /** * Removes given key mapping from cache if one exists and value is equal to the passed in value. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/854e1981/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 95fd3fd..1a8b7b2 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 @@ -3024,7 +3024,34 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, } /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> removexAsync(K key, CacheEntryPredicate... filter) { + @Override public IgniteInternalFuture<Boolean> removexAsync(K key) { + A.notNull(key, "key"); + + return removexAsync(key, null, CU.empty0()); + } + + + /** + * Asynchronously removes given key mapping from cache. + * <p> + * This method will return {@code true} if remove did occur, which means that all optionally + * provided filters have passed and there was something to remove, {@code false} otherwise. + * <p> + * If write-through is enabled, the value will be removed from {@link org.apache.ignite.cache.store.CacheStore} + * via <code>CacheStore#remove(Transaction, Object)</code> method. + * <h2 class="header">Transactions</h2> + * This method is transactional and will enlist the entry into ongoing transaction + * if there is one. + * + * @param key Key whose mapping is to be removed from cache. + * @param filter Optional filter to check prior to removing value form cache. Note + * that filter is checked atomically together with remove operation. + * @return Future for the remove operation. The future will return {@code true} + * if optional filters passed validation and remove did occur, {@code false} otherwise. + * Note that if filter is not specified, this method will return {@code true}. + * @throws NullPointerException if the key is {@code null}. + */ + public IgniteInternalFuture<Boolean> removexAsync(K key, CacheEntryPredicate... filter) { A.notNull(key, "key"); return removexAsync(key, null, filter); @@ -4636,7 +4663,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, * @param filter Filters to evaluate. * @return Key set. */ - @Override public Set<K> keySet(@Nullable CacheEntryPredicate... filter) { + public Set<K> keySet(@Nullable CacheEntryPredicate... filter) { return map.keySet(filter); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/854e1981/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java index 615a6df..96afb74 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java @@ -517,11 +517,6 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K, V } /** {@inheritDoc} */ - @Override public Set<K> keySet(@Nullable CacheEntryPredicate... filter) { - return cache.keySet(filter); - } - - /** {@inheritDoc} */ @Override public Set<K> primaryKeySet() { return cache.primaryKeySet(); } @@ -685,7 +680,7 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K, V /** {@inheritDoc} */ @Override public boolean removex(K key) throws IgniteCheckedException { - return removexAsync(key, (CacheEntryPredicate[])null).get(); + return removexAsync(key).get(); } /** {@inheritDoc} */ @@ -706,9 +701,8 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K, V } /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> removexAsync(K key, - @Nullable CacheEntryPredicate[] filter) { - return removexAsync(key, null, filter); + @Override public IgniteInternalFuture<Boolean> removexAsync(K key) { + return removexAsync(key, null, CU.empty0()); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/854e1981/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java index 3556b47..9627864 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java @@ -948,18 +948,6 @@ public class GridCacheProxyImpl<K, V> implements GridCacheProxy<K, V>, Externali } /** {@inheritDoc} */ - @Override public Set<K> keySet(@Nullable CacheEntryPredicate... filter) { - GridCacheProjectionImpl<K, V> prev = gate.enter(prj); - - try { - return delegate.keySet(filter); - } - finally { - gate.leave(prev); - } - } - - /** {@inheritDoc} */ @Override public Set<K> primaryKeySet() { GridCacheProjectionImpl<K, V> prev = gate.enter(prj); @@ -1418,12 +1406,11 @@ public class GridCacheProxyImpl<K, V> implements GridCacheProxy<K, V>, Externali } /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> removexAsync(K key, - @Nullable CacheEntryPredicate[] filter) { + @Override public IgniteInternalFuture<Boolean> removexAsync(K key) { GridCacheProjectionImpl<K, V> prev = gate.enter(prj); try { - return delegate.removexAsync(key, filter); + return delegate.removexAsync(key); } finally { gate.leave(prev);