IGNITE-2931: Simplified filters in GridCacheAdapter and related classes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/244441a4 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/244441a4 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/244441a4 Branch: refs/heads/ignite-2004 Commit: 244441a484785ac2f7b300d6b0bc73cdaf5f8e69 Parents: 1aa2a2b Author: vozerov-gridgain <[email protected]> Authored: Fri Apr 1 14:23:35 2016 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Fri Apr 1 14:23:35 2016 +0300 ---------------------------------------------------------------------- .../cache/CacheEvictableEntryImpl.java | 2 +- .../processors/cache/GridCacheAdapter.java | 158 +++++-------------- .../processors/cache/GridCacheContext.java | 18 +-- .../processors/cache/GridCacheMapEntry.java | 4 +- .../processors/cache/GridCacheUtils.java | 10 ++ .../GridDistributedTxRemoteAdapter.java | 3 +- .../dht/atomic/GridDhtAtomicCache.java | 61 +++---- .../distributed/near/GridNearAtomicCache.java | 15 +- .../distributed/near/GridNearCacheAdapter.java | 30 +--- .../local/atomic/GridLocalAtomicCache.java | 60 +++---- .../cache/transactions/IgniteInternalTx.java | 4 +- .../cache/transactions/IgniteTxAdapter.java | 3 +- .../transactions/IgniteTxLocalAdapter.java | 62 +++----- .../cache/transactions/IgniteTxLocalEx.java | 8 +- 14 files changed, 158 insertions(+), 280 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java index be377c3..b32362a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java @@ -129,7 +129,7 @@ public class CacheEvictableEntryImpl<K, V> implements EvictableEntry<K, V> { IgniteInternalTx tx = cached.context().tm().userTx(); if (tx != null) { - GridTuple<CacheObject> peek = tx.peek(cached.context(), false, cached.key(), null); + GridTuple<CacheObject> peek = tx.peek(cached.context(), false, cached.key()); if (peek != null) return peek.get().value(cached.context().cacheObjectContext(), false); http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/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 d6571cc..cfef152 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 @@ -1026,41 +1026,22 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V /** {@inheritDoc} */ @Override public Set<K> keySet() { - return keySet((CacheEntryPredicate[])null); + return map.keySet(); } /** {@inheritDoc} */ @Override public Set<K> keySetx() { - return keySetx((CacheEntryPredicate[])null); + return map.keySetx(); } /** {@inheritDoc} */ @Override public Set<K> primaryKeySet() { - return primaryKeySet((CacheEntryPredicate[])null); + return map.keySet(CU.cachePrimary(ctx.grid().affinity(ctx.name()), ctx.localNode())); } /** {@inheritDoc} */ @Override public Collection<V> values() { - return values((CacheEntryPredicate[])null); - } - - /** - * Collection of values cached on this node. You can remove - * elements from this collection, but you cannot add elements to this collection. - * All removal operation will be reflected on the cache itself. - * <p> - * Iterator over this collection will not fail if collection was - * concurrently updated by another thread. This means that iterator may or - * may not return latest values depending on whether they were added before - * or after current iterator position. - * <p> - * NOTE: this operation is not distributed and returns only the values cached on this node. - * - * @param filter Filters. - * @return Collection of cached values. - */ - public Collection<V> values(CacheEntryPredicate... filter) { - return map.values(filter); + return map.values(); } /** @@ -2083,7 +2064,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V /** {@inheritDoc} */ @Override public V getAndPut(K key, V val) throws IgniteCheckedException { - return getAndPut(key, val, CU.empty0()); + return getAndPut(key, val, null); } /** @@ -2093,7 +2074,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V * @return Previous value. * @throws IgniteCheckedException If failed. */ - @Nullable public V getAndPut(final K key, final V val, @Nullable final CacheEntryPredicate[] filter) + @Nullable public V getAndPut(final K key, final V val, @Nullable final CacheEntryPredicate filter) throws IgniteCheckedException { boolean statsEnabled = ctx.config().isStatisticsEnabled(); @@ -2111,7 +2092,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "put [key=" + key + ", val=" + val + ", filter=" + Arrays.toString(filter) + ']'; + return "put [key=" + key + ", val=" + val + ", filter=" + filter + ']'; } }); @@ -2123,7 +2104,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V /** {@inheritDoc} */ @Override public IgniteInternalFuture<V> getAndPutAsync(K key, V val) { - return getAndPutAsync(key, val, CU.empty0()); + return getAndPutAsync(key, val, null); } /** @@ -2132,7 +2113,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V * @param filter Filter. * @return Put operation future. */ - public IgniteInternalFuture<V> getAndPutAsync(K key, V val, @Nullable CacheEntryPredicate[] filter) { + public IgniteInternalFuture<V> getAndPutAsync(K key, V val, @Nullable CacheEntryPredicate filter) { final boolean statsEnabled = ctx.config().isStatisticsEnabled(); final long start = statsEnabled ? System.nanoTime() : 0L; @@ -2152,7 +2133,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V * @return Put operation future. */ public IgniteInternalFuture<V> getAndPutAsync0(final K key, final V val, - @Nullable final CacheEntryPredicate... filter) { + @Nullable final CacheEntryPredicate filter) { A.notNull(key, "key", val, "val"); if (keyCheck) @@ -2165,14 +2146,14 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "putAsync [key=" + key + ", val=" + val + ", filter=" + Arrays.toString(filter) + ']'; + return "putAsync [key=" + key + ", val=" + val + ", filter=" + filter + ']'; } }); } /** {@inheritDoc} */ @Override public boolean put(final K key, final V val) throws IgniteCheckedException { - return put(key, val, CU.empty0()); + return put(key, val, null); } /** @@ -2184,7 +2165,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V * specified. * @throws IgniteCheckedException If put operation failed. */ - public boolean put(final K key, final V val, final CacheEntryPredicate[] filter) + public boolean put(final K key, final V val, final CacheEntryPredicate filter) throws IgniteCheckedException { boolean statsEnabled = ctx.config().isStatisticsEnabled(); @@ -2201,7 +2182,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "putx [key=" + key + ", val=" + val + ", filter=" + Arrays.toString(filter) + ']'; + return "putx [key=" + key + ", val=" + val + ", filter=" + filter + ']'; } }); @@ -2479,7 +2460,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> putAsync(K key, V val) { - return putAsync(key, val, CU.empty0()); + return putAsync(key, val, null); } /** @@ -2488,7 +2469,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V * @param filter Filter. * @return Put future. */ - public IgniteInternalFuture<Boolean> putAsync(K key, V val, @Nullable CacheEntryPredicate... filter) { + public IgniteInternalFuture<Boolean> putAsync(K key, V val, @Nullable CacheEntryPredicate filter) { final boolean statsEnabled = ctx.config().isStatisticsEnabled(); final long start = statsEnabled ? System.nanoTime() : 0L; @@ -2508,7 +2489,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V * @return Putx operation future. */ public IgniteInternalFuture<Boolean> putAsync0(final K key, final V val, - @Nullable final CacheEntryPredicate... filter) { + @Nullable final CacheEntryPredicate filter) { A.notNull(key, "key", val, "val"); if (keyCheck) @@ -2521,7 +2502,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "putxAsync [key=" + key + ", val=" + val + ", filter=" + Arrays.toString(filter) + ']'; + return "putxAsync [key=" + key + ", val=" + val + ", filter=" + filter + ']'; } }); } @@ -2541,7 +2522,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V return syncOp(new SyncOp<V>(true) { @Override public V op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { - return (V)tx.putAsync(ctx, key, val, true, ctx.noValArray()).get().value(); + return (V)tx.putAsync(ctx, key, val, true, ctx.noVal()).get().value(); } @Override public String toString() { @@ -2563,7 +2544,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V IgniteInternalFuture<V> fut = asyncOp(new AsyncOp<V>() { @Override public IgniteInternalFuture<V> op(IgniteTxLocalAdapter tx) { - return tx.putAsync(ctx, key, val, true, ctx.noValArray()) + return tx.putAsync(ctx, key, val, true, ctx.noVal()) .chain((IgniteClosure<IgniteInternalFuture<GridCacheReturn>, V>)RET2VAL); } @@ -2591,7 +2572,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V Boolean stored = syncOp(new SyncOp<Boolean>(true) { @Override public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { - return tx.putAsync(ctx, key, val, false, ctx.noValArray()).get().success(); + return tx.putAsync(ctx, key, val, false, ctx.noVal()).get().success(); } @Override public String toString() { @@ -2618,7 +2599,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V IgniteInternalFuture<Boolean> fut = asyncOp(new AsyncOp<Boolean>() { @Override public IgniteInternalFuture<Boolean> op(IgniteTxLocalAdapter tx) { - return tx.putAsync(ctx, key, val, false, ctx.noValArray()).chain( + return tx.putAsync(ctx, key, val, false, ctx.noVal()).chain( (IgniteClosure<IgniteInternalFuture<GridCacheReturn>, Boolean>)RET2FLAG); } @@ -2642,7 +2623,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V return syncOp(new SyncOp<V>(true) { @Override public V op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { - return (V)tx.putAsync(ctx, key, val, true, ctx.hasValArray()).get().value(); + return (V)tx.putAsync(ctx, key, val, true, ctx.hasVal()).get().value(); } @Override public String toString() { @@ -2664,7 +2645,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V IgniteInternalFuture<V> fut = asyncOp(new AsyncOp<V>() { @Override public IgniteInternalFuture<V> op(IgniteTxLocalAdapter tx) { - return tx.putAsync(ctx, key, val, true, ctx.hasValArray()).chain( + return tx.putAsync(ctx, key, val, true, ctx.hasVal()).chain( (IgniteClosure<IgniteInternalFuture<GridCacheReturn>, V>)RET2VAL); } @@ -2688,7 +2669,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V return syncOp(new SyncOp<Boolean>(true) { @Override public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { - return tx.putAsync(ctx, key, val, false, ctx.hasValArray()).get().success(); + return tx.putAsync(ctx, key, val, false, ctx.hasVal()).get().success(); } @Override public String toString() { @@ -2706,7 +2687,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V return asyncOp(new AsyncOp<Boolean>() { @Override public IgniteInternalFuture<Boolean> op(IgniteTxLocalAdapter tx) { - return tx.putAsync(ctx, key, val, false, ctx.hasValArray()).chain( + return tx.putAsync(ctx, key, val, false, ctx.hasVal()).chain( (IgniteClosure<IgniteInternalFuture<GridCacheReturn>, Boolean>) RET2FLAG); } @@ -2729,8 +2710,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V if (ctx.deploymentEnabled()) ctx.deploy().registerClass(oldVal); - return tx.putAsync(ctx, key, newVal, false, ctx.equalsValArray(oldVal)).get() - .success(); + return tx.putAsync(ctx, key, newVal, false, ctx.equalsVal(oldVal)).get().success(); } @Override public String toString() { @@ -2762,7 +2742,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } } - return tx.putAsync(ctx, key, newVal, false, ctx.equalsValArray(oldVal)).chain( + return tx.putAsync(ctx, key, newVal, false, ctx.equalsVal(oldVal)).chain( (IgniteClosure<IgniteInternalFuture<GridCacheReturn>, Boolean>)RET2FLAG); } @@ -2791,7 +2771,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V syncOp(new SyncInOp(m.size() == 1) { @Override public void inOp(IgniteTxLocalAdapter tx) throws IgniteCheckedException { - tx.putAllAsync(ctx, m, false, CU.empty0()).get(); + tx.putAllAsync(ctx, m, false).get(); } @Override public String toString() { @@ -2813,7 +2793,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V return asyncOp(new AsyncInOp(m.keySet()) { @Override public IgniteInternalFuture<?> inOp(IgniteTxLocalAdapter tx) { - return tx.putAllAsync(ctx, m, false, CU.empty0()).chain(RET2NULL); + return tx.putAllAsync(ctx, m, false).chain(RET2NULL); } @Override public String toString() { @@ -2838,7 +2818,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V V ret = tx.removeAllAsync(ctx, Collections.singletonList(key), /*retval*/true, - CU.empty0(), + null, /*singleRmv*/false).get().value(); if (ctx.config().getInterceptor() != null) @@ -2875,7 +2855,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V return tx.removeAllAsync(ctx, Collections.singletonList(key), /*retval*/true, - CU.empty0(), + null, /*singleRmv*/false).chain((IgniteClosure<IgniteInternalFuture<GridCacheReturn>, V>)RET2VAL); } @@ -2925,7 +2905,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V tx.removeAllAsync(ctx, keys, /*retval*/false, - CU.empty0(), + null, /*singleRmv*/false).get(); } @@ -2955,7 +2935,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V return tx.removeAllAsync(ctx, keys, /*retval*/false, - CU.empty0(), + null, /*singleRmv*/false).chain(RET2NULL); } @@ -2986,7 +2966,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V return tx.removeAllAsync(ctx, Collections.singletonList(key), /*retval*/false, - CU.empty0(), + null, /*singleRmv*/true).get().success(); } @@ -3005,7 +2985,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); } /** @@ -3013,7 +2993,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; @@ -3034,7 +3014,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "removeAsync [key=" + key + ", filter=" + Arrays.toString(filter) + ']'; + return "removeAsync [key=" + key + ", filter=" + filter + ']'; } }); @@ -3102,7 +3082,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V return tx.removeAllAsync(ctx, Collections.singletonList(key), /*retval*/false, - ctx.equalsValArray(val), + ctx.equalsVal(val), /*singleRmv*/false).get().success(); } @@ -3143,7 +3123,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V return tx.removeAllAsync(ctx, Collections.singletonList(key), /*retval*/false, - ctx.equalsValArray(val), + ctx.equalsVal(val), /*singleRmv*/false).chain( (IgniteClosure<IgniteInternalFuture<GridCacheReturn>, Boolean>)RET2FLAG); } @@ -3159,28 +3139,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V return fut; } - /** - * @param filter Filter. - * @return Future. - */ - public IgniteInternalFuture<?> localRemoveAll(final CacheEntryPredicate filter) { - final Set<? extends K> keys = filter != null ? keySet(filter) : keySet(); - - return asyncOp(new AsyncInOp(keys) { - @Override public IgniteInternalFuture<?> inOp(IgniteTxLocalAdapter tx) { - return tx.removeAllAsync(ctx, - keys, - /*retval*/false, - null, - /*singleRmv*/false); - } - - @Override public String toString() { - return "removeAllAsync [filter=" + filter + ']'; - } - }); - } - /** {@inheritDoc} */ @Override public CacheMetrics clusterMetrics() { return clusterMetrics(ctx.grid().cluster().forCacheNodes(ctx.name())); @@ -4585,42 +4543,10 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } /** - * @param filter Filters to evaluate. * @return Primary entry set. */ - public Set<Cache.Entry<K, V>> primaryEntrySet( - @Nullable CacheEntryPredicate... filter) { - return map.entries( - F0.and0( - filter, - CU.cachePrimary(ctx.grid().affinity(ctx.name()), ctx.localNode()))); - } - - /** - * @param filter Filters to evaluate. - * @return Key set. - */ - public Set<K> keySet(@Nullable CacheEntryPredicate... filter) { - return map.keySet(filter); - } - - /** - * @param filter Filters to evaluate. - * @return Key set including internal keys. - */ - public Set<K> keySetx(@Nullable CacheEntryPredicate... filter) { - return map.keySetx(filter); - } - - /** - * @param filter Primary key set. - * @return Primary key set. - */ - public Set<K> primaryKeySet(@Nullable CacheEntryPredicate... filter) { - return map.keySet( - F0.and0( - filter, - CU.cachePrimary(ctx.grid().affinity(ctx.name()), ctx.localNode()))); + public Set<Cache.Entry<K, V>> primaryEntrySet() { + return map.entries(CU.cachePrimary(ctx.grid().affinity(ctx.name()), ctx.localNode())); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/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 5729959..e948c8e 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 @@ -1107,30 +1107,22 @@ public class GridCacheContext<K, V> implements Externalizable { /** * @return No value filter. */ - public CacheEntryPredicate[] noValArray() { - return new CacheEntryPredicate[]{new CacheEntrySerializablePredicate(new CacheEntryPredicateNoValue())}; + public CacheEntryPredicate noVal() { + return new CacheEntrySerializablePredicate(new CacheEntryPredicateNoValue()); } /** * @return Has value filter. */ - public CacheEntryPredicate[] hasValArray() { - return new CacheEntryPredicate[]{new CacheEntrySerializablePredicate(new CacheEntryPredicateHasValue())}; - } - - /** - * @param val Value to check. - * @return Predicate array that checks for value. - */ - public CacheEntryPredicate[] equalsValArray(V val) { - return new CacheEntryPredicate[]{new CacheEntryPredicateContainsValue(toCacheObject(val))}; + public CacheEntryPredicate hasVal() { + return new CacheEntrySerializablePredicate(new CacheEntryPredicateHasValue()); } /** * @param val Value to check. * @return Predicate that checks for value. */ - public CacheEntryPredicate equalsValue(V val) { + public CacheEntryPredicate equalsVal(V val) { return new CacheEntryPredicateContainsValue(toCacheObject(val)); } http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java index 08941ca..511eed4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java @@ -3859,7 +3859,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme CacheObject val; if (tx != null) { - GridTuple<CacheObject> peek = tx.peek(cctx, false, key, null); + GridTuple<CacheObject> peek = tx.peek(cctx, false, key); val = peek == null ? rawGetOrUnmarshal(false) : peek.get(); } @@ -3890,7 +3890,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme IgniteInternalTx tx = cctx.tm().userTx(); if (tx != null) { - GridTuple<CacheObject> peek = tx.peek(cctx, false, key, null); + GridTuple<CacheObject> peek = tx.peek(cctx, false, key); if (peek != null) return peek.get(); http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/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 1cdd303..4744580 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 @@ -381,6 +381,16 @@ public class GridCacheUtils { } /** + * Create filter array. + * + * @param filter Filter. + * @return Filter array. + */ + public static CacheEntryPredicate[] filterArray(@Nullable CacheEntryPredicate filter) { + return filter != null ? new CacheEntryPredicate[] { filter } : CU.empty0(); + } + + /** * Entry predicate factory mostly used for deserialization. * * @param <K> Key type. http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java index 8e9d4a7..262d959 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java @@ -224,8 +224,7 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter /** {@inheritDoc} */ @Override public GridTuple<CacheObject> peek(GridCacheContext cacheCtx, boolean failFast, - KeyCacheObject key, - CacheEntryPredicate[] filter) + KeyCacheObject key) throws GridCacheFilterFailedException { assert false : "Method peek can only be called on user transaction: " + this; http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/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 1797acd..1b5b8ad 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 @@ -430,18 +430,18 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { } /** {@inheritDoc} */ - @Override public V getAndPut(K key, V val, @Nullable CacheEntryPredicate[] filter) throws IgniteCheckedException { + @Override public V getAndPut(K key, V val, @Nullable CacheEntryPredicate filter) throws IgniteCheckedException { return getAndPutAsync0(key, val, filter).get(); } /** {@inheritDoc} */ - @Override public boolean put(K key, V val, CacheEntryPredicate[] filter) throws IgniteCheckedException { + @Override public boolean put(K key, V val, CacheEntryPredicate filter) throws IgniteCheckedException { return putAsync(key, val, filter).get(); } /** {@inheritDoc} */ @SuppressWarnings("unchecked") - @Override public IgniteInternalFuture<V> getAndPutAsync0(K key, V val, @Nullable CacheEntryPredicate... filter) { + @Override public IgniteInternalFuture<V> getAndPutAsync0(K key, V val, @Nullable CacheEntryPredicate filter) { A.notNull(key, "key", val, "val"); return updateAsync0( @@ -456,7 +456,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { /** {@inheritDoc} */ @SuppressWarnings("unchecked") - @Override public IgniteInternalFuture<Boolean> putAsync0(K key, V val, @Nullable CacheEntryPredicate... filter) { + @Override public IgniteInternalFuture<Boolean> putAsync0(K key, V val, @Nullable CacheEntryPredicate filter) { A.notNull(key, "key", val, "val"); return updateAsync0( @@ -479,7 +479,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { null, null, true, - ctx.noValArray(), + ctx.noVal(), false).get(); } @@ -492,7 +492,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @Override public IgniteInternalFuture<V> getAndPutIfAbsentAsync(K key, V val) { A.notNull(key, "key", val, "val"); - return getAndPutAsync(key, val, ctx.noValArray()); + return getAndPutAsync(key, val, ctx.noVal()); } /** {@inheritDoc} */ @@ -504,7 +504,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @Override public IgniteInternalFuture<Boolean> putIfAbsentAsync(K key, V val) { A.notNull(key, "key", val, "val"); - return putAsync(key, val, ctx.noValArray()); + return putAsync(key, val, ctx.noVal()); } /** {@inheritDoc} */ @@ -516,7 +516,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @Override public IgniteInternalFuture<V> getAndReplaceAsync(K key, V val) { A.notNull(key, "key", val, "val"); - return getAndPutAsync(key, val, ctx.hasValArray()); + return getAndPutAsync(key, val, ctx.hasVal()); } /** {@inheritDoc} */ @@ -528,7 +528,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @Override public IgniteInternalFuture<Boolean> replaceAsync(K key, V val) { A.notNull(key, "key", val, "val"); - return putAsync(key, val, ctx.hasValArray()); + return putAsync(key, val, ctx.hasVal()); } /** {@inheritDoc} */ @@ -540,7 +540,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @Override public IgniteInternalFuture<Boolean> replaceAsync(K key, V oldVal, V newVal) { A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal"); - return putAsync(key, newVal, ctx.equalsValArray(oldVal)); + return putAsync(key, newVal, ctx.equalsVal(oldVal)); } /** {@inheritDoc} */ @@ -557,7 +557,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { null, false, false, - CU.empty0(), true, UPDATE).chain(RET2NULL); } @@ -579,7 +578,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { null, false, false, - null, true, UPDATE); } @@ -594,7 +592,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @Override public IgniteInternalFuture<V> getAndRemoveAsync(K key) { A.notNull(key, "key"); - return removeAsync0(key, true, CU.empty0()); + return removeAsync0(key, true, null); } /** {@inheritDoc} */ @@ -606,17 +604,17 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @Override public IgniteInternalFuture<?> removeAllAsync(Collection<? extends K> keys) { A.notNull(keys, "keys"); - return removeAllAsync0(keys, null, false, false, CU.empty0()).chain(RET2NULL); + return removeAllAsync0(keys, null, false, false).chain(RET2NULL); } /** {@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 removeAsync0(key, false, filter); @@ -631,12 +629,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)); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<?> localRemoveAll(CacheEntryPredicate filter) { - return removeAllAsync(keySet(filter)); + return removeAsync(key, ctx.equalsVal(val)); } /** {@inheritDoc} */ @@ -649,7 +642,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @Override public IgniteInternalFuture<?> removeAllConflictAsync(Map<KeyCacheObject, GridCacheVersion> conflictMap) { ctx.dr().onReceiveCacheEntriesReceived(conflictMap.size()); - return removeAllAsync0(null, conflictMap, false, false, null); + return removeAllAsync0(null, conflictMap, false, false); } /** @@ -812,7 +805,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { null, false, false, - null, true, TRANSFORM); @@ -849,7 +841,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { null, false, false, - null, true, TRANSFORM); } @@ -864,7 +855,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { * @param conflictRmvMap Conflict remove map. * @param retval Return value required flag. * @param rawRetval Return {@code GridCacheReturn} instance. - * @param filter Cache entry filter for atomic updates. * @param waitTopFut Whether to wait for topology future. * @return Completion future. */ @@ -877,7 +867,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @Nullable Map<KeyCacheObject, GridCacheVersion> conflictRmvMap, final boolean retval, final boolean rawRetval, - @Nullable final CacheEntryPredicate[] filter, final boolean waitTopFut, final GridCacheOperation op ) { @@ -948,7 +937,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { retval, rawRetval, opCtx != null ? opCtx.expiry() : null, - filter, + CU.filterArray(null), subjId, taskNameHash, opCtx != null && opCtx.skipStore(), @@ -983,7 +972,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @Nullable EntryProcessor proc, @Nullable Object[] invokeArgs, final boolean retval, - @Nullable final CacheEntryPredicate[] filter, + @Nullable final CacheEntryPredicate filter, final boolean waitTopFut ) { assert val == null || proc == null; @@ -1015,7 +1004,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { * @return Future. */ private IgniteInternalFuture removeAsync0(K key, final boolean retval, - @Nullable final CacheEntryPredicate[] filter) { + @Nullable CacheEntryPredicate filter) { final boolean statsEnabled = ctx.config().isStatisticsEnabled(); final long start = statsEnabled ? System.nanoTime() : 0L; @@ -1059,7 +1048,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @Nullable EntryProcessor proc, @Nullable Object[] invokeArgs, boolean retval, - @Nullable final CacheEntryPredicate[] filter, + @Nullable CacheEntryPredicate filter, boolean waitTopFut ) { CacheOperationContext opCtx = ctx.operationContextPerCall(); @@ -1115,7 +1104,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { retval, false, opCtx != null ? opCtx.expiry() : null, - filter, + CU.filterArray(filter), ctx.subjectIdPerCall(null, opCtx), ctx.kernalContext().job().currentTaskNameHash(), opCtx != null && opCtx.skipStore(), @@ -1131,15 +1120,13 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { * @param conflictMap Conflict map. * @param retval Return value required flag. * @param rawRetval Return {@code GridCacheReturn} instance. - * @param filter Cache entry filter for atomic removes. * @return Completion future. */ private IgniteInternalFuture removeAllAsync0( @Nullable Collection<? extends K> keys, @Nullable Map<KeyCacheObject, GridCacheVersion> conflictMap, final boolean retval, - boolean rawRetval, - @Nullable final CacheEntryPredicate[] filter + boolean rawRetval ) { assert ctx.updatesAllowed(); @@ -1184,8 +1171,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { drVers != null ? drVers : (keys != null ? null : conflictMap.values()), retval, rawRetval, - (filter != null && opCtx != null) ? opCtx.expiry() : null, - filter, + opCtx != null ? opCtx.expiry() : null, + CU.filterArray(null), subjId, taskNameHash, opCtx != null && opCtx.skipStore(), http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/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 6cd7745..5bb9aaa 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 @@ -429,24 +429,24 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> { } /** {@inheritDoc} */ - @Override public V getAndPut(K key, V val, @Nullable CacheEntryPredicate[] filter) throws IgniteCheckedException { + @Override public V getAndPut(K key, V val, @Nullable CacheEntryPredicate filter) throws IgniteCheckedException { return dht.getAndPut(key, val, filter); } /** {@inheritDoc} */ - @Override public boolean put(K key, V val, CacheEntryPredicate[] filter) throws IgniteCheckedException { + @Override public boolean put(K key, V val, CacheEntryPredicate filter) throws IgniteCheckedException { return dht.put(key, val, filter); } /** {@inheritDoc} */ @SuppressWarnings("unchecked") - @Override public IgniteInternalFuture<V> getAndPutAsync0(K key, V val, @Nullable CacheEntryPredicate... filter) { + @Override public IgniteInternalFuture<V> getAndPutAsync0(K key, V val, @Nullable CacheEntryPredicate filter) { return dht.getAndPutAsync0(key, val, filter); } /** {@inheritDoc} */ @SuppressWarnings("unchecked") - @Override public IgniteInternalFuture<Boolean> putAsync0(K key, V val, @Nullable CacheEntryPredicate... filter) { + @Override public IgniteInternalFuture<Boolean> putAsync0(K key, V val, @Nullable CacheEntryPredicate filter) { return dht.putAsync0(key, val, filter); } @@ -598,7 +598,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); } @@ -623,11 +623,6 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> { } /** {@inheritDoc} */ - @Override public IgniteInternalFuture<?> localRemoveAll(CacheEntryPredicate filter) { - return dht.localRemoveAll(filter); - } - - /** {@inheritDoc} */ @Override public void removeAllConflict(Map<KeyCacheObject, GridCacheVersion> drMap) throws IgniteCheckedException { dht.removeAllConflict(drMap); http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/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 c750be6..8483cb1 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 @@ -356,8 +356,7 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda } /** {@inheritDoc} */ - @Override public Set<Cache.Entry<K, V>> primaryEntrySet( - @Nullable final CacheEntryPredicate... filter) { + @Override public Set<Cache.Entry<K, V>> primaryEntrySet() { final AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); Collection<Cache.Entry<K, V>> entries = @@ -368,13 +367,6 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda @Override public Collection<Cache.Entry<K, V>> apply(GridDhtLocalPartition p) { Collection<GridDhtCacheEntry> entries0 = p.entries(); - if (!F.isEmpty(filter)) - entries0 = F.view(entries0, new CacheEntryPredicateAdapter() { - @Override public boolean apply(GridCacheEntryEx e) { - return F.isAll(e, filter); - } - }); - return F.viewReadOnly( entries0, new C1<GridDhtCacheEntry, Cache.Entry<K, V>>() { @@ -399,26 +391,18 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda } /** {@inheritDoc} */ - @Override public Set<K> keySet(@Nullable CacheEntryPredicate[] filter) { - return new GridCacheKeySet<>(ctx, entrySet(filter), null); - } - - /** - * @param filter Entry filter. - * @return Keys for near cache only. - */ - public Set<K> nearKeySet(@Nullable CacheEntryPredicate filter) { - return super.keySet(filter); + @Override public Set<K> keySet() { + return new GridCacheKeySet<>(ctx, entrySet(), null); } /** {@inheritDoc} */ - @Override public Set<K> primaryKeySet(@Nullable CacheEntryPredicate... filter) { - return new GridCacheKeySet<>(ctx, primaryEntrySet(filter), null); + @Override public Set<K> primaryKeySet() { + return new GridCacheKeySet<>(ctx, primaryEntrySet(), null); } /** {@inheritDoc} */ - @Override public Collection<V> values(CacheEntryPredicate... filter) { - return new GridCacheValueCollection<>(ctx, entrySet(filter), ctx.vararg(F.<K, V>cacheHasPeekValue())); + @Override public Collection<V> values() { + return new GridCacheValueCollection<>(ctx, entrySet(), ctx.vararg(F.<K, V>cacheHasPeekValue())); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/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 2df7340..1632112 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 @@ -135,7 +135,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { /** {@inheritDoc} */ @SuppressWarnings("unchecked") - @Override public V getAndPut(K key, V val, @Nullable CacheEntryPredicate[] filter) throws IgniteCheckedException { + @Override public V getAndPut(K key, V val, @Nullable CacheEntryPredicate filter) throws IgniteCheckedException { A.notNull(key, "key", val, "val"); CacheOperationContext opCtx = ctx.operationContextPerCall(); @@ -154,7 +154,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { } /** {@inheritDoc} */ - @Override public boolean put(K key, V val, CacheEntryPredicate[] filter) throws IgniteCheckedException { + @Override public boolean put(K key, V val, CacheEntryPredicate filter) throws IgniteCheckedException { A.notNull(key, "key", val, "val"); boolean statsEnabled = ctx.config().isStatisticsEnabled(); @@ -183,7 +183,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { /** {@inheritDoc} */ @SuppressWarnings("unchecked") - @Override public IgniteInternalFuture<V> getAndPutAsync0(K key, V val, @Nullable CacheEntryPredicate... filter) { + @Override public IgniteInternalFuture<V> getAndPutAsync0(K key, V val, @Nullable CacheEntryPredicate filter) { A.notNull(key, "key", val, "val"); return updateAllAsync0(F0.asMap(key, val), @@ -196,7 +196,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { /** {@inheritDoc} */ @SuppressWarnings("unchecked") - @Override public IgniteInternalFuture<Boolean> putAsync0(K key, V val, @Nullable CacheEntryPredicate... filter) { + @Override public IgniteInternalFuture<Boolean> putAsync0(K key, V val, @Nullable CacheEntryPredicate filter) { A.notNull(key, "key", val, "val"); return updateAllAsync0(F0.asMap(key, val), @@ -210,55 +210,55 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public V getAndPutIfAbsent(K key, V val) throws IgniteCheckedException { - return getAndPut(key, val, ctx.noValArray()); + return getAndPut(key, val, ctx.noVal()); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<V> getAndPutIfAbsentAsync(K key, V val) { - return getAndPutAsync(key, val, ctx.noValArray()); + return getAndPutAsync(key, val, ctx.noVal()); } /** {@inheritDoc} */ @Override public boolean putIfAbsent(K key, V val) throws IgniteCheckedException { - return put(key, val, ctx.noValArray()); + return put(key, val, ctx.noVal()); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> putIfAbsentAsync(K key, V val) { - return putAsync(key, val, ctx.noValArray()); + return putAsync(key, val, ctx.noVal()); } /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public V getAndReplace(K key, V val) throws IgniteCheckedException { - return getAndPut(key, val, ctx.hasValArray()); + return getAndPut(key, val, ctx.hasVal()); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<V> getAndReplaceAsync(K key, V val) { - return getAndPutAsync(key, val, ctx.hasValArray()); + return getAndPutAsync(key, val, ctx.hasVal()); } /** {@inheritDoc} */ @Override public boolean replace(K key, V val) throws IgniteCheckedException { - return put(key, val, ctx.hasValArray()); + return put(key, val, ctx.hasVal()); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> replaceAsync(K key, V val) { - return putAsync(key, val, ctx.hasValArray()); + return putAsync(key, val, ctx.hasVal()); } /** {@inheritDoc} */ @Override public boolean replace(K key, V oldVal, V newVal) throws IgniteCheckedException { A.notNull(oldVal, "oldVal"); - return put(key, newVal, ctx.equalsValArray(oldVal)); + return put(key, newVal, ctx.equalsVal(oldVal)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> replaceAsync(K key, V oldVal, V newVal) { - return putAsync(key, newVal, ctx.equalsValArray(oldVal)); + return putAsync(key, newVal, ctx.equalsVal(oldVal)); } /** {@inheritDoc} */ @@ -276,7 +276,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { expiryPerCall(), false, false, - CU.empty0(), + null, ctx.writeThrough(), ctx.readThrough(), opCtx != null && opCtx.isKeepBinary()); @@ -292,7 +292,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { null, false, false, - CU.empty0()).chain(RET2NULL); + null).chain(RET2NULL); } /** {@inheritDoc} */ @@ -307,7 +307,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { expiryPerCall(), true, false, - CU.empty0(), + null, ctx.writeThrough(), ctx.readThrough(), opCtx != null && opCtx.isKeepBinary()); @@ -316,7 +316,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public IgniteInternalFuture<V> getAndRemoveAsync(K key) { - return removeAllAsync0(Collections.singletonList(key), true, false, CU.empty0()); + return removeAllAsync0(Collections.singletonList(key), true, false, null); } /** {@inheritDoc} */ @@ -331,7 +331,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { expiryPerCall(), false, false, - CU.empty0(), + null, ctx.writeThrough(), ctx.readThrough(), opCtx != null && opCtx.isKeepBinary()); @@ -339,7 +339,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { /** {@inheritDoc} */ @Override public IgniteInternalFuture<?> removeAllAsync(Collection<? extends K> keys) { - return removeAllAsync0(keys, false, false, CU.empty0()).chain(RET2NULL); + return removeAllAsync0(keys, false, false, null).chain(RET2NULL); } /** {@inheritDoc} */ @@ -360,7 +360,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { expiryPerCall(), false, false, - CU.empty0(), + null, ctx.writeThrough(), ctx.readThrough(), opCtx != null && opCtx.isKeepBinary()); @@ -373,7 +373,7 @@ 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); @@ -392,7 +392,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { expiryPerCall(), false, false, - ctx.equalsValArray(val), + ctx.equalsVal(val), ctx.writeThrough(), ctx.readThrough(), opCtx != null && opCtx.isKeepBinary()); @@ -400,7 +400,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} */ @@ -790,7 +790,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { @Nullable final Object[] invokeArgs, final boolean retval, final boolean rawRetval, - @Nullable final CacheEntryPredicate[] filter + @Nullable final CacheEntryPredicate filter ) { final GridCacheOperation op = invokeMap != null ? TRANSFORM : UPDATE; @@ -844,7 +844,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { @Nullable final Collection<? extends K> keys, final boolean retval, final boolean rawRetval, - @Nullable final CacheEntryPredicate[] filter + @Nullable final CacheEntryPredicate filter ) { final boolean writeThrough = ctx.writeThrough(); @@ -906,7 +906,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { @Nullable ExpiryPolicy expiryPlc, boolean retval, boolean rawRetval, - CacheEntryPredicate[] filter, + CacheEntryPredicate filter, boolean writeThrough, boolean readThrough, boolean keepBinary @@ -925,6 +925,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { UUID subjId = ctx.subjectIdPerCall(null); + CacheEntryPredicate[] filters = CU.filterArray(filter); + if (writeThrough && keys.size() > 1) { return updateWithBatch(op, keys, @@ -932,7 +934,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { invokeArgs, expiryPlc, ver, - filter, + filters, keepBinary, subjId, taskName); @@ -978,7 +980,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { expiryPlc, true, true, - filter, + filters, intercept, subjId, taskName); http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java index 914b4ff..cdf2354 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java @@ -515,15 +515,13 @@ public interface IgniteInternalTx extends AutoCloseable, GridTimeoutObject { * @param ctx Cache context. * @param failFast Fail-fast flag. * @param key Key to look up. - * @param filter Filter to check. * @return Current value for the key within transaction. * @throws GridCacheFilterFailedException If filter failed and failFast is {@code true}. */ @Nullable public GridTuple<CacheObject> peek( GridCacheContext ctx, boolean failFast, - KeyCacheObject key, - @Nullable CacheEntryPredicate[] filter) throws GridCacheFilterFailedException; + KeyCacheObject key) throws GridCacheFilterFailedException; /** * @return Start version. http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java index 9e5d626..55bcf45 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java @@ -2001,8 +2001,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement /** {@inheritDoc} */ @Nullable @Override public GridTuple<CacheObject> peek(GridCacheContext ctx, boolean failFast, - KeyCacheObject key, - @Nullable CacheEntryPredicate[] filter) { + KeyCacheObject key) { return null; } http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java index 0337145..11a35cb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java @@ -399,20 +399,12 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig @Nullable @Override public GridTuple<CacheObject> peek( GridCacheContext cacheCtx, boolean failFast, - KeyCacheObject key, - CacheEntryPredicate[] filter + KeyCacheObject key ) throws GridCacheFilterFailedException { IgniteTxEntry e = entry(cacheCtx.txKey(key)); - if (e != null) { - // We should look at tx entry previous value. If this is a user peek then previous - // value is the same as value. If this is a filter evaluation peek then previous value holds - // value visible to filter while value contains value enlisted for write. - if (!F.isEmpty(filter) && !F.isAll(e.cached(), filter)) - return e.hasPreviousValue() ? F.t(CU.<CacheObject>failed(failFast, e.previousValue())) : null; - + if (e != null) return e.hasPreviousValue() ? F.t(e.previousValue()) : null; - } return null; } @@ -2040,16 +2032,14 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig @Override public <K, V> IgniteInternalFuture<GridCacheReturn> putAllAsync( GridCacheContext cacheCtx, Map<? extends K, ? extends V> map, - boolean retval, - CacheEntryPredicate[] filter + boolean retval ) { return (IgniteInternalFuture<GridCacheReturn>)putAllAsync0(cacheCtx, map, null, null, null, - retval, - filter); + retval); } /** {@inheritDoc} */ @@ -2058,7 +2048,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig K key, V val, boolean retval, - CacheEntryPredicate[] filter) { + CacheEntryPredicate filter) { return putAsync0(cacheCtx, key, val, null, null, retval, filter); } @@ -2086,8 +2076,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig null, null, drMap, - false, - null); + false); } /** {@inheritDoc} */ @@ -2102,8 +2091,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig map, invokeArgs, null, - true, - null); + true); } /** {@inheritDoc} */ @@ -3041,7 +3029,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig @Nullable EntryProcessor<K, V, Object> entryProcessor, @Nullable final Object[] invokeArgs, final boolean retval, - @Nullable final CacheEntryPredicate[] filter + @Nullable final CacheEntryPredicate filter ) { assert key != null; @@ -3058,6 +3046,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig boolean keepBinary = opCtx != null && opCtx.isKeepBinary(); + final CacheEntryPredicate[] filters = CU.filterArray(filter); + final IgniteInternalFuture<Void> loadFut = enlistWrite( cacheCtx, cacheKey, @@ -3067,7 +3057,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig invokeArgs, retval, /*lockOnly*/false, - filter, + filters, ret, opCtx != null && opCtx.skipStore(), /*singleRmv*/false, @@ -3108,7 +3098,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig retval, /*read*/false, -1L, - filter, + filters, /*computeInvoke*/true); return ret; @@ -3161,7 +3151,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig * @param invokeArgs Optional arguments for EntryProcessor. * @param drMap DR map. * @param retval Key-transform value map to store. - * @param filter Filter. * @return Operation future. */ @SuppressWarnings("unchecked") @@ -3171,11 +3160,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig @Nullable Map<? extends K, ? extends EntryProcessor<K, V, Object>> invokeMap, @Nullable final Object[] invokeArgs, @Nullable Map<KeyCacheObject, GridCacheDrInfo> drMap, - final boolean retval, - @Nullable final CacheEntryPredicate[] filter + final boolean retval ) { - assert filter == null || invokeMap == null; - try { beforePut(cacheCtx, retval); } @@ -3235,7 +3221,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig invokeArgs, retval, false, - filter, + CU.filterArray(null), ret, enlisted, drMap, @@ -3283,7 +3269,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig retval, /*read*/false, -1L, - filter, + CU.filterArray(null), /*computeInvoke*/true); return ret; @@ -3402,7 +3388,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig GridCacheContext cacheCtx, Collection<? extends K> keys, boolean retval, - CacheEntryPredicate[] filter, + CacheEntryPredicate filter, boolean singleRmv ) { return removeAllAsync0(cacheCtx, keys, null, retval, filter, singleRmv); @@ -3423,7 +3409,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig @Nullable final Collection<? extends K> keys, @Nullable Map<KeyCacheObject, GridCacheVersion> drMap, final boolean retval, - @Nullable final CacheEntryPredicate[] filter, + @Nullable final CacheEntryPredicate filter, boolean singleRmv) { try { checkUpdatesAllowed(cacheCtx); @@ -3494,7 +3480,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig ExpiryPolicy plc; - if (!F.isEmpty(filter)) + final CacheEntryPredicate[] filters = CU.filterArray(filter); + + if (!F.isEmpty(filters)) plc = opCtx != null ? opCtx.expiry() : null; else plc = null; @@ -3510,7 +3498,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig /** invoke arguments */null, retval, /** lock only */false, - filter, + filters, ret, enlisted, null, @@ -3561,12 +3549,12 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig postLockWrite(cacheCtx, enlisted, ret, - /*remove*/true, + /*remove*/true, retval, - /*read*/false, + /*read*/false, -1L, - filter, - /*computeInvoke*/false); + filters, + /*computeInvoke*/false); return ret; } http://git-wip-us.apache.org/repos/asf/ignite/blob/244441a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java index 78f517c..5911e89 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java @@ -83,14 +83,12 @@ public interface IgniteTxLocalEx extends IgniteInternalTx { * @param cacheCtx Cache context. * @param map Map to put. * @param retval Flag indicating whether a value should be returned. - * @param filter Filter. * @return Future for put operation. */ public <K, V> IgniteInternalFuture<GridCacheReturn> putAllAsync( GridCacheContext cacheCtx, Map<? extends K, ? extends V> map, - boolean retval, - CacheEntryPredicate[] filter); + boolean retval); /** * @param cacheCtx Cache context. @@ -105,7 +103,7 @@ public interface IgniteTxLocalEx extends IgniteInternalTx { K key, V val, boolean retval, - CacheEntryPredicate[] filter); + CacheEntryPredicate filter); /** * @param cacheCtx Cache context. @@ -143,7 +141,7 @@ public interface IgniteTxLocalEx extends IgniteInternalTx { GridCacheContext cacheCtx, Collection<? extends K> keys, boolean retval, - CacheEntryPredicate[] filter, + CacheEntryPredicate filter, boolean singleRmv); /**
