ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [22/22] incubator-ignite git commit: #ignite-738: remove execute from CacheQuery.
Date Mon, 13 Apr 2015 17:34:09 GMT
#ignite-738: remove execute from CacheQuery.


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

Branch: refs/heads/ignite-738
Commit: 87d281467a81a174b81adf537a2d407e22788f62
Parents: b6882fd
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Mon Apr 13 20:31:50 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Mon Apr 13 20:31:50 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/query/CacheQuery.java      | 19 --------
 .../cache/query/GridCacheQueryAdapter.java      | 48 ++++++--------------
 ...CacheReplicatedPreloadLifecycleSelfTest.java | 25 +++++-----
 3 files changed, 24 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/87d28146/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
index bab6db6..93576ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
@@ -21,7 +21,6 @@ import org.apache.ignite.cache.affinity.*;
 import org.apache.ignite.cache.query.*;
 import org.apache.ignite.cache.query.annotations.*;
 import org.apache.ignite.cluster.*;
-import org.apache.ignite.lang.*;
 import org.jetbrains.annotations.*;
 
 /**
@@ -260,24 +259,6 @@ public interface CacheQuery<T> {
     public CacheQueryFuture<T> execute(@Nullable Object... args);
 
     /**
-     * Executes the query the same way as {@link #execute(Object...)} method but reduces
result remotely.
-     *
-     * @param rmtReducer Remote reducer.
-     * @param args Optional arguments.
-     * @return Future for the query result.
-     */
-    public <R> CacheQueryFuture<R> execute(IgniteReducer<T, R> rmtReducer,
@Nullable Object... args);
-
-    /**
-     * Executes the query the same way as {@link #execute(Object...)} method but transforms
result remotely.
-     *
-     * @param rmtTransform Remote transformer.
-     * @param args Optional arguments.
-     * @return Future for the query result.
-     */
-    public <R> CacheQueryFuture<R> execute(IgniteClosure<T, R> rmtTransform,
@Nullable Object... args);
-
-    /**
      * Gets metrics for this query.
      *
      * @return Query metrics.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/87d28146/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
index 4b1fc87..fa54bbc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
@@ -363,36 +363,6 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T>
{
 
     /** {@inheritDoc} */
     @Override public CacheQueryFuture<T> execute(@Nullable Object... args) {
-        return execute(null, null, args);
-    }
-
-    /** {@inheritDoc} */
-    @Override public <R> CacheQueryFuture<R> execute(IgniteReducer<T, R>
rmtReducer, @Nullable Object... args) {
-        return execute(rmtReducer, null, args);
-    }
-
-    /** {@inheritDoc} */
-    @Override public <R> CacheQueryFuture<R> execute(IgniteClosure<T, R>
rmtTransform, @Nullable Object... args) {
-        return execute(null, rmtTransform, args);
-    }
-
-    @Override public QueryMetrics metrics() {
-        return metrics.copy();
-    }
-
-    @Override public void resetMetrics() {
-        metrics = new GridCacheQueryMetricsAdapter();
-    }
-
-    /**
-     * @param rmtReducer Optional reducer.
-     * @param rmtTransform Optional transformer.
-     * @param args Arguments.
-     * @return Future.
-     */
-    @SuppressWarnings("IfMayBeConditional")
-    private <R> CacheQueryFuture<R> execute(@Nullable IgniteReducer<T, R>
rmtReducer,
-        @Nullable IgniteClosure<T, R> rmtTransform, @Nullable Object... args) {
         Collection<ClusterNode> nodes = nodes();
 
         cctx.checkSecurity(SecurityPermission.CACHE_READ);
@@ -405,7 +375,7 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T>
{
 
         if (cctx.deploymentEnabled()) {
             try {
-                cctx.deploy().registerClasses(filter, rmtReducer, rmtTransform);
+                cctx.deploy().registerClasses(filter, null, null);
                 cctx.deploy().registerClasses(args);
             }
             catch (IgniteCheckedException e) {
@@ -418,18 +388,26 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T>
{
 
         taskHash = cctx.kernalContext().job().currentTaskNameHash();
 
-        GridCacheQueryBean bean = new GridCacheQueryBean(this, (IgniteReducer<Object,
Object>)rmtReducer,
-            (IgniteClosure<Object, Object>)rmtTransform, args);
+        GridCacheQueryBean bean = new GridCacheQueryBean(this, null, null, args);
 
         GridCacheQueryManager qryMgr = cctx.queries();
 
         boolean loc = nodes.size() == 1 && F.first(nodes).id().equals(cctx.localNodeId());
 
         if (type == SQL_FIELDS || type == SPI)
-            return (CacheQueryFuture<R>)(loc ? qryMgr.queryFieldsLocal(bean) :
+            return (CacheQueryFuture<T>)(loc ? qryMgr.queryFieldsLocal(bean) :
                 qryMgr.queryFieldsDistributed(bean, nodes));
         else
-            return (CacheQueryFuture<R>)(loc ? qryMgr.queryLocal(bean) : qryMgr.queryDistributed(bean,
nodes));
+            return (CacheQueryFuture<T>)(loc ? qryMgr.queryLocal(bean) : qryMgr.queryDistributed(bean,
nodes));
+    }
+
+
+    @Override public QueryMetrics metrics() {
+        return metrics.copy();
+    }
+
+    @Override public void resetMetrics() {
+        metrics = new GridCacheQueryMetricsAdapter();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/87d28146/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java
index 4e6e08c..525a8f7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java
@@ -177,6 +177,7 @@ public class GridCacheReplicatedPreloadLifecycleSelfTest extends GridCachePreloa
             info("Checking '" + (i + 1) + "' nodes...");
 
             for (int j = 0; j < G.allGrids().size(); j++) {
+                final Ignite grid = grid(j);
                 GridCacheAdapter<Object, MyValue> c2 = ((IgniteKernal)grid(j)).internalCache("two");
 
                 CacheQuery<Map.Entry<Object, MyValue>> qry = c2.queries().createScanQuery(null);
@@ -186,18 +187,13 @@ public class GridCacheReplicatedPreloadLifecycleSelfTest extends GridCachePreloa
 
                 qry = qry.projection(grid(j).cluster());
 
-                int totalCnt = F.sumInt(qry.execute(new IgniteReducer<Map.Entry<Object,
MyValue>, Integer>() {
-                    @IgniteInstanceResource
-                    private Ignite grid;
-
-                    @LoggerResource
-                    private IgniteLogger log0;
-
+                int totalCnt = F.reduce(qry.execute().get(), new IgniteReducer<Map.Entry<Object,
MyValue>, Integer>() {
                     private int cnt;
 
-                    @Override public boolean collect(Map.Entry<Object, MyValue> e)
{
-                        if (!quiet && log0.isInfoEnabled())
-                            log0.info("Collecting entry: " + e);
+                    @Override
+                    public boolean collect(Map.Entry<Object, MyValue> e) {
+                        if (!quiet && grid.log().isInfoEnabled())
+                            grid.log().info("Collecting entry: " + e);
 
                         Object key = e.getKey();
 
@@ -205,10 +201,10 @@ public class GridCacheReplicatedPreloadLifecycleSelfTest extends GridCachePreloa
 
                         try {
                             Object v1 = e.getValue();
-                            Object v2 = ((IgniteKernal)grid).getCache("one").get(key);
+                            Object v2 = ((IgniteKernal) grid).getCache("one").get(key);
 
                             assertNotNull("Cache c1 misses value for key [i=" + j0 + ", j="
+ i0 +
-                                ", missedKey=" + key + ", cache=" + ((IgniteKernal)grid).getCache("one").values()
+ ']', v2);
+                                ", missedKey=" + key + ", cache=" + ((IgniteKernal) grid).getCache("one").values()
+ ']', v2);
                             assertEquals(v1, v2);
                         }
                         catch (IgniteCheckedException e1) {
@@ -222,10 +218,11 @@ public class GridCacheReplicatedPreloadLifecycleSelfTest extends GridCachePreloa
                         return true;
                     }
 
-                    @Override public Integer reduce() {
+                    @Override
+                    public Integer reduce() {
                         return cnt;
                     }
-                }).get());
+                });
 
                 info("Total entry count [grid=" + j + ", totalCnt=" + totalCnt + ']');
 


Mime
View raw message