ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [12/50] [abbrv] incubator-ignite git commit: # ignite-51 filters refactoring
Date Thu, 05 Mar 2015 08:55:10 GMT
# ignite-51 filters refactoring


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

Branch: refs/heads/ignite-user-req
Commit: e229d1b13acdfdc75fd28bb4851990c25bfd8c15
Parents: 5d40c42
Author: sboikov <sboikov@gridgain.com>
Authored: Wed Mar 4 09:33:35 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Wed Mar 4 10:38:17 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheEntryPredicate.java   |  4 +---
 .../cache/CacheEntryPredicateAdapter.java       |  3 ++-
 .../processors/cache/GridCacheAdapter.java      | 10 ++++-----
 .../cache/GridCacheEvictionManager.java         |  2 +-
 .../processors/cache/GridCacheMapEntry.java     |  2 +-
 .../dht/atomic/GridDhtAtomicCache.java          |  2 +-
 .../dht/atomic/GridNearAtomicUpdateRequest.java | 20 ++++++++++++++----
 .../dht/colocated/GridDhtColocatedCache.java    |  2 +-
 .../distributed/near/GridNearLockRequest.java   |  2 --
 .../cache/GridCacheAbstractFullApiSelfTest.java |  2 --
 ...achePartitionedMultiNodeFullApiSelfTest.java |  9 ++++++--
 ...dCacheAbstractReduceFieldsQuerySelfTest.java | 22 --------------------
 12 files changed, 35 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e229d1b1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java
index ecccd7b..d1cf231 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java
@@ -21,12 +21,10 @@ import org.apache.ignite.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.plugin.extensions.communication.*;
 
-import java.io.*;
-
 /**
  *
  */
-public interface CacheEntryPredicate extends IgnitePredicate<GridCacheEntryEx>, Message,
Serializable {
+public interface CacheEntryPredicate extends IgnitePredicate<GridCacheEntryEx>, Message
{
     /**
      * @param ctx Context.
      * @throws IgniteCheckedException If failed.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e229d1b1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
index dd6df0b..3214e10 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
@@ -21,12 +21,13 @@ import org.apache.ignite.*;
 import org.apache.ignite.internal.processors.cache.transactions.*;
 import org.apache.ignite.plugin.extensions.communication.*;
 
+import java.io.*;
 import java.nio.*;
 
 /**
  *
  */
-public abstract class CacheEntryPredicateAdapter implements CacheEntryPredicate {
+public abstract class CacheEntryPredicateAdapter implements CacheEntryPredicate, Serializable
{
     /** {@inheritDoc} */
     @Override public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException
{
         // No-op.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e229d1b1/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 2670854..98dd24d 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
@@ -893,7 +893,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
 
     /** {@inheritDoc} */
     @Override public V peek(K key) {
-        return peek(key, (CacheEntryPredicate) null);
+        return peek(key, (CacheEntryPredicate)null);
     }
 
     /** {@inheritDoc} */
@@ -1260,22 +1260,22 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
 
     /** {@inheritDoc} */
     @Override public Set<Cache.Entry<K, V>> primaryEntrySet() {
-        return primaryEntrySet((CacheEntryPredicate[]) null);
+        return primaryEntrySet((CacheEntryPredicate[])null);
     }
 
     /** {@inheritDoc} */
     @Override public Set<K> keySet() {
-        return keySet((CacheEntryPredicate[]) null);
+        return keySet((CacheEntryPredicate[])null);
     }
 
     /** {@inheritDoc} */
     @Override public Set<K> primaryKeySet() {
-        return primaryKeySet((CacheEntryPredicate[]) null);
+        return primaryKeySet((CacheEntryPredicate[])null);
     }
 
     /** {@inheritDoc} */
     @Override public Collection<V> values() {
-        return values((CacheEntryPredicate[]) null);
+        return values((CacheEntryPredicate[])null);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e229d1b1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index 5a40751..89dec21 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -855,7 +855,7 @@ public class GridCacheEvictionManager<K, V> extends GridCacheManagerAdapter<K,
V
      * @throws IgniteCheckedException In case of error.
      */
     public boolean evict(@Nullable GridCacheEntryEx entry, @Nullable GridCacheVersion obsoleteVer,
-            boolean explicit, @Nullable CacheEntryPredicate[] filter) throws IgniteCheckedException
{
+        boolean explicit, @Nullable CacheEntryPredicate[] filter) throws IgniteCheckedException
{
         if (entry == null)
             return true;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e229d1b1/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 004cc63..2adc34a 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
@@ -3119,7 +3119,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx
{
      * @throws GridCacheFilterFailedException If filter failed.
      */
     @SuppressWarnings({"unchecked"})
-    @Nullable private <K, V> CacheObject peekDb(boolean failFast, CacheEntryPredicate[]
filter)
+    @Nullable private CacheObject peekDb(boolean failFast, CacheEntryPredicate[] filter)
         throws IgniteCheckedException, GridCacheFilterFailedException {
         if (!cctx.isAll(this, filter))
             return CU.failed(failFast);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e229d1b1/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 16cc223..8737ac3 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
@@ -2454,7 +2454,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
                             /*metrics*/true,
                             /*primary*/false,
                             /*check version*/!req.forceTransformBackups(),
-                            null,
+                            CU.empty0(),
                             replicate ? DR_BACKUP : DR_NONE,
                             ttl,
                             expireTime,

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e229d1b1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
index 1ab0fa0..4b64caf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
@@ -508,8 +508,18 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements
Gri
             prepareMarshalCacheObjects(vals, cctx);
 
         if (filter != null) {
-            for (CacheEntryPredicate p : filter)
-                p.prepareMarshal(cctx);
+            boolean hasFilter = false;
+
+            for (CacheEntryPredicate p : filter) {
+                if (p != null) {
+                    hasFilter = true;
+
+                    p.prepareMarshal(cctx);
+                }
+            }
+
+            if (!hasFilter)
+                filter = null;
         }
 
         invokeArgsBytes = marshalInvokeArguments(invokeArgs, ctx);
@@ -532,8 +542,10 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements
Gri
             finishUnmarshalCacheObjects(vals, cctx, ldr);
 
         if (filter != null) {
-            for (CacheEntryPredicate p : filter)
-                p.finishUnmarshal(cctx, ldr);
+            for (CacheEntryPredicate p : filter) {
+                if (p != null)
+                    p.finishUnmarshal(cctx, ldr);
+            }
         }
 
         invokeArgs = unmarshalInvokeArguments(invokeArgsBytes, ctx, ldr);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e229d1b1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 87c0591..7ec6fe2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -431,7 +431,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
 
                 GridDistributedCacheEntry entry = peekExx(cacheKey);
 
-                if (entry == null || !ctx.isAll(entry, filter))
+                if (!ctx.isAll(entry, filter))
                     break; // While.
 
                 GridCacheMvccCandidate lock =

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e229d1b1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
index c027d1a..1e75b5b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.processors.cache.distributed.near;
 
 import org.apache.ignite.*;
-import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.distributed.*;
 import org.apache.ignite.internal.processors.cache.transactions.*;
@@ -30,7 +29,6 @@ import org.apache.ignite.plugin.extensions.communication.*;
 import org.apache.ignite.transactions.*;
 import org.jetbrains.annotations.*;
 
-import javax.cache.*;
 import java.io.*;
 import java.nio.*;
 import java.util.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e229d1b1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 5972f75..be78585 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -2814,7 +2814,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
                 lock1_2.unlock();
             }
 
-
             for (int i = 0; i < 100; i++)
                 if (cache.isLocalLocked("key1", false) || cache.isLocalLocked("key2", false))
                     Thread.sleep(10);
@@ -2834,7 +2833,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
                 lock1_2.unlock();
             }
 
-
             for (int i = 0; i < 100; i++)
                 if (cache.isLocalLocked("key1", false) || cache.isLocalLocked("key2", false))
                     Thread.sleep(10);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e229d1b1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
index 8ba2047..4d6bca6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
@@ -325,9 +325,14 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
 
         CacheEntryPredicateAdapter prjFilter = new CacheEntryPredicateAdapter() {
             @Override public boolean apply(GridCacheEntryEx e) {
-                Integer val = CU.value(e.rawGet(), e.context(), false);
+                try {
+                    Integer val = CU.value(e.rawGetOrUnmarshal(false), e.context(), false);
 
-                return val != null && val >= 1 && val <= 3;
+                    return val != null && val >= 1 && val <= 3;
+                }
+                catch (IgniteCheckedException err) {
+                    throw new IgniteException(err);
+                }
             }
         };
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e229d1b1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/reducefields/GridCacheAbstractReduceFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/reducefields/GridCacheAbstractReduceFieldsQuerySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/reducefields/GridCacheAbstractReduceFieldsQuerySelfTest.java
index 95e43a7..4ae28b3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/reducefields/GridCacheAbstractReduceFieldsQuerySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/reducefields/GridCacheAbstractReduceFieldsQuerySelfTest.java
@@ -219,28 +219,6 @@ public abstract class GridCacheAbstractReduceFieldsQuerySelfTest extends
GridCom
 //        assertEquals("Average", 25, avg.intValue());
 //    }
 
-    /**
-     * @throws Exception If failed.
-     */
-    public void testOnProjection() throws Exception {
-        CacheEntryPredicateAdapter p = new CacheEntryPredicateAdapter() {
-            @Override public boolean apply(GridCacheEntryEx e) {
-                Person val = CU.value(e.rawGet(), e.context(), false);
-
-                return val != null && val.orgId == 1;
-            }
-        };
-
-        CacheProjection<CacheAffinityKey<String>, Person> cachePrj =
-            ((IgniteKernal)grid(0)).<CacheAffinityKey<String>, Person>cache(null).projection(p);
-
-        CacheQuery<List<?>> qry = cachePrj.queries().createSqlFieldsQuery("select
age from Person");
-
-        Collection<IgniteBiTuple<Integer, Integer>> res = qry.execute(new AverageRemoteReducer()).get();
-
-        assertEquals("Average", 30, F.reduce(res, new AverageLocalReducer()).intValue());
-    }
-
 //    /**
 //     * @throws Exception If failed.
 //     */


Mime
View raw message