Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-sql-tests c930607b9 -> 73199bd2d


#IGNITE-SQL Changed sql benchmarks


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

Branch: refs/heads/ignite-sql-tests
Commit: 73199bd2da2fa8ebbcd0f97d055e6be372da43f6
Parents: c930607
Author: nikolay_tikhonov <[email protected]>
Authored: Thu Feb 12 11:15:34 2015 +0300
Committer: nikolay_tikhonov <[email protected]>
Committed: Thu Feb 12 11:15:34 2015 +0300

----------------------------------------------------------------------
 .../cache/IgniteSqlQueryBenchmark.java          | 22 +++++++++--------
 .../cache/IgniteSqlQueryJoinBenchmark.java      | 26 +++++++++++---------
 .../cache/IgniteSqlQueryPutBenchmark.java       | 22 +++++++++--------
 3 files changed, 38 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73199bd2/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java
index cf72b6a..488a5ab 100644
--- 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java
@@ -19,10 +19,10 @@ package org.apache.ignite.yardstick.cache;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.query.*;
-import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.yardstick.cache.model.*;
 import org.yardstickframework.*;
 
+import javax.cache.*;
 import java.util.*;
 import java.util.concurrent.*;
 
@@ -33,7 +33,11 @@ import static org.yardstickframework.BenchmarkUtils.*;
  */
 public class IgniteSqlQueryBenchmark extends IgniteCacheAbstractBenchmark {
     /** */
-    private CacheQuery qry;
+    private ThreadLocal<SqlQuery> qry = new ThreadLocal<SqlQuery>() {
+        @Override protected SqlQuery initialValue() {
+            return new SqlQuery(Person.class, "salary >= ? and salary <= ?");
+        }
+    };
 
     /** {@inheritDoc} */
     @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
@@ -53,8 +57,6 @@ public class IgniteSqlQueryBenchmark extends 
IgniteCacheAbstractBenchmark {
         }
 
         println(cfg, "Finished populating query data in " + 
((System.nanoTime() - start) / 1_000_000) + " ms.");
-
-        qry = null; // TODO: should be fixed after IGNITE-2 
cache.queries().createSqlQuery(Person.class, "salary >= ? and salary <= ?");
     }
 
     /** {@inheritDoc} */
@@ -63,10 +65,10 @@ public class IgniteSqlQueryBenchmark extends 
IgniteCacheAbstractBenchmark {
 
         double maxSalary = salary + 1000;
 
-        Collection<Map.Entry<Integer, Person>> entries = executeQuery(salary, 
maxSalary);
+        Collection<Cache.Entry<Integer, Object>> entries = 
executeQuery(salary, maxSalary);
 
-        for (Map.Entry<Integer, Person> entry : entries) {
-            Person p = entry.getValue();
+        for (Cache.Entry<Integer, Object> entry : entries) {
+            Person p = (Person)entry.getValue();
 
             if (p.getSalary() < salary || p.getSalary() > maxSalary)
                 throw new Exception("Invalid person retrieved [min=" + salary 
+ ", max=" + maxSalary +
@@ -82,10 +84,10 @@ public class IgniteSqlQueryBenchmark extends 
IgniteCacheAbstractBenchmark {
      * @return Query result.
      * @throws Exception If failed.
      */
-    private Collection<Map.Entry<Integer, Person>> executeQuery(double 
minSalary, double maxSalary) throws Exception {
-        CacheQuery<Map.Entry<Integer, Person>> q = 
(CacheQuery<Map.Entry<Integer, Person>>)qry;
+    private Collection<Cache.Entry<Integer, Object>> executeQuery(double 
minSalary, double maxSalary) throws Exception {
+        qry.get().setArgs(minSalary, maxSalary);
 
-        return q.execute(minSalary, maxSalary).get();
+        return cache.query(qry.get()).getAll();
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73199bd2/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 3bee6f0..92ceff6 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
@@ -19,7 +19,6 @@ package org.apache.ignite.yardstick.cache;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.query.*;
-import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.yardstick.cache.model.*;
 import org.yardstickframework.*;
 
@@ -33,7 +32,16 @@ import static org.yardstickframework.BenchmarkUtils.*;
  */
 public class IgniteSqlQueryJoinBenchmark extends IgniteCacheAbstractBenchmark {
     /** */
-    private CacheQuery qry;
+    private ThreadLocal<SqlFieldsQuery> qry = new 
ThreadLocal<SqlFieldsQuery>() {
+        @Override protected SqlFieldsQuery initialValue() {
+            return new SqlFieldsQuery(
+                "select p.id, p.orgId, p.firstName, p.lastName, p.salary, 
o.name " +
+                "from Person p " +
+                "left join Organization o " +
+                "on p.id = o.id " +
+                "where salary >= ? and salary <= ?");
+        }
+    };
 
     /** {@inheritDoc} */
     @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
@@ -53,9 +61,8 @@ public class IgniteSqlQueryJoinBenchmark extends 
IgniteCacheAbstractBenchmark {
             dataLdr.flush();
 
             // Populate persons.
-            for (int i = 0; i < args.range() && 
!Thread.currentThread().isInterrupted(); i++) {
-                Person p =
-                    new Person(i, 
ThreadLocalRandom.current().nextInt(orgRange), "firstName" + i, "lastName" + i, 
i * 1000);
+            for (int i = orgRange; i < orgRange + args.range() && 
!Thread.currentThread().isInterrupted(); i++) {
+                Person p = new Person(i, nextRandom(orgRange), "firstName" + 
i, "lastName" + i, (i - orgRange) * 1000);
 
                 dataLdr.addData(i, p);
 
@@ -65,11 +72,6 @@ public class IgniteSqlQueryJoinBenchmark extends 
IgniteCacheAbstractBenchmark {
         }
 
         println(cfg, "Finished populating join query data in " + 
((System.nanoTime() - start) / 1_000_000) + " ms.");
-
-        qry = null; // TODO: should be fixed after IGNITE-2 
cache.queries().createSqlFieldsQuery(
-            // "select p.id, p.orgId, p.firstName, p.lastName, p.salary, 
o.name " +
-            //    "from Person p, Organization o " +
-            //    "where p.id = o.id and salary >= ? and salary <= ?");
     }
 
     /** {@inheritDoc} */
@@ -107,9 +109,9 @@ public class IgniteSqlQueryJoinBenchmark extends 
IgniteCacheAbstractBenchmark {
      * @throws Exception If failed.
      */
     private Collection<List<?>> executeQueryJoin(double minSalary, double 
maxSalary) throws Exception {
-        CacheQuery<List<?>> q = (CacheQuery<List<?>>)qry;
+        qry.get().setArgs(minSalary, maxSalary);
 
-        return q.execute(minSalary, maxSalary).get();
+        return cache.queryFields(qry.get()).getAll();
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73199bd2/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
index 4cecd96..734e9b4 100644
--- 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
@@ -19,10 +19,10 @@ package org.apache.ignite.yardstick.cache;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.query.*;
-import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.yardstick.cache.model.*;
 import org.yardstickframework.*;
 
+import javax.cache.*;
 import java.util.*;
 import java.util.concurrent.*;
 
@@ -31,13 +31,15 @@ import java.util.concurrent.*;
  */
 public class IgniteSqlQueryPutBenchmark extends IgniteCacheAbstractBenchmark {
     /** */
-    private CacheQuery qry;
+    private ThreadLocal<SqlQuery> qry = new ThreadLocal<SqlQuery>() {
+        @Override protected SqlQuery initialValue() {
+            return new SqlQuery("salary >= ? and salary <= ?");
+        }
+    };
 
     /** {@inheritDoc} */
     @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
         super.setUp(cfg);
-
-        qry = null; // TODO: should be fixed after IGNITE-2 
cache.queries().createSqlQuery(Person.class, "salary >= ? and salary <= ?");
     }
 
     /** {@inheritDoc} */
@@ -49,10 +51,10 @@ public class IgniteSqlQueryPutBenchmark extends 
IgniteCacheAbstractBenchmark {
 
             double maxSalary = salary + 1000;
 
-            Collection<Map.Entry<Integer, Person>> entries = 
executeQuery(salary, maxSalary);
+            Collection<Cache.Entry<Integer, Object>> entries = 
executeQuery(salary, maxSalary);
 
-            for (Map.Entry<Integer, Person> entry : entries) {
-                Person p = entry.getValue();
+            for (Cache.Entry<Integer, Object> entry : entries) {
+                Person p = (Person)entry.getValue();
 
                 if (p.getSalary() < salary || p.getSalary() > maxSalary)
                     throw new Exception("Invalid person retrieved [min=" + 
salary + ", max=" + maxSalary +
@@ -74,10 +76,10 @@ public class IgniteSqlQueryPutBenchmark extends 
IgniteCacheAbstractBenchmark {
      * @return Query result.
      * @throws Exception If failed.
      */
-    private Collection<Map.Entry<Integer, Person>> executeQuery(double 
minSalary, double maxSalary) throws Exception {
-        CacheQuery<Map.Entry<Integer, Person>> q = 
(CacheQuery<Map.Entry<Integer, Person>>)qry;
+    private Collection<Cache.Entry<Integer, Object>> executeQuery(double 
minSalary, double maxSalary) throws Exception {
+        qry.get().setArgs(minSalary, maxSalary);
 
-        return q.execute(minSalary, maxSalary).get();
+        return cache.query(qry.get()).getAll();
     }
 
     /** {@inheritDoc} */

Reply via email to