ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [04/10] incubator-ignite git commit: IGNITE-543 - Query API changes
Date Sat, 21 Mar 2015 03:13:10 GMT
IGNITE-543 - Query API changes


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

Branch: refs/heads/ignite-45
Commit: dcbab7d647fd77c65f90a0472fb749721d8c71bf
Parents: 62f93c2
Author: Valentin Kulichenko <vkulichenko@gridgain.com>
Authored: Fri Mar 20 19:10:39 2015 -0700
Committer: Valentin Kulichenko <vkulichenko@gridgain.com>
Committed: Fri Mar 20 19:10:39 2015 -0700

----------------------------------------------------------------------
 .../datagrid/CachePopularNumbersExample.java    |   2 +-
 .../examples/datagrid/CacheQueryExample.java    |  27 ++--
 .../java/org/apache/ignite/IgniteCache.java     |  30 +----
 .../ignite/cache/query/ContinuousQuery.java     |  19 ++-
 .../org/apache/ignite/cache/query/Query.java    |  36 ++++--
 .../apache/ignite/cache/query/ScanQuery.java    |  28 +++--
 .../org/apache/ignite/cache/query/SpiQuery.java |  17 ++-
 .../ignite/cache/query/SqlFieldsQuery.java      |  17 ++-
 .../org/apache/ignite/cache/query/SqlQuery.java |  21 +++-
 .../apache/ignite/cache/query/TextQuery.java    |  21 +++-
 .../processors/cache/IgniteCacheProxy.java      | 123 +++----------------
 .../query/jdbc/GridCacheQueryJdbcTask.java      |   2 +-
 ...ridCacheContinuousQueryAbstractSelfTest.java |   2 +-
 .../cache/GridCacheCrossCacheQuerySelfTest.java |   6 +-
 .../GridCacheQueryIndexDisabledSelfTest.java    |  16 +--
 .../cache/GridCacheQuerySimpleBenchmark.java    |   2 +-
 .../IgniteCacheAbstractFieldsQuerySelfTest.java |  36 +++---
 .../cache/IgniteCacheAbstractQuerySelfTest.java |  87 ++++++-------
 ...gniteCacheSqlQueryMultiThreadedSelfTest.java |   4 +-
 .../IgniteCacheAtomicFieldsQuerySelfTest.java   |   2 +-
 .../IgniteCachePartitionedQuerySelfTest.java    |   8 +-
 ...gniteCacheReplicatedFieldsQuerySelfTest.java |   2 +-
 .../IgniteCacheReplicatedQuerySelfTest.java     |  16 +--
 .../local/IgniteCacheLocalQuerySelfTest.java    |   7 +-
 .../ignite/scalar/pimps/ScalarCachePimp.scala   |   4 +-
 .../cache/IgniteSqlQueryJoinBenchmark.java      |   2 +-
 26 files changed, 256 insertions(+), 281 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
index 56e7521..f2cd74b 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
@@ -117,7 +117,7 @@ public class CachePopularNumbersExample {
                 IgniteCache<Integer, Long> cache = ignite.jcache(CACHE_NAME);
 
                 try {
-                    List<List<?>> results = new ArrayList<>(cache.queryFields(
+                    List<List<?>> results = new ArrayList<>(cache.query(
                         new SqlFieldsQuery("select _key, _val from Long order by _val desc, _key limit ?").setArgs(cnt))
                         .getAll());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
index f30c147..2a7ad19 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
@@ -121,13 +121,16 @@ public class CacheQueryExample {
 
         // Execute queries for salary ranges.
         print("People with salaries between 0 and 1000: ",
-            cache.query(new SqlQuery(Person.class, sql).setArgs(0, 1000)).getAll());
+            cache.query(new SqlQuery<CacheAffinityKey<UUID>, Person>(Person.class, sql).
+                setArgs(0, 1000)).getAll());
 
         print("People with salaries between 1000 and 2000: ",
-            cache.query(new SqlQuery(Person.class, sql).setArgs(1000, 2000)).getAll());
+            cache.query(new SqlQuery<CacheAffinityKey<UUID>, Person>(Person.class, sql).
+                setArgs(1000, 2000)).getAll());
 
         print("People with salaries greater than 2000: ",
-            cache.query(new SqlQuery(Person.class, sql).setArgs(2000, Integer.MAX_VALUE)).getAll());
+            cache.query(new SqlQuery<CacheAffinityKey<UUID>, Person>(Person.class, sql).
+                setArgs(2000, Integer.MAX_VALUE)).getAll());
     }
 
     /**
@@ -146,9 +149,11 @@ public class CacheQueryExample {
 
         // Execute queries for find employees for different organizations.
         print("Following people are 'GridGain' employees: ",
-            cache.query(new SqlQuery(Person.class, joinSql).setArgs("GridGain")).getAll());
+            cache.query(new SqlQuery<CacheAffinityKey<UUID>, Person>(Person.class, joinSql).
+                setArgs("GridGain")).getAll());
         print("Following people are 'Other' employees: ",
-            cache.query(new SqlQuery(Person.class, joinSql).setArgs("Other")).getAll());
+            cache.query(new SqlQuery<CacheAffinityKey<UUID>, Person>(Person.class, joinSql).
+                setArgs("Other")).getAll());
     }
 
     /**
@@ -161,11 +166,11 @@ public class CacheQueryExample {
 
         //  Query for all people with "Master Degree" in their resumes.
         QueryCursor<Cache.Entry<CacheAffinityKey<UUID>, Person>> masters =
-            cache.query(new TextQuery(Person.class, "Master"));
+            cache.query(new TextQuery<CacheAffinityKey<UUID>, Person>(Person.class, "Master"));
 
         // Query for all people with "Bachelor Degree" in their resumes.
         QueryCursor<Cache.Entry<CacheAffinityKey<UUID>, Person>> bachelors =
-            cache.query(new TextQuery(Person.class, "Bachelor"));
+            cache.query(new TextQuery<CacheAffinityKey<UUID>, Person>(Person.class, "Bachelor"));
 
         print("Following people have 'Master Degree' in their resumes: ", masters.getAll());
         print("Following people have 'Bachelor Degree' in their resumes: ", bachelors.getAll());
@@ -180,7 +185,7 @@ public class CacheQueryExample {
         IgniteCache<CacheAffinityKey<UUID>, Person> cache = Ignition.ignite().jcache(CACHE_NAME);
 
         // Calculate average of salary of all persons in GridGain.
-        QueryCursor<List<?>> cursor = cache.queryFields(new SqlFieldsQuery(
+        QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(
             "select avg(salary) from Person, Organization where Person.orgId = Organization.id and "
                 + "lower(Organization.name) = lower(?)").setArgs("GridGain"));
 
@@ -198,7 +203,7 @@ public class CacheQueryExample {
         IgniteCache<?, ?> cache = Ignition.ignite().jcache(CACHE_NAME);
 
         // Create query to get names of all employees.
-        QueryCursor<List<?>> cursor = cache.queryFields(
+        QueryCursor<List<?>> cursor = cache.query(
             new SqlFieldsQuery("select concat(firstName, ' ', lastName) from Person"));
 
         // Execute query to get collection of rows. In this particular
@@ -219,7 +224,7 @@ public class CacheQueryExample {
         IgniteCache<?, ?> cache = Ignition.ignite().jcache(CACHE_NAME);
 
         // Execute query to get names of all employees.
-        QueryCursor<List<?>> cursor = cache.queryFields(new SqlFieldsQuery("select concat(firstName, ' ', lastName), "
+        QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("select concat(firstName, ' ', lastName), "
             + "Organization.name from Person, Organization where "
             + "Person.orgId = Organization.id"));
 
@@ -237,7 +242,7 @@ public class CacheQueryExample {
      * @throws InterruptedException In case of error.
      */
     private static void initialize() throws IgniteCheckedException, InterruptedException {
-        IgniteCache cache = Ignition.ignite().jcache(CACHE_NAME);
+        IgniteCache<Object, Object> cache = Ignition.ignite().jcache(CACHE_NAME);
 
         // Organizations.
         Organization org1 = new Organization("GridGain");

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index 04a2200..5977623 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -205,35 +205,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
      * @see TextQuery
      * @see SpiQuery
      */
-    public QueryCursor<Entry<K, V>> query(Query qry);
-
-    /**
-     * Queries separate entry fields.
-     *
-     * @param qry SQL Query.
-     * @return Cursor.
-     */
-    public QueryCursor<List<?>> queryFields(SqlFieldsQuery qry);
-
-    /**
-     * Queries cache locally. Accepts any subclass of {@link Query}.
-     *
-     * @param qry Query.
-     * @return Cursor.
-     * @see ScanQuery
-     * @see SqlQuery
-     * @see TextQuery
-     * @see SpiQuery
-     */
-    public QueryCursor<Entry<K, V>> localQuery(Query qry);
-
-    /**
-     * Queries separate entry fields locally.
-     *
-     * @param qry SQL Query.
-     * @return Cursor.
-     */
-    public QueryCursor<List<?>> localQueryFields(SqlFieldsQuery qry);
+    public <R> QueryCursor<R> query(Query<R> qry);
 
     /**
      * Allows for iteration over local cache entries.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java
index 169c4be..9814995 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java
@@ -19,6 +19,7 @@ package org.apache.ignite.cache.query;
 
 import org.apache.ignite.*;
 
+import javax.cache.*;
 import javax.cache.event.*;
 
 /**
@@ -103,7 +104,7 @@ import javax.cache.event.*;
  * be empty in this case, but it will still unregister listeners when {@link QueryCursor#close()}
  * is called.
  */
-public final class ContinuousQuery<K, V> extends Query<ContinuousQuery<K,V>> {
+public final class ContinuousQuery<K, V> extends Query<Cache.Entry<K, V>> {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -123,7 +124,7 @@ public final class ContinuousQuery<K, V> extends Query<ContinuousQuery<K,V>> {
     public static final boolean DFLT_AUTO_UNSUBSCRIBE = true;
 
     /** Initial query. */
-    private Query initQry;
+    private Query<Cache.Entry<K, V>> initQry;
 
     /** Local listener. */
     private CacheEntryUpdatedListener<K, V> locLsnr;
@@ -150,7 +151,7 @@ public final class ContinuousQuery<K, V> extends Query<ContinuousQuery<K,V>> {
      * @param initQry Initial query.
      * @return {@code this} for chaining.
      */
-    public ContinuousQuery<K, V> setInitialQuery(Query initQry) {
+    public ContinuousQuery<K, V> setInitialQuery(Query<Cache.Entry<K, V>> initQry) {
         this.initQry = initQry;
 
         return this;
@@ -161,7 +162,7 @@ public final class ContinuousQuery<K, V> extends Query<ContinuousQuery<K,V>> {
      *
      * @return Initial query.
      */
-    public Query getInitialQuery() {
+    public Query<Cache.Entry<K, V>> getInitialQuery() {
         return initQry;
     }
 
@@ -301,6 +302,16 @@ public final class ContinuousQuery<K, V> extends Query<ContinuousQuery<K,V>> {
         return this;
     }
 
+    /** {@inheritDoc} */
+    @Override public ContinuousQuery<K, V> setPageSize(int pageSize) {
+        return (ContinuousQuery<K, V>)super.setPageSize(pageSize);
+    }
+
+    /** {@inheritDoc} */
+    @Override public ContinuousQuery<K, V> setLocal(boolean loc) {
+        return (ContinuousQuery<K, V>)super.setLocal(loc);
+    }
+
     /**
      * Gets automatic unsubscription flag value.
      *

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java b/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
index 227a755..c120fc5 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
@@ -28,11 +28,8 @@ import java.io.*;
  * text queries accordingly.
  *
  * @see IgniteCache#query(Query)
- * @see IgniteCache#localQuery(Query)
- * @see IgniteCache#queryFields(SqlFieldsQuery)
- * @see IgniteCache#localQueryFields(SqlFieldsQuery)
  */
-public abstract class Query<T extends Query> implements Serializable {
+public abstract class Query<R> implements Serializable {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -42,6 +39,9 @@ public abstract class Query<T extends Query> implements Serializable {
     /** Page size. */
     private int pageSize;
 
+    /** Local flag. */
+    private boolean loc;
+
     /**
      * Empty constructor.
      */
@@ -62,13 +62,33 @@ public abstract class Query<T extends Query> implements Serializable {
      * Sets optional page size, if {@code 0}, then default is used.
      *
      * @param pageSize Optional page size.
-     * @return {@code this} For chaining.
+     * @return {@code this} for chaining.
      */
-    @SuppressWarnings("unchecked")
-    public T setPageSize(int pageSize) {
+    public Query<R> setPageSize(int pageSize) {
         this.pageSize = pageSize;
 
-        return (T)this;
+        return this;
+    }
+
+    /**
+     * Returns {@code true} if this query should be executed on local node only.
+     *
+     * @return Local flag.
+     */
+    public boolean isLocal() {
+        return loc;
+    }
+
+    /**
+     * Sets whether this query should be executed on local node only.
+     *
+     * @param loc Local flag.
+     * @return {@code this} for chaining.
+     */
+    public Query<R> setLocal(boolean loc) {
+        this.loc = loc;
+
+        return this;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/core/src/main/java/org/apache/ignite/cache/query/ScanQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/ScanQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/ScanQuery.java
index af9b0be..f2a43eb 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/ScanQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/ScanQuery.java
@@ -22,18 +22,19 @@ import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
 import org.jetbrains.annotations.*;
 
+import javax.cache.*;
+
 /**
  * Scan query over cache entries. Will accept all the entries if no predicate was set.
  *
  * @see IgniteCache#query(Query)
- * @see IgniteCache#localQuery(Query)
  */
-public class ScanQuery<K, V> extends Query<ScanQuery<K, V>> {
+public class ScanQuery<K, V> extends Query<Cache.Entry<K, V>> {
     /** */
     private static final long serialVersionUID = 0L;
 
     /** */
-    private IgniteBiPredicate<K,V> filter;
+    private IgniteBiPredicate<K, V> filter;
 
     /**
      * Create scan query returning all entries.
@@ -47,7 +48,7 @@ public class ScanQuery<K, V> extends Query<ScanQuery<K, V>> {
      *
      * @param filter Filter. If {@code null} then all entries will be returned.
      */
-    public ScanQuery(@Nullable IgniteBiPredicate<K,V> filter) {
+    public ScanQuery(@Nullable IgniteBiPredicate<K, V> filter) {
         setFilter(filter);
     }
 
@@ -56,7 +57,7 @@ public class ScanQuery<K, V> extends Query<ScanQuery<K, V>> {
      *
      * @return Filter.
      */
-    public IgniteBiPredicate<K,V> getFilter() {
+    public IgniteBiPredicate<K, V> getFilter() {
         return filter;
     }
 
@@ -64,13 +65,26 @@ public class ScanQuery<K, V> extends Query<ScanQuery<K, V>> {
      * Sets filter.
      *
      * @param filter Filter. If {@code null} then all entries will be returned.
+     * @return {@code this} for chaining.
      */
-    public void setFilter(@Nullable IgniteBiPredicate<K,V> filter) {
+    public ScanQuery<K, V> setFilter(@Nullable IgniteBiPredicate<K, V> filter) {
         this.filter = filter;
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public ScanQuery<K, V> setPageSize(int pageSize) {
+        return (ScanQuery<K, V>)super.setPageSize(pageSize);
+    }
+
+    /** {@inheritDoc} */
+    @Override public ScanQuery<K, V> setLocal(boolean loc) {
+        return (ScanQuery<K, V>)super.setLocal(loc);
     }
 
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(ScanQuery.class, this);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/core/src/main/java/org/apache/ignite/cache/query/SpiQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SpiQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/SpiQuery.java
index 34d609a..71b9d23 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SpiQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SpiQuery.java
@@ -22,13 +22,14 @@ import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.spi.indexing.*;
 
+import javax.cache.*;
+
 /**
  * Query to be used by {@link IndexingSpi} implementations.
  *
  * @see IgniteCache#query(Query)
- * @see IgniteCache#localQuery(Query)
  */
-public final class SpiQuery extends Query<SpiQuery> {
+public final class SpiQuery<K, V> extends Query<Cache.Entry<K, V>> {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -51,13 +52,23 @@ public final class SpiQuery extends Query<SpiQuery> {
      * @param args SQL arguments.
      * @return {@code this} For chaining.
      */
-    public SpiQuery setArgs(Object... args) {
+    public SpiQuery<K, V> setArgs(Object... args) {
         this.args = args;
 
         return this;
     }
 
     /** {@inheritDoc} */
+    @Override public SqlQuery<K, V> setPageSize(int pageSize) {
+        return (SqlQuery<K, V>)super.setPageSize(pageSize);
+    }
+
+    /** {@inheritDoc} */
+    @Override public SqlQuery<K, V> setLocal(boolean loc) {
+        return (SqlQuery<K, V>)super.setLocal(loc);
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(SpiQuery.class, this);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
index c0733e6..632942c 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
@@ -21,13 +21,14 @@ import org.apache.ignite.*;
 import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 
+import java.util.*;
+
 /**
  * SQL Fields query.
  *
- * @see IgniteCache#queryFields(SqlFieldsQuery)
- * @see IgniteCache#localQueryFields(SqlFieldsQuery)
+ * @see IgniteCache#query(Query)
  */
-public final class SqlFieldsQuery extends Query<SqlFieldsQuery>{
+public final class SqlFieldsQuery extends Query<List<?>> {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -92,6 +93,16 @@ public final class SqlFieldsQuery extends Query<SqlFieldsQuery>{
     }
 
     /** {@inheritDoc} */
+    @Override public SqlFieldsQuery setPageSize(int pageSize) {
+        return (SqlFieldsQuery)super.setPageSize(pageSize);
+    }
+
+    /** {@inheritDoc} */
+    @Override public SqlFieldsQuery setLocal(boolean loc) {
+        return (SqlFieldsQuery)super.setLocal(loc);
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(SqlFieldsQuery.class, this);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
index e8da799..64a8d4c 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
@@ -22,13 +22,14 @@ import org.apache.ignite.internal.processors.query.*;
 import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 
+import javax.cache.*;
+
 /**
  * SQL Query.
  *
  * @see IgniteCache#query(Query)
- * @see IgniteCache#localQuery(Query)
  */
-public final class SqlQuery extends Query<SqlQuery> {
+public final class SqlQuery<K, V> extends Query<Cache.Entry<K, V>> {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -79,7 +80,7 @@ public final class SqlQuery extends Query<SqlQuery> {
      * @param sql SQL clause.
      * @return {@code this} For chaining.
      */
-    public SqlQuery setSql(String sql) {
+    public SqlQuery<K, V> setSql(String sql) {
         A.notNull(sql, "sql");
 
         this.sql = sql;
@@ -102,7 +103,7 @@ public final class SqlQuery extends Query<SqlQuery> {
      * @param args SQL arguments.
      * @return {@code this} For chaining.
      */
-    public SqlQuery setArgs(Object... args) {
+    public SqlQuery<K, V> setArgs(Object... args) {
         this.args = args;
 
         return this;
@@ -123,12 +124,22 @@ public final class SqlQuery extends Query<SqlQuery> {
      * @param type Type.
      * @return {@code this} For chaining.
      */
-    public SqlQuery setType(String type) {
+    public SqlQuery<K, V> setType(String type) {
         this.type = type;
 
         return this;
     }
 
+    /** {@inheritDoc} */
+    @Override public SqlQuery<K, V> setPageSize(int pageSize) {
+        return (SqlQuery<K, V>)super.setPageSize(pageSize);
+    }
+
+    /** {@inheritDoc} */
+    @Override public SqlQuery<K, V> setLocal(boolean loc) {
+        return (SqlQuery<K, V>)super.setLocal(loc);
+    }
+
     /**
      * @param type Type.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java
index c48331b..0bb4c63 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java
@@ -21,13 +21,14 @@ import org.apache.ignite.*;
 import org.apache.ignite.internal.processors.query.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 
+import javax.cache.*;
+
 /**
  * Query for Lucene based fulltext search.
  *
  * @see IgniteCache#query(Query)
- * @see IgniteCache#localQuery(Query)
  */
-public final class TextQuery extends Query<TextQuery> {
+public final class TextQuery<K, V> extends Query<Cache.Entry<K, V>> {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -74,7 +75,7 @@ public final class TextQuery extends Query<TextQuery> {
      * @param type Type.
      * @return {@code this} For chaining.
      */
-    public TextQuery setType(Class<?> type) {
+    public TextQuery<K, V> setType(Class<?> type) {
         return setType(GridQueryProcessor.typeName(type));
     }
 
@@ -84,7 +85,7 @@ public final class TextQuery extends Query<TextQuery> {
      * @param type Type.
      * @return {@code this} For chaining.
      */
-    public TextQuery setType(String type) {
+    public TextQuery<K, V> setType(String type) {
         this.type = type;
 
         return this;
@@ -105,7 +106,7 @@ public final class TextQuery extends Query<TextQuery> {
      * @param txt Text search string.
      * @return {@code this} For chaining.
      */
-    public TextQuery setText(String txt) {
+    public TextQuery<K, V> setText(String txt) {
         A.notNull(txt, "txt");
 
         this.txt = txt;
@@ -114,6 +115,16 @@ public final class TextQuery extends Query<TextQuery> {
     }
 
     /** {@inheritDoc} */
+    @Override public TextQuery<K, V> setPageSize(int pageSize) {
+        return (TextQuery<K, V>)super.setPageSize(pageSize);
+    }
+
+    /** {@inheritDoc} */
+    @Override public TextQuery<K, V> setLocal(boolean loc) {
+        return (TextQuery<K, V>)super.setLocal(loc);
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(TextQuery.class, this);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 53e9a00..f55de0e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -352,7 +352,8 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
      * @param loc Local flag.
      * @return Initial iteration cursor.
      */
-    private QueryCursor<Entry<K,V>> queryContinuous(ContinuousQuery<K, V> qry, boolean loc) {
+    @SuppressWarnings("unchecked")
+    private QueryCursor<Entry<K, V>> queryContinuous(ContinuousQuery qry, boolean loc) {
         if (qry.getInitialQuery() instanceof ContinuousQuery)
             throw new IgniteException("Initial predicate for continuous query can't be an instance of another " +
                 "continuous query. Use SCAN or SQL query for initial iteration.");
@@ -369,12 +370,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
                 qry.isAutoUnsubscribe(),
                 loc ? ctx.grid().cluster().forLocal() : null);
 
-            final QueryCursor<Cache.Entry<K, V>> cur;
-
-            if (qry.getInitialQuery() != null)
-                cur = loc ? localQuery(qry.getInitialQuery()) : query(qry.getInitialQuery());
-            else
-                cur = null;
+            final QueryCursor<Cache.Entry<K, V>> cur = query(qry.getInitialQuery());
 
             return new QueryCursor<Cache.Entry<K, V>>() {
                 @Override public Iterator<Cache.Entry<K, V>> iterator() {
@@ -405,7 +401,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Override public QueryCursor<Entry<K,V>> query(Query qry) {
+    @Override public <R> QueryCursor<R> query(Query<R> qry) {
         A.notNull(qry, "qry");
 
         GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
@@ -414,18 +410,27 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
             validate(qry);
 
             if (qry instanceof ContinuousQuery)
-                return queryContinuous((ContinuousQuery<K,V>)qry, false);
+                return (QueryCursor<R>)queryContinuous((ContinuousQuery<K, V>)qry, qry.isLocal());
 
             if (qry instanceof SqlQuery) {
                 SqlQuery p = (SqlQuery)qry;
 
-                if (isReplicatedDataNode() || ctx.isLocal())
-                    return doLocalQuery(p);
+                if (isReplicatedDataNode() || ctx.isLocal() || qry.isLocal())
+                    return (QueryCursor<R>)new QueryCursorImpl<>(ctx.kernalContext().query().<K, V>queryLocal(ctx, p));
 
-                return ctx.kernalContext().query().queryTwoStep(ctx, p);
+                return (QueryCursor<R>)ctx.kernalContext().query().queryTwoStep(ctx, p);
             }
 
-            return query(qry, projection(false));
+            if (qry instanceof SqlFieldsQuery) {
+                SqlFieldsQuery p = (SqlFieldsQuery)qry;
+
+                if (isReplicatedDataNode() || ctx.isLocal() || qry.isLocal())
+                    return (QueryCursor<R>)ctx.kernalContext().query().queryLocalFields(ctx, p);
+
+                return (QueryCursor<R>)ctx.kernalContext().query().queryTwoStep(ctx, p);
+            }
+
+            return (QueryCursor<R>)query(qry, projection(qry.isLocal()));
         }
         catch (Exception e) {
             if (e instanceof CacheException)
@@ -450,47 +455,6 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
         return grp.node(ctx.localNodeId()) != null;
     }
 
-    /** {@inheritDoc} */
-    @Override public QueryCursor<List<?>> queryFields(SqlFieldsQuery qry) {
-        A.notNull(qry, "qry");
-
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            validate(qry);
-
-            if (isReplicatedDataNode() || ctx.isLocal())
-                return doLocalFieldsQuery(qry);
-
-            return ctx.kernalContext().query().queryTwoStep(ctx, qry);
-        }
-        catch (Exception e) {
-            if (e instanceof CacheException)
-                throw e;
-
-            throw new CacheException(e);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /**
-     * @param p Query.
-     * @return Cursor.
-     */
-    private QueryCursor<Entry<K,V>> doLocalQuery(SqlQuery p) {
-        return new QueryCursorImpl<>(ctx.kernalContext().query().<K,V>queryLocal(ctx, p));
-    }
-
-    /**
-     * @param q Query.
-     * @return Cursor.
-     */
-    private QueryCursor<List<?>> doLocalFieldsQuery(SqlFieldsQuery q) {
-        return ctx.kernalContext().query().queryLocalFields(ctx, q);
-    }
-
     /**
      * Checks query.
      *
@@ -504,57 +468,6 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
     }
 
     /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public QueryCursor<Entry<K,V>> localQuery(Query qry) {
-        A.notNull(qry, "qry");
-
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            validate(qry);
-
-            if (qry instanceof ContinuousQuery)
-                return queryContinuous((ContinuousQuery<K,V>)qry, true);
-
-            if (qry instanceof SqlQuery)
-                return doLocalQuery((SqlQuery)qry);
-
-            return query(qry, projection(true));
-        }
-        catch (Exception e) {
-            if (e instanceof CacheException)
-                throw e;
-
-            throw new CacheException(e);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public QueryCursor<List<?>> localQueryFields(SqlFieldsQuery qry) {
-        A.notNull(qry, "qry");
-
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            validate(qry);
-
-            return doLocalFieldsQuery(qry);
-        }
-        catch (Exception e) {
-            if (e instanceof CacheException)
-                throw e;
-
-            throw new CacheException(e);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
     @Override public Iterable<Entry<K, V>> localEntries(CachePeekMode... peekModes) throws CacheException {
         GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
index 332c649..b2391b7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
@@ -193,7 +193,7 @@ public class GridCacheQueryJdbcTask extends ComputeTaskAdapter<byte[], byte[]> {
 
                 qry.setPageSize(pageSize);
 
-                QueryCursor<List<?>> cursor = cache.queryFields(qry);
+                QueryCursor<List<?>> cursor = cache.query(qry);
 
                 Collection<GridQueryFieldMetadata> meta = ((QueryCursorImpl<List<?>>)cursor).fieldsMeta();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
index 080a5a3..cbf9eb1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
@@ -443,7 +443,7 @@ public abstract class GridCacheContinuousQueryAbstractSelfTest extends GridCommo
             }
         });
 
-        try (QueryCursor<Cache.Entry<Integer, Integer>> ignored = cache.localQuery(qry)) {
+        try (QueryCursor<Cache.Entry<Integer, Integer>> ignored = cache.query(qry.setLocal(true))) {
             int locKey = -1;
             int rmtKey = -1;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
index 6a672c0..112d602 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
@@ -235,9 +235,9 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest {
     public void testApiQueries() throws Exception {
         IgniteCache<Object,Object> c = ignite.jcache("partitioned");
 
-        c.queryFields(new SqlFieldsQuery("select cast(? as varchar) from FactPurchase").setArgs("aaa")).getAll();
+        c.query(new SqlFieldsQuery("select cast(? as varchar) from FactPurchase").setArgs("aaa")).getAll();
 
-        List<List<?>> res = c.queryFields(new SqlFieldsQuery("select cast(? as varchar), id " +
+        List<List<?>> res = c.query(new SqlFieldsQuery("select cast(? as varchar), id " +
             "from FactPurchase order by id limit ? offset ?").setArgs("aaa", 1, 1)).getAll();
 
         assertEquals(1, res.size());
@@ -270,7 +270,7 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest {
                         start = t;
                     }
 
-                    c.queryFields(new SqlFieldsQuery("select * from FactPurchase")).getAll();
+                    c.query(new SqlFieldsQuery("select * from FactPurchase")).getAll();
                 }
 
                 return null;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexDisabledSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexDisabledSelfTest.java
index 72ac087..d158370 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexDisabledSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexDisabledSelfTest.java
@@ -69,7 +69,7 @@ public class GridCacheQueryIndexDisabledSelfTest extends GridCommonAbstractTest
         IgniteCache<Integer, SqlValue> cache = jcache();
 
         try {
-            cache.query(new SqlQuery(SqlValue.class, "val >= 0")).getAll();
+            cache.query(new SqlQuery<Integer, SqlValue>(SqlValue.class, "val >= 0")).getAll();
 
             assert false;
         }
@@ -100,7 +100,7 @@ public class GridCacheQueryIndexDisabledSelfTest extends GridCommonAbstractTest
         }
 
         try {
-            cache.queryFields(new SqlFieldsQuery("select * from Person")).getAll();
+            cache.query(new SqlFieldsQuery("select * from Person")).getAll();
 
             assert false;
         }
@@ -119,7 +119,7 @@ public class GridCacheQueryIndexDisabledSelfTest extends GridCommonAbstractTest
         IgniteCache<Integer, String> cache = jcache();
 
         try {
-            cache.query(new TextQuery(String.class, "text")).getAll();
+            cache.query(new TextQuery<Integer, String>(String.class, "text")).getAll();
 
             assert false;
         }
@@ -138,11 +138,11 @@ public class GridCacheQueryIndexDisabledSelfTest extends GridCommonAbstractTest
         IgniteCache<Integer, String> cache = jcache();
 
         try {
-            cache.localQuery(new ScanQuery<>(new IgniteBiPredicate<Integer, String>() {
+            cache.query(new ScanQuery<>(new IgniteBiPredicate<Integer, String>() {
                 @Override public boolean apply(Integer id, String s) {
                     return s.equals("");
                 }
-            })).getAll();
+            }).setLocal(true)).getAll();
         }
         catch (IgniteException e) {
             assertTrue("Scan query should work with disable query indexing.", false);
@@ -155,7 +155,7 @@ public class GridCacheQueryIndexDisabledSelfTest extends GridCommonAbstractTest
         IgniteCache<Integer, SqlValue> cache = jcache();
 
         try {
-            cache.localQuery(new SqlQuery(SqlValue.class, "val >= 0")).getAll();
+            cache.query(new SqlQuery<Integer, SqlValue>(SqlValue.class, "val >= 0").setLocal(true)).getAll();
 
             assert false;
         }
@@ -174,7 +174,7 @@ public class GridCacheQueryIndexDisabledSelfTest extends GridCommonAbstractTest
         IgniteCache<Integer, SqlValue> cache = jcache();
 
         try {
-            cache.queryFields(new SqlFieldsQuery("select * from Person")).getAll();
+            cache.query(new SqlFieldsQuery("select * from Person")).getAll();
 
             assert false;
         }
@@ -193,7 +193,7 @@ public class GridCacheQueryIndexDisabledSelfTest extends GridCommonAbstractTest
         IgniteCache<Integer, String> cache = jcache();
 
         try {
-            cache.localQuery(new TextQuery(String.class, "text")).getAll();
+            cache.query(new TextQuery<Integer, String>(String.class, "text").setLocal(true)).getAll();
 
             assert false;
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySimpleBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySimpleBenchmark.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySimpleBenchmark.java
index 86cea6b..693b22c 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySimpleBenchmark.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySimpleBenchmark.java
@@ -137,7 +137,7 @@ public class GridCacheQuerySimpleBenchmark extends GridCommonAbstractTest {
                 while (!end.get()) {
                     int salary = rnd.nextInt(maxSalary);
 
-                    c.queryFields(new SqlFieldsQuery("select name from Person where salary = ?").setArgs(salary))
+                    c.query(new SqlFieldsQuery("select name from Person where salary = ?").setArgs(salary))
                         .getAll();
 
                     qrys.increment();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
index 59c66a3..c855e92 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
@@ -196,7 +196,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
     /** @throws Exception If failed. */
     public void testExecute() throws Exception {
         QueryCursor<List<?>> qry = grid(0).jcache(null)
-            .queryFields(new SqlFieldsQuery("select _KEY, name, age from Person"));
+            .query(new SqlFieldsQuery("select _KEY, name, age from Person"));
 
         List<List<?>> res = new ArrayList<>(qry.getAll());
 
@@ -242,7 +242,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
     /** @throws Exception If failed. */
     public void testExecuteWithArguments() throws Exception {
         QueryCursor<List<?>> qry = grid(0).jcache(null)
-            .queryFields(new SqlFieldsQuery("select _KEY, name, age from Person where age > ?").setArgs(30));
+            .query(new SqlFieldsQuery("select _KEY, name, age from Person where age > ?").setArgs(30));
 
         List<List<?>> res = new ArrayList<>(qry.getAll());
 
@@ -283,7 +283,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
     /** @throws Exception If failed. */
     public void testSelectAllJoined() throws Exception {
         QueryCursor<List<?>> qry = grid(0).jcache(null)
-            .queryFields(new SqlFieldsQuery("select * from Person p, Organization o where p.orgId = o.id"));
+            .query(new SqlFieldsQuery("select * from Person p, Organization o where p.orgId = o.id"));
 
         List<List<?>> res = new ArrayList<>(qry.getAll());
 
@@ -345,7 +345,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
     /** @throws Exception If failed. */
     public void testEmptyResult() throws Exception {
         QueryCursor<List<?>> qry = grid(0).jcache(null)
-            .queryFields(new SqlFieldsQuery("select name from Person where age = 0"));
+            .query(new SqlFieldsQuery("select name from Person where age = 0"));
 
         Collection<List<?>> res = qry.getAll();
 
@@ -355,7 +355,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
 
     /** @throws Exception If failed. */
     public void testQueryString() throws Exception {
-        QueryCursor<List<?>> qry = grid(0).jcache(null).queryFields(new SqlFieldsQuery("select * from String"));
+        QueryCursor<List<?>> qry = grid(0).jcache(null).query(new SqlFieldsQuery("select * from String"));
 
         Collection<List<?>> res = qry.getAll();
 
@@ -372,7 +372,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
 
     /** @throws Exception If failed. */
     public void testQueryIntegersWithJoin() throws Exception {
-        QueryCursor<List<?>> qry = grid(0).jcache(null).queryFields(new SqlFieldsQuery(
+        QueryCursor<List<?>> qry = grid(0).jcache(null).query(new SqlFieldsQuery(
             "select i._KEY, i._VAL, j._KEY, j._VAL from Integer i join Integer j where i._VAL >= 100"));
 
         Collection<List<?>> res = qry.getAll();
@@ -396,7 +396,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
     public void testPagination() throws Exception {
         // Query with page size 20.
         QueryCursor<List<?>> qry = grid(0).jcache(null)
-                .queryFields(new SqlFieldsQuery("select * from Integer").setPageSize(20));
+                .query(new SqlFieldsQuery("select * from Integer").setPageSize(20));
 
         List<List<?>> res = new ArrayList<>(qry.getAll());
 
@@ -421,7 +421,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
         for (int i = 0; i < 200; i++)
             cache.put(i, i);
 
-        QueryCursor<List<?>> qry = cache.queryFields(new SqlFieldsQuery("select * from Integer"));
+        QueryCursor<List<?>> qry = cache.query(new SqlFieldsQuery("select * from Integer"));
 
         Collection<List<?>> res = qry.getAll();
 
@@ -437,7 +437,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
 
         GridTestUtils.assertThrows(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
-                return cache.queryFields(new SqlFieldsQuery("select * from String"));
+                return cache.query(new SqlFieldsQuery("select * from String"));
             }
         }, CacheException.class, null);
     }
@@ -453,14 +453,12 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
 
         cache.put(key, val);
 
-        Collection<List<?>> res = cache.queryFields(new SqlFieldsQuery("select * from Person")).getAll();
+        Collection<List<?>> res = cache.query(new SqlFieldsQuery("select * from Person")).getAll();
 
         assertEquals(1, res.size());
 
-        int cnt = 0;
-
         for (Collection<?> row : res) {
-            cnt = 0;
+            int cnt = 0;
 
             for (Object fieldVal : row) {
                 if (cnt == 0)
@@ -499,7 +497,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
      */
     private void testPaginationIterator(@Nullable String cacheName) throws Exception {
         QueryCursor<List<?>> qry = grid(0).jcache(cacheName)
-            .queryFields(new SqlFieldsQuery("select _key, _val from Integer").setPageSize(10));
+            .query(new SqlFieldsQuery("select _key, _val from Integer").setPageSize(10));
 
         int cnt = 0;
 
@@ -519,7 +517,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
     /** @throws Exception If failed. */
     public void testPaginationIteratorKeepAll() throws Exception {
         QueryCursor<List<?>> qry = grid(0).jcache(null)
-            .queryFields(new SqlFieldsQuery("select _key, _val from Integer").setPageSize(10));
+            .query(new SqlFieldsQuery("select _key, _val from Integer").setPageSize(10));
 
         int cnt = 0;
 
@@ -535,7 +533,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
 
         assertEquals(size, cnt);
 
-        qry = grid(0).jcache(null).queryFields(new SqlFieldsQuery("select _key, _val from Integer").setPageSize(10));
+        qry = grid(0).jcache(null).query(new SqlFieldsQuery("select _key, _val from Integer").setPageSize(10));
 
         List<List<?>> list = new ArrayList<>(qry.getAll());
 
@@ -570,8 +568,8 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
      * @throws Exception If failed.
      */
     private void testPaginationGet(@Nullable String cacheName) throws Exception {
-        QueryCursor<List<?>> qry = grid(0).jcache(null)
-            .queryFields(new SqlFieldsQuery("select _key, _val from Integer").setPageSize(10));
+        QueryCursor<List<?>> qry = grid(0).jcache(cacheName)
+            .query(new SqlFieldsQuery("select _key, _val from Integer").setPageSize(10));
 
         List<List<?>> list = new ArrayList<>(qry.getAll());
 
@@ -594,7 +592,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
     /** @throws Exception If failed. */
     public void testEmptyGrid() throws Exception {
         QueryCursor<List<?>> qry = grid(0).jcache(null)
-            .queryFields(new SqlFieldsQuery("select name, age from Person where age = 25"));
+            .query(new SqlFieldsQuery("select name, age from Person where age = 25"));
 
         List<?> res = F.first(qry.getAll());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
index d770d54..aa5a352 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
@@ -215,7 +215,8 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
         cache.put(666, "test");
 
-        QueryCursor<Cache.Entry<Integer, String>> qry = cache.query(new SqlQuery(String.class, "_val='test'"));
+        QueryCursor<Cache.Entry<Integer, String>> qry =
+            cache.query(new SqlQuery<Integer, String>(String.class, "_val='test'"));
 
         Cache.Entry<Integer, String> entry = F.first(qry.getAll());
 
@@ -238,7 +239,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         cache.put(key, val);
 
         QueryCursor<Cache.Entry<Integer, Integer>> qry =
-            cache.query(new SqlQuery(Integer.class, "_key = ? and _val > 1").setArgs(key));
+            cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_key = ? and _val > 1").setArgs(key));
 
         Cache.Entry<Integer, Integer> entry = F.first(qry.getAll());
 
@@ -257,7 +258,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         // Without alias.
         final IgniteCache<Object, Object> cache = ignite.jcache(null);
 
-        QueryCursor<List<?>> qry = cache.queryFields(new SqlFieldsQuery("select square(1), square(2)"));
+        QueryCursor<List<?>> qry = cache.query(new SqlFieldsQuery("select square(1), square(2)"));
 
         Collection<List<?>> res = qry.getAll();
 
@@ -272,7 +273,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         assertEquals(4, row.get(1));
 
         // With alias.
-        qry = cache.queryFields(new SqlFieldsQuery("select _cube_(1), _cube_(2)"));
+        qry = cache.query(new SqlFieldsQuery("select _cube_(1), _cube_(2)"));
 
         res = qry.getAll();
 
@@ -291,7 +292,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
             log,
             new Callable<Object>() {
                 @Override public Object call() throws Exception {
-                    cache.queryFields(new SqlFieldsQuery("select no()"));
+                    cache.query(new SqlFieldsQuery("select no()"));
 
                     return null;
                 }
@@ -312,7 +313,8 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
         IgniteCache<Integer, Integer> cache = ignite.jcache(null);
 
-        List<Cache.Entry<Integer, Integer>> qry = cache.query(new SqlQuery(Integer.class, "1=1")).getAll();
+        List<Cache.Entry<Integer, Integer>> qry =
+            cache.query(new SqlQuery<Integer, Integer>(Integer.class, "1=1")).getAll();
 
         Cache.Entry<Integer, Integer> res = F.first(qry);
 
@@ -320,7 +322,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
         U.sleep(1020);
 
-        qry = cache.query(new SqlQuery(Integer.class, "1=1")).getAll();
+        qry = cache.query(new SqlQuery<Integer, Integer>(Integer.class, "1=1")).getAll();
 
         res = F.first(qry);
 
@@ -336,7 +338,8 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         cache.put(1, 1);
         cache.put(2, 2);
 
-        QueryCursor<Cache.Entry<Integer,Integer>> qry = cache.query(new SqlQuery(Integer.class, "_key between 2 and 1"));
+        QueryCursor<Cache.Entry<Integer,Integer>> qry =
+            cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_key between 2 and 1"));
 
         assertTrue(qry.getAll().isEmpty());
     }
@@ -366,7 +369,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         cache.put(new Key(100501), val2);
 
         QueryCursor<Cache.Entry<Key, GridCacheQueryTestValue>> qry = cache
-            .query(new SqlQuery(GridCacheQueryTestValue.class,
+            .query(new SqlQuery<Key, GridCacheQueryTestValue>(GridCacheQueryTestValue.class,
                     "fieldName='field1' and field2=1 and field3=1 and id=100500 and embeddedField2=11 and x=3"));
 
         Cache.Entry<Key, GridCacheQueryTestValue> entry = F.first(qry.getAll());
@@ -421,7 +424,8 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
         cache.put(10, "value");
 
-        QueryCursor<Cache.Entry<Integer, String>> qry = cache.query(new SqlQuery(String.class, "true"));
+        QueryCursor<Cache.Entry<Integer, String>> qry =
+            cache.query(new SqlQuery<Integer, String>(String.class, "true"));
 
         Iterator<Cache.Entry<Integer, String>> iter = qry.iterator();
 
@@ -442,7 +446,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         cache.put(1, val);
 
         QueryCursor<Cache.Entry<Integer, ObjectValue>> qry =
-            cache.query(new SqlQuery(ObjectValue.class, "_val=?").setArgs(val));
+            cache.query(new SqlQuery<Integer, ObjectValue>(ObjectValue.class, "_val=?").setArgs(val));
 
         Iterator<Cache.Entry<Integer, ObjectValue>> iter = qry.iterator();
 
@@ -455,7 +459,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
         assert !iter.hasNext();
 
-        qry = cache.query(new TextQuery(ObjectValue.class, "test"));
+        qry = cache.query(new TextQuery<Integer, ObjectValue>(ObjectValue.class, "test"));
 
         iter = qry.iterator();
 
@@ -502,7 +506,8 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
 
         QueryCursor<Cache.Entry<Integer, ObjectValue>> qry =
-            cache.query(new SqlQuery(ObjectValue.class, "intVal >= ? order by intVal").setArgs(0));
+            cache.query(new SqlQuery<Integer, ObjectValue>(ObjectValue.class, "intVal >= ? order by intVal").
+                setArgs(0));
 
         Iterator<Cache.Entry<Integer, ObjectValue>> iter = qry.iterator();
 
@@ -514,7 +519,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
         while (iter.hasNext()) {
             next = iter.next();
-            
+
             ObjectValue v = next.getValue();
 
             assert !set.contains(v.intValue());
@@ -529,7 +534,8 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         for (int i = 0; i < cnt; i++)
             assert set.contains(i);
 
-        qry = cache.query(new SqlQuery(ObjectValue.class, "MOD(intVal, 2) = ? order by intVal").setArgs(0));
+        qry = cache.query(new SqlQuery<Integer, ObjectValue>(ObjectValue.class, "MOD(intVal, 2) = ? order by intVal").
+            setArgs(0));
 
         iter = qry.iterator();
 
@@ -568,11 +574,11 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
         // Try to execute on empty cache first.
         QueryCursor<Cache.Entry<Integer, ObjectValue>> qry =
-            cache.query(new TextQuery(ObjectValue.class, "full"));
+            cache.query(new TextQuery<Integer, ObjectValue>(ObjectValue.class, "full"));
 
         assert qry.getAll().isEmpty();
 
-        qry = cache.query(new TextQuery(ObjectValue.class, "full"));
+        qry = cache.query(new TextQuery<Integer, ObjectValue>(ObjectValue.class, "full"));
 
         assert qry.getAll().isEmpty();
 
@@ -589,7 +595,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
         cache.put(key2, val2);
 
-        qry = cache.query(new TextQuery(ObjectValue.class, "full"));
+        qry = cache.query(new TextQuery<Integer, ObjectValue>(ObjectValue.class, "full"));
 
         Collection<Cache.Entry<Integer, ObjectValue>> res = qry.getAll();
 
@@ -597,7 +603,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
         assert res.size() == 2;
 
-        qry = cache.query(new TextQuery(ObjectValue.class, "full"));
+        qry = cache.query(new TextQuery<Integer, ObjectValue>(ObjectValue.class, "full"));
 
         res = qry.getAll();
 
@@ -616,7 +622,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         c1.put(777, "value");
 
         // Scan query.
-        QueryCursor<Cache.Entry<Integer, String>> qry = c1.query(new ScanQuery<String, String>());
+        QueryCursor<Cache.Entry<Integer, String>> qry = c1.query(new ScanQuery<Integer, String>());
 
         Iterator<Cache.Entry<Integer, String>> iter = qry.iterator();
 
@@ -645,14 +651,14 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         c.put(1, new ObjectValue("ObjectValue str", 1));
         c.put("key", new ObjectValueOther("ObjectValueOther str"));
 
-        Collection<Cache.Entry<Object, Object>> res = c.query(new TextQuery(ObjectValue.class, "str")).getAll();
+        Collection<Cache.Entry<Object, Object>> res = c.query(new TextQuery<>(ObjectValue.class, "str")).getAll();
 
         assert res != null;
         int expCnt = 1;
         assert res.size() == expCnt;
         assert F.first(res).getValue().getClass() == ObjectValue.class;
 
-        res = c.query(new TextQuery(ObjectValueOther.class, "str")).getAll();
+        res = c.query(new TextQuery<>(ObjectValueOther.class, "str")).getAll();
 
         assert res != null;
         assert res.size() == expCnt;
@@ -684,7 +690,8 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         cache.put(1, 1);
         cache.put(2, 2);
 
-        QueryCursor<Cache.Entry<Integer, Integer>> q = cache.query(new SqlQuery(Integer.class, "_val > 1"));
+        QueryCursor<Cache.Entry<Integer, Integer>> q =
+            cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_val > 1"));
 
         Collection<Cache.Entry<Integer, Integer>> res = q.getAll();
 
@@ -720,7 +727,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         for (int i = 0; i < 50; i++)
             cache.put(i, i);
 
-        SqlQuery qry = new SqlQuery(Integer.class, "_key >= 0");
+        SqlQuery<Integer, Integer> qry = new SqlQuery<>(Integer.class, "_key >= 0");
 
         qry.setPageSize(10);
 
@@ -763,7 +770,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
             cache.put(i, i);
 
         QueryCursor<Cache.Entry<Integer, Integer>> q =
-            cache.query(new SqlQuery(Integer.class, "_key >= 0"));
+            cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_key >= 0"));
 
         List<Cache.Entry<Integer, Integer>> list = new ArrayList<>(q.getAll());
 
@@ -790,7 +797,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         for (int i = 0; i < 50; i++)
             cache.put(i, i);
 
-        QueryCursor<Cache.Entry<Integer, Integer>> q = cache.query(new ScanQuery(new IgniteBiPredicate<Integer,Integer>() {
+        QueryCursor<Cache.Entry<Integer, Integer>> q = cache.query(new ScanQuery<>(new IgniteBiPredicate<Integer,Integer>() {
             @Override public boolean apply(Integer k, Integer v) {
                 assertNotNull(k);
                 assertNotNull(v);
@@ -827,8 +834,8 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         cache.put(new BadHashKeyObject("test_key0"), (byte)10);
         cache.put(new BadHashKeyObject("test_key1"), (byte)7);
 
-        assertEquals(10, cache.query(new SqlQuery(Byte.class, "_key = ?").setArgs(
-            new BadHashKeyObject("test_key0"))).getAll().get(0).getValue().intValue());
+        assertEquals(10, cache.query(new SqlQuery<BadHashKeyObject, Byte>(Byte.class, "_key = ?").
+            setArgs(new BadHashKeyObject("test_key0"))).getAll().get(0).getValue().intValue());
     }
 
     /**
@@ -842,7 +849,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         cache.put(new ObjectValue("test_key1", 12), 17L);
 
         assertEquals(11005L,
-            cache.query(new TextQuery(Long.class, "test_key0"))
+            cache.query(new TextQuery<ObjectValue, Long>(Long.class, "test_key0"))
                 .getAll().get(0).getValue().intValue());
     }
 
@@ -856,7 +863,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
             cache.put(i, i);
 
         QueryCursor<Cache.Entry<Integer, Integer>> q =
-            cache.query(new SqlQuery(Integer.class, "_key >= 0"));
+            cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_key >= 0"));
 
         Collection<Cache.Entry<Integer, Integer>> res = q.getAll();
 
@@ -886,7 +893,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
             cache.put(i, i);
 
         QueryCursor<Cache.Entry<Integer, Integer>> q =
-                cache.query(new SqlQuery(Integer.class, "limit 5"));
+            cache.query(new SqlQuery<Integer, Integer>(Integer.class, "limit 5"));
 
         Collection<Cache.Entry<Integer, Integer>> res = q.getAll();
 
@@ -914,7 +921,8 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         cache.put(2, new ArrayObject(new Long[] {4L, 5L, 6L}));
 
         QueryCursor<Cache.Entry<Integer, ArrayObject>> q =
-            cache.query(new SqlQuery(ArrayObject.class, "array_contains(arr, cast(? as long))").setArgs(4));
+            cache.query(new SqlQuery<Integer, ArrayObject>(ArrayObject.class, "array_contains(arr, cast(? as long))").
+                setArgs(4));
 
         Collection<Cache.Entry<Integer, ArrayObject>> res = q.getAll();
 
@@ -965,7 +973,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
             cache.put(i, i);
 
         QueryCursor<Cache.Entry<Integer, Integer>> q =
-            cache.query(new SqlQuery(Integer.class, "_key >= ?").setArgs(10));
+            cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_key >= ?").setArgs(10));
 
         q.getAll();
 
@@ -1059,13 +1067,6 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
      * @throws Exception If failed.
      */
     public void testTextQueryEvents() throws Exception {
-        testTextQueryEvents(false);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    private void testTextQueryEvents(final boolean customSubjId) throws Exception {
         final Map<UUID, Person> map = new ConcurrentHashMap8<>();
         final CountDownLatch latch = new CountDownLatch(2);
         final CountDownLatch execLatch = new CountDownLatch(cacheMode() == REPLICATED ? 1 : gridCount());
@@ -1126,7 +1127,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         cache.put(k2, new Person("Tom White", 1000));
         cache.put(k3, new Person("Mike Green", 1000));
 
-        QueryCursor<Cache.Entry<UUID, Person>> q = cache.query(new TextQuery(Person.class, "White"));
+        QueryCursor<Cache.Entry<UUID, Person>> q = cache.query(new TextQuery<UUID, Person>(Person.class, "White"));
 
         q.getAll();
 
@@ -1170,8 +1171,8 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         for (int i = 1; i <= 20; i++)
             cache.put(UUID.randomUUID(), new Person("Person " + i, i));
 
-        QueryCursor<List<?>> q = cache
-            .queryFields(new SqlFieldsQuery("select _key, name from Person where salary > ?").setArgs(10));
+        QueryCursor<List<?>> q = cache.query(new SqlFieldsQuery("select _key, name from Person where salary > ?").
+            setArgs(10));
 
         q.getAll();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java
index 88183c7..3c45e8e 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java
@@ -103,7 +103,7 @@ public class IgniteCacheSqlQueryMultiThreadedSelfTest extends GridCommonAbstract
             @Override public Void call() throws Exception {
                 for (int i = 0; i < 100; i++) {
                     QueryCursor<Cache.Entry<Integer, Person>> qry =
-                        cache.query(new SqlQuery("Person", "age >= 0"));
+                        cache.query(new SqlQuery<Integer, Person>("Person", "age >= 0"));
 
                     int cnt = 0;
 
@@ -134,7 +134,7 @@ public class IgniteCacheSqlQueryMultiThreadedSelfTest extends GridCommonAbstract
                 Random rnd = new GridRandom();
 
                 while (!stop.get()) {
-                    List<List<?>> res = cache.queryFields(
+                    List<List<?>> res = cache.query(
                         new SqlFieldsQuery("select avg(age) from Person where age > 0")).getAll();
 
                     assertEquals(1, res.size());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicFieldsQuerySelfTest.java
index 406814e..2a81c0f 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicFieldsQuerySelfTest.java
@@ -45,7 +45,7 @@ public class IgniteCacheAtomicFieldsQuerySelfTest extends IgniteCachePartitioned
      */
     public void testUnsupportedOperations() {
         try {
-            QueryCursor<List<?>> qry = grid(0).jcache(null).queryFields(new SqlFieldsQuery(
+            QueryCursor<List<?>> qry = grid(0).jcache(null).query(new SqlFieldsQuery(
                 "update Person set name = ?").setArgs("Mary Poppins"));
 
             qry.getAll();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
index f1c77b3..124c60b 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
@@ -64,14 +64,14 @@ public class IgniteCachePartitionedQuerySelfTest extends IgniteCacheAbstractQuer
 
         // Fields query
         QueryCursor<List<?>> qry = cache0
-            .queryFields(new SqlFieldsQuery("select name from Person where salary > ?").setArgs(1600));
+            .query(new SqlFieldsQuery("select name from Person where salary > ?").setArgs(1600));
 
         Collection<List<?>> res = qry.getAll();
 
         assertEquals(3, res.size());
 
         // Fields query count(*)
-        qry = cache0.queryFields(new SqlFieldsQuery("select count(*) from Person"));
+        qry = cache0.query(new SqlFieldsQuery("select count(*) from Person"));
 
         res = qry.getAll();
 
@@ -104,7 +104,7 @@ public class IgniteCachePartitionedQuerySelfTest extends IgniteCacheAbstractQuer
         assert grid(0).cluster().nodes().size() == gridCount();
 
         QueryCursor<Cache.Entry<UUID, Person>> qry =
-            cache0.query(new SqlQuery(Person.class, "salary < 2000"));
+            cache0.query(new SqlQuery<UUID, Person>(Person.class, "salary < 2000"));
 
         // Execute on full projection, duplicates are expected.
         Collection<Cache.Entry<UUID, Person>> entries = qry.getAll();
@@ -127,7 +127,7 @@ public class IgniteCachePartitionedQuerySelfTest extends IgniteCacheAbstractQuer
         for (Cache.Entry<UUID, Person> entry : entries) {
             assertEquals(entry.getKey(), entry.getValue().id());
 
-            assert F.<Person>asList(persons).contains(entry.getValue());
+            assert F.asList(persons).contains(entry.getValue());
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java
index c0d02c3..c9ef268 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java
@@ -55,7 +55,7 @@ public class IgniteCacheReplicatedFieldsQuerySelfTest extends IgniteCacheAbstrac
 
         for (int i = 0; i < maximumQueryIteratorCount + 1; i++) {
             QueryCursor<List<?>> q = cache
-               .queryFields(new SqlFieldsQuery("select _key from Integer where _key >= 0 order by _key"));
+               .query(new SqlFieldsQuery("select _key from Integer where _key >= 0 order by _key"));
 
             assertEquals(0, q.iterator().next().get(0));
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
index 7545770..49f4463 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
@@ -120,7 +120,7 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
             assertEquals(0, c.localSize());
 
             Collection<Cache.Entry<Integer, Integer>> res =
-                c.query(new SqlQuery(Integer.class, "_key >= 5 order by _key")).getAll();
+                c.query(new SqlQuery<Integer, Integer>(Integer.class, "_key >= 5 order by _key")).getAll();
 
             assertEquals(5, res.size());
 
@@ -154,7 +154,7 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
         assertEquals(keyCnt, cache3.localSize());
 
         QueryCursor<Cache.Entry<CacheKey, CacheValue>> qry =
-            cache1.query(new SqlQuery(CacheValue.class, "true"));
+            cache1.query(new SqlQuery<CacheKey, CacheValue>(CacheValue.class, "true"));
 
         Iterator<Cache.Entry<CacheKey, CacheValue>> iter = qry.iterator();
 
@@ -238,13 +238,13 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
         latch.await();
 
         QueryCursor<Cache.Entry<CacheKey, CacheValue>> qry =
-            cache1.query(new SqlQuery(CacheValue.class, "val > 1 and val < 4"));
+            cache1.query(new SqlQuery<CacheKey, CacheValue>(CacheValue.class, "val > 1 and val < 4"));
 
         // Distributed query.
         assertEquals(2, qry.getAll().size());
 
         // Create new query, old query cannot be modified after it has been executed.
-        qry = cache3.localQuery(new SqlQuery(CacheValue.class, "val > 1 and val < 4"));
+        qry = cache3.query(new SqlQuery<CacheKey, CacheValue>(CacheValue.class, "val > 1 and val < 4").setLocal(true));
 
         // Tests execute on node.
         Iterator<Cache.Entry<CacheKey, CacheValue>> iter = qry.iterator();
@@ -293,7 +293,7 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
         // Create query with key filter.
 
         QueryCursor<Cache.Entry<CacheKey, CacheValue>> qry =
-            cache1.query(new SqlQuery(CacheValue.class, "val > 0"));
+            cache1.query(new SqlQuery<CacheKey, CacheValue>(CacheValue.class, "val > 0"));
 
         assertEquals(keyCnt, qry.getAll().size());
     }
@@ -313,7 +313,7 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
 
         for (int i = 0; i < GridCacheQueryManager.MAX_ITERATORS + 1; i++) {
             QueryCursor<Cache.Entry<Integer, Integer>> q =
-                cache.query(new SqlQuery(Integer.class, "_key >= 0 order by _key"));
+                cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_key >= 0 order by _key"));
 
             assertEquals(0, (int)q.iterator().next().getKey());
 
@@ -352,7 +352,7 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
                 cache.put(i, i);
 
             QueryCursor<Cache.Entry<Integer, Integer>> q =
-                cache.query(new SqlQuery(Integer.class, "_key >= 0 order by _key"));
+                cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_key >= 0 order by _key"));
 
             assertEquals(0, (int) q.iterator().next().getKey());
 
@@ -411,7 +411,7 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
      */
     private void checkQueryResults(IgniteCache<CacheKey, CacheValue> cache) throws Exception {
         QueryCursor<Cache.Entry<CacheKey, CacheValue>> qry =
-            cache.localQuery(new SqlQuery(CacheValue.class, "val > 1 and val < 4"));
+            cache.query(new SqlQuery<CacheKey, CacheValue>(CacheValue.class, "val > 1 and val < 4").setLocal(true));
 
         Iterator<Cache.Entry<CacheKey, CacheValue>> iter = qry.iterator();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQuerySelfTest.java
index 5e9cf62..c7373a6 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQuerySelfTest.java
@@ -19,11 +19,8 @@ package org.apache.ignite.internal.processors.cache.local;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
-import org.apache.ignite.internal.*;
 import org.apache.ignite.cache.query.*;
 import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.processors.cache.query.*;
-import org.apache.ignite.lang.*;
 
 import javax.cache.*;
 import java.util.*;
@@ -58,7 +55,7 @@ public class IgniteCacheLocalQuerySelfTest extends IgniteCacheAbstractQuerySelfT
 
         // Tests equals query.
         QueryCursor<Cache.Entry<Integer, String>> qry =
-            cache.localQuery(new SqlQuery(String.class, "_val='value1'"));
+            cache.query(new SqlQuery<Integer, String>(String.class, "_val='value1'").setLocal(true));
 
         Iterator<Cache.Entry<Integer, String>> iter = qry.iterator();
 
@@ -71,7 +68,7 @@ public class IgniteCacheLocalQuerySelfTest extends IgniteCacheAbstractQuerySelfT
         assert "value1".equals(entry.getValue());
 
         // Tests like query.
-        qry = cache.localQuery(new SqlQuery(String.class, "_val like 'value%'"));
+        qry = cache.query(new SqlQuery<Integer, String>(String.class, "_val like 'value%'").setLocal(true));
 
         iter = qry.iterator();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarCachePimp.scala
----------------------------------------------------------------------
diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarCachePimp.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarCachePimp.scala
index 42bd716..dab4671 100644
--- a/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarCachePimp.scala
+++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarCachePimp.scala
@@ -547,7 +547,7 @@ with Iterable[Cache.Entry[K, V]] with Ordered[IgniteCache[K, V]] {
         assert(clause != null)
         assert(args != null)
 
-        val query = new SqlQuery(cls, clause)
+        val query = new SqlQuery[K, V](cls, clause)
 
         if (args != null && args.size > 0)
             query.setArgs(args.map(_.asInstanceOf[AnyRef]) : _*)
@@ -669,7 +669,7 @@ with Iterable[Cache.Entry[K, V]] with Ordered[IgniteCache[K, V]] {
         if (args != null && args.nonEmpty)
             query.setArgs(args.map(_.asInstanceOf[AnyRef]) : _*)
 
-        value.queryFields(query)
+        value.query(query)
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcbab7d6/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java
index 19ab337..4ab757a 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java
@@ -106,7 +106,7 @@ public class IgniteSqlQueryJoinBenchmark extends IgniteCacheAbstractBenchmark {
 
         qry.setArgs(minSalary, maxSalary);
 
-        return cache.queryFields(qry).getAll();
+        return cache.query(qry).getAll();
     }
 
     /** {@inheritDoc} */


Mime
View raw message