Repository: ignite Updated Branches: refs/heads/ignite-1232 22f923cb3 -> 445bf55e9
ignite-1232 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/445bf55e Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/445bf55e Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/445bf55e Branch: refs/heads/ignite-1232 Commit: 445bf55e926fea1c79d2e058571e606803ac7853 Parents: 22f923c Author: sboikov <[email protected]> Authored: Mon Jul 18 12:15:28 2016 +0300 Committer: sboikov <[email protected]> Committed: Mon Jul 18 15:42:30 2016 +0300 ---------------------------------------------------------------------- .../cache/query/GridCacheTwoStepQuery.java | 2 +- .../processors/igfs/IgfsIpcHandler.java | 1 - .../messages/GridQueryNextPageResponse.java | 2 - .../junits/common/GridCommonAbstractTest.java | 6 +- .../processors/query/h2/IgniteH2Indexing.java | 2 +- .../query/h2/opt/GridH2CollocationModel.java | 6 +- .../query/h2/opt/GridH2QueryContext.java | 9 +-- .../processors/query/h2/opt/GridH2Table.java | 34 +++++----- .../query/h2/sql/GridSqlQueryParser.java | 10 ++- .../query/h2/sql/GridSqlQuerySplitter.java | 2 +- .../query/h2/twostep/GridMapQueryExecutor.java | 28 ++++++-- .../query/h2/twostep/GridMergeIndex.java | 3 +- .../h2/twostep/GridReduceQueryExecutor.java | 6 +- .../query/h2/twostep/msg/GridH2Integer.java | 12 ---- .../cache/GridCacheCrossCacheQuerySelfTest.java | 3 - ...acheDistributedJoinCustomAffinityMapper.java | 2 +- ...ributedJoinPartitionedAndReplicatedTest.java | 26 ++++---- ...CacheDistributedJoinQueryConditionsTest.java | 68 +++++++++++++------- .../query/IgniteSqlSplitterSelfTest.java | 52 +++++++++------ 19 files changed, 156 insertions(+), 118 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/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 6238ca2..eacf59c 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 @@ -98,7 +98,7 @@ public class GridCacheTwoStepQuery { /** * @param skipMergeTbl Skip merge table. */ - public void skipMergeTbl(boolean skipMergeTbl) { + public void skipMergeTable(boolean skipMergeTbl) { this.skipMergeTbl = skipMergeTbl; } http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java index c2ecd98..a888aff 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java @@ -32,7 +32,6 @@ import org.apache.ignite.internal.igfs.common.IgfsIpcCommand; import org.apache.ignite.internal.igfs.common.IgfsMessage; import org.apache.ignite.internal.igfs.common.IgfsPathControlRequest; import org.apache.ignite.internal.igfs.common.IgfsStreamControlRequest; -import org.apache.ignite.internal.managers.communication.GridIoPolicy; import org.apache.ignite.internal.util.future.GridFinishedFuture; import org.apache.ignite.internal.util.future.GridFutureAdapter; import org.apache.ignite.internal.util.typedef.F; http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java index a930ca3..4889069 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java @@ -24,7 +24,6 @@ import org.apache.ignite.internal.GridDirectCollection; import org.apache.ignite.internal.GridDirectTransient; import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; @@ -56,7 +55,6 @@ public class GridQueryNextPageResponse implements Message { /** */ @GridDirectCollection(Message.class) - @GridToStringInclude private Collection<Message> vals; /** */ http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java index f41f4c5..e475754 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java @@ -1187,12 +1187,16 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { * @return Key. */ protected final Integer keyForNode(Affinity<Object> aff, AtomicInteger key, ClusterNode node) { - while (true) { + for (int i = 0; i < 100_000; i++) { Integer next = key.getAndIncrement(); if (aff.mapKeyToNode(next).equals(node)) return next; } + + fail("Failed to find key for node: " + node); + + return null; } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/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 0c1752c..2153c18 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 @@ -1818,7 +1818,7 @@ public class IgniteH2Indexing implements GridQueryIndexing { } /** {@inheritDoc} */ - @Override public void registerCache(GridCacheContext<?,?> cctx, CacheConfiguration<?,?> ccfg) + @Override public void registerCache(GridCacheContext<?, ?> cctx, CacheConfiguration<?,?> ccfg) throws IgniteCheckedException { String schema = schemaNameFromCacheConf(ccfg); http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java index b3cb7f1..0f76316 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java @@ -331,7 +331,7 @@ public final class GridH2CollocationModel { if (tbl.rowDescriptor().context().customAffinityMapper()) throw customAffinityError(tbl.spaceName()); - if (childFilters.length > 1 && F.isEmpty(tf.getIndexConditions())) { + if (F.isEmpty(tf.getIndexConditions())) { throw new CacheException("Failed to prepare distributed join query: " + "join condition does not use index [joinedCache=" + tbl.spaceName() + ", plan=" + tf.getSelect().getPlanSQL() + ']'); @@ -350,7 +350,9 @@ public final class GridH2CollocationModel { for (int i = 0; i < idxConditions.size(); i++) { IndexCondition c = idxConditions.get(i); - if (c.getCompareType() == Comparison.EQUAL && + int cmpType = c.getCompareType(); + + if ((cmpType == Comparison.EQUAL || cmpType == Comparison.EQUAL_NULL_SAFE) && c.getColumn().getColumnId() == affColId && c.isEvaluatable()) { affKeyCondFound = true; http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java index 3e68b4e..14e34d9 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java @@ -73,7 +73,7 @@ public class GridH2QueryContext { private AffinityTopologyVersion topVer; /** */ - private Map<UUID,int[]> partsMap; + private Map<UUID, int[]> partsMap; /** */ private UUID[] partsNodes; @@ -503,13 +503,6 @@ public class GridH2QueryContext { return this; } - /** - * @return Query type. - */ - public GridH2QueryType queryType() { - return key.type; - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridH2QueryContext.class, this); http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java index 53c2ed6..e2356f1 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java @@ -113,30 +113,28 @@ public class GridH2Table extends TableBase { this.desc = desc; this.spaceName = spaceName; - if (desc != null && desc.context() != null) { - if (!desc.context().customAffinityMapper()) { - boolean affinityColExists = true; + if (desc != null && desc.context() != null && !desc.context().customAffinityMapper()) { + boolean affinityColExists = true; - String affKey = desc.type().affinityKey(); + String affKey = desc.type().affinityKey(); - int affKeyColId = -1; + int affKeyColId = -1; - if (affKey != null) { - String colName = desc.context().config().isSqlEscapeAll() ? affKey : affKey.toUpperCase(); + if (affKey != null) { + String colName = desc.context().config().isSqlEscapeAll() ? affKey : affKey.toUpperCase(); - if (doesColumnExist(colName)) - affKeyColId = getColumn(colName).getColumnId(); - else - affinityColExists = false; - } + if (doesColumnExist(colName)) + affKeyColId = getColumn(colName).getColumnId(); else - affKeyColId = KEY_COL; + affinityColExists = false; + } + else + affKeyColId = KEY_COL; - if (affinityColExists) { - affKeyCol = indexColumn(affKeyColId, SortOrder.ASCENDING); + if (affinityColExists) { + affKeyCol = indexColumn(affKeyColId, SortOrder.ASCENDING); - assert affKeyCol != null; - } + assert affKeyCol != null; } } @@ -275,7 +273,7 @@ public class GridH2Table extends TableBase { } /** - * @return {@code true} If we must snapshot and release index snapshots in {@link #lock(Session, boolean, boolean)} + * @return {@code True} If we must snapshot and release index snapshots in {@link #lock(Session, boolean, boolean)} * and {@link #unlock(Session)} methods. */ private boolean snapshotInLock() { http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java index e35d4e9..a7451c1 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java @@ -383,6 +383,10 @@ public class GridSqlQueryParser { throw new CacheException("Unsupported query: " + qry); } + /** + * @param qry Prepared. + * @return Query. + */ public GridSqlQuery parse(Prepared qry) { return parse(qry, null); } @@ -463,8 +467,10 @@ public class GridSqlQueryParser { if (expression instanceof ExpressionColumn) { ExpressionColumn expCol = (ExpressionColumn)expression; - return new GridSqlColumn(expCol.getColumn(), parseTable(expCol.getTableFilter()), - expression.getColumnName(), expression.getSQL()); + return new GridSqlColumn(expCol.getColumn(), + parseTable(expCol.getTableFilter()), + expression.getColumnName(), + expression.getSQL()); } if (expression instanceof Alias) http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/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 f37277d..7205a18 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 @@ -397,7 +397,7 @@ public class GridSqlQuerySplitter { findParams(rdcQry, params, new ArrayList<>(), paramIdxs).toArray()); rdc.parameterIndexes(toArray(paramIdxs)); - res.skipMergeTbl(rdcQry.simpleQuery()); + res.skipMergeTable(rdcQry.simpleQuery()); return rdc; } http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java index cc03721..3238134 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java @@ -429,8 +429,16 @@ public class GridMapQueryExecutor { private void onQueryRequest(ClusterNode node, GridQueryRequest req) { List<String> caches = (List<String>)F.concat(true, req.space(), req.extraSpaces()); - onQueryRequest0(node, req.requestId(), req.queries(), caches, req.topologyVersion(), null, req.partitions(), - null, req.pageSize(), false); + onQueryRequest0(node, + req.requestId(), + req.queries(), + caches, + req.topologyVersion(), + null, + req.partitions(), + null, + req.pageSize(), + false); } /** @@ -441,8 +449,16 @@ public class GridMapQueryExecutor { Map<UUID,int[]> partsMap = req.partitions(); int[] parts = partsMap == null ? null : partsMap.get(ctx.localNodeId()); - onQueryRequest0(node, req.requestId(),req.queries(), req.caches(), req.topologyVersion(), partsMap, parts, - req.tables(), req.pageSize(), req.isFlagSet(GridH2QueryRequest.FLAG_DISTRIBUTED_JOINS)); + onQueryRequest0(node, + req.requestId(), + req.queries(), + req.caches(), + req.topologyVersion(), + partsMap, + parts, + req.tables(), + req.pageSize(), + req.isFlagSet(GridH2QueryRequest.FLAG_DISTRIBUTED_JOINS)); } /** @@ -499,7 +515,9 @@ public class GridMapQueryExecutor { throw new IllegalStateException(); // Prepare query context. - GridH2QueryContext qctx = new GridH2QueryContext(ctx.localNodeId(), node.id(), reqId, + GridH2QueryContext qctx = new GridH2QueryContext(ctx.localNodeId(), + node.id(), + reqId, mainCctx.isReplicated() ? REPLICATED : MAP) .filter(h2.backupFilter(topVer, parts)) .partitionsMap(partsMap) http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java index 521a2a1..796ea66 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java @@ -33,6 +33,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.query.h2.opt.GridH2Cursor; +import org.apache.ignite.internal.util.typedef.internal.U; import org.h2.engine.Session; import org.h2.index.BaseIndex; import org.h2.index.Cursor; @@ -145,7 +146,7 @@ public abstract class GridMergeIndex extends BaseIndex { public void setSources(Collection<ClusterNode> nodes) { assert remainingRows == null; - remainingRows = new HashMap<>(nodes.size(), 1f); + remainingRows = U.newHashMap(nodes.size()); for (ClusterNode node : nodes) { if (remainingRows.put(node.id(), new Counter()) != null) http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/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 9092e71..5c2ff29 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 @@ -108,7 +108,7 @@ public class GridReduceQueryExecutor { public static final byte QUERY_POOL = GridIoPolicy.SYSTEM_POOL; /** */ - private static final IgniteProductVersion DISTRIBUTED_JOIN_SINCE = IgniteProductVersion.fromString("1.4.0"); + private static final IgniteProductVersion DISTRIBUTED_JOIN_SINCE = IgniteProductVersion.fromString("1.7.0"); /** */ private boolean oldNodesInTop = true; @@ -1193,11 +1193,11 @@ public class GridReduceQueryExecutor { * @param m Map. * @return Converted map. */ - private static Map<UUID,int[]> convert(Map<ClusterNode, IntArray> m) { + private static Map<UUID, int[]> convert(Map<ClusterNode, IntArray> m) { if (m == null) return null; - Map<UUID,int[]> res = new HashMap<>(m.size(), 1f); + Map<UUID, int[]> res = U.newHashMap(m.size()); for (Map.Entry<ClusterNode,IntArray> entry : m.entrySet()) res.put(entry.getKey().id(), toArray(entry.getValue())); http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Integer.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Integer.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Integer.java index 16ebcad..7c6046c 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Integer.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Integer.java @@ -47,18 +47,6 @@ public class GridH2Integer extends GridH2ValueMessage { x = val.getInt(); } - /** - * @param x Primitive value. - * @return Instance of {@link GridH2Integer}. - */ - public static GridH2Integer fromInt(int x) { - GridH2Integer res = new GridH2Integer(); - - res.x = x; - - return res; - } - /** {@inheritDoc} */ @Override public Value value(GridKernalContext ctx) { return ValueInt.get(x); http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java index eb84fd3..1f10593 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java @@ -131,7 +131,6 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest { SqlFieldsQuery qry = new SqlFieldsQuery("select f.productId, p.name, f.price " + "from FactPurchase f, \"replicated\".DimProduct p where p.id = f.productId "); - qry.setEnforceJoinOrder(true); for (List<?> o : qryProc.queryTwoStep(cache.context(), qry).getAll()) { X.println("___ -> " + o); @@ -165,7 +164,6 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest { "from FactPurchase f, \"replicated\".DimProduct p " + "where p.id = f.productId " + "group by f.productId, p.name"); - qry.setEnforceJoinOrder(true); for (List<?> o : qryProc.queryTwoStep(cache.context(), qry).getAll()) { X.println("___ -> " + o); @@ -183,7 +181,6 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest { "where p.id = f.productId " + "group by f.productId, p.name " + "having s >= 15"); - qry.setEnforceJoinOrder(true); for (List<?> o : qryProc.queryTwoStep(cache.context(), qry).getAll()) { X.println("___ -> " + o); http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCustomAffinityMapper.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCustomAffinityMapper.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCustomAffinityMapper.java index 7c3ce3a..1d4f7b2 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCustomAffinityMapper.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCustomAffinityMapper.java @@ -216,7 +216,7 @@ public class IgniteCacheDistributedJoinCustomAffinityMapper extends GridCommonAb }, CacheException.class, null); assertTrue("Unexpected error message: " + err.getMessage(), - err.getMessage().contains("Can not use distributed joins for cache with custom AffinityKeyMapper configured.")); + err.getMessage().contains("can not use distributed joins for cache with custom AffinityKeyMapper configured.")); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinPartitionedAndReplicatedTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinPartitionedAndReplicatedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinPartitionedAndReplicatedTest.java index 985c541..d7610dc 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinPartitionedAndReplicatedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinPartitionedAndReplicatedTest.java @@ -258,27 +258,27 @@ public class IgniteCacheDistributedJoinPartitionedAndReplicatedTest extends Grid checkQuery("select o.name, p._key, p.name, a.name " + "from \"org\".Organization o, \"person\".Person p, \"acc\".Account a " + - "where p.orgId = o._key and p._key = a.personId", qryCache, false, 2); + "where p.orgId = o._key and p._key = a.personId and a.orgId=o._key", qryCache, false, 2); checkQuery("select o.name, p._key, p.name, a.name " + "from \"org\".Organization o, \"acc\".Account a, \"person\".Person p " + - "where p.orgId = o._key and p._key = a.personId", qryCache, false, 2); + "where p.orgId = o._key and p._key = a.personId and a.orgId=o._key", qryCache, false, 2); checkQuery("select o.name, p._key, p.name, a.name " + "from \"person\".Person p, \"org\".Organization o, \"acc\".Account a " + - "where p.orgId = o._key and p._key = a.personId", qryCache, false, 2); + "where p.orgId = o._key and p._key = a.personId and a.orgId=o._key", qryCache, false, 2); checkQuery("select * from (select o.name n1, p._key, p.name n2, a.name n3 " + "from \"acc\".Account a, \"person\".Person p, \"org\".Organization o " + - "where p.orgId = o._key and p._key = a.personId)", qryCache, false, 2); + "where p.orgId = o._key and p._key = a.personId and a.orgId=o._key)", qryCache, false, 2); checkQuery("select * from (select o.name n1, p._key, p.name n2, a.name n3 " + "from \"person\".Person p, \"acc\".Account a, \"org\".Organization o " + - "where p.orgId = o._key and p._key = a.personId)", qryCache, false, 2); + "where p.orgId = o._key and p._key = a.personId and a.orgId=o._key)", qryCache, false, 2); List<List<?>> res = checkQuery("select count(*) " + "from \"org\".Organization o, \"person\".Person p, \"acc\".Account a " + - "where p.orgId = o._key and p._key = a.personId", qryCache, false, 1); + "where p.orgId = o._key and p._key = a.personId and a.orgId=o._key", qryCache, false, 1); assertEquals(2L, res.get(0).get(0)); @@ -298,25 +298,25 @@ public class IgniteCacheDistributedJoinPartitionedAndReplicatedTest extends Grid checkQuery("select o.name, p._key, p.name, a.name " + "from \"org\".Organization o, \"person\".Person p, \"acc\".Account a " + - "where p.orgId = o._key and p._key = a.personId", qryCache, false, 4); + "where p.orgId = o._key and p._key = a.personId and a.orgId=o._key", qryCache, false, 4); checkQuery("select o.name, p._key, p.name, a.name " + "from \"org\".Organization o inner join \"person\".Person p on p.orgId = o._key " + - "inner join \"acc\".Account a on p._key = a.personId", qryCache, false, 4); + "inner join \"acc\".Account a on p._key = a.personId and a.orgId=o._key", qryCache, false, 4); res = checkQuery("select count(*) " + "from \"org\".Organization o, \"person\".Person p, \"acc\".Account a " + - "where p.orgId = o._key and p._key = a.personId", qryCache, false, 1); + "where p.orgId = o._key and p._key = a.personId and a.orgId=o._key", qryCache, false, 1); assertEquals(4L, res.get(0).get(0)); checkQuery("select o.name, p._key, p.name, a.name " + "from \"org\".Organization o, \"person\".Person p, \"acc\".Account a " + - "where p.orgId = o._key and a.orgId = o._key", qryCache, false, 4); + "where p.orgId = o._key and a.orgId = o._key and a.orgId=o._key", qryCache, false, 4); res = checkQuery("select count(*) " + "from \"org\".Organization o, \"person\".Person p, \"acc\".Account a " + - "where p.orgId = o._key and a.orgId = o._key", qryCache, false, 1); + "where p.orgId = o._key and a.orgId = o._key and a.orgId=o._key", qryCache, false, 1); assertEquals(4L, res.get(0).get(0)); @@ -353,7 +353,7 @@ public class IgniteCacheDistributedJoinPartitionedAndReplicatedTest extends Grid cache1 + ", " + cache2 + ", " + cache3 + " " + - "where p.orgId = o._key and p._key = a.personId"; + "where p.orgId = o._key and p._key = a.personId and a.orgId=o._key"; checkQuery(qry, qryCache, false, expSize); @@ -361,7 +361,7 @@ public class IgniteCacheDistributedJoinPartitionedAndReplicatedTest extends Grid cache1 + ", " + cache2 + ", " + cache3 + " " + - "where p.orgId = o._key and a.orgId = o._key"; + "where p.orgId = o._key and a.orgId = o._key and a.orgId=o._key"; checkQuery(qry, qryCache, false, expSize); } http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinQueryConditionsTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinQueryConditionsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinQueryConditionsTest.java index 1124067..934e16b 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinQueryConditionsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinQueryConditionsTest.java @@ -112,19 +112,10 @@ public class IgniteCacheDistributedJoinQueryConditionsTest extends GridCommonAbs cacheConfiguration(ORG_CACHE).setQueryEntities(F.asList(organizationEntity(idx))); IgniteCache<Object, Object> pCache = client.createCache(ccfg1); - IgniteCache<Object, Object> orgCache = client.createCache(ccfg2); + client.createCache(ccfg2); List<Integer> orgIds = putData1(); -// checkQuery("select * from " + -// "(select _key, name from \"org\".Organization) o " + -// "inner join " + -// "(select orgId from Person) p " + -// "on p.orgId = o._key", pCache, total); -// -// checkQuery("select _key, name from \"org\".Organization o " + -// "inner join (select orgId from Person) p on p.orgId = o._key", pCache, total); - checkQuery("select o._key, o.name, p._key, p.name " + "from \"org\".Organization o, Person p " + "where p.orgId = o._key", pCache, total); @@ -341,10 +332,6 @@ public class IgniteCacheDistributedJoinQueryConditionsTest extends GridCommonAbs checkQuery("select p1._key, p1.name, p2._key, p2.name " + "from Person p1, Person p2 " + "where p1.name > p2.name", pCache, 3); - -// checkQuery("select p1._key, p1.name, p2._key, p2.name " + -// "from Person p1, Person p2 " + -// "where p1.name != p2.name", pCache, 6); } finally { client.destroyCache(PERSON_CACHE); @@ -383,8 +370,48 @@ public class IgniteCacheDistributedJoinQueryConditionsTest extends GridCommonAbs checkQuery("select o._key from \"org\".Organization o, Person p where p.orgId = o._key", pCache, 1); -// checkQuery("select o.name from \"org\".Organization o where o._key in " + -// "(select o._key from \"org\".Organization o, Person p where p.orgId = o._key)", pCache, 1); + // Distributed join is not enabled for expressions, just check query does not fail. + checkQuery("select o.name from \"org\".Organization o where o._key in " + + "(select o._key from \"org\".Organization o, Person p where p.orgId = o._key)", pCache, 0); + } + finally { + client.destroyCache(PERSON_CACHE); + client.destroyCache(ORG_CACHE); + } + } + + /** + * @throws Exception If failed. + */ + public void testJoinQuery6() throws Exception { + Ignite client = grid(2); + + try { + CacheConfiguration ccfg1 = + cacheConfiguration(PERSON_CACHE).setQueryEntities(F.asList(personEntity(true, true))); + CacheConfiguration ccfg2 = + cacheConfiguration(ORG_CACHE).setQueryEntities(F.asList(organizationEntity(true))); + + IgniteCache<Object, Object> pCache = client.createCache(ccfg1); + + client.createCache(ccfg2); + + putData1(); + + checkQuery("select _key, name from \"org\".Organization o " + + "inner join (select orgId from Person) p on p.orgId = o._key", pCache, total); + + checkQuery("select o._key, o.name from (select _key, name from \"org\".Organization) o " + + "inner join Person p on p.orgId = o._key", pCache, total); + + checkQuery("select o._key, o.name from (select _key, name from \"org\".Organization) o " + + "inner join (select orgId from Person) p on p.orgId = o._key", pCache, total); + + checkQuery("select * from " + + "(select _key, name from \"org\".Organization) o " + + "inner join " + + "(select orgId from Person) p " + + "on p.orgId = o._key", pCache, total); } finally { client.destroyCache(PERSON_CACHE); @@ -418,19 +445,14 @@ public class IgniteCacheDistributedJoinQueryConditionsTest extends GridCommonAbs boolean enforceJoinOrder, int expSize, Object... args) { - String plan = (String)cache.query(new SqlFieldsQuery("explain " + sql) - .setDistributedJoins(true) - .setEnforceJoinOrder(enforceJoinOrder)) - .getAll().get(0).get(0); - - log.info("Plan: " + plan); - SqlFieldsQuery qry = new SqlFieldsQuery(sql); qry.setDistributedJoins(true); qry.setEnforceJoinOrder(enforceJoinOrder); qry.setArgs(args); + log.info("Plan: " + queryPlan(cache, qry)); + QueryCursor<List<?>> cur = cache.query(qry); List<List<?>> res = cur.getAll(); http://git-wip-us.apache.org/repos/asf/ignite/blob/445bf55e/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java index 966e3dc..8ab70ba 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java @@ -526,27 +526,32 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest { checkNoBatchedJoin(persPart, "select p._key k1, o._key k2 ", "\"persPart\".Person2 p", "\"orgPart\".Organization o", - "where p._key = o._key"); - -// checkNoBatchedJoin(persPart, "select p._key k1, o._key k2 ", -// "(select * from \"persPart\".Person2) p", -// "\"orgPart\".Organization o", -// "where p._key = o._key"); + "where p._key = o._key", true); checkNoBatchedJoin(persPart, "select p._key k1, o._key k2 ", "\"persPart\".Person2 p", "\"orgRepl\".Organization o", - "where p._key = o._key"); + "where p._key = o._key", true); checkNoBatchedJoin(persPartAff, "select p._key k1, o._key k2 ", "\"persPartAff\".Person2 p", "\"orgPart\".Organization o", - "where p.affKey = o._key"); + "where p.affKey = o._key", true); checkNoBatchedJoin(persPartAff, "select p._key k1, o._key k2 ", "\"persPartAff\".Person2 p", "\"orgRepl\".Organization o", - "where p.affKey = o._key"); + "where p.affKey = o._key", true); + + checkNoBatchedJoin(persPart, "select p._key k1, o._key k2 ", + "(select * from \"persPart\".Person2) p", + "\"orgPart\".Organization o", + "where p._key = o._key", false); + + checkNoBatchedJoin(persPart, "select p._key k1, o._key k2 ", + "\"persPart\".Person2 p", + "(select * from \"orgPart\".Organization) o", + "where p._key = o._key", false); // Join multiple. @@ -767,32 +772,39 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest { * @param cache1 Cache name1. * @param cache2 Cache name2. * @param where Where clause. + * @param testEnforceJoinOrder If {@code true} tests query with enforced join order. */ private void checkNoBatchedJoin(IgniteCache<Object, Object> cache, String select, String cache1, String cache2, - String where) { - checkQueryPlan(cache, - true, - 0, - select + - "from " + cache1 + "," + cache2 + " "+ where); + String where, + boolean testEnforceJoinOrder) { checkQueryPlan(cache, false, 0, select + "from " + cache1 + "," + cache2 + " "+ where); - checkQueryPlan(cache, - true, - 0, - select + - "from " + cache2 + "," + cache1 + " "+ where); + checkQueryPlan(cache, false, 0, select + "from " + cache2 + "," + cache1 + " "+ where); + + if (testEnforceJoinOrder) { + checkQueryPlan(cache, + true, + 0, + select + + "from " + cache1 + "," + cache2 + " "+ where); + + checkQueryPlan(cache, + true, + 0, + select + + "from " + cache2 + "," + cache1 + " "+ where); + } } /**
