ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-1232
Date Thu, 21 Jul 2016 13:47:32 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1232-1 bdc4147f7 -> 4838f0e26


ignite-1232


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

Branch: refs/heads/ignite-1232-1
Commit: 4838f0e261e5f6dba3c86d970ebfc8d90df41b30
Parents: bdc4147
Author: sboikov <sboikov@gridgain.com>
Authored: Thu Jul 21 12:59:06 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Thu Jul 21 16:46:10 2016 +0300

----------------------------------------------------------------------
 .../examples/datagrid/CacheQueryExample.java    |  76 +++++++++---
 .../query/h2/opt/GridH2TreeIndex.java           |   2 +-
 .../IgniteCacheCrossCacheJoinRandomTest.java    |   2 +-
 ...IgniteCacheJoinQueryWithAffinityKeyTest.java | 115 ++++++++++++++++---
 .../yardstick/IgniteBenchmarkArguments.java     |  11 --
 .../IgniteSqlQueryDistributedJoinBenchmark.java |  45 ++++++--
 ...lQueryDistributedJoinBroadcastBenchmark.java |  28 +++++
 7 files changed, 223 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4838f0e2/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 9200489..2db3234 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
@@ -46,8 +46,11 @@ import org.apache.ignite.lang.IgniteBiPredicate;
  * limitations (not applied if data is queried from one node only):
  * <ul>
  *     <li>
- *         Joins will work correctly only if joined objects are stored in
+ *         Non-distributed joins will work correctly only if joined objects are stored in
  *         collocated mode. Refer to {@link AffinityKey} javadoc for more details.
+ *         <p>
+ *         To use distributed joins it is necessary to set query 'distributedJoin' flag using
+ *         {@link SqlFieldsQuery#setDistributedJoins(boolean)} or {@link SqlQuery#setDistributedJoins(boolean)}.
  *     </li>
  *     <li>
  *         Note that if you created query on to replicated cache, all data will
@@ -66,6 +69,9 @@ public class CacheQueryExample {
     private static final String ORG_CACHE = CacheQueryExample.class.getSimpleName() + "Organizations";
 
     /** Persons cache name. */
+    private static final String COLLOCATED_PERSON_CACHE = CacheQueryExample.class.getSimpleName()
+ "CollocatedPersons";
+
+    /** Persons cache name. */
     private static final String PERSON_CACHE = CacheQueryExample.class.getSimpleName() +
"Persons";
 
     /**
@@ -84,14 +90,20 @@ public class CacheQueryExample {
             orgCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
             orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
 
+            CacheConfiguration<AffinityKey<Long>, Person> colPersonCacheCfg =
new CacheConfiguration<>(COLLOCATED_PERSON_CACHE);
+
+            colPersonCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
+            colPersonCacheCfg.setIndexedTypes(AffinityKey.class, Person.class);
+
             CacheConfiguration<AffinityKey<Long>, Person> personCacheCfg = new
CacheConfiguration<>(PERSON_CACHE);
 
             personCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
-            personCacheCfg.setIndexedTypes(AffinityKey.class, Person.class);
+            personCacheCfg.setIndexedTypes(Long.class, Person.class);
 
             // Auto-close cache at the end of the example.
             try (
                 IgniteCache<Long, Organization> orgCache = ignite.getOrCreateCache(orgCacheCfg);
+                IgniteCache<AffinityKey<Long>, Person> colPersonCache = ignite.getOrCreateCache(colPersonCacheCfg);
                 IgniteCache<AffinityKey<Long>, Person> personCache = ignite.getOrCreateCache(personCacheCfg)
             ) {
                 // Populate cache.
@@ -103,9 +115,12 @@ public class CacheQueryExample {
                 // Example for SQL-based querying employees based on salary ranges.
                 sqlQuery();
 
-                // Example for SQL-based querying employees for a given organization (includes
SQL join).
+                // Example for SQL-based querying employees for a given organization (includes
SQL join for collocated objects).
                 sqlQueryWithJoin();
 
+                // Example for SQL-based querying employees for a given organization (includes
distributed SQL join).
+                sqlQueryWithDistributedJoin();
+
                 // Example for TEXT-based querying for a given string in peoples resumes.
                 textQuery();
 
@@ -121,6 +136,7 @@ public class CacheQueryExample {
             }
             finally {
                 // Distributed cache could be removed from cluster only by #destroyCache()
call.
+                ignite.destroyCache(COLLOCATED_PERSON_CACHE);
                 ignite.destroyCache(PERSON_CACHE);
                 ignite.destroyCache(ORG_CACHE);
             }
@@ -170,7 +186,7 @@ public class CacheQueryExample {
      * Example for SQL queries based on all employees working for a specific organization.
      */
     private static void sqlQueryWithJoin() {
-        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(COLLOCATED_PERSON_CACHE);
 
         // SQL clause query which joins on 2 types to select people for a specific organization.
         String joinSql =
@@ -189,6 +205,32 @@ public class CacheQueryExample {
     }
 
     /**
+     * Example for SQL queries based on all employees working for a specific organization
(query uses distributed join).
+     */
+    private static void sqlQueryWithDistributedJoin() {
+        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+
+        // SQL clause query which joins on 2 types to select people for a specific organization.
+        String joinSql =
+            "from Person, \"" + ORG_CACHE + "\".Organization as org " +
+            "where Person.orgId = org.id " +
+            "and lower(org.name) = lower(?)";
+
+        SqlQuery qry = new SqlQuery<AffinityKey<Long>, Person>(Person.class,
joinSql).
+            setArgs("ApacheIgnite");
+
+        // Enable distributed joins for query.
+        qry.setDistributedJoins(true);
+
+        // Execute queries for find employees for different organizations.
+        print("Following people are 'ApacheIgnite' employees (distributed join): ", cache.query(qry).getAll());
+
+        qry.setArgs("Other");
+
+        print("Following people are 'Other' employees (distributed join): ", cache.query(qry).getAll());
+    }
+
+    /**
      * Example for TEXT queries using LUCENE-based indexing of people's resumes.
      */
     private static void textQuery() {
@@ -210,7 +252,7 @@ public class CacheQueryExample {
      * Example for SQL queries to calculate average salary for a specific organization.
      */
     private static void sqlQueryWithAggregation() {
-        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(COLLOCATED_PERSON_CACHE);
 
         // Calculate average of salary of all persons in ApacheIgnite.
         // Note that we also join on Organization cache as well.
@@ -249,7 +291,7 @@ public class CacheQueryExample {
      * fields instead of whole key-value pairs.
      */
     private static void sqlFieldsQueryWithJoin() {
-        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(COLLOCATED_PERSON_CACHE);
 
         // Execute query to get names of all employees.
         String sql =
@@ -263,7 +305,7 @@ public class CacheQueryExample {
         List<List<?>> res = cursor.getAll();
 
         // Print persons' names and organizations' names.
-        print("Names of all employees and organizations they belong to:", res);
+        print("Names of all employees and organizations they belong to: ", res);
     }
 
     /**
@@ -282,9 +324,11 @@ public class CacheQueryExample {
         orgCache.put(org1.id(), org1);
         orgCache.put(org2.id(), org2);
 
-        IgniteCache<AffinityKey<Long>, Person> personCache = Ignition.ignite().cache(PERSON_CACHE);
+        IgniteCache<AffinityKey<Long>, Person> colPersonCache = Ignition.ignite().cache(COLLOCATED_PERSON_CACHE);
+        IgniteCache<Long, Person> personCache = Ignition.ignite().cache(PERSON_CACHE);
 
-        // Clear cache before running the example.
+        // Clear caches before running the example.
+        colPersonCache.clear();
         personCache.clear();
 
         // People.
@@ -295,10 +339,16 @@ public class CacheQueryExample {
 
         // Note that in this example we use custom affinity key for Person objects
         // to ensure that all persons are collocated with their organizations.
-        personCache.put(p1.key(), p1);
-        personCache.put(p2.key(), p2);
-        personCache.put(p3.key(), p3);
-        personCache.put(p4.key(), p4);
+        colPersonCache.put(p1.key(), p1);
+        colPersonCache.put(p2.key(), p2);
+        colPersonCache.put(p3.key(), p3);
+        colPersonCache.put(p4.key(), p4);
+
+        // These Person objects are not collocated with their organizations.
+        personCache.put(p1.id, p1);
+        personCache.put(p2.id, p2);
+        personCache.put(p3.id, p3);
+        personCache.put(p4.id, p4);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/4838f0e2/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
index c8c0446..33aaf7b 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
@@ -48,7 +48,7 @@ import org.jetbrains.annotations.Nullable;
 @SuppressWarnings("ComparatorNotSerializable")
 public class GridH2TreeIndex extends GridH2IndexBase implements Comparator<GridSearchRowPointer>
{
     /** */
-    protected final ConcurrentNavigableMap<GridSearchRowPointer, GridH2Row> tree;
+    private final ConcurrentNavigableMap<GridSearchRowPointer, GridH2Row> tree;
 
     /** */
     private final boolean snapshotEnabled;

http://git-wip-us.apache.org/repos/asf/ignite/blob/4838f0e2/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java
index 2fa9f4c..f646ce2 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java
@@ -206,7 +206,7 @@ public class IgniteCacheCrossCacheJoinRandomTest extends AbstractH2CompareQueryT
     /**
      * @throws Exception If failed.
      */
-    public void testJoin3Caches() throws Exception {
+    public void _testJoin3Caches() throws Exception {
         testJoin(3, MODES_1);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4838f0e2/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java
index d27fe1b..44bca5e 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java
@@ -63,6 +63,9 @@ public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractT
     /** */
     private boolean client;
 
+    /** */
+    private boolean escape;
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -113,6 +116,15 @@ public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractT
     /**
      * @throws Exception If failed.
      */
+    public void testJoinQueryEscapeAll() throws Exception {
+        escape = true;
+
+        testJoinQuery();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testJoinQueryWithAffinityKey() throws Exception {
         testJoinQuery(PARTITIONED, 0, true, true);
 
@@ -124,6 +136,15 @@ public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractT
     /**
      * @throws Exception If failed.
      */
+    public void testJoinQueryWithAffinityKeyEscapeAll() throws Exception {
+        escape = true;
+
+        testJoinQueryWithAffinityKey();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testJoinQueryWithAffinityKeyNotQueryField() throws Exception {
         testJoinQuery(PARTITIONED, 0, true, false);
 
@@ -133,12 +154,21 @@ public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractT
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testJoinQueryWithAffinityKeyNotQueryFieldEscapeAll() throws Exception {
+        escape = true;
+
+        testJoinQueryWithAffinityKeyNotQueryField();
+    }
+
+    /**
      * @param cacheMode Cache mode.
      * @param backups Number of backups.
      * @param affKey If {@code true} uses key with affinity key field.
      * @param includeAffKey If {@code true} includes affinity key field in query fields.
      */
-    public void testJoinQuery(CacheMode cacheMode, int backups, final boolean affKey, boolean
includeAffKey) {
+    private void testJoinQuery(CacheMode cacheMode, int backups, final boolean affKey, boolean
includeAffKey) {
         CacheConfiguration ccfg = cacheConfiguration(cacheMode, backups, affKey, includeAffKey);
 
         log.info("Test cache [mode=" + cacheMode + ", backups=" + backups + ']');
@@ -179,9 +209,18 @@ public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractT
      * @param cnts Organizations per person counts.
      */
     private void checkOrganizationPersonsJoin(IgniteCache cache, Map<Integer, Integer>
cnts) {
-        SqlFieldsQuery qry = new SqlFieldsQuery("select o.name, p.name " +
-            "from Organization o, Person p " +
-            "where p.orgId = o._key and o._key=?");
+        SqlFieldsQuery qry;
+
+        if (escape) {
+            qry = new SqlFieldsQuery("select o.\"name\", p.\"name\" " +
+                "from \"Organization\" o, \"Person\" p " +
+                "where p.\"orgId\" = o._key and o._key=?");
+        }
+        else {
+            qry = new SqlFieldsQuery("select o.name, p.name " +
+                "from Organization o, Person p " +
+                "where p.orgId = o._key and o._key=?");
+        }
 
         qry.setDistributedJoins(true);
 
@@ -197,8 +236,16 @@ public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractT
             total += res.size();
         }
 
-        SqlFieldsQuery qry2 = new SqlFieldsQuery("select count(*) " +
-            "from Organization o, Person p where p.orgId = o._key");
+        SqlFieldsQuery qry2;
+
+        if (escape) {
+            qry2 = new SqlFieldsQuery("select count(*) " +
+                "from \"Organization\" o, \"Person\" p where p.\"orgId\" = o._key");
+        }
+        else {
+            qry2 = new SqlFieldsQuery("select count(*) " +
+                "from Organization o, Person p where p.orgId = o._key");
+        }
 
         qry2.setDistributedJoins(true);
 
@@ -214,15 +261,33 @@ public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractT
      * @param affKey If {@code true} uses key with affinity key field.
      */
     private void checkPersonAccountsJoin(IgniteCache cache, Map<Object, Integer> cnts,
boolean affKey) {
-        SqlFieldsQuery qry1 = new SqlFieldsQuery("select p.name " +
-            "from Person p, " + (affKey ? "AccountKeyWithAffinity" : "Account") + " a " +
-            "where p._key = a.personKey and p._key=?");
+        String sql1;
+
+        if (escape) {
+            sql1 = "select p.\"name\" from \"Person\" p, \"" + (affKey ? "AccountKeyWithAffinity"
: "Account") + "\" a " +
+                "where p._key = a.\"personKey\" and p._key=?";
+        }
+        else {
+            sql1 = "select p.name from Person p, " + (affKey ? "AccountKeyWithAffinity" :
"Account") + " a " +
+                "where p._key = a.personKey and p._key=?";
+        }
+
+        SqlFieldsQuery qry1 = new SqlFieldsQuery(sql1);
 
         qry1.setDistributedJoins(true);
 
-        SqlFieldsQuery qry2 = new SqlFieldsQuery("select p.name " +
-            "from Person p, " + (affKey ? "AccountKeyWithAffinity" : "Account") + " a " +
-            "where p.id = a.personId and p.id=?");
+        String sql2;
+
+        if (escape) {
+            sql2 = "select p.\"name\" from \"Person\" p, \"" + (affKey ? "AccountKeyWithAffinity"
: "Account") + "\" a " +
+                "where p.\"id\" = a.\"personId\" and p.\"id\"=?";
+        }
+        else {
+            sql2 = "select p.name from Person p, " + (affKey ? "AccountKeyWithAffinity" :
"Account") + " a " +
+                "where p.id = a.personId and p.id=?";
+        }
+
+        SqlFieldsQuery qry2 = new SqlFieldsQuery(sql2);
 
         qry2.setDistributedJoins(true);
 
@@ -252,13 +317,25 @@ public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractT
 
         SqlFieldsQuery[] qrys = new SqlFieldsQuery[2];
 
-        qrys[0] = new SqlFieldsQuery("select count(*) " +
-            "from Person p, " + (affKey ? "AccountKeyWithAffinity" : "Account") + " a " +
-            "where p.id = a.personId");
 
-        qrys[1] = new SqlFieldsQuery("select count(*) " +
-            "from Person p, " + (affKey ? "AccountKeyWithAffinity" : "Account") + " a " +
-            "where p._key = a.personKey");
+        if (escape) {
+            qrys[0] = new SqlFieldsQuery("select count(*) " +
+                "from \"Person\" p, \"" + (affKey ? "AccountKeyWithAffinity" : "Account")
+ "\" a " +
+                "where p.\"id\" = a.\"personId\"");
+
+            qrys[1] = new SqlFieldsQuery("select count(*) " +
+                "from \"Person\" p, \"" + (affKey ? "AccountKeyWithAffinity" : "Account")
+ "\" a " +
+                "where p._key = a.\"personKey\"");
+        }
+        else {
+            qrys[0] = new SqlFieldsQuery("select count(*) " +
+                "from Person p, " + (affKey ? "AccountKeyWithAffinity" : "Account") + " a
" +
+                "where p.id = a.personId");
+
+            qrys[1] = new SqlFieldsQuery("select count(*) " +
+                "from Person p, " + (affKey ? "AccountKeyWithAffinity" : "Account") + " a
" +
+                "where p._key = a.personKey");
+        }
 
         for (SqlFieldsQuery qry : qrys) {
             qry.setDistributedJoins(true);
@@ -318,6 +395,8 @@ public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractT
 
         ccfg.setQueryEntities(F.asList(account, person, org));
 
+        ccfg.setSqlEscapeAll(escape);
+
         return ccfg;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4838f0e2/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
index 79bdd75..1854938 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
@@ -156,10 +156,6 @@ public class IgniteBenchmarkArguments {
     @Parameter(names = {"-ltops", "--allowedLoadTestOperations"}, variableArity = true, description
= "List of enabled load test operations")
     private List<String> allowedLoadTestOps = new ArrayList<>();
 
-    /** */
-    @Parameter(names = {"-bcj", "--broadcastJoin"}, description = "Use broadcast distributed
join")
-    private boolean broadcastJoin;
-
     /**
      * @return List of enabled load test operations.
      */
@@ -385,13 +381,6 @@ public class IgniteBenchmarkArguments {
     }
 
     /**
-     * @return {@code True} if should use broadcast for distributed join.
-     */
-    public boolean broadcastJoin() {
-        return broadcastJoin;
-    }
-
-    /**
      * @return Description.
      */
     public String description() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/4838f0e2/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBenchmark.java
index ad220a6..1f009e6 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBenchmark.java
@@ -36,14 +36,21 @@ public class IgniteSqlQueryDistributedJoinBenchmark extends IgniteCacheAbstractB
     /** */
     private int orgRange;
 
+    /** */
+    private boolean broadcast;
+
     /** {@inheritDoc} */
     @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
         super.setUp(cfg);
 
+        broadcast = broadcastJoin();
+
         println(cfg, "Populating query data...");
 
         long start = System.nanoTime();
 
+        int personCnt = 0;
+
         try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cache.getName()))
{
             orgRange = args.range() / 10;
 
@@ -60,8 +67,6 @@ public class IgniteSqlQueryDistributedJoinBenchmark extends IgniteCacheAbstractB
 
             dataLdr.flush();
 
-            int personCnt = 0;
-
             // Populate persons.
             for (int orgId = 0; orgId < orgRange; orgId++) {
                 int persons = orgId % 10 + 1;
@@ -87,16 +92,26 @@ public class IgniteSqlQueryDistributedJoinBenchmark extends IgniteCacheAbstractB
             dataLdr.close();
         }
 
-        println(cfg, "Finished populating join query data in " + ((System.nanoTime() - start)
/ 1_000_000) + " ms.");
+        println(cfg, "Finished populating join query [orgCnt=" + orgRange +
+            ", personCnt=" + personCnt +
+            ", broadcastJoin=" + broadcast +
+            ", time=" + ((System.nanoTime() - start) / 1_000_000) + "ms]");
 
-        executeQueryJoin(0, args.broadcastJoin(), true);
+        executeQueryJoin(0, broadcast, true);
+    }
+
+    /**
+     * @return Broadcast join flag.
+     */
+    protected boolean broadcastJoin() {
+        return false;
     }
 
     /** {@inheritDoc} */
     @Override public boolean test(Map<Object, Object> ctx) throws Exception {
         int orgId = nextRandom(orgRange);
 
-        Collection<List<?>> res = executeQueryJoin(orgId, args.broadcastJoin(),
false);
+        Collection<List<?>> res = executeQueryJoin(orgId, broadcast, false);
 
         int persons = orgId % 10 + 1;
 
@@ -127,21 +142,20 @@ public class IgniteSqlQueryDistributedJoinBenchmark extends IgniteCacheAbstractB
 
         if (broadcast) {
             sql = "select p.id, p.orgId, p.firstName, p.lastName, o.name " +
-                "from Organization o " +
-                "join Person p " +
-                "on p.orgId = o._key " +
-                "where o._key=?";
+                "from Person p " +
+                "join Organization o " +
+                "on p.orgId = o.id " +
+                "where o.id=?";
         }
         else {
             sql = "select p.id, p.orgId, p.firstName, p.lastName, o.name " +
-                "from Person p " +
-                "join Organization o " +
+                "from Organization o " +
+                "join Person p " +
                 "on p.orgId = o._key " +
                 "where o._key=?";
         }
 
         qry = new SqlFieldsQuery(planOnly ? ("explain " + sql) : sql);
-        qry.setEnforceJoinOrder(true);
         qry.setDistributedJoins(true);
         qry.setArgs(orgId);
 
@@ -150,6 +164,13 @@ public class IgniteSqlQueryDistributedJoinBenchmark extends IgniteCacheAbstractB
 
             println("Query execution plan:\n" + plan);
 
+            if (broadcast) {
+                if (plan.contains("batched:unicast") || !plan.contains("batched:broadcast"))
+                    throw new Exception("Unexpected query plan: " + plan);
+            }
+            else if (!plan.contains("batched:unicast") || plan.contains("batched:broadcast"))
+                throw new Exception("Unexpected query plan: " + plan);
+
             return null;
         }
         else

http://git-wip-us.apache.org/repos/asf/ignite/blob/4838f0e2/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBroadcastBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBroadcastBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBroadcastBenchmark.java
new file mode 100644
index 0000000..8b03e3e
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBroadcastBenchmark.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache;
+
+/**
+ *
+ */
+public class IgniteSqlQueryDistributedJoinBroadcastBenchmark extends IgniteSqlQueryDistributedJoinBenchmark
{
+    /** {@inheritDoc} */
+    @Override protected boolean broadcastJoin() {
+        return true;
+    }
+}
\ No newline at end of file


Mime
View raw message