ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [32/50] [abbrv] incubator-ignite git commit: ignite-sql-tests - wip
Date Sun, 08 Feb 2015 14:35:28 GMT
ignite-sql-tests - wip


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

Branch: refs/heads/ignite-sql-tests
Commit: 9cd702990d00d68b3c21d87ba507bb12db8ff936
Parents: 2b4cdf6
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Sat Feb 7 18:16:13 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Sat Feb 7 18:16:13 2015 +0300

----------------------------------------------------------------------
 .../ignite/cache/query/QueryPredicate.java      | 82 ++++++++++++++++++--
 .../ignite/cache/query/QueryScanPredicate.java  | 51 ++++++++++--
 .../ignite/cache/query/QuerySpiPredicate.java   | 25 ++----
 .../ignite/cache/query/QuerySqlPredicate.java   | 65 +++++++---------
 .../ignite/cache/query/QueryTextPredicate.java  | 34 +++++---
 ...hePartitionedQueryMultiThreadedSelfTest.java |  5 +-
 .../IgniteCacheAbstractFieldsQuerySelfTest.java | 12 +--
 .../cache/IgniteCacheAbstractQuerySelfTest.java | 29 ++++---
 .../IgniteCacheQueryMultiThreadedSelfTest.java  | 10 +--
 ...gniteCacheSqlQueryMultiThreadedSelfTest.java |  3 +-
 .../IgniteCacheAtomicFieldsQuerySelfTest.java   |  2 +-
 .../IgniteCachePartitionedQuerySelfTest.java    |  2 +-
 12 files changed, 207 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cd70299/modules/core/src/main/java/org/apache/ignite/cache/query/QueryPredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryPredicate.java
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryPredicate.java
index 3cb043c..f02a1f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryPredicate.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryPredicate.java
@@ -20,15 +20,16 @@ package org.apache.ignite.cache.query;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
+import org.apache.ignite.spi.indexing.*;
 
 import java.io.*;
 
 /**
- * Query predicate to pass into any of {@code Cache.query(...)} methods.
+ * Query to pass into any of {@code Cache.query(...)} methods.
  * Use {@link QuerySqlPredicate} and {@link QueryTextPredicate} for SQL and
  * text queries accordingly.
  */
-public abstract class QueryPredicate implements Serializable {
+public abstract class QueryPredicate<T extends QueryPredicate> implements Serializable
{
     /** Page size. */
     private int pageSize;
 
@@ -40,13 +41,74 @@ public abstract class QueryPredicate implements Serializable {
     }
 
     /**
-     * Constructs query predicate with optional page size, if {@code 0},
-     * then {@link CacheQueryConfiguration#getPageSize()} is used.
+     * Factory method for SQL queries.
      *
-     * @param pageSize Optional page size.
+     * @param sql SQL Query string.
+     * @return SQL Query instance.
      */
-    protected QueryPredicate(int pageSize) {
-        this.pageSize = pageSize;
+    public static QuerySqlPredicate sql(String sql) {
+        return new QuerySqlPredicate(sql);
+    }
+
+    /**
+     * Factory method for SQL queries.
+     *
+     * @param type Type to be queried.
+     * @param sql SQL Query string.
+     * @return SQL Query instance.
+     */
+    public static QuerySqlPredicate sql(Class<?> type, String sql) {
+        return sql(sql).setType(type);
+    }
+
+    /**
+     * Factory method for Lucene fulltext queries.
+     *
+     * @param txt Search string.
+     * @return Fulltext query.
+     */
+    public static QueryTextPredicate text(String txt) {
+        return new QueryTextPredicate(txt);
+    }
+
+    /**
+     * Factory method for Lucene fulltext queries.
+     *
+     * @param type Type to be queried.
+     * @param txt Search string.
+     * @return Fulltext query.
+     */
+    public static QueryTextPredicate text(Class<?> type, String txt) {
+        return text(txt).setType(type);
+    }
+
+    /**
+     * Factory method for SPI queries.
+     *
+     * @param filter Filter.
+     * @return SPI Query.
+     */
+    public static <K, V> QueryScanPredicate<K, V> scan(final IgniteBiPredicate<K,
V> filter) {
+        return new QueryScanPredicate<>(filter);
+    }
+
+    /**
+     * Factory method for SPI queries returning all entries.
+     *
+     * @return SPI Query.
+     */
+    public static <K, V> QueryScanPredicate<K, V> scan() {
+        return new QueryScanPredicate<>();
+    }
+
+    /**
+     * Factory method for SPI queries.
+     *
+     * @return SPI Query.
+     * @see IndexingSpi
+     */
+    public static QuerySpiPredicate spi() {
+        return new QuerySpiPredicate();
     }
 
     /**
@@ -62,9 +124,13 @@ public abstract class QueryPredicate implements Serializable {
      * Sets optional page size, if {@code 0}, then {@link CacheQueryConfiguration#getPageSize()}
is used.
      *
      * @param pageSize Optional page size.
+     * @return {@code this} For chaining.
      */
-    public void setPageSize(int pageSize) {
+    @SuppressWarnings("unchecked")
+    public T setPageSize(int pageSize) {
         this.pageSize = pageSize;
+
+        return (T)this;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cd70299/modules/core/src/main/java/org/apache/ignite/cache/query/QueryScanPredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryScanPredicate.java
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryScanPredicate.java
index c6b355f..bcb686c 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryScanPredicate.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryScanPredicate.java
@@ -17,14 +17,53 @@
 
 package org.apache.ignite.cache.query;
 
+import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
 
 /**
- * Scan predicate over cache entries. By default will accept all the entries.
+ * Scan query over cache entries. By default will accept all the entries.
  */
-public class QueryScanPredicate<K, V> extends QueryPredicate implements IgniteBiPredicate<K,
V> {
-    /** {@inheritDoc} */
-    @Override public boolean apply(K k, V v) {
-        return true;
+public class QueryScanPredicate<K, V> extends QueryPredicate<QueryScanPredicate<K,
V>> {
+    /** */
+    private IgniteBiPredicate<K,V> filter;
+
+    /**
+     * Create scan query returning all entries.
+     */
+    public QueryScanPredicate() {
+        this(new IgniteBiPredicate<K,V>() {
+            @Override public boolean apply(K k, V v) {
+                return true;
+            }
+        });
+    }
+
+    /**
+     * Create scan query with filter.
+     *
+     * @param filter Filter.
+     */
+    public QueryScanPredicate(IgniteBiPredicate<K,V> filter) {
+        setFilter(filter);
+    }
+
+    /**
+     * Gets filter.
+     *
+     * @return Filter.
+     */
+    public IgniteBiPredicate<K,V> getFilter() {
+        return filter;
+    }
+
+    /**
+     * Sets filter.
+     *
+     * @param filter Filter.
+     */
+    public void setFilter(IgniteBiPredicate<K,V> filter) {
+        A.notNull(filter, "filter");
+
+        this.filter = filter;
     }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cd70299/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySpiPredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySpiPredicate.java
b/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySpiPredicate.java
index 17cb916..0baf313 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySpiPredicate.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySpiPredicate.java
@@ -20,29 +20,13 @@ package org.apache.ignite.cache.query;
 import org.apache.ignite.spi.indexing.*;
 
 /**
- * Predicate to be used by {@link IndexingSpi} implementations.
+ * Query to be used by {@link IndexingSpi} implementations.
  */
-public class QuerySpiPredicate extends QueryPredicate {
+public final class QuerySpiPredicate extends QueryPredicate<QuerySpiPredicate> {
     /** Arguments. */
     private Object[] args;
 
     /**
-     * Constructs SPI predicate.
-     */
-    public QuerySpiPredicate() {
-        // No-op.
-    }
-
-    /**
-     * Constructs SPI predicate with given arguments.
-     *
-     * @param args Arguments.
-     */
-    public QuerySpiPredicate(Object... args) {
-        this.args = args;
-    }
-
-    /**
      * Gets SQL arguments.
      *
      * @return SQL arguments.
@@ -55,8 +39,11 @@ public class QuerySpiPredicate extends QueryPredicate {
      * Sets SQL arguments.
      *
      * @param args SQL arguments.
+     * @return {@code this} For chaining.
      */
-    public void setArgs(Object... args) {
+    public QuerySpiPredicate setArgs(Object... args) {
         this.args = args;
+
+        return this;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cd70299/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySqlPredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySqlPredicate.java
b/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySqlPredicate.java
index a235985..30f3ebf 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySqlPredicate.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySqlPredicate.java
@@ -17,13 +17,14 @@
 
 package org.apache.ignite.cache.query;
 
+import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 
 /**
  * Query SQL predicate to use with any of the {@code JCache.query(...)} and
  * {@code JCache.queryFields(...)} methods.
  */
-public final class QuerySqlPredicate extends QueryPredicate {
+public final class QuerySqlPredicate extends QueryPredicate<QuerySqlPredicate> {
     /** */
     private String type;
 
@@ -31,49 +32,28 @@ public final class QuerySqlPredicate extends QueryPredicate {
     private String sql;
 
     /** Arguments. */
+    @GridToStringInclude
     private Object[] args;
 
     /**
-     * Empty constructor.
-     */
-    public QuerySqlPredicate() {
-        // No-op.
-    }
-
-    /**
-     * Constructs SQL predicate with given type, SQL clause and arguments.
+     * Constructs query for the given SQL query.
      *
-     * @param type Class.
-     * @param sql SQL clause.
-     * @param args Arguments.
+     * @param sql SQL Query.
      */
-    public QuerySqlPredicate(Class<?> type, String sql, Object... args) {
-        setType(type);
+    public QuerySqlPredicate(String sql) {
         setSql(sql);
-        setArgs(args);
     }
 
     /**
-     * Constructs SQL predicate with given type, SQL clause and arguments.
+     * Constructs query for the given type and SQL query.
      *
-     * @param type Type to query in cache.
-     * @param sql SQL clause.
-     * @param args Arguments.
+     * @param type Type.
+     * @param sql SQL Query.
      */
-    public QuerySqlPredicate(String type, String sql, Object... args) {
-        setType(type);
-        setSql(sql);
-        setArgs(args);
-    }
+    public QuerySqlPredicate(Class<?> type, String sql) {
+        this(sql);
 
-    /**
-     * Constructs SQL predicate with given SQL clause and arguments.
-     *
-     * @param sql SQL clause.
-     * @param args Arguments.
-     */
-    public QuerySqlPredicate(String sql, Object... args) {
-        this((String)null, sql, args);
+        setType(type);
     }
 
     /**
@@ -89,9 +69,14 @@ public final class QuerySqlPredicate extends QueryPredicate {
      * Sets SQL clause.
      *
      * @param sql SQL clause.
+     * @return {@code this} For chaining.
      */
-    public void setSql(String sql) {
+    public QuerySqlPredicate setSql(String sql) {
+        A.notNull(sql, "sql");
+
         this.sql = sql;
+
+        return this;
     }
 
     /**
@@ -107,9 +92,12 @@ public final class QuerySqlPredicate extends QueryPredicate {
      * Sets SQL arguments.
      *
      * @param args SQL arguments.
+     * @return {@code this} For chaining.
      */
-    public void setArgs(Object... args) {
+    public QuerySqlPredicate setArgs(Object... args) {
         this.args = args;
+
+        return this;
     }
 
     /**
@@ -125,16 +113,19 @@ public final class QuerySqlPredicate extends QueryPredicate {
      * Sets type for query.
      *
      * @param type Type.
+     * @return {@code this} For chaining.
      */
-    public void setType(String type) {
+    public QuerySqlPredicate setType(String type) {
         this.type = type;
+
+        return this;
     }
 
     /**
      * @param type Type.
      */
-    public void setType(Class<?> type) {
-        setType(name(type));
+    public QuerySqlPredicate setType(Class<?> type) {
+        return setType(name(type));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cd70299/modules/core/src/main/java/org/apache/ignite/cache/query/QueryTextPredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryTextPredicate.java
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryTextPredicate.java
index c3765cc..d58625b 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryTextPredicate.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryTextPredicate.java
@@ -24,7 +24,7 @@ import static org.apache.ignite.cache.query.QuerySqlPredicate.name;
 /**
  * Predicate for Lucene based fulltext search.
  */
-public final class QueryTextPredicate extends QueryPredicate {
+public final class QueryTextPredicate extends QueryPredicate<QueryTextPredicate> {
     /** */
     private String type;
 
@@ -32,21 +32,24 @@ public final class QueryTextPredicate extends QueryPredicate {
     private String txt;
 
     /**
-     * @param type Type to query.
+     * Constructs query for the given search string.
+     *
      * @param txt Search string.
      */
-    public QueryTextPredicate(Class<?> type, String txt) {
-        setType(type);
+    public QueryTextPredicate(String txt) {
         setText(txt);
     }
 
     /**
-     * @param type Type to query.
+     * Constructs query for the given search string.
+     *
+     * @param type Type.
      * @param txt Search string.
      */
-    public QueryTextPredicate(String type, String txt) {
+    public QueryTextPredicate(Class<?> type, String txt) {
+        this(txt);
+
         setType(type);
-        setText(txt);
     }
 
     /**
@@ -62,18 +65,22 @@ public final class QueryTextPredicate extends QueryPredicate {
      * Sets type for query.
      *
      * @param type Type.
+     * @return {@code this} For chaining.
      */
-    public void setType(Class<?> type) {
-        setType(name(type));
+    public QueryTextPredicate setType(Class<?> type) {
+        return setType(name(type));
     }
 
     /**
      * Sets type for query.
      *
      * @param type Type.
+     * @return {@code this} For chaining.
      */
-    public void setType(String type) {
+    public QueryTextPredicate setType(String type) {
         this.type = type;
+
+        return this;
     }
 
     /**
@@ -89,9 +96,14 @@ public final class QueryTextPredicate extends QueryPredicate {
      * Sets text search string.
      *
      * @param txt Text search string.
+     * @return {@code this} For chaining.
      */
-    public void setText(String txt) {
+    public QueryTextPredicate setText(String txt) {
+        A.notNull(txt, "txt");
+
         this.txt = txt;
+
+        return this;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cd70299/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQueryMultiThreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQueryMultiThreadedSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQueryMultiThreadedSelfTest.java
index 32864a8..998cfed 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQueryMultiThreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQueryMultiThreadedSelfTest.java
@@ -40,6 +40,7 @@ import java.util.concurrent.atomic.*;
 import static org.apache.ignite.cache.CacheAtomicityMode.*;
 import static org.apache.ignite.cache.CacheDistributionMode.*;
 import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.query.QueryPredicate.*;
 
 /**
  * Tests for partitioned cache queries.
@@ -150,7 +151,7 @@ public class IgniteCachePartitionedQueryMultiThreadedSelfTest extends
GridCommon
             @Override public void applyx() throws IgniteCheckedException {
                 while (!done.get()) {
                     QueryCursor<Cache.Entry<UUID, Person>> master =
-                        cache0.query(new QueryTextPredicate(Person.class, "Master"));
+                        cache0.query(text(Person.class, "Master"));
 
                     Collection<Cache.Entry<UUID, Person>> entries = master.getAll();
 
@@ -171,7 +172,7 @@ public class IgniteCachePartitionedQueryMultiThreadedSelfTest extends
GridCommon
             @Override public void applyx() throws IgniteCheckedException {
                 while (!done.get()) {
                     QueryCursor<Cache.Entry<UUID, Person>> bachelors =
-                            cache0.query(new QuerySqlPredicate(Person.class, "degree = 'Bachelor'"));
+                            cache0.query(sql(Person.class, "degree = 'Bachelor'"));
 
                     Collection<Cache.Entry<UUID, Person>> entries = bachelors.getAll();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cd70299/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 b999394..4ce6e75 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
@@ -223,7 +223,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 QuerySqlPredicate("select _KEY, name, age from Person where
age > ?", 30));
+            .queryFields(new QuerySqlPredicate("select _KEY, name, age from Person where
age > ?").setArgs(30));
 
         List<List<?>> res = new ArrayList<>(qry.getAll());
 
@@ -379,7 +379,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 QuerySqlPredicate("select * from Integer", 20, new Object[0]));
+                .queryFields(new QuerySqlPredicate("select * from Integer").setPageSize(20));
 
         List<List<?>> res = new ArrayList<>(qry.getAll());
 
@@ -482,7 +482,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
      */
     private void testPaginationIterator(@Nullable String cacheName) throws Exception {
         QueryCursor<List<?>> qry = grid(0).jcache(cacheName)
-            .queryFields(new QuerySqlPredicate("select _key, _val from Integer", 10, new
Object[0]));
+            .queryFields(new QuerySqlPredicate("select _key, _val from Integer").setPageSize(10));
 
         int cnt = 0;
 
@@ -506,7 +506,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
      * @return Predicate.
      */
     private QuerySqlPredicate sqlPage(int pageSize, String sql, Object ... args) {
-        QuerySqlPredicate q = new QuerySqlPredicate(sql, args);
+        QuerySqlPredicate q = new QuerySqlPredicate(sql).setArgs(args);
 
         q.setPageSize(pageSize);
 
@@ -516,7 +516,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 QuerySqlPredicate("select _key, _val from Integer", 10, new
Object[0]));
+            .queryFields(new QuerySqlPredicate("select _key, _val from Integer").setPageSize(10));
 
         int cnt = 0;
 
@@ -568,7 +568,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
      */
     private void testPaginationGet(@Nullable String cacheName) throws Exception {
         QueryCursor<List<?>> qry = grid(0).jcache(null)
-            .queryFields(new QuerySqlPredicate("select _key, _val from Integer", 10, new
Object[0]));
+            .queryFields(new QuerySqlPredicate("select _key, _val from Integer").setPageSize(10));
 
         List<List<?>> list = new ArrayList<>(qry.getAll());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cd70299/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 e1fd827..729820b 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
@@ -53,6 +53,7 @@ import static org.apache.ignite.cache.CacheDistributionMode.*;
 import static org.apache.ignite.cache.CacheMode.*;
 import static org.apache.ignite.cache.CachePreloadMode.*;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
+import static org.apache.ignite.cache.query.QueryPredicate.*;
 import static org.apache.ignite.events.IgniteEventType.*;
 import static org.apache.ignite.internal.processors.cache.query.CacheQueryType.*;
 import static org.junit.Assert.*;
@@ -429,7 +430,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         cache.put(1, val);
 
         QueryCursor<Cache.Entry<Integer, ObjectValue>> qry =
-            cache.query(new QuerySqlPredicate(ObjectValue.class, "_val=?", val));
+            cache.query(sql(ObjectValue.class, "_val=?").setArgs(val));
 
         Iterator<Cache.Entry<Integer, ObjectValue>> iter = qry.iterator();
 
@@ -442,7 +443,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
         assert !iter.hasNext();
 
-        qry = cache.query(new QueryTextPredicate(ObjectValue.class, "test"));
+        qry = cache.query(text(ObjectValue.class, "test"));
 
         iter = qry.iterator();
 
@@ -489,7 +490,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
 
         QueryCursor<Cache.Entry<Integer, ObjectValue>> qry =
-            cache.query(new QuerySqlPredicate(ObjectValue.class, "intVal >= ? order by
intVal", 0));
+            cache.query(new QuerySqlPredicate(ObjectValue.class, "intVal >= ? order by
intVal").setArgs(0));
 
         Iterator<Cache.Entry<Integer, ObjectValue>> iter = qry.iterator();
 
@@ -516,7 +517,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         for (int i = 0; i < cnt; i++)
             assert set.contains(i);
 
-        qry = cache.query(new QuerySqlPredicate(ObjectValue.class, "MOD(intVal, 2) = ? order
by intVal", 0));
+        qry = cache.query(new QuerySqlPredicate(ObjectValue.class, "MOD(intVal, 2) = ? order
by intVal").setArgs(0));
 
         iter = qry.iterator();
 
@@ -811,14 +812,14 @@ 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 QueryScanPredicate<Integer,
Integer>() {
+        QueryCursor<Cache.Entry<Integer, Integer>> q = cache.query(scan(new IgniteBiPredicate<Integer,Integer>()
{
             @Override public boolean apply(Integer k, Integer v) {
                 assertNotNull(k);
                 assertNotNull(v);
 
                 return k >= 20 && v < 40;
             }
-        });
+        }));
 
         List<Cache.Entry<Integer, Integer>> list = new ArrayList<>(q.getAll());
 
@@ -870,7 +871,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         cache.put(new BadHashKeyObject("test_key0"), 1005001);
         cache.put(new BadHashKeyObject("test_key1"), 7);
 
-        assertEquals(1005001, cache.query(new QuerySqlPredicate(Integer.class, "_key = ?",
+        assertEquals(1005001, cache.query(new QuerySqlPredicate(Integer.class, "_key = ?").setArgs(
                 new BadHashKeyObject("test_key0"))).iterator().next().getValue().intValue());
     }
 
@@ -1105,7 +1106,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
             cache.put(i, i);
 
         QueryCursor<Cache.Entry<Integer, Integer>> q =
-            cache.query(new QuerySqlPredicate(Integer.class, "_key >= ?", 10));
+            cache.query(new QuerySqlPredicate(Integer.class, "_key >= ?").setArgs(10));
 
         if (customSubjId)
             ((GridCacheQueryAdapter)q).subjectId(subjId);
@@ -1192,13 +1193,11 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         for (int i = 0; i < 20; i++)
             cache.put(i, i);
 
-        QueryCursor<Cache.Entry<Integer, Integer>> q = cache.query(
-            new QueryScanPredicate<Integer, Integer>() {
-                @Override public boolean apply(Integer k, Integer v) {
-                    return k >= 10;
-                }
+        QueryCursor<Cache.Entry<Integer, Integer>> q = cache.query(scan(new IgniteBiPredicate<Integer,Integer>()
{
+            @Override public boolean apply(Integer k, Integer v) {
+                return k >= 10;
             }
-        );
+        }));
 
         if (customSubjId)
             ((GridCacheQueryAdapter)q).subjectId(subjId);
@@ -1375,7 +1374,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
             cache.put(i, new Person("Person " + i, i));
 
         QueryCursor<List<?>> q = cache
-            .queryFields(new QuerySqlPredicate("select _key, name from Person where salary
> ?", 10));
+            .queryFields(new QuerySqlPredicate("select _key, name from Person where salary
> ?").setArgs(10));
 
         if (customSubjId)
             ((GridCacheQueryAdapter)q).subjectId(subjId);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cd70299/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java
index 1ee45d1..4f42a93 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java
@@ -300,8 +300,8 @@ public class IgniteCacheQueryMultiThreadedSelfTest extends GridCommonAbstractTes
                             int from = rnd.nextInt(valCnt);
 
                             QueryCursor<Cache.Entry<Integer, String>> qry = c.query(
-                                    new QuerySqlPredicate(String.class, "_val between ? and
?", String.valueOf(from),
-                                            String.valueOf(from + 250)));
+                                    new QuerySqlPredicate(String.class, "_val between ? and
?").setArgs(
+                                        String.valueOf(from), String.valueOf(from + 250)));
 
                             Collection<Cache.Entry<Integer, String>> res = qry.getAll();
 
@@ -383,7 +383,7 @@ public class IgniteCacheQueryMultiThreadedSelfTest extends GridCommonAbstractTes
                             int from = rnd.nextInt(valCnt);
 
                             Collection<Cache.Entry<Integer, Long>> res = c.query(new
QuerySqlPredicate(Long.class,
-                                "_val between ? and ?", from, from + 250)).getAll();
+                                "_val between ? and ?").setArgs(from, from + 250)).getAll();
 
                             for (Cache.Entry<Integer, Long> ignored : res) {
                                 //No-op.
@@ -462,7 +462,7 @@ public class IgniteCacheQueryMultiThreadedSelfTest extends GridCommonAbstractTes
                             int from = rnd.nextInt(valCnt);
 
                             Collection<Cache.Entry<Integer, Object>> res = c.query(
-                                new QuerySqlPredicate(Object.class, "_val between ? and ?",
from, from + 250))
+                                new QuerySqlPredicate(Object.class, "_val between ? and ?").setArgs(from,
from + 250))
                                 .getAll();
 
                             for (Cache.Entry<Integer, Object> ignored : res) {
@@ -539,7 +539,7 @@ public class IgniteCacheQueryMultiThreadedSelfTest extends GridCommonAbstractTes
                             int from = rnd.nextInt(valCnt);
 
                             Collection<Cache.Entry<Integer, TestValue>> res =
-                                c.query(new QuerySqlPredicate(TestValue.class, "TestValue.val
between ? and ?",
+                                c.query(new QuerySqlPredicate(TestValue.class, "TestValue.val
between ? and ?").setArgs(
                                     from, from + 250)).getAll();
 
                             for (Cache.Entry<Integer, TestValue> ignored : res) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cd70299/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 c5b50e7..4e89ad2 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
@@ -96,8 +96,7 @@ public class IgniteCacheSqlQueryMultiThreadedSelfTest extends GridCommonAbstract
             @Override public Void call() throws Exception {
                 for (int i = 0; i < 100; i++) {
                     Iterator<Cache.Entry<Integer, Person>> iter =
-                        cache.query(new QuerySqlPredicate("Person", "age >= 0"))
-                        .iterator();
+                        cache.query(QueryPredicate.sql("age >= 0").setType("Person")).iterator();
 
                     int cnt = 0;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cd70299/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 264d1df..056f878 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
@@ -46,7 +46,7 @@ public class IgniteCacheAtomicFieldsQuerySelfTest extends IgniteCachePartitioned
     public void testUnsupportedOperations() {
         try {
             QueryCursor<List<?>> qry = grid(0).jcache(null).queryFields(new QuerySqlPredicate(
-                "update Person set name = ?", "Mary Poppins"));
+                "update Person set name = ?").setArgs("Mary Poppins"));
 
             qry.getAll();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9cd70299/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 1f25b81..ecf7e6f 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
@@ -96,7 +96,7 @@ public class IgniteCachePartitionedQuerySelfTest extends IgniteCacheAbstractQuer
 
         // Fields query
         QueryCursor<List<?>> qry = cache0
-            .queryFields(new QuerySqlPredicate("select name from Person where salary >
?", 1600));
+            .queryFields(new QuerySqlPredicate("select name from Person where salary >
?").setArgs(1600));
 
         Collection<List<?>> res = qry.getAll();
 


Mime
View raw message