ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: IGNITE-190 Changed CachePopularNumbersExample.
Date Fri, 06 Feb 2015 11:24:01 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-190 3ae3ed10e -> 799305a80


IGNITE-190 Changed CachePopularNumbersExample.


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

Branch: refs/heads/ignite-190
Commit: 799305a800ffdceccc2bcdf9cc2d092581c77ada
Parents: 3ae3ed1
Author: nikolay_tikhonov <ntikhonov@gridgain.com>
Authored: Fri Feb 6 14:24:06 2015 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Fri Feb 6 14:24:06 2015 +0300

----------------------------------------------------------------------
 .../datagrid/CachePopularNumbersExample.java        | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/799305a8/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
index d76b8d7..2046b8c 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
@@ -18,10 +18,9 @@
 package org.apache.ignite.examples.datagrid;
 
 import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.query.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.dataload.*;
-import org.apache.ignite.internal.processors.cache.query.*;
 
 import javax.cache.processor.*;
 import java.util.*;
@@ -114,18 +113,13 @@ public class CachePopularNumbersExample {
      */
     private static TimerTask scheduleQuery(final Ignite ignite, Timer timer, final int cnt)
{
         TimerTask task = new TimerTask() {
-            private CacheQuery<List<?>> qry;
-
             @Override public void run() {
                 // Get reference to cache.
-                GridCache<Integer, Long> cache = ignite.cache(CACHE_NAME);
-
-                if (qry == null)
-                    qry = cache.queries().
-                        createSqlFieldsQuery("select _key, _val from Long order by _val desc
limit " + cnt);
+                IgniteCache<Integer, Long> cache = ignite.jcache(CACHE_NAME);
 
                 try {
-                    List<List<?>> results = new ArrayList<>(qry.execute().get());
+                    List<List<?>> results = new ArrayList<>(cache.queryFields(
+                        new QuerySqlPredicate("select _key, _val from Long order by _val
desc limit " + cnt)).getAll());
 
                     Collections.sort(results, new Comparator<List<?>>() {
                         @Override public int compare(List<?> r1, List<?> r2)
{
@@ -144,7 +138,7 @@ public class CachePopularNumbersExample {
 
                     System.out.println("----------------");
                 }
-                catch (IgniteCheckedException e) {
+                catch (Exception e) {
                     e.printStackTrace();
                 }
             }


Mime
View raw message