Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CE9DF174A0 for ; Thu, 16 Apr 2015 17:37:26 +0000 (UTC) Received: (qmail 59344 invoked by uid 500); 16 Apr 2015 17:37:26 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 59313 invoked by uid 500); 16 Apr 2015 17:37:26 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 59304 invoked by uid 99); 16 Apr 2015 17:37:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Apr 2015 17:37:26 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 16 Apr 2015 17:36:55 +0000 Received: (qmail 55825 invoked by uid 99); 16 Apr 2015 17:36:52 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Apr 2015 17:36:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 22895E10B1; Thu, 16 Apr 2015 17:36:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Date: Thu, 16 Apr 2015 17:36:59 -0000 Message-Id: <3883f4c2b04d4be9a5ebb58c7fa82fe6@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [09/39] incubator-ignite git commit: #ignite-738: GridH2IndexingGeoSelfTest uses new query API. X-Virus-Checked: Checked by ClamAV on apache.org #ignite-738: GridH2IndexingGeoSelfTest uses new query API. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b388252e Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b388252e Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b388252e Branch: refs/heads/ignite-485 Commit: b388252ee366fcb8d8b14f9f05d1b10bbcaa8067 Parents: 4dd76db Author: ivasilinets Authored: Mon Apr 13 17:57:42 2015 +0300 Committer: ivasilinets Committed: Mon Apr 13 17:57:42 2015 +0300 ---------------------------------------------------------------------- .../query/h2/GridH2IndexingGeoSelfTest.java | 52 +++++++++++--------- 1 file changed, 29 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b388252e/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java index 9abf228..8566960 100644 --- a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java +++ b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java @@ -19,14 +19,16 @@ package org.apache.ignite.internal.processors.query.h2; import com.vividsolutions.jts.geom.*; import com.vividsolutions.jts.io.*; +import org.apache.ignite.*; +import org.apache.ignite.cache.query.*; import org.apache.ignite.cache.query.annotations.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.processors.cache.query.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.testframework.*; +import javax.cache.*; import java.io.*; import java.util.*; import java.util.concurrent.*; @@ -64,7 +66,7 @@ public class GridH2IndexingGeoSelfTest extends GridCacheAbstractSelfTest { */ @SuppressWarnings("unchecked") public void testGeo() throws Exception { - GridCacheAdapter cache = ((IgniteKernal)grid(0)).internalCache(null); + IgniteCache cache = grid(0).cache(null); WKTReader r = new WKTReader(); @@ -73,46 +75,50 @@ public class GridH2IndexingGeoSelfTest extends GridCacheAbstractSelfTest { cache.getAndPut(2, new EnemyCamp(r.read("POINT(70 30)"), "C")); cache.getAndPut(3, new EnemyCamp(r.read("POINT(75 25)"), "D")); - CacheQuery> qry = cache.queries().createSqlQuery(EnemyCamp.class, - "coords && ?"); + SqlQuery qry = new SqlQuery(EnemyCamp.class, "coords && ?"); - Collection> res = qry.execute(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 70))")) - .get(); + Collection> res = cache.query( + qry.setArgs(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 70))"))).getAll(); checkPoints(res, "A"); - res = qry.execute(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 5))")).get(); + res = cache.query( + qry.setArgs(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 5))"))).getAll(); checkPoints(res, "C", "D"); // Move B to the first polygon. cache.getAndPut(1, new EnemyCamp(r.read("POINT(20 75)"), "B")); - res = qry.execute(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 70))")).get(); + res = cache.query( + qry.setArgs(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 70))"))).getAll(); checkPoints(res, "A", "B"); // Move B to the second polygon. cache.getAndPut(1, new EnemyCamp(r.read("POINT(30 30)"), "B")); - res = qry.execute(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 5))")).get(); + res = cache.query( + qry.setArgs(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 5))"))).getAll(); checkPoints(res, "B", "C", "D"); // Remove B. cache.getAndRemove(1); - res = qry.execute(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 70))")).get(); + res = cache.query( + qry.setArgs(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 70))"))).getAll(); checkPoints(res, "A"); - res = qry.execute(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 5))")).get(); + res = cache.query( + qry.setArgs(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 5))"))).getAll(); checkPoints(res, "C", "D"); // Check explaint request. - assertTrue(F.first(cache.queries().createSqlFieldsQuery("explain select * from EnemyCamp " + - "where coords && 'POINT(25 75)'").execute().get()).get(0).toString().contains("coords_idx")); + assertTrue(F.first(cache.query(new SqlFieldsQuery("explain select * from EnemyCamp " + + "where coords && 'POINT(25 75)'")).getAll()).get(0).toString().contains("coords_idx")); } /** @@ -120,9 +126,9 @@ public class GridH2IndexingGeoSelfTest extends GridCacheAbstractSelfTest { */ @SuppressWarnings("unchecked") public void testGeoMultithreaded() throws Exception { - final GridCacheAdapter cache1 = ((IgniteKernal)grid(0)).internalCache(null); - final GridCacheAdapter cache2 = ((IgniteKernal)grid(1)).internalCache(null); - final GridCacheAdapter cache3 = ((IgniteKernal)grid(2)).internalCache(null); + final IgniteCache cache1 = grid(0).cache(null); + final IgniteCache cache2 = grid(1).cache(null); + final IgniteCache cache3 = grid(2).cache(null); final String[] points = new String[CNT]; @@ -153,7 +159,7 @@ public class GridH2IndexingGeoSelfTest extends GridCacheAbstractSelfTest { while (!stop.get()) { int cacheIdx = rnd.nextInt(0, 3); - GridCacheAdapter cache = cacheIdx == 0 ? cache1 : cacheIdx == 1 ? cache2 : cache3; + IgniteCache cache = cacheIdx == 0 ? cache1 : cacheIdx == 1 ? cache2 : cache3; int idx = rnd.nextInt(CNT); int x = rnd.nextInt(1, 100); @@ -178,13 +184,13 @@ public class GridH2IndexingGeoSelfTest extends GridCacheAbstractSelfTest { try { int cacheIdx = rnd.nextInt(0, 3); - GridCacheAdapter cache = cacheIdx == 0 ? cache1 : cacheIdx == 1 ? cache2 : cache3; + IgniteCache cache = cacheIdx == 0 ? cache1 : cacheIdx == 1 ? cache2 : cache3; - CacheQuery> qry = cache.queries().createSqlQuery( + SqlQuery qry = new SqlQuery<>( EnemyCamp.class, "coords && ?"); - Collection> res = qry.execute( - r.read("POLYGON((0 0, 0 100, 100 100, 100 0, 0 0))")).get(); + Collection> res = cache.query(qry.setArgs( + r.read("POLYGON((0 0, 0 100, 100 100, 100 0, 0 0))"))).getAll(); checkPoints(res, points); @@ -222,12 +228,12 @@ public class GridH2IndexingGeoSelfTest extends GridCacheAbstractSelfTest { * @param res Result. * @param points Expected points. */ - private void checkPoints( Collection> res, String... points) { + private void checkPoints( Collection> res, String... points) { Set set = new HashSet<>(Arrays.asList(points)); assertEquals(set.size(), res.size()); - for (Map.Entry e : res) + for (Cache.Entry e : res) assertTrue(set.remove(e.getValue().name)); }