ignite-sql - fix after merge

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

Branch: refs/heads/sprint-1
Commit: c0e7b6d440fedbf559cd9e93e356ebee6e62416d
Parents: 2429519
Author: S.Vladykin <svlady...@gridgain.com>
Authored: Mon Jan 26 17:16:25 2015 +0300
Committer: S.Vladykin <svlady...@gridgain.com>
Committed: Mon Jan 26 17:16:25 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/internal/GridTopic.java   |    5 +-
 .../cache/query/GridCacheQueriesEx.java         |   17 +
 .../cache/query/GridCacheQueriesImpl.java       |   16 +
 .../cache/query/GridCacheQueriesProxy.java      |   25 +
 .../cache/query/GridCacheQueryManager.java      |   64 +-
 .../processors/query/GridQueryIndexing.java     |   19 +
 .../processors/query/GridQueryProcessor.java    |   36 +
 .../org/gridgain/grid/kernal/GridTopic.java     |  832 -----
 .../cache/query/GridCacheQueriesEx.java         |   68 -
 .../cache/query/GridCacheQueriesImpl.java       |  264 --
 .../cache/query/GridCacheQueriesProxy.java      |  297 --
 .../cache/query/GridCacheQueryManager.java      | 3197 ------------------
 .../cache/query/GridCacheSqlQuery.java          |    6 +-
 .../cache/query/GridCacheSqlResult.java         |    2 +
 .../cache/query/GridCacheTwoStepQuery.java      |    8 +-
 .../processors/query/GridQueryIndexing.java     |  189 --
 .../processors/query/GridQueryProcessor.java    | 1717 ----------
 .../testsuites/GridUtilSelfTestSuite.java       |   70 -
 .../query/h2/GridH2ResultSetIterator.java       |    2 +-
 .../processors/query/h2/IgniteH2Indexing.java   |  170 +-
 .../query/h2/opt/GridH2IndexBase.java           |    5 +-
 .../processors/query/h2/GridH2Indexing.java     | 2011 -----------
 .../query/h2/GridH2ResultSetIterator.java       |  131 -
 .../query/h2/opt/GridH2IndexBase.java           |  209 --
 .../query/h2/sql/GridSqlFunction.java           |    2 +-
 .../query/h2/twostep/GridMapQueryExecutor.java  |   13 +-
 .../query/h2/twostep/GridMergeIndex.java        |    3 -
 .../h2/twostep/GridMergeIndexUnsorted.java      |    1 -
 .../h2/twostep/GridReduceQueryExecutor.java     |   16 +-
 .../query/h2/twostep/GridResultPage.java        |    2 +-
 .../twostep/messages/GridNextPageResponse.java  |    2 +-
 .../cache/GridCacheCrossCacheQuerySelfTest.java |   58 +-
 .../processors/query/h2/sql/GridQueryTest.java  |   37 +-
 33 files changed, 318 insertions(+), 9176 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c0e7b6d4/modules/core/src/main/java/org/apache/ignite/internal/GridTopic.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/GridTopic.java 
b/modules/core/src/main/java/org/apache/ignite/internal/GridTopic.java
index dcc3c15..d48f5a9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridTopic.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridTopic.java
@@ -85,7 +85,10 @@ public enum GridTopic {
     TOPIC_TIME_SYNC,
 
     /** */
-    TOPIC_HADOOP;
+    TOPIC_HADOOP,
+
+    /** */
+    TOPIC_QUERY;
 
     /** Enum values. */
     private static final GridTopic[] VALS = values();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c0e7b6d4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesEx.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesEx.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesEx.java
index bccba8e..4ee40aa 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesEx.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesEx.java
@@ -19,6 +19,8 @@ package org.apache.ignite.internal.processors.cache.query;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.query.*;
+import org.apache.ignite.lang.*;
+import org.gridgain.grid.kernal.processors.cache.query.*;
 
 import java.util.*;
 
@@ -49,4 +51,19 @@ public interface GridCacheQueriesEx<K, V> extends 
CacheQueries<K, V> {
      * @return Query.
      */
     public <R> CacheQuery<R> createSpiQuery();
+
+    /**
+     * @param space Space name.
+     * @param qry Query.
+     * @return Future.
+     */
+    public IgniteFuture<GridCacheSqlResult> execute(String space, 
GridCacheTwoStepQuery qry);
+
+    /**
+     * @param space Space.
+     * @param sqlQry Query.
+     * @param params Parameters.
+     * @return Result.
+     */
+    public IgniteFuture<GridCacheSqlResult> executeTwoStepQuery(String space, 
String sqlQry, Object... params);
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c0e7b6d4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesImpl.java
index 364eb01..18bf3e7 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesImpl.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.spi.indexing.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
+import org.gridgain.grid.kernal.processors.cache.query.*;
 import org.jetbrains.annotations.*;
 
 import java.io.*;
@@ -166,6 +167,21 @@ public class GridCacheQueriesImpl<K, V> implements 
GridCacheQueriesEx<K, V>, Ext
     }
 
     /** {@inheritDoc} */
+    @Override public IgniteFuture<GridCacheSqlResult> execute(String space, 
GridCacheTwoStepQuery qry) {
+        return ctx.kernalContext().query().queryTwoStep(space, qry);
+    }
+
+    /**
+     * @param space Space.
+     * @param sqlQry Query.
+     * @param params Parameters.
+     * @return Result.
+     */
+    public IgniteFuture<GridCacheSqlResult> executeTwoStepQuery(String space, 
String sqlQry, Object[] params) {
+        return ctx.kernalContext().query().queryTwoStep(space, sqlQry, params);
+    }
+
+    /** {@inheritDoc} */
     @Override public CacheContinuousQuery<K, V> createContinuousQuery() {
         return ctx.continuousQueries().createQuery(prj == null ? null : 
prj.predicate());
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c0e7b6d4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesProxy.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesProxy.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesProxy.java
index 26c9d55..a3e219c 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesProxy.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesProxy.java
@@ -22,6 +22,7 @@ import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.query.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.lang.*;
+import org.gridgain.grid.kernal.processors.cache.query.*;
 import org.jetbrains.annotations.*;
 
 import java.io.*;
@@ -174,6 +175,30 @@ public class GridCacheQueriesProxy<K, V> implements 
GridCacheQueriesEx<K, V>, Ex
     }
 
     /** {@inheritDoc} */
+    @Override public IgniteFuture<GridCacheSqlResult> execute(String space, 
GridCacheTwoStepQuery qry) {
+        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+        try {
+            return delegate.execute(space, qry);
+        }
+        finally {
+            gate.leave(prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<GridCacheSqlResult> 
executeTwoStepQuery(String space, String sqlQry, Object[] params) {
+        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+        try {
+            return delegate.executeTwoStepQuery(space, sqlQry, params);
+        }
+        finally {
+            gate.leave(prev);
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public IgniteFuture<?> rebuildIndexes(Class<?> cls) {
         GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c0e7b6d4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index ae5fe77..6e5cf09 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -23,22 +23,22 @@ import org.apache.ignite.cache.query.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.util.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.resources.*;
-import org.apache.ignite.spi.*;
-import org.apache.ignite.spi.indexing.*;
 import org.apache.ignite.internal.managers.eventstorage.*;
+import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.datastructures.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.query.*;
 import org.apache.ignite.internal.processors.task.*;
+import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.future.*;
 import org.apache.ignite.internal.util.io.*;
 import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
+import org.apache.ignite.spi.*;
+import org.apache.ignite.spi.indexing.*;
 import org.jdk8.backport.*;
 import org.jetbrains.annotations.*;
 
@@ -47,8 +47,8 @@ import java.sql.*;
 import java.util.*;
 import java.util.concurrent.*;
 
-import static org.apache.ignite.cache.CacheMode.*;
 import static org.apache.ignite.events.IgniteEventType.*;
+import static org.apache.ignite.cache.CacheMode.*;
 import static org.apache.ignite.internal.GridClosureCallMode.*;
 import static 
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.*;
 
@@ -58,7 +58,7 @@ import static 
org.apache.ignite.internal.processors.cache.query.GridCacheQueryTy
 @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
 public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
     /** */
-    protected GridQueryProcessor idxProc;
+    protected GridQueryProcessor qryProc;
 
     /** */
     private String space;
@@ -85,7 +85,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
 
     /** {@inheritDoc} */
     @Override public void start0() throws IgniteCheckedException {
-        idxProc = cctx.kernalContext().query();
+        qryProc = cctx.kernalContext().query();
         space = cctx.name();
         maxIterCnt = cctx.config().getMaximumQueryIteratorCount();
 
@@ -172,7 +172,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
             throw new IllegalStateException("Failed to get size (grid is 
stopping).");
 
         try {
-            return idxProc.size(space, valType);
+            return qryProc.size(space, valType);
         }
         finally {
             leaveBusy();
@@ -200,7 +200,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
             throw new IllegalStateException("Failed to rebuild indexes (grid 
is stopping).");
 
         try {
-            return idxProc.rebuildIndexes(space, typeName);
+            return qryProc.rebuildIndexes(space, typeName);
         }
         finally {
             leaveBusy();
@@ -217,7 +217,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
             throw new IllegalStateException("Failed to rebuild indexes (grid 
is stopping).");
 
         try {
-            return idxProc.rebuildAllIndexes();
+            return qryProc.rebuildAllIndexes();
         }
         finally {
             leaveBusy();
@@ -269,7 +269,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
             return; // Ignore index update when node is stopping.
 
         try {
-            idxProc.onSwap(space, key);
+            qryProc.onSwap(space, key);
         }
         finally {
             leaveBusy();
@@ -289,7 +289,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
             return; // Ignore index update when node is stopping.
 
         try {
-            idxProc.onUnswap(space, key, val, valBytes);
+            qryProc.onUnswap(space, key, val, valBytes);
         }
         finally {
             leaveBusy();
@@ -331,7 +331,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
             if (val == null)
                 val = cctx.marshaller().unmarshal(valBytes, 
cctx.deploy().globalLoader());
 
-            idxProc.store(space, key, keyBytes, val, valBytes, 
CU.versionToBytes(ver), expirationTime);
+            qryProc.store(space, key, keyBytes, val, valBytes, 
CU.versionToBytes(ver), expirationTime);
         }
         finally {
             invalidateResultCache();
@@ -356,7 +356,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
             return; // Ignore index update when node is stopping.
 
         try {
-            idxProc.remove(space, key);
+            qryProc.remove(space, key);
         }
         finally {
             invalidateResultCache();
@@ -375,7 +375,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
             return; // Ignore index update when node is stopping.
 
         try {
-            idxProc.onUndeploy(space, ldr);
+            qryProc.onUndeploy(space, ldr);
         }
         catch (IgniteCheckedException e) {
             throw new IgniteException(e);
@@ -484,7 +484,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
                             cctx.localNode(),
                             "SQL query executed.",
                             EVT_CACHE_QUERY_EXECUTED,
-                            CacheQueryType.SQL,
+                            org.apache.ignite.cache.query.CacheQueryType.SQL,
                             cctx.namex(),
                             qry.queryClassName(),
                             qry.clause(),
@@ -495,7 +495,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
                             taskName));
                     }
 
-                    iter = idxProc.query(space, qry.clause(), F.asList(args),
+                    iter = qryProc.query(space, qry.clause(), F.asList(args),
                         qry.queryClassName(), filter(qry));
 
                     break;
@@ -506,7 +506,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
                             cctx.localNode(),
                             "Scan query executed.",
                             EVT_CACHE_QUERY_EXECUTED,
-                            CacheQueryType.SCAN,
+                            org.apache.ignite.cache.query.CacheQueryType.SCAN,
                             cctx.namex(),
                             null,
                             null,
@@ -527,7 +527,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
                             cctx.localNode(),
                             "Full text query executed.",
                             EVT_CACHE_QUERY_EXECUTED,
-                            CacheQueryType.FULL_TEXT,
+                            
org.apache.ignite.cache.query.CacheQueryType.FULL_TEXT,
                             cctx.namex(),
                             qry.queryClassName(),
                             qry.clause(),
@@ -538,7 +538,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
                             taskName));
                     }
 
-                    iter = idxProc.queryText(space, qry.clause(), 
qry.queryClassName(), filter(qry));
+                    iter = qryProc.queryText(space, qry.clause(), 
qry.queryClassName(), filter(qry));
 
                     break;
 
@@ -601,7 +601,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
                     cctx.localNode(),
                     "SQL fields query executed.",
                     EVT_CACHE_QUERY_EXECUTED,
-                    CacheQueryType.SQL_FIELDS,
+                    org.apache.ignite.cache.query.CacheQueryType.SQL_FIELDS,
                     cctx.namex(),
                     null,
                     qry.clause(),
@@ -633,7 +633,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
                     cctx.localNode(),
                     "SPI query executed.",
                     EVT_CACHE_QUERY_EXECUTED,
-                    CacheQueryType.SPI,
+                    org.apache.ignite.cache.query.CacheQueryType.SPI,
                     cctx.namex(),
                     null,
                     null,
@@ -657,7 +657,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
             else {
                 assert qry.type() == SQL_FIELDS;
 
-                GridQueryFieldsResult qryRes = idxProc.queryFields(space, 
qry.clause(), F.asList(args), filter(qry));
+                GridQueryFieldsResult qryRes = qryProc.queryFields(space, 
qry.clause(), F.asList(args), filter(qry));
 
                 res.metaData(qryRes.metaData());
 
@@ -756,8 +756,8 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
         GridIterator<IgniteBiTuple<K, V>> heapIt = new 
GridIteratorAdapter<IgniteBiTuple<K, V>>() {
             private IgniteBiTuple<K, V> next;
 
-            private Iterator<K> iter = qry.includeBackups() || 
cctx.isReplicated() ?
-                prj.keySet().iterator() : prj.primaryKeySet().iterator();
+            private Iterator<K> iter = prj.keySet().iterator();
+
             {
                 advance();
             }
@@ -1065,7 +1065,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
                             cctx.localNode(),
                             "SQL fields query result set row read.",
                             EVT_CACHE_QUERY_OBJECT_READ,
-                            CacheQueryType.SQL_FIELDS,
+                            
org.apache.ignite.cache.query.CacheQueryType.SQL_FIELDS,
                             cctx.namex(),
                             null,
                             qry.clause(),
@@ -1252,7 +1252,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
                                     cctx.localNode(),
                                     "SQL query entry read.",
                                     EVT_CACHE_QUERY_OBJECT_READ,
-                                    CacheQueryType.SQL,
+                                    
org.apache.ignite.cache.query.CacheQueryType.SQL,
                                     cctx.namex(),
                                     qry.queryClassName(),
                                     qry.clause(),
@@ -1275,7 +1275,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
                                     cctx.localNode(),
                                     "Full text query entry read.",
                                     EVT_CACHE_QUERY_OBJECT_READ,
-                                    CacheQueryType.FULL_TEXT,
+                                    
org.apache.ignite.cache.query.CacheQueryType.FULL_TEXT,
                                     cctx.namex(),
                                     qry.queryClassName(),
                                     qry.clause(),
@@ -1298,7 +1298,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
                                     cctx.localNode(),
                                     "Scan query entry read.",
                                     EVT_CACHE_QUERY_OBJECT_READ,
-                                    CacheQueryType.SCAN,
+                                    
org.apache.ignite.cache.query.CacheQueryType.SCAN,
                                     cctx.namex(),
                                     null,
                                     null,
@@ -1907,7 +1907,7 @@ public abstract class GridCacheQueryManager<K, V> extends 
GridCacheManagerAdapte
 
                     for (GridQueryTypeDescriptor type : types) {
                         // Filter internal types (e.g., data structures).
-                        if (type.name().startsWith("Cache"))
+                        if (type.name().startsWith("GridCache"))
                             continue;
 
                         names.add(type.name());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c0e7b6d4/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
index 8bc9405..0127ae9 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
@@ -22,6 +22,7 @@ import org.apache.ignite.internal.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.spi.indexing.*;
 import org.apache.ignite.internal.util.lang.*;
+import org.gridgain.grid.kernal.processors.cache.query.*;
 import org.jetbrains.annotations.*;
 
 import java.util.*;
@@ -45,6 +46,24 @@ public interface GridQueryIndexing {
      */
     public void stop() throws IgniteCheckedException;
 
+
+    /**
+     * Runs two step query.
+     *
+     * @param space Space name.
+     * @param qry Query.
+     * @return Future.
+     */
+    public IgniteFuture<GridCacheSqlResult> queryTwoStep(String space,  
GridCacheTwoStepQuery qry);
+
+    /**
+     * @param space Space.
+     * @param sqlQry Query.
+     * @param params Parameters.
+     * @return Result.
+     */
+    public IgniteFuture<GridCacheSqlResult> queryTwoStep(String space, String 
sqlQry, Object[] params);
+
     /**
      * Queries individual fields (generally used by JDBC drivers).
      *

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c0e7b6d4/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 0ac2edf..98864ef 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -32,6 +32,7 @@ import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.internal.util.worker.*;
+import org.gridgain.grid.kernal.processors.cache.query.*;
 import org.jdk8.backport.*;
 import org.jetbrains.annotations.*;
 
@@ -435,6 +436,41 @@ public class GridQueryProcessor extends 
GridProcessorAdapter {
     }
 
     /**
+     * @param space Space name.
+     * @param qry Query.
+     * @return Future.
+     */
+    public IgniteFuture<GridCacheSqlResult> queryTwoStep(String space, 
GridCacheTwoStepQuery qry) {
+        if (!busyLock.enterBusy())
+            throw new IllegalStateException("Failed to execute query (grid is 
stopping).");
+
+        try {
+            return idx.queryTwoStep(space, qry);
+        }
+        finally {
+            busyLock.leaveBusy();
+        }
+    }
+
+    /**
+     * @param space Space.
+     * @param sqlQry Query.
+     * @param params Parameters.
+     * @return Result.
+     */
+    public IgniteFuture<GridCacheSqlResult> queryTwoStep(String space, String 
sqlQry, Object[] params) {
+        if (!busyLock.enterBusy())
+            throw new IllegalStateException("Failed to execute query (grid is 
stopping).");
+
+        try {
+            return idx.queryTwoStep(space, sqlQry, params);
+        }
+        finally {
+            busyLock.leaveBusy();
+        }
+    }
+
+    /**
      * @param space Space.
      * @param key Key.
      * @throws IgniteCheckedException Thrown in case of any errors.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c0e7b6d4/modules/core/src/main/java/org/gridgain/grid/kernal/GridTopic.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTopic.java 
b/modules/core/src/main/java/org/gridgain/grid/kernal/GridTopic.java
deleted file mode 100644
index 9b98723..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTopic.java
+++ /dev/null
@@ -1,832 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.gridgain.grid.kernal;
-
-import org.apache.ignite.lang.*;
-import org.apache.ignite.marshaller.optimized.*;
-import org.gridgain.grid.util.typedef.internal.*;
-import org.jetbrains.annotations.*;
-
-import java.io.*;
-import java.nio.charset.*;
-import java.util.*;
-
-/**
- * Communication topic.
- */
-public enum GridTopic {
-    /** */
-    TOPIC_JOB,
-
-    /** */
-    TOPIC_JOB_SIBLINGS,
-
-    /** */
-    TOPIC_TASK,
-
-    /** */
-    TOPIC_CHECKPOINT,
-
-    /** */
-    TOPIC_JOB_CANCEL,
-
-    /** */
-    TOPIC_TASK_CANCEL,
-
-    /** */
-    TOPIC_CLASSLOAD,
-
-    /** */
-    TOPIC_EVENT,
-
-    /** Cache topic. */
-    TOPIC_CACHE,
-
-    /** */
-    TOPIC_COMM_USER,
-
-    /** */
-    TOPIC_REST,
-
-    /** */
-    TOPIC_REPLICATION,
-
-    /** */
-    TOPIC_GGFS,
-
-    /** */
-    TOPIC_DATALOAD,
-
-    /** */
-    TOPIC_STREAM,
-
-    /** */
-    TOPIC_CONTINUOUS,
-
-    /** */
-    TOPIC_MONGO,
-
-    /** */
-    TOPIC_TIME_SYNC,
-
-    /** */
-    TOPIC_HADOOP,
-
-    /** */
-    TOPIC_QUERY;
-
-    /** Enum values. */
-    private static final GridTopic[] VALS = values();
-
-    /** Default charset to work with strings. */
-    private static final Charset DFLT_CHARSET = Charset.forName("UTF-8");
-
-    /**
-     * Efficiently gets enumerated value from its ordinal.
-     *
-     * @param ord Ordinal value.
-     * @return Enumerated value.
-     */
-    @Nullable public static GridTopic fromOrdinal(int ord) {
-        return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
-    }
-
-    /**
-     * @param id Topic ID.
-     * @return Grid message topic with specified ID.
-     */
-    public Object topic(IgniteUuid id) {
-        return new T1(this, id);
-    }
-
-    /**
-     * @param id1 ID1.
-     * @param id2 ID2.
-     * @return Grid message topic with specified IDs.
-     */
-    public Object topic(IgniteUuid id1, UUID id2) {
-        return new T2(this, id1, id2);
-    }
-
-    /**
-     * @param id1 ID1.
-     * @param id2 ID2.
-     * @return Grid message topic with specified IDs.
-     */
-    public Object topic(IgniteUuid id1, long id2) {
-        return new T8(this, id1, id2);
-    }
-
-    /**
-     * NOTE: The method should be used only for cases when there is no any 
other non-string identifier(s)
-     * to use to differentiate topics.
-     *
-     * @param id Topic ID.
-     * @return Grid message topic with specified ID.
-     */
-    public Object topic(String id) {
-        return new T3(this, UUID.nameUUIDFromBytes(id.getBytes(DFLT_CHARSET)));
-    }
-
-    /**
-     * @param id1 ID1.
-     * @param id2 ID2.
-     * @return Grid message topic with specified IDs.
-     */
-    public Object topic(String id1, long id2) {
-        return new T6(this, 
UUID.nameUUIDFromBytes(id1.getBytes(DFLT_CHARSET)), id2);
-    }
-
-    /**
-     * @param id1 ID1.
-     * @param id2 ID2.
-     * @param id3 ID3.
-     * @return Grid message topic with specified IDs.
-     */
-    public Object topic(String id1, int id2, long id3) {
-        return new T5(this, 
UUID.nameUUIDFromBytes(id1.getBytes(DFLT_CHARSET)), id2, id3);
-    }
-
-    /**
-     * @param id1 ID1.
-     * @param id2 ID2.
-     * @param id3 ID3.
-     * @return Grid message topic with specified IDs.
-     */
-    public Object topic(String id1, UUID id2, long id3) {
-        return new T4(this, 
UUID.nameUUIDFromBytes(id1.getBytes(DFLT_CHARSET)), id2, id3);
-    }
-
-    /**
-     * @param id1 ID1.
-     * @param id2 ID2.
-     * @param id3 ID3.
-     * @param id4 ID4.
-     * @return Grid message topic with specified IDs.
-     */
-    public Object topic(String id1, UUID id2, int id3, long id4) {
-        return new T7(this, 
UUID.nameUUIDFromBytes(id1.getBytes(DFLT_CHARSET)), id2, id3, id4);
-    }
-
-    /**
-     *
-     */
-    private static class T1 implements Externalizable, 
IgniteOptimizedMarshallable {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** */
-        @SuppressWarnings({"NonConstantFieldWithUpperCaseName", 
"AbbreviationUsage", "UnusedDeclaration"})
-        private static Object GG_CLASS_ID;
-
-        /** */
-        private GridTopic topic;
-
-        /** */
-        private IgniteUuid id;
-
-        /**
-         * No-arg constructor needed for {@link Serializable}.
-         */
-        public T1() {
-            // No-op.
-        }
-
-        /**
-         * @param topic Topic.
-         * @param id ID.
-         */
-        private T1(GridTopic topic, IgniteUuid id) {
-            this.topic = topic;
-            this.id = id;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object ggClassId() {
-            return GG_CLASS_ID;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return topic.ordinal() + id.hashCode();
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object obj) {
-            if (obj.getClass() == T1.class) {
-                T1 that = (T1)obj;
-
-                return topic == that.topic && id.equals(that.id);
-            }
-
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws 
IOException {
-            out.writeByte(topic.ordinal());
-            U.writeGridUuid(out, id);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-            topic = fromOrdinal(in.readByte());
-            id = U.readGridUuid(in);
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(T1.class, this);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class T2 implements Externalizable, 
IgniteOptimizedMarshallable {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** */
-        @SuppressWarnings({"NonConstantFieldWithUpperCaseName", 
"AbbreviationUsage", "UnusedDeclaration"})
-        private static Object GG_CLASS_ID;
-
-        /** */
-        private GridTopic topic;
-
-        /** */
-        private IgniteUuid id1;
-
-        /** */
-        private UUID id2;
-
-        /**
-         * No-arg constructor needed for {@link Serializable}.
-         */
-        public T2() {
-            // No-op.
-        }
-
-        /**
-         * @param topic Topic.
-         * @param id1 ID1.
-         * @param id2 ID2.
-         */
-        private T2(GridTopic topic, IgniteUuid id1, UUID id2) {
-            this.topic = topic;
-            this.id1 = id1;
-            this.id2 = id2;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object ggClassId() {
-            return GG_CLASS_ID;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return topic.ordinal() + id1.hashCode() + id2.hashCode();
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object obj) {
-            if (obj.getClass() == T2.class) {
-                T2 that = (T2)obj;
-
-                return topic == that.topic && id1.equals(that.id1) && 
id2.equals(that.id2);
-            }
-
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws 
IOException {
-            out.writeByte(topic.ordinal());
-            U.writeGridUuid(out, id1);
-            U.writeUuid(out, id2);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-            topic = fromOrdinal(in.readByte());
-            id1 = U.readGridUuid(in);
-            id2 = U.readUuid(in);
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(T2.class, this);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class T3 implements Externalizable, 
IgniteOptimizedMarshallable {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** */
-        @SuppressWarnings({"NonConstantFieldWithUpperCaseName", 
"AbbreviationUsage", "UnusedDeclaration"})
-        private static Object GG_CLASS_ID;
-
-        /** */
-        private GridTopic topic;
-
-        /** */
-        private UUID id1;
-
-        /**
-         * No-arg constructor needed for {@link Serializable}.
-         */
-        public T3() {
-            // No-op.
-        }
-
-        /**
-         * @param topic Topic.
-         * @param id1 ID1.
-         */
-        private T3(GridTopic topic, UUID id1) {
-            this.topic = topic;
-            this.id1 = id1;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return topic.ordinal() + id1.hashCode();
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object obj) {
-            if (obj.getClass() == T3.class) {
-                T3 that = (T3)obj;
-
-                return topic == that.topic && id1.equals(that.id1);
-            }
-
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object ggClassId() {
-            return GG_CLASS_ID;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws 
IOException {
-            out.writeByte(topic.ordinal());
-            U.writeUuid(out, id1);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-            topic = fromOrdinal(in.readByte());
-            id1 = U.readUuid(in);
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(T3.class, this);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class T4 implements Externalizable, 
IgniteOptimizedMarshallable {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** */
-        @SuppressWarnings({"NonConstantFieldWithUpperCaseName", 
"AbbreviationUsage", "UnusedDeclaration"})
-        private static Object GG_CLASS_ID;
-
-        /** */
-        private GridTopic topic;
-
-        /** */
-        private UUID id1;
-
-        /** */
-        private UUID id2;
-
-        /** */
-        private long id3;
-
-        /**
-         * No-arg constructor needed for {@link Serializable}.
-         */
-        public T4() {
-            // No-op.
-        }
-
-        /**
-         * @param topic Topic.
-         * @param id1 ID1.
-         * @param id2 ID2.
-         * @param id3 ID3.
-         */
-        private T4(GridTopic topic, UUID id1, UUID id2, long id3) {
-            this.topic = topic;
-            this.id1 = id1;
-            this.id2 = id2;
-            this.id3 = id3;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object ggClassId() {
-            return GG_CLASS_ID;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return topic.ordinal() + id1.hashCode() + id2.hashCode() + 
(int)(id3 ^ (id3 >>> 32));
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object obj) {
-            if (obj.getClass() == T4.class) {
-                T4 that = (T4)obj;
-
-                return topic == that.topic && id1.equals(that.id1) && 
id2.equals(that.id2) && id3 == that.id3;
-            }
-
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws 
IOException {
-            out.writeByte(topic.ordinal());
-            U.writeUuid(out, id1);
-            U.writeUuid(out, id2);
-            out.writeLong(id3);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-            topic = fromOrdinal(in.readByte());
-            id1 = U.readUuid(in);
-            id2 = U.readUuid(in);
-            id3 = in.readLong();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(T4.class, this);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class T5 implements Externalizable, 
IgniteOptimizedMarshallable {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** */
-        @SuppressWarnings({"NonConstantFieldWithUpperCaseName", 
"AbbreviationUsage", "UnusedDeclaration"})
-        private static Object GG_CLASS_ID;
-
-        /** */
-        private GridTopic topic;
-
-        /** */
-        private UUID id1;
-
-        /** */
-        private int id2;
-
-        /** */
-        private long id3;
-
-        /**
-         * No-arg constructor needed for {@link Serializable}.
-         */
-        public T5() {
-            // No-op.
-        }
-
-        /**
-         * @param topic Topic.
-         * @param id1 ID1.
-         * @param id2 ID2.
-         * @param id3 ID3.
-         */
-        private T5(GridTopic topic, UUID id1, int id2, long id3) {
-            this.topic = topic;
-            this.id1 = id1;
-            this.id2 = id2;
-            this.id3 = id3;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object ggClassId() {
-            return GG_CLASS_ID;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return topic.ordinal() + id1.hashCode() + id2 + (int)(id3 ^ (id3 
>>> 32));
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object obj) {
-            if (obj.getClass() == T5.class) {
-                T5 that = (T5)obj;
-
-                return topic == that.topic && id1.equals(that.id1) && id2 == 
that.id2 && id3 == that.id3;
-            }
-
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws 
IOException {
-            out.writeByte(topic.ordinal());
-            U.writeUuid(out, id1);
-            out.writeInt(id2);
-            out.writeLong(id3);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-            topic = fromOrdinal(in.readByte());
-            id1 = U.readUuid(in);
-            id2 = in.readInt();
-            id3 = in.readLong();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(T5.class, this);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class T6 implements Externalizable, 
IgniteOptimizedMarshallable {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** */
-        @SuppressWarnings({"NonConstantFieldWithUpperCaseName", 
"AbbreviationUsage", "UnusedDeclaration"})
-        private static Object GG_CLASS_ID;
-
-        /** */
-        private GridTopic topic;
-
-        /** */
-        private UUID id1;
-
-        /** */
-        private long id2;
-
-        /**
-         * No-arg constructor needed for {@link Serializable}.
-         */
-        public T6() {
-            // No-op.
-        }
-
-        /**
-         * @param topic Topic.
-         * @param id1 ID 1.
-         * @param id2 ID 2.
-         */
-        private T6(GridTopic topic, UUID id1, long id2) {
-            this.topic = topic;
-            this.id1 = id1;
-            this.id2 = id2;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object ggClassId() {
-            return GG_CLASS_ID;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return topic.ordinal() + id1.hashCode () + (int)(id2 ^ (id2 >>> 
32));
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object obj) {
-            if (obj.getClass() == T6.class) {
-                T6 that = (T6)obj;
-
-                return topic == that.topic && id1.equals(that.id1) && id2 == 
that.id2;
-            }
-
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws 
IOException {
-            out.writeByte(topic.ordinal());
-            U.writeUuid(out, id1);
-            out.writeLong(id2);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-            topic = fromOrdinal(in.readByte());
-            id1 = U.readUuid(in);
-            id2 = in.readLong();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(T6.class, this);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class T7 implements Externalizable, 
IgniteOptimizedMarshallable {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** */
-        @SuppressWarnings({"NonConstantFieldWithUpperCaseName", 
"AbbreviationUsage", "UnusedDeclaration"})
-        private static Object GG_CLASS_ID;
-
-        /** */
-        private GridTopic topic;
-
-        /** */
-        private UUID id1;
-
-        /** */
-        private UUID id2;
-
-        /** */
-        private int id3;
-
-        /** */
-        private long id4;
-
-        /**
-         * No-arg constructor needed for {@link Serializable}.
-         */
-        public T7() {
-            // No-op.
-        }
-
-        /**
-         * @param topic Topic.
-         * @param id1 ID1.
-         * @param id2 ID2.
-         * @param id3 ID3.
-         * @param id4 ID4.
-         */
-        private T7(GridTopic topic, UUID id1, UUID id2, int id3, long id4) {
-            this.topic = topic;
-            this.id1 = id1;
-            this.id2 = id2;
-            this.id3 = id3;
-            this.id4 = id4;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object ggClassId() {
-            return GG_CLASS_ID;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return topic.ordinal() + id1.hashCode() + id2.hashCode() + id3 + 
(int)(id4 ^ (id4 >>> 32));
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object obj) {
-            if (obj.getClass() == T7.class) {
-                T7 that = (T7)obj;
-
-                return topic == that.topic && id1.equals(that.id1) && 
id2.equals(that.id2) && id3 == that.id3 &&
-                    id4 == that.id4;
-            }
-
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws 
IOException {
-            out.writeByte(topic.ordinal());
-            U.writeUuid(out, id1);
-            U.writeUuid(out, id2);
-            out.writeInt(id3);
-            out.writeLong(id4);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-            topic = fromOrdinal(in.readByte());
-            id1 = U.readUuid(in);
-            id2 = U.readUuid(in);
-            id3 = in.readInt();
-            id4 = in.readLong();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(T7.class, this);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class T8 implements Externalizable, 
IgniteOptimizedMarshallable {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** */
-        @SuppressWarnings({"NonConstantFieldWithUpperCaseName", 
"AbbreviationUsage", "UnusedDeclaration"})
-        private static Object GG_CLASS_ID;
-
-        /** */
-        private GridTopic topic;
-
-        /** */
-        private IgniteUuid id1;
-
-        /** */
-        private long id2;
-
-        /**
-         * No-arg constructor needed for {@link Serializable}.
-         */
-        public T8() {
-            // No-op.
-        }
-
-        /**
-         * @param topic Topic.
-         * @param id1 ID1.
-         * @param id2 ID2.
-         */
-        private T8(GridTopic topic, IgniteUuid id1, long id2) {
-            this.topic = topic;
-            this.id1 = id1;
-            this.id2 = id2;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object ggClassId() {
-            return GG_CLASS_ID;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return topic.ordinal() + id1.hashCode() + (int)(id2 ^ (id2 >>> 
32));
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object obj) {
-            if (obj.getClass() == T8.class) {
-                T8 that = (T8)obj;
-
-                return topic == that.topic && id1.equals(that.id1) && id2 == 
that.id2;
-            }
-
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws 
IOException {
-            out.writeByte(topic.ordinal());
-            U.writeGridUuid(out, id1);
-            out.writeLong(id2);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-            topic = fromOrdinal(in.readByte());
-            id1 = U.readGridUuid(in);
-            id2 = in.readLong();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(T8.class, this);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c0e7b6d4/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueriesEx.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueriesEx.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueriesEx.java
deleted file mode 100644
index 4088546..0000000
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueriesEx.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.gridgain.grid.kernal.processors.cache.query;
-
-import org.apache.ignite.*;
-import org.apache.ignite.lang.*;
-import org.gridgain.grid.cache.query.*;
-
-import java.util.*;
-
-/**
- * Extended queries interface.
- */
-public interface GridCacheQueriesEx<K, V> extends GridCacheQueries<K, V> {
-    /**
-     * Gets SQL metadata.
-     *
-     * @return SQL metadata.
-     * @throws IgniteCheckedException In case of error.
-     */
-    public Collection<GridCacheSqlMetadata> sqlMetadata() throws 
IgniteCheckedException;
-
-    /**
-     * Creates SQL fields query which will include results metadata if needed.
-     *
-     * @param qry SQL query.
-     * @param incMeta Whether to include results metadata.
-     * @return Created query.
-     */
-    public GridCacheQuery<List<?>> createSqlFieldsQuery(String qry, boolean 
incMeta);
-
-    /**
-     * Creates SPI query.
-     *
-     * @return Query.
-     */
-    public <R> GridCacheQuery<R> createSpiQuery();
-
-    /**
-     * @param space Space name.
-     * @param qry Query.
-     * @return Future.
-     */
-    public IgniteFuture<GridCacheSqlResult> execute(String space, 
GridCacheTwoStepQuery qry);
-
-    /**
-     * @param space Space.
-     * @param sqlQry Query.
-     * @param params Parameters.
-     * @return Result.
-     */
-    public IgniteFuture<GridCacheSqlResult> executeTwoStepQuery(String space, 
String sqlQry, Object... params);
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c0e7b6d4/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueriesImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueriesImpl.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueriesImpl.java
deleted file mode 100644
index 55421cf..0000000
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueriesImpl.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.gridgain.grid.kernal.processors.cache.query;
-
-import org.apache.ignite.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.spi.indexing.*;
-import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.query.*;
-import org.gridgain.grid.kernal.processors.cache.*;
-import org.gridgain.grid.util.typedef.internal.*;
-import org.jetbrains.annotations.*;
-
-import java.io.*;
-import java.util.*;
-
-import static 
org.gridgain.grid.kernal.processors.cache.query.GridCacheQueryType.*;
-
-/**
- * {@link GridCacheQueries} implementation.
- */
-public class GridCacheQueriesImpl<K, V> implements GridCacheQueriesEx<K, V>, 
Externalizable {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** */
-    private GridCacheContext<K, V> ctx;
-
-    /** */
-    private GridCacheProjectionImpl<K, V> prj;
-
-    /**
-     * Required by {@link Externalizable}.
-     */
-    public GridCacheQueriesImpl() {
-        // No-op.
-    }
-
-    /**
-     * @param ctx Context.
-     * @param prj Projection.
-     */
-    public GridCacheQueriesImpl(GridCacheContext<K, V> ctx, @Nullable 
GridCacheProjectionImpl<K, V> prj) {
-        assert ctx != null;
-
-        this.ctx = ctx;
-        this.prj = prj;
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQuery<Map.Entry<K, V>> createSqlQuery(Class<?> 
cls, String clause) {
-        A.notNull(cls, "cls");
-        A.notNull(clause, "clause");
-
-        return new GridCacheQueryAdapter<>(ctx,
-            SQL,
-            filter(),
-            ctx.kernalContext().query().typeName(U.box(cls)),
-            clause,
-            null,
-            false,
-            prj != null && prj.isKeepPortable());
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQuery<Map.Entry<K, V>> createSqlQuery(String 
clsName, String clause) {
-        A.notNull("clsName", clsName);
-        A.notNull("clause", clause);
-
-        return new GridCacheQueryAdapter<>(ctx,
-            SQL,
-            filter(),
-            clsName,
-            clause,
-            null,
-            false,
-            prj != null && prj.isKeepPortable());
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQuery<List<?>> createSqlFieldsQuery(String qry) {
-        A.notNull(qry, "qry");
-
-        return new GridCacheQueryAdapter<>(ctx,
-            SQL_FIELDS,
-            filter(),
-            null,
-            qry,
-            null,
-            false,
-            prj != null && prj.isKeepPortable());
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQuery<Map.Entry<K, V>> 
createFullTextQuery(Class<?> cls, String search) {
-        A.notNull(cls, "cls");
-        A.notNull(search, "search");
-
-        return new GridCacheQueryAdapter<>(ctx,
-            TEXT,
-            filter(),
-            ctx.kernalContext().query().typeName(U.box(cls)),
-            search,
-            null,
-            false,
-            prj != null && prj.isKeepPortable());
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQuery<Map.Entry<K, V>> 
createFullTextQuery(String clsName, String search) {
-        A.notNull("clsName", clsName);
-        A.notNull("search", search);
-
-        return new GridCacheQueryAdapter<>(ctx,
-            TEXT,
-            filter(),
-            clsName,
-            search,
-            null,
-            false,
-            prj != null && prj.isKeepPortable());
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public GridCacheQuery<Map.Entry<K, V>> createScanQuery(@Nullable 
IgniteBiPredicate<K, V> filter) {
-        return new GridCacheQueryAdapter<>(ctx,
-            SCAN,
-            filter(),
-            null,
-            null,
-            (IgniteBiPredicate<Object, Object>)filter,
-            false,
-            prj != null && prj.isKeepPortable());
-    }
-
-    /**
-     * Query for {@link GridIndexingSpi}.
-     *
-     * @return Query.
-     */
-    public <R> GridCacheQuery<R> createSpiQuery() {
-        return new GridCacheQueryAdapter<>(ctx,
-            SPI,
-            filter(),
-            null,
-            null,
-            null,
-            false,
-            prj != null && prj.isKeepPortable());
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<GridCacheSqlResult> execute(String space, 
GridCacheTwoStepQuery qry) {
-        return ctx.kernalContext().query().queryTwoStep(space, qry);
-    }
-
-    /**
-     * @param space Space.
-     * @param sqlQry Query.
-     * @param params Parameters.
-     * @return Result.
-     */
-    public IgniteFuture<GridCacheSqlResult> executeTwoStepQuery(String space, 
String sqlQry, Object[] params) {
-        return ctx.kernalContext().query().queryTwoStep(space, sqlQry, params);
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheContinuousQuery<K, V> createContinuousQuery() {
-        return ctx.continuousQueries().createQuery(prj == null ? null : 
prj.predicate());
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<?> rebuildIndexes(Class<?> cls) {
-        A.notNull(cls, "cls");
-
-        return ctx.queries().rebuildIndexes(cls);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<?> rebuildIndexes(String typeName) {
-        A.notNull("typeName", typeName);
-
-        return ctx.queries().rebuildIndexes(typeName);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<?> rebuildAllIndexes() {
-        return ctx.queries().rebuildAllIndexes();
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQueryMetrics metrics() {
-        return ctx.queries().metrics();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void resetMetrics() {
-        ctx.queries().resetMetrics();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Collection<GridCacheSqlMetadata> sqlMetadata() throws 
IgniteCheckedException {
-        return ctx.queries().sqlMetadata();
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQuery<List<?>> createSqlFieldsQuery(String qry, 
boolean incMeta) {
-        assert qry != null;
-
-        return new GridCacheQueryAdapter<>(ctx,
-            SQL_FIELDS,
-            filter(),
-            null,
-            qry,
-            null,
-            incMeta,
-            prj != null && prj.isKeepPortable());
-    }
-
-    /**
-     * @return Optional projection filter.
-     */
-    @SuppressWarnings("unchecked")
-    @Nullable private IgnitePredicate<GridCacheEntry<Object, Object>> filter() 
{
-        return prj == null ? null : ((GridCacheProjectionImpl<Object, 
Object>)prj).predicate();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(prj);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-        prj = (GridCacheProjectionImpl<K, V>)in.readObject();
-    }
-
-    /**
-     * Reconstructs object on unmarshalling.
-     *
-     * @return Reconstructed object.
-     * @throws ObjectStreamException Thrown in case of unmarshalling error.
-     */
-    private Object readResolve() throws ObjectStreamException {
-        return prj.queries();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c0e7b6d4/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueriesProxy.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueriesProxy.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueriesProxy.java
deleted file mode 100644
index bea549d..0000000
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueriesProxy.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.gridgain.grid.kernal.processors.cache.query;
-
-import org.apache.ignite.*;
-import org.apache.ignite.lang.*;
-import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.query.*;
-import org.gridgain.grid.kernal.processors.cache.*;
-import org.jetbrains.annotations.*;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * Per-projection queries object returned to user.
- */
-public class GridCacheQueriesProxy<K, V> implements GridCacheQueriesEx<K, V>, 
Externalizable {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** */
-    private GridCacheGateway<K, V> gate;
-
-    /** */
-    private GridCacheProjectionImpl<K, V> prj;
-
-    /** */
-    private GridCacheQueriesEx<K, V> delegate;
-
-    /**
-     * Required by {@link Externalizable}.
-     */
-    public GridCacheQueriesProxy() {
-        // No-op.
-    }
-
-    /**
-     * Create cache queries implementation.
-     *
-     * @param cctx Сontext.
-     * @param prj Optional cache projection.
-     * @param delegate Delegate object.
-     */
-    public GridCacheQueriesProxy(GridCacheContext<K, V> cctx, @Nullable 
GridCacheProjectionImpl<K, V> prj,
-        GridCacheQueriesEx<K, V> delegate) {
-        assert cctx != null;
-        assert delegate != null;
-
-        gate = cctx.gate();
-
-        this.prj = prj;
-        this.delegate = delegate;
-    }
-
-    /**
-     * Gets cache projection.
-     *
-     * @return Cache projection.
-     */
-    public GridCacheProjection<K, V> projection() {
-        return prj;
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQuery<Map.Entry<K, V>> createSqlQuery(Class<?> 
cls, String clause) {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.createSqlQuery(cls, clause);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQuery<Map.Entry<K, V>> createSqlQuery(String 
clsName, String clause) {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.createSqlQuery(clsName, clause);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQuery<List<?>> createSqlFieldsQuery(String qry) {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.createSqlFieldsQuery(qry);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQuery<Map.Entry<K, V>> 
createFullTextQuery(Class<?> cls, String search) {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.createFullTextQuery(cls, search);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQuery<Map.Entry<K, V>> 
createFullTextQuery(String clsName, String search) {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.createFullTextQuery(clsName, search);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQuery<Map.Entry<K, V>> createScanQuery(@Nullable 
IgniteBiPredicate<K, V> filter) {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.createScanQuery(filter);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheContinuousQuery<K, V> createContinuousQuery() {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.createContinuousQuery();
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <R> GridCacheQuery<R> createSpiQuery() {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.createSpiQuery();
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<GridCacheSqlResult> execute(String space, 
GridCacheTwoStepQuery qry) {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.execute(space, qry);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<GridCacheSqlResult> 
executeTwoStepQuery(String space, String sqlQry, Object[] params) {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.executeTwoStepQuery(space, sqlQry, params);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<?> rebuildIndexes(Class<?> cls) {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.rebuildIndexes(cls);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<?> rebuildIndexes(String typeName) {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.rebuildIndexes(typeName);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<?> rebuildAllIndexes() {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.rebuildAllIndexes();
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQueryMetrics metrics() {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.metrics();
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void resetMetrics() {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            delegate.resetMetrics();
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public Collection<GridCacheSqlMetadata> sqlMetadata() throws 
IgniteCheckedException {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.sqlMetadata();
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheQuery<List<?>> createSqlFieldsQuery(String qry, 
boolean incMeta) {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.createSqlFieldsQuery(qry, incMeta);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(prj);
-        out.writeObject(delegate);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-        prj = (GridCacheProjectionImpl<K, V>)in.readObject();
-        delegate = (GridCacheQueriesEx<K, V>)in.readObject();
-
-        gate = prj.context().gate();
-    }
-}

Reply via email to