ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [27/29] ignite git commit: Formatting
Date Wed, 26 Apr 2017 09:31:48 GMT
Formatting


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

Branch: refs/heads/ignite-5024
Commit: 7d33dd50b152eed29d9995dfd37403cda27f46a2
Parents: 1ccb943
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Wed Apr 26 06:31:25 2017 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Wed Apr 26 06:31:25 2017 +0300

----------------------------------------------------------------------
 .../examples/datagrid/CacheQueryExample.java    | 54 +++++++++++---------
 1 file changed, 30 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7d33dd50/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 85d74e0..aa52cc1 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
@@ -90,23 +90,24 @@ public class CacheQueryExample {
             orgCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
             orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
 
-            CacheConfiguration<AffinityKey<Long>, Person> colPersonCacheCfg =
new CacheConfiguration<>(COLLOCATED_PERSON_CACHE);
+            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);
+            CacheConfiguration<Long, Person> personCacheCfg = new CacheConfiguration<>(PERSON_CACHE);
 
             personCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
             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.
+            try {
+                // Create caches.
+                ignite.getOrCreateCache(orgCacheCfg);
+                ignite.getOrCreateCache(colPersonCacheCfg);
+                ignite.getOrCreateCache(personCacheCfg);
+
+                // Populate caches.
                 initialize();
 
                 // Example for SCAN-based query based on a predicate.
@@ -115,16 +116,19 @@ 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 for collocated objects).
+                // 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).
+                // 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();
 
-                // Example for SQL-based querying to calculate average salary among all employees
within a company.
+                // Example for SQL-based querying to calculate average salary
+                // among all employees within a company.
                 sqlQueryWithAggregation();
 
                 // Example for SQL-based fields queries that return only required
@@ -135,7 +139,7 @@ public class CacheQueryExample {
                 sqlFieldsQueryWithJoin();
             }
             finally {
-                // Distributed cache could be removed from cluster only by #destroyCache()
call.
+                // Distributed cache could be removed from cluster only by Ignite.destroyCache()
call.
                 ignite.destroyCache(COLLOCATED_PERSON_CACHE);
                 ignite.destroyCache(PERSON_CACHE);
                 ignite.destroyCache(ORG_CACHE);
@@ -146,10 +150,11 @@ public class CacheQueryExample {
     }
 
     /**
-     * Example for scan query based on a predicate.
+     * Example for scan query based on a predicate using binary objects.
      */
     private static void scanQuery() {
-        IgniteCache<BinaryObject, BinaryObject> cache = Ignition.ignite().cache(COLLOCATED_PERSON_CACHE).withKeepBinary();
+        IgniteCache<BinaryObject, BinaryObject> cache = Ignition.ignite()
+            .cache(COLLOCATED_PERSON_CACHE).withKeepBinary();
 
         ScanQuery<BinaryObject, BinaryObject> scan = new ScanQuery<>(
             new IgniteBiPredicate<BinaryObject, BinaryObject>() {
@@ -167,7 +172,7 @@ public class CacheQueryExample {
      * Example for SQL queries based on salary ranges.
      */
     private static void sqlQuery() {
-        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+        IgniteCache<Long, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
 
         // SQL clause which selects salaries based on range.
         String sql = "salary > ? and salary <= ?";
@@ -205,10 +210,11 @@ public class CacheQueryExample {
     }
 
     /**
-     * Example for SQL queries based on all employees working for a specific organization
(query uses distributed join).
+     * 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);
+        IgniteCache<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 =
@@ -234,15 +240,15 @@ public class CacheQueryExample {
      * Example for TEXT queries using LUCENE-based indexing of people's resumes.
      */
     private static void textQuery() {
-        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+        IgniteCache<Long, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
 
         //  Query for all people with "Master Degree" in their resumes.
-        QueryCursor<Cache.Entry<AffinityKey<Long>, Person>> masters =
-            cache.query(new TextQuery<AffinityKey<Long>, Person>(Person.class,
"Master"));
+        QueryCursor<Cache.Entry<Long, Person>> masters =
+            cache.query(new TextQuery<Long, Person>(Person.class, "Master"));
 
         // Query for all people with "Bachelor Degree" in their resumes.
-        QueryCursor<Cache.Entry<AffinityKey<Long>, Person>> bachelors =
-            cache.query(new TextQuery<AffinityKey<Long>, Person>(Person.class,
"Bachelor"));
+        QueryCursor<Cache.Entry<Long, Person>> bachelors =
+            cache.query(new TextQuery<Long, 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());
@@ -273,7 +279,7 @@ public class CacheQueryExample {
      * fields instead of whole key-value pairs.
      */
     private static void sqlFieldsQuery() {
-        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+        IgniteCache<Long, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
 
         // Execute query to get names of all employees.
         QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(


Mime
View raw message