You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/07/14 04:25:21 UTC
[9/9] ignite git commit: ignite-1232
ignite-1232
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b9f2ee49
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b9f2ee49
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b9f2ee49
Branch: refs/heads/ignite-1232
Commit: b9f2ee49dc558373e71ffb5b82fd054724d9f5b9
Parents: 8d3d9b4
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jul 13 14:43:04 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Jul 14 07:24:51 2016 +0300
----------------------------------------------------------------------
.../processors/query/h2/IgniteH2Indexing.java | 3 ++
.../query/h2/opt/GridH2CollocationModel.java | 23 +++++++++--
.../query/h2/opt/GridH2IndexBase.java | 11 +-----
.../query/h2/opt/GridH2TreeIndex.java | 17 +++++++++
...teCacheJoinPartitionedAndReplicatedTest.java | 40 ++++++++++++++++----
.../IgniteCacheQuerySelfTestSuite.java | 2 -
6 files changed, 74 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9f2ee49/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 5d25dd4..0c1752c 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
@@ -1871,6 +1871,9 @@ public class IgniteH2Indexing implements GridQueryIndexing {
@Nullable @Override public <K, V> IgniteBiPredicate<K, V> forSpace(String spaceName) {
final GridCacheAdapter<Object, Object> cache = ctx.cache().internalCache(spaceName);
+ if (cache.context().isReplicated())
+ return null;
+
final GridCacheAffinityManager aff = cache.context().affinity();
if (parts != null) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9f2ee49/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 c11d9e0..d8757a0 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
@@ -48,6 +48,9 @@ public final class GridH2CollocationModel {
private static final int MULTIPLIER_BROADCAST = 200;
/** */
+ private static final int MULTIPLIER_REPLICATED_NOT_LAST = 1000;
+
+ /** */
private final GridH2CollocationModel upper;
/** */
@@ -206,7 +209,7 @@ public final class GridH2CollocationModel {
if (m > maxMultiplier) {
maxMultiplier = m;
- if (maxMultiplier == MULTIPLIER_BROADCAST)
+ if (maxMultiplier == MULTIPLIER_REPLICATED_NOT_LAST)
break;
}
}
@@ -224,7 +227,7 @@ public final class GridH2CollocationModel {
GridH2Table tbl = (GridH2Table)upper.childFilters[filter].getTable();
// Backup filter is used for REPLICATED cache if this is first cache in query.
- if (!tbl.isPartitioned() && filter != 0) {
+ if (!tbl.isPartitioned()) {
type = Type.REPLICATED;
multiplier = MULTIPLIER_COLLOCATED;
@@ -236,7 +239,7 @@ public final class GridH2CollocationModel {
// to all the affinity nodes the "base" does not need to get remote results.
if (!upper.findPartitionedTableBefore(filter)) {
type = Type.PARTITIONED_COLLOCATED;
- multiplier = MULTIPLIER_COLLOCATED;
+ multiplier = upper.previousReplicated(filter) ? MULTIPLIER_REPLICATED_NOT_LAST : MULTIPLIER_COLLOCATED;
return;
}
@@ -265,6 +268,9 @@ public final class GridH2CollocationModel {
default:
throw new IllegalStateException();
}
+
+ if (upper.previousReplicated(filter))
+ multiplier = MULTIPLIER_REPLICATED_NOT_LAST;
}
}
@@ -287,6 +293,17 @@ public final class GridH2CollocationModel {
}
/**
+ * @param f Current filter.
+ * @return {@code true} If previous table is REPLICATED.
+ */
+ private boolean previousReplicated(int f) {
+ if (f > 0 && child(f - 1, true).type(true) == Type.REPLICATED)
+ return true;
+
+ return upper != null && upper.previousReplicated(filter);
+ }
+
+ /**
* @param f Filter.
* @return Affinity join type.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9f2ee49/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
index 9ee417b..985d4ba 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
@@ -212,17 +212,8 @@ public abstract class GridH2IndexBase extends BaseIndex {
protected static IndexingQueryFilter threadLocalFilter(GridH2Table tbl, TableFilter tblFilter) {
GridH2QueryContext qctx = GridH2QueryContext.get();
- if (qctx != null) {
- if (!tbl.isPartitioned()) {
- if (tblFilter == null || qctx.queryType() == REPLICATED || qctx.queryType() == LOCAL)
- return null;
-
- if (tblFilter != tblFilter.getSelect().getTopFilters().get(0))
- return null;
- }
-
+ if (qctx != null)
return qctx.filter();
- }
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9f2ee49/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
index 6ac6645..5dfc8e6 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
@@ -465,6 +465,23 @@ public class GridH2TreeIndex extends GridH2IndexBase implements Comparator<GridS
/** {@inheritDoc} */
@Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder) {
+ TableFilter tblFilter = filters[filter];
+
+ if (false && tblFilter.getJoin() != null) {
+ GridH2Table tbl = (GridH2Table)tblFilter.getTable();
+
+ TableFilter join = tblFilter.getJoin();
+
+ if (!tbl.isPartitioned() && join.isJoinOuter() && join.getTable() instanceof GridH2Table) {
+ GridH2Table joinTbl = (GridH2Table)join.getTable();
+
+ if (joinTbl.isPartitioned())
+ throw new CacheException("Outer join REPLICATED PARTITIONED table [replCache=" + tbl.spaceName() +
+ ", partCache=" + joinTbl.spaceName() + ", sql=" + tblFilter.getSelect().getPlanSQL() + ']');
+ }
+ }
+
+
long rowCnt = getRowCountApproximation();
double baseCost = getCostRangeIndex(masks, rowCnt, filters, filter, sortOrder, false);
int mul = getDistributedMultiplier(ses, filters, filter);
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9f2ee49/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java
index 9ba35d3..1d528c9 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java
@@ -17,9 +17,6 @@
package org.apache.ignite.internal.processors.cache;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.QueryEntity;
@@ -32,8 +29,15 @@ import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import javax.cache.CacheException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+
import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -101,6 +105,8 @@ public class IgniteCacheJoinPartitionedAndReplicatedTest extends GridCommonAbstr
{
CacheConfiguration ccfg = configuration(ORG_CACHE_REPLICATED);
+ ccfg.setCacheMode(REPLICATED);
+
QueryEntity entity = new QueryEntity();
entity.setKeyType(Integer.class.getName());
entity.setValueType(Organization.class.getName());
@@ -193,10 +199,6 @@ public class IgniteCacheJoinPartitionedAndReplicatedTest extends GridCommonAbstr
checkQuery("select p.name from \"person\".Person p", personCache, 2);
checkQuery("select o.name, p._key, p.name " +
- "from \"person\".Person p left join \"org\".Organization o " +
- "on (p.orgId = o.id)", orgCache, 2);
-
- checkQuery("select o.name, p._key, p.name " +
"from \"org\".Organization o left join \"person\".Person p " +
"on (p.orgId = o.id)", orgCache, 2);
@@ -207,6 +209,30 @@ public class IgniteCacheJoinPartitionedAndReplicatedTest extends GridCommonAbstr
checkQuery("select o.name, p._key, p.name " +
"from \"orgRepl\".Organization o left join \"person\".Person p " +
"on (p.orgId = o.id)", orgCacheRepl, 2);
+
+ checkQueryFails("select o.name, p._key, p.name " +
+ "from \"person\".Person p left join \"org\".Organization o " +
+ "on (p.orgId = o.id)", personCache);
+
+ checkQueryFails("select o.name, p._key, p.name " +
+ "from \"org\".Organization o right join \"person\".Person p " +
+ "on (p.orgId = o.id)", personCache);
+ }
+
+ /**
+ * @param sql SQL.
+ * @param cache Cache.
+ */
+ private void checkQueryFails(final String sql, final IgniteCache<Object, Object> cache) {
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ SqlFieldsQuery qry = new SqlFieldsQuery(sql);
+
+ cache.query(qry).getAll();
+
+ return null;
+ }
+ }, CacheException.class, null);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/b9f2ee49/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 50bf51c..951522a 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
@@ -27,7 +27,6 @@ import org.apache.ignite.internal.processors.cache.IgniteBinaryWrappedObjectFiel
import org.apache.ignite.internal.processors.cache.IgniteCacheCollocatedQuerySelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheCrossCacheJoinRandomTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinCollocatedAndNotTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinCustomAffinityMapper;
import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinPartitionedAndReplicatedTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinQueryConditionsTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheDuplicateEntityConfigurationSelfTest;
@@ -131,7 +130,6 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
suite.addTestSuite(IgniteCacheDistributedJoinQueryConditionsTest.class);
suite.addTestSuite(IgniteCacheJoinPartitionedAndReplicatedTest.class);
suite.addTestSuite(IgniteCacheDistributedJoinNoIndexTest.class);
- suite.addTestSuite(IgniteCacheDistributedJoinCustomAffinityMapper.class);
suite.addTestSuite(IgniteCrossCachesJoinsQueryTest.class);
suite.addTestSuite(IgniteCacheCrossCacheJoinRandomTest.class);