ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [01/48] incubator-ignite git commit: #ignite-738: move GridCacheQueryCommandHandler to new query API.
Date Thu, 16 Apr 2015 08:38:01 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-737 7c6fb23e9 -> cb7347b0a


#ignite-738: move GridCacheQueryCommandHandler to new query API.


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

Branch: refs/heads/ignite-737
Commit: 4623cadef3c8879738e0925d2e83838e2e364778
Parents: f9e922a
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Mon Apr 13 15:44:57 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Mon Apr 13 15:44:57 2015 +0300

----------------------------------------------------------------------
 .../message/GridClientCacheQueryRequest.java    | 108 -------------------
 .../cache/GridCacheQueryCommandHandler.java     |  58 +++-------
 .../rest/request/GridRestCacheQueryRequest.java |  41 -------
 3 files changed, 14 insertions(+), 193 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4623cade/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheQueryRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheQueryRequest.java
index b62d2b5..c2d7f36 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheQueryRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheQueryRequest.java
@@ -106,27 +106,9 @@ public class GridClientCacheQueryRequest extends GridClientAbstractMessage
{
     /** Page size. */
     private int pageSize;
 
-    /** Timeout. */
-    private long timeout;
-
-    /** Include backups flag. */
-    private boolean includeBackups;
-
-    /** Enable dedup flag. */
-    private boolean enableDedup;
-
-    /** Keep portable flag. */
-    private boolean keepPortable;
-
     /** Class name. */
     private String clsName;
 
-    /** Remote reducer class name. */
-    private String rmtReducerClsName;
-
-    /** Remote transformer class name. */
-    private String rmtTransformerClsName;
-
     /** Query arguments. */
     private Object[] qryArgs;
 
@@ -215,55 +197,6 @@ public class GridClientCacheQueryRequest extends GridClientAbstractMessage
{
     }
 
     /**
-     * @return Query timeout.
-     */
-    public long timeout() {
-        return timeout;
-    }
-
-    /**
-     * @param timeout Query timeout.
-     */
-    public void timeout(long timeout) {
-        this.timeout = timeout;
-    }
-
-    /**
-     * @return Include backups flag.
-     */
-    public boolean includeBackups() {
-        return includeBackups;
-    }
-
-    /**
-     * @param includeBackups Include backups flag.
-     */
-    public void includeBackups(boolean includeBackups) {
-        this.includeBackups = includeBackups;
-    }
-
-    /**
-     * @return Enable de-duplication flag.
-     */
-    public boolean enableDedup() {
-        return enableDedup;
-    }
-
-    /**
-     * @return Keep portable flag.
-     */
-    public boolean keepPortable() {
-        return keepPortable;
-    }
-
-    /**
-     * @param enableDedup Enable de-duplication flag.
-     */
-    public void enableDedup(boolean enableDedup) {
-        this.enableDedup = enableDedup;
-    }
-
-    /**
      * @return Class name.
      */
     public String className() {
@@ -278,34 +211,6 @@ public class GridClientCacheQueryRequest extends GridClientAbstractMessage
{
     }
 
     /**
-     * @return Remote reducer class name.
-     */
-    public String remoteReducerClassName() {
-        return rmtReducerClsName;
-    }
-
-    /**
-     * @param rmtReducerClsName Remote reducer class name.
-     */
-    public void remoteReducerClassName(String rmtReducerClsName) {
-        this.rmtReducerClsName = rmtReducerClsName;
-    }
-
-    /**
-     * @return Remote transformer class name.
-     */
-    public String remoteTransformerClassName() {
-        return rmtTransformerClsName;
-    }
-
-    /**
-     * @param rmtTransformerClsName Remote transformer class name.
-     */
-    public void remoteTransformerClassName(String rmtTransformerClsName) {
-        this.rmtTransformerClsName = rmtTransformerClsName;
-    }
-
-    /**
      * @return Query arguments.
      */
     public Object[] queryArguments() {
@@ -329,13 +234,7 @@ public class GridClientCacheQueryRequest extends GridClientAbstractMessage
{
         cacheName = U.readString(in);
         clause = U.readString(in);
         pageSize = in.readInt();
-        timeout = in.readLong();
-        includeBackups = in.readBoolean();
-        enableDedup = in.readBoolean();
-        keepPortable = in.readBoolean();
         clsName = U.readString(in);
-        rmtReducerClsName = U.readString(in);
-        rmtTransformerClsName = U.readString(in);
         qryArgs = U.readArray(in);
     }
 
@@ -348,14 +247,7 @@ public class GridClientCacheQueryRequest extends GridClientAbstractMessage
{
         out.writeInt(type == null ? -1 : type.ordinal());
         U.writeString(out, cacheName);
         U.writeString(out, clause);
-        out.writeInt(pageSize);
-        out.writeLong(timeout);
-        out.writeBoolean(includeBackups);
-        out.writeBoolean(enableDedup);
-        out.writeBoolean(keepPortable);
         U.writeString(out, clsName);
-        U.writeString(out, rmtReducerClsName);
-        U.writeString(out, rmtTransformerClsName);
         U.writeArray(out, qryArgs);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4623cade/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java
index 93f69c2..a1fecaa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java
@@ -19,11 +19,10 @@ package org.apache.ignite.internal.processors.rest.handlers.cache;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.query.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.internal.processors.rest.*;
-import org.apache.ignite.internal.processors.rest.client.message.*;
 import org.apache.ignite.internal.processors.rest.handlers.*;
 import org.apache.ignite.internal.processors.rest.request.*;
 import org.apache.ignite.internal.util.future.*;
@@ -175,10 +174,7 @@ public class GridCacheQueryCommandHandler extends GridRestCommandHandlerAdapter
     ) throws IgniteCheckedException {
         if (wrapper == null)
             throw new IgniteCheckedException("Failed to find query future (query has been
expired).");
-
-        GridCacheQueryFutureAdapter<?, ?, ?> fut = wrapper.future();
-
-        Collection<Object> col = (Collection<Object>)fut.nextPage();
+        Collection<Object> col = wrapper.result();
 
         GridCacheRestResponse res = new GridCacheRestResponse();
 
@@ -268,28 +264,28 @@ public class GridCacheQueryCommandHandler extends GridRestCommandHandlerAdapter
         @Override public GridRestResponse call() throws Exception {
             long qryId = qryIdGen.getAndIncrement();
 
-            CacheQueries<Object,Object> queries = ((IgniteKernal)g).getCache(req.cacheName()).queries();
+            IgniteCache cache = g.cache(req.cacheName());
 
-            CacheQuery<?> qry;
+            Query qry;
 
             switch (req.type()) {
                 case SQL:
-                    qry = queries.createSqlQuery(req.className(), req.clause());
+                    qry = new SqlQuery(req.className(), req.clause()).setArgs(req.queryArguments());
 
                     break;
 
                 case SQL_FIELDS:
-                    qry = queries.createSqlFieldsQuery(req.clause());
+                    qry = new SqlFieldsQuery(req.clause()).setArgs(req.queryArguments());
 
                     break;
 
                 case FULL_TEXT:
-                    qry = queries.createFullTextQuery(req.className(), req.clause());
+                    qry = new TextQuery(req.className(), req.clause());
 
                     break;
 
                 case SCAN:
-                    qry = queries.createScanQuery(instance(IgniteBiPredicate.class, req.className()));
+                    qry = new ScanQuery(instance(IgniteBiPredicate.class, req.className()));
 
                     break;
 
@@ -297,38 +293,12 @@ public class GridCacheQueryCommandHandler extends GridRestCommandHandlerAdapter
                     throw new IgniteCheckedException("Unsupported query type: " + req.type());
             }
 
-            boolean keepPortable = req.keepPortable();
-
-            if (!keepPortable) {
-                if (req.type() != GridClientCacheQueryRequest.GridQueryType.SCAN &&
-                    (req.remoteReducerClassName() == null && req.remoteTransformerClassName()
== null))
-                    // Do not deserialize values on server if not needed.
-                    keepPortable = true;
-            }
-
-            ((GridCacheQueryAdapter)qry).keepPortable(keepPortable);
-            ((GridCacheQueryAdapter)qry).subjectId(req.clientId());
-
             if (req.pageSize() > 0)
-                qry = qry.pageSize(req.pageSize());
-
-            if (req.timeout() > 0)
-                qry = qry.timeout(req.timeout());
+                qry = qry.setPageSize(req.pageSize());
 
-            qry = qry.includeBackups(req.includeBackups()).enableDedup(req.enableDedup()).keepAll(false);
+            List<?> fut;
 
-            GridCacheQueryFutureAdapter<?, ?, ?> fut;
-
-            if (req.remoteReducerClassName() != null)
-                fut = (GridCacheQueryFutureAdapter<?, ?, ?>)qry.execute(
-                    instance(IgniteReducer.class, req.remoteReducerClassName()),
-                    req.queryArguments());
-            else if (req.remoteTransformerClassName() != null)
-                fut = (GridCacheQueryFutureAdapter<?, ?, ?>)qry.execute(
-                    instance(IgniteClosure.class, req.remoteTransformerClassName()),
-                    req.queryArguments());
-            else
-                fut = (GridCacheQueryFutureAdapter<?, ?, ?>)qry.execute(req.queryArguments());
+            fut = cache.query(qry).getAll();
 
             ConcurrentMap<QueryExecutionKey, QueryFutureWrapper> locMap = g.cluster().nodeLocalMap();
 
@@ -447,7 +417,7 @@ public class GridCacheQueryCommandHandler extends GridRestCommandHandlerAdapter
      */
     private static class QueryFutureWrapper {
         /** Query future. */
-        private final GridCacheQueryFutureAdapter<?, ?, ?> qryFut;
+        private final List qryFut;
 
         /** Last future use timestamp. */
         private volatile long lastUseTs;
@@ -455,7 +425,7 @@ public class GridCacheQueryCommandHandler extends GridRestCommandHandlerAdapter
         /**
          * @param qryFut Query future.
          */
-        private QueryFutureWrapper(GridCacheQueryFutureAdapter<?, ?, ?> qryFut) {
+        private QueryFutureWrapper(List qryFut) {
             this.qryFut = qryFut;
 
             lastUseTs = U.currentTimeMillis();
@@ -464,7 +434,7 @@ public class GridCacheQueryCommandHandler extends GridRestCommandHandlerAdapter
         /**
          * @return Query future.
          */
-        private GridCacheQueryFutureAdapter<?, ?, ?> future() {
+        private List result() {
             lastUseTs = U.currentTimeMillis();
 
             return qryFut;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4623cade/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestCacheQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestCacheQueryRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestCacheQueryRequest.java
index 3558eec..e32dd32 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestCacheQueryRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestCacheQueryRequest.java
@@ -81,53 +81,12 @@ public class GridRestCacheQueryRequest extends GridRestRequest implements
Serial
     }
 
     /**
-     * @return Timeout.
-     */
-    public long timeout() {
-        return msg.timeout();
-    }
-
-    /**
-     * @return Include backups.
-     */
-    public boolean includeBackups() {
-        return msg.includeBackups();
-    }
-
-    /**
-     * @return Enable dedup.
-     */
-    public boolean enableDedup() {
-        return msg.enableDedup();
-    }
-
-    /**
-     * @return Keep portable flag.
-     */
-    public boolean keepPortable() {
-        return msg.keepPortable();
-    }
-
-    /**
      * @return Class name.
      */
     public String className() {
         return msg.className();
     }
 
-    /**
-     * @return Remot reducer class name.
-     */
-    public String remoteReducerClassName() {
-        return msg.remoteReducerClassName();
-    }
-
-    /**
-     * @return Remote transformer class name.
-     */
-    public String remoteTransformerClassName() {
-        return msg.remoteTransformerClassName();
-    }
 
     /**
      * @return Query arguments.


Mime
View raw message