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 F2BD718C09 for ; Mon, 15 Feb 2016 07:51:46 +0000 (UTC) Received: (qmail 45436 invoked by uid 500); 15 Feb 2016 07:51:46 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 45309 invoked by uid 500); 15 Feb 2016 07:51:46 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 44442 invoked by uid 99); 15 Feb 2016 07:51:46 -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; Mon, 15 Feb 2016 07:51:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5884CE0A1B; Mon, 15 Feb 2016 07:51:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Mon, 15 Feb 2016 07:52:20 -0000 Message-Id: In-Reply-To: <77de44b693254128834c6663cef0cf9f@git.apache.org> References: <77de44b693254128834c6663cef0cf9f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [36/50] [abbrv] ignite git commit: ignite-split2 - fixes after merge ignite-split2 - fixes after merge Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2847880c Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2847880c Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2847880c Branch: refs/heads/ignite-1232 Commit: 2847880c29f8b6fc4603c31ad3d75d852b037a75 Parents: 5303fb8 Author: S.Vladykin Authored: Sat Dec 26 08:15:58 2015 +0300 Committer: S.Vladykin Committed: Sat Dec 26 08:15:58 2015 +0300 ---------------------------------------------------------------------- .../cache/query/GridCacheTwoStepQuery.java | 28 ++++++++---- .../processors/query/h2/IgniteH2Indexing.java | 16 +++++-- .../query/h2/sql/GridSqlQuerySplitter.java | 47 ++++++++++---------- .../h2/twostep/GridReduceQueryExecutor.java | 2 +- .../IgniteBinaryCacheQueryTestSuite.java | 11 ----- .../IgniteCacheQuerySelfTestSuite.java | 5 --- 6 files changed, 57 insertions(+), 52 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/2847880c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java index dfc84b8..6238ca2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache.query; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Set; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -45,7 +46,10 @@ public class GridCacheTwoStepQuery { private boolean explain; /** */ - private Set spaces; + private Collection spaces; + + /** */ + private Set schemas; /** */ private Set tbls; @@ -57,11 +61,11 @@ public class GridCacheTwoStepQuery { private boolean skipMergeTbl; /** - * @param spaces All spaces accessed in query. - * @param tbls Tables. + * @param schemas Schema names in query. + * @param tbls Tables in query. */ - public GridCacheTwoStepQuery(Set spaces, Set tbls) { - this.spaces = spaces; + public GridCacheTwoStepQuery(Set schemas, Set tbls) { + this.schemas = schemas; this.tbls = tbls; } @@ -160,26 +164,34 @@ public class GridCacheTwoStepQuery { /** * @return Spaces. */ - public Set spaces() { + public Collection spaces() { return spaces; } /** * @param spaces Spaces. */ - public void spaces(Set spaces) { + public void spaces(Collection spaces) { this.spaces = spaces; } /** + * @return Schemas. + */ + public Set schemas() { + return schemas; + } + + /** * @param args New arguments to copy with. * @return Copy. */ public GridCacheTwoStepQuery copy(Object[] args) { assert !explain; - GridCacheTwoStepQuery cp = new GridCacheTwoStepQuery(spaces, tbls); + GridCacheTwoStepQuery cp = new GridCacheTwoStepQuery(schemas, tbls); + cp.spaces = spaces; cp.rdc = rdc.copy(args); cp.skipMergeTbl = skipMergeTbl; cp.pageSize = pageSize; http://git-wip-us.apache.org/repos/asf/ignite/blob/2847880c/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java index 90dcc88..58026ca 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java @@ -953,7 +953,7 @@ public class IgniteH2Indexing implements GridQueryIndexing { String sql = generateQuery(qry, tbl); - Connection conn = connectionForThread(tbl.schema()); + Connection conn = connectionForThread(tbl.schemaName()); initLocalQueryContext(conn, false, filter); @@ -1105,6 +1105,16 @@ public class IgniteH2Indexing implements GridQueryIndexing { twoStepQry = GridSqlQuerySplitter.split((JdbcPreparedStatement)stmt, qry.getArgs(), groupByCollocated, distributedJoins); + // Setup spaces from schemas. + if (!twoStepQry.schemas().isEmpty()) { + Collection spaces = new ArrayList<>(twoStepQry.schemas().size()); + + for (String schema : twoStepQry.schemas()) + spaces.add(space(schema)); + + twoStepQry.spaces(spaces); + } + meta = meta(stmt.getMetaData()); } catch (IgniteCheckedException e) { @@ -1701,7 +1711,7 @@ public class IgniteH2Indexing implements GridQueryIndexing { throws IgniteCheckedException { String schema = schemaNameFromCacheConf(ccfg); - if (schemas.putIfAbsent(schema, new Schema(ccfg.getName(), cctx, ccfg)) != null) + if (schemas.putIfAbsent(schema, new Schema(ccfg.getName(), schema, cctx, ccfg)) != null) throw new IgniteCheckedException("Cache already registered: " + U.maskName(ccfg.getName())); space2schema.put(emptyIfNull(ccfg.getName()), schema); @@ -2460,7 +2470,7 @@ public class IgniteH2Indexing implements GridQueryIndexing { * @param cctx Cache context. * @param ccfg Cache configuration. */ - private Schema(@Nullable String spaceName, GridCacheContext cctx, CacheConfiguration ccfg) { + private Schema(String spaceName, String schemaName, GridCacheContext cctx, CacheConfiguration ccfg) { this.spaceName = spaceName; this.cctx = cctx; this.schemaName = schemaName; http://git-wip-us.apache.org/repos/asf/ignite/blob/2847880c/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java index 08f12d9..a6781bd 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java @@ -26,7 +26,6 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.query.GridCacheSqlQuery; import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery; -import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; @@ -170,7 +169,7 @@ public class GridSqlQuerySplitter { qry = collectAllTables(qry, schemas, tbls); // Build resulting two step query. - GridCacheTwoStepQuery res = new GridCacheTwoStepQuery(spaces, tbls); + GridCacheTwoStepQuery res = new GridCacheTwoStepQuery(schemas, tbls); // Map query will be direct reference to the original query AST. // Thus all the modifications will be performed on the original AST, so we should be careful when @@ -280,7 +279,7 @@ public class GridSqlQuerySplitter { * @param collocatedGroupBy Whether the query has collocated GROUP BY keys. * @return Reduce query for the given map query. */ - public static GridCacheSqlQuery split(GridCacheTwoStepQuery res, int splitIdx, final GridSqlSelect mapQry, + private static GridCacheSqlQuery split(GridCacheTwoStepQuery res, int splitIdx, final GridSqlSelect mapQry, Object[] params, boolean collocatedGroupBy) { final boolean explain = mapQry.explain(); @@ -436,27 +435,26 @@ public class GridSqlQuerySplitter { /** * @param qry Query. - * @param spaces Space names. + * @param schemas Schema names. * @param tbls Tables. - * @param schemas Shemas' names. * @return Query. */ - private static GridSqlQuery collectAllTables(GridSqlQuery qry, Set spaces, Set tbls) { + private static GridSqlQuery collectAllTables(GridSqlQuery qry, Set schemas, Set tbls) { if (qry instanceof GridSqlUnion) { GridSqlUnion union = (GridSqlUnion)qry; - collectAllTables(union.left(), spaces, tbls); - collectAllTables(union.right(), spaces, tbls); + collectAllTables(union.left(), schemas, tbls); + collectAllTables(union.right(), schemas, tbls); } else { GridSqlSelect select = (GridSqlSelect)qry; - collectAllTablesInFrom(select.from(), spaces, tbls); + collectAllTablesInFrom(select.from(), schemas, tbls); for (GridSqlElement el : select.columns(false)) - collectAllTablesInSubqueries(el, spaces, tbls); + collectAllTablesInSubqueries(el, schemas, tbls); - collectAllTablesInSubqueries(select.where(), spaces, tbls); + collectAllTablesInSubqueries(select.where(), schemas, tbls); } return qry; @@ -464,11 +462,10 @@ public class GridSqlQuerySplitter { /** * @param from From element. - * @param spaces Space names. + * @param schemas Schema names. * @param tbls Tables. - * @param schemas Shemas' names. */ - private static void collectAllTablesInFrom(GridSqlElement from, final Set spaces, final Set tbls) { + private static void collectAllTablesInFrom(GridSqlElement from, final Set schemas, final Set tbls) { findTablesInFrom(from, new IgnitePredicate() { @Override public boolean apply(GridSqlElement el) { if (el instanceof GridSqlTable) { @@ -476,14 +473,16 @@ public class GridSqlQuerySplitter { String schema = tbl.schema(); - if (schema != null && spaces != null) - spaces.add(IgniteH2Indexing.space(schema)); + boolean addSchema = tbls == null; if (tbls != null) - tbls.add(tbl.dataTable().identifier()); + addSchema = tbls.add(tbl.dataTable().identifier()); + + if (addSchema && schema != null && schemas != null) + schemas.add(schema); } else if (el instanceof GridSqlSubquery) - collectAllTables(((GridSqlSubquery)el).select(), spaces, tbls); + collectAllTables(((GridSqlSubquery)el).select(), schemas, tbls); return false; } @@ -524,13 +523,13 @@ public class GridSqlQuerySplitter { } /** - * Searches spaces in subqueries in SELECT and WHERE clauses. + * Searches schema names and tables in subqueries in SELECT and WHERE clauses. + * * @param el Element. - * @param spaces Space names. + * @param schemas Schema names. * @param tbls Tables. - * @param schemas Schemas' names. */ - private static void collectAllTablesInSubqueries(GridSqlElement el, Set spaces, Set tbls) { + private static void collectAllTablesInSubqueries(GridSqlElement el, Set schemas, Set tbls) { if (el == null) return; @@ -538,10 +537,10 @@ public class GridSqlQuerySplitter { if (el instanceof GridSqlOperation || el instanceof GridSqlFunction) { for (GridSqlElement child : el) - collectAllTablesInSubqueries(child, spaces, tbls); + collectAllTablesInSubqueries(child, schemas, tbls); } else if (el instanceof GridSqlSubquery) - collectAllTables(((GridSqlSubquery)el).select(), spaces, tbls); + collectAllTables(((GridSqlSubquery)el).select(), schemas, tbls); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/2847880c/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java index fffb822..a5fca5d 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java @@ -1043,7 +1043,7 @@ public class GridReduceQueryExecutor { * @param allSpaces All spaces. * @return List of all extra spaces or {@code null} if none. */ - private List extraSpaces(String mainSpace, Set allSpaces) { + private List extraSpaces(String mainSpace, Collection allSpaces) { if (F.isEmpty(allSpaces) || (allSpaces.size() == 1 && allSpaces.contains(mainSpace))) return null; http://git-wip-us.apache.org/repos/asf/ignite/blob/2847880c/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java index de94d53..2e0e4e2 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java @@ -32,7 +32,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexDisabledSe import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexingDisabledSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheQueryInternalKeysSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheQuerySerializationSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheReduceQueryMultithreadedSelfTest; import org.apache.ignite.internal.processors.cache.IgniteBinaryObjectFieldsQuerySelfTest; import org.apache.ignite.internal.processors.cache.IgniteBinaryWrappedObjectFieldsQuerySelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheBinaryObjectsScanSelfTest; @@ -95,10 +94,6 @@ import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheCon import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientReconnectTest; import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTest; import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTxReconnectTest; -import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryLocalSelfTest; -import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryPartitionedSelfTest; -import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryReplicatedSelfTest; import org.apache.ignite.internal.processors.query.IgniteSqlSplitterSelfTest; import org.apache.ignite.internal.processors.query.h2.sql.BaseH2CompareQueryTest; import org.apache.ignite.internal.processors.query.h2.sql.GridQueryParsingTest; @@ -200,12 +195,6 @@ public class IgniteBinaryCacheQueryTestSuite extends TestSuite { suite.addTestSuite(CacheContinuousQueryFailoverTxSelfTest.class); suite.addTestSuite(CacheContinuousQueryFailoverTxReplicatedSelfTest.class); - // Reduce fields queries. - suite.addTestSuite(GridCacheReduceFieldsQueryLocalSelfTest.class); - suite.addTestSuite(GridCacheReduceFieldsQueryPartitionedSelfTest.class); - suite.addTestSuite(GridCacheReduceFieldsQueryAtomicSelfTest.class); - suite.addTestSuite(GridCacheReduceFieldsQueryReplicatedSelfTest.class); - suite.addTestSuite(GridCacheQueryIndexingDisabledSelfTest.class); //Should be adjusted. Not ready to be used with BinaryMarshaller. http://git-wip-us.apache.org/repos/asf/ignite/blob/2847880c/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java index 5bef70b..0d099f2 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java @@ -29,7 +29,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexDisabledSe import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexingDisabledSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheQueryInternalKeysSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheQuerySerializationSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheReduceQueryMultithreadedSelfTest; import org.apache.ignite.internal.processors.cache.IgniteBinaryObjectFieldsQuerySelfTest; import org.apache.ignite.internal.processors.cache.IgniteBinaryWrappedObjectFieldsQuerySelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheCollocatedQuerySelfTest; @@ -90,10 +89,6 @@ import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheCon import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientReconnectTest; import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTest; import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTxReconnectTest; -import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryLocalSelfTest; -import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryPartitionedSelfTest; -import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryReplicatedSelfTest; import org.apache.ignite.internal.processors.query.IgniteSqlSchemaIndexingTest; import org.apache.ignite.internal.processors.query.IgniteSqlSplitterSelfTest; import org.apache.ignite.internal.processors.query.h2.sql.BaseH2CompareQueryTest;