ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [34/50] [abbrv] incubator-ignite git commit: # sprint-2 - example fix.
Date Wed, 25 Mar 2015 12:06:20 GMT
# sprint-2 - example fix.


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

Branch: refs/heads/ignite-565
Commit: 4a79172b5f1701f214788c75364e4b6cea79398a
Parents: ac048de
Author: Dmitiry Setrakyan <dsetrakyan@gridgain.com>
Authored: Wed Mar 25 00:09:27 2015 -0700
Committer: Dmitiry Setrakyan <dsetrakyan@gridgain.com>
Committed: Wed Mar 25 00:09:27 2015 -0700

----------------------------------------------------------------------
 .../examples/datagrid/CacheQueryExample.java    | 33 ++++++++++----------
 1 file changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4a79172b/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 4ef9fa2..9b69d81 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
@@ -57,10 +57,10 @@ import java.util.*;
  */
 public class CacheQueryExample {
     /** Organizations cache name. */
-    private static final String ORGANIZATIONS_CACHE_NAME = CacheQueryExample.class.getSimpleName()
+ "Organizations";
+    private static final String ORG_CACHE = CacheQueryExample.class.getSimpleName() + "Organizations";
 
     /** Persons cache name. */
-    private static final String PERSONS_CACHE_NAME = CacheQueryExample.class.getSimpleName()
+ "Persons";
+    private static final String PERSON_CACHE = CacheQueryExample.class.getSimpleName() +
"Persons";
 
     /**
      * Executes example.
@@ -76,13 +76,13 @@ public class CacheQueryExample {
             CacheConfiguration<?, ?> orgCacheCfg = new CacheConfiguration<>();
 
             orgCacheCfg.setCacheMode(CacheMode.PARTITIONED);
-            orgCacheCfg.setName(ORGANIZATIONS_CACHE_NAME);
+            orgCacheCfg.setName(ORG_CACHE);
             orgCacheCfg.setIndexedTypes(UUID.class, Organization.class);
 
             CacheConfiguration<?, ?> personCacheCfg = new CacheConfiguration<>();
 
             personCacheCfg.setCacheMode(CacheMode.PARTITIONED);
-            personCacheCfg.setName(PERSONS_CACHE_NAME);
+            personCacheCfg.setName(PERSON_CACHE);
             personCacheCfg.setIndexedTypes(AffinityKey.class, Person.class);
 
             try (
@@ -123,7 +123,7 @@ public class CacheQueryExample {
      * Example for scan query based on a predicate.
      */
     private static void scanQuery() {
-        IgniteCache<AffinityKey<UUID>, Person> cache = Ignition.ignite().cache(PERSONS_CACHE_NAME);
+        IgniteCache<AffinityKey<UUID>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
 
         ScanQuery<AffinityKey<UUID>, Person> scan = new ScanQuery<>(
             new IgniteBiPredicate<AffinityKey<UUID>, Person>() {
@@ -141,7 +141,7 @@ public class CacheQueryExample {
      * Example for SQL queries based on salary ranges.
      */
     private static void sqlQuery() {
-        IgniteCache<AffinityKey<UUID>, Person> cache = Ignition.ignite().cache(PERSONS_CACHE_NAME);
+        IgniteCache<AffinityKey<UUID>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
 
         // SQL clause which selects salaries based on range.
         String sql = "salary > ? and salary <= ?";
@@ -160,11 +160,11 @@ public class CacheQueryExample {
      * Example for SQL queries based on all employees working for a specific organization.
      */
     private static void sqlQueryWithJoin() {
-        IgniteCache<AffinityKey<UUID>, Person> cache = Ignition.ignite().cache(PERSONS_CACHE_NAME);
+        IgniteCache<AffinityKey<UUID>, 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, \"" + ORGANIZATIONS_CACHE_NAME + "\".Organization as org " +
+            "from Person, \"" + ORG_CACHE + "\".Organization as org " +
             "where Person.orgId = org.id " +
             "and lower(org.name) = lower(?)";
 
@@ -182,7 +182,7 @@ public class CacheQueryExample {
      * Example for TEXT queries using LUCENE-based indexing of people's resumes.
      */
     private static void textQuery() {
-        IgniteCache<AffinityKey<UUID>, Person> cache = Ignition.ignite().cache(PERSONS_CACHE_NAME);
+        IgniteCache<AffinityKey<UUID>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
 
         //  Query for all people with "Master Degree" in their resumes.
         QueryCursor<Cache.Entry<AffinityKey<UUID>, Person>> masters =
@@ -200,12 +200,13 @@ public class CacheQueryExample {
      * Example for SQL queries to calculate average salary for a specific organization.
      */
     private static void sqlQueryWithAggregation() {
-        IgniteCache<AffinityKey<UUID>, Person> cache = Ignition.ignite().cache(PERSONS_CACHE_NAME);
+        IgniteCache<AffinityKey<UUID>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
 
         // Calculate average of salary of all persons in GridGain.
+        // Note that we also join on Organization cache as well.
         String sql =
             "select avg(salary) " +
-            "from Person, \"" + ORGANIZATIONS_CACHE_NAME + "\".Organization as org " +
+            "from Person, \"" + ORG_CACHE + "\".Organization as org " +
             "where Person.orgId = org.id " +
             "and lower(org.name) = lower(?)";
 
@@ -220,7 +221,7 @@ public class CacheQueryExample {
      * fields instead of whole key-value pairs.
      */
     private static void sqlFieldsQuery() {
-        IgniteCache<?, ?> cache = Ignition.ignite().cache(PERSONS_CACHE_NAME);
+        IgniteCache<?, ?> cache = Ignition.ignite().cache(PERSON_CACHE);
 
         // Execute query to get names of all employees.
         QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(
@@ -238,12 +239,12 @@ public class CacheQueryExample {
      * fields instead of whole key-value pairs.
      */
     private static void sqlFieldsQueryWithJoin() {
-        IgniteCache<?, ?> cache = Ignition.ignite().cache(PERSONS_CACHE_NAME);
+        IgniteCache<?, ?> cache = Ignition.ignite().cache(PERSON_CACHE);
 
         // Execute query to get names of all employees.
         String sql =
             "select concat(firstName, ' ', lastName), org.name " +
-            "from Person, \"" + ORGANIZATIONS_CACHE_NAME + "\".Organization as org " +
+            "from Person, \"" + ORG_CACHE + "\".Organization as org " +
             "where Person.orgId = org.id";
 
         QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(sql));
@@ -259,7 +260,7 @@ public class CacheQueryExample {
      * Populate cache with test data.
      */
     private static void initialize() {
-        IgniteCache<UUID, Organization> orgCache = Ignition.ignite().cache(ORGANIZATIONS_CACHE_NAME);
+        IgniteCache<UUID, Organization> orgCache = Ignition.ignite().cache(ORG_CACHE);
 
         // Organizations.
         Organization org1 = new Organization("GridGain");
@@ -268,7 +269,7 @@ public class CacheQueryExample {
         orgCache.put(org1.id, org1);
         orgCache.put(org2.id, org2);
 
-        IgniteCache<AffinityKey<UUID>, Person> personCache = Ignition.ignite().cache(PERSONS_CACHE_NAME);
+        IgniteCache<AffinityKey<UUID>, Person> personCache = Ignition.ignite().cache(PERSON_CACHE);
 
         // People.
         Person p1 = new Person(org1, "John", "Doe", 2000, "John Doe has Master Degree.");


Mime
View raw message