You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/05/17 14:01:37 UTC
[3/9] ignite git commit: WIP on refactor.
WIP on refactor.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/78259fe8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/78259fe8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/78259fe8
Branch: refs/heads/ignite-5054-splitter-2
Commit: 78259fe87c0284c7d60502a25aa465122689a689
Parents: df67892
Author: devozerov <vo...@gridgain.com>
Authored: Wed May 17 13:58:14 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Wed May 17 13:58:14 2017 +0300
----------------------------------------------------------------------
.../cache/query/GridCacheTwoStepQuery.java | 40 ++-------------
.../processors/query/h2/IgniteH2Indexing.java | 53 +++++++++-----------
.../h2/twostep/GridReduceQueryExecutor.java | 5 ++
3 files changed, 34 insertions(+), 64 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/78259fe8/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java
index 2b723b3..cb4f06b 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java
@@ -18,7 +18,6 @@
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;
@@ -49,12 +48,6 @@ public class GridCacheTwoStepQuery {
private String originalSql;
/** */
- private Collection<String> spaces;
-
- /** */
- private Set<String> schemas;
-
- /** */
private Set<QueryTable> tbls;
/** */
@@ -206,13 +199,6 @@ public class GridCacheTwoStepQuery {
}
/**
- * @param extraCaches Caches.
- */
- public void extraCaches(List<Integer> extraCaches) {
- this.extraCaches = extraCaches;
- }
-
- /**
* @return Original query SQL.
*/
public String originalSql() {
@@ -220,27 +206,6 @@ public class GridCacheTwoStepQuery {
}
/**
- * @return Spaces.
- */
- public Collection<String> spaces() {
- return spaces;
- }
-
- /**
- * @param spaces Spaces.
- */
- public void spaces(Collection<String> spaces) {
- this.spaces = spaces;
- }
-
- /**
- * @return Schemas.
- */
- public Set<String> schemas() {
- return schemas;
- }
-
- /**
* @return {@code True} If query is local.
*/
public boolean isLocal() {
@@ -264,7 +229,6 @@ public class GridCacheTwoStepQuery {
cp.caches = caches;
cp.extraCaches = extraCaches;
- cp.spaces = spaces;
cp.rdc = rdc.copy();
cp.skipMergeTbl = skipMergeTbl;
cp.pageSize = pageSize;
@@ -290,6 +254,10 @@ public class GridCacheTwoStepQuery {
return tbls;
}
+ public Set<QueryTable> tables0() {
+ return tbls;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridCacheTwoStepQuery.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/78259fe8/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 4de5adc..122917c 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
@@ -46,6 +46,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -88,6 +89,7 @@ import org.apache.ignite.internal.processors.cache.database.tree.io.PageIO;
import org.apache.ignite.internal.processors.cache.query.GridCacheQueryMarshallable;
import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery;
import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
+import org.apache.ignite.internal.processors.cache.query.QueryTable;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator;
import org.apache.ignite.internal.processors.query.GridQueryCancel;
@@ -289,7 +291,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
/** */
private GridTimeoutProcessor.CancelableTask stmtCacheCleanupTask;
- /**
+ /*
* Command in H2 prepared statement.
*/
static {
@@ -1672,8 +1674,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
}
}
- List<Integer> caches;
- List<Integer> extraCaches = null;
+ LinkedHashSet<Integer> caches0 = new LinkedHashSet<>();
// Setup spaces from schemas.
assert twoStepQry != null;
@@ -1681,41 +1682,25 @@ public class IgniteH2Indexing implements GridQueryIndexing {
int tblCnt = twoStepQry.tablesCount();
if (tblCnt > 0) {
- Collection<String> spaces = new ArrayList<>(tblCnt);
-
- caches = new ArrayList<>(tblCnt + 1);
-
- caches.add(cctx.cacheId());
-
- for (String schema : twoStepQry.schemas()) {
- String space0 = space(schema);
+ caches0.add(cctx.cacheId());
- spaces.add(space0);
+ for (QueryTable table : twoStepQry.tables0()) {
+ String cacheName = cacheNameForSchemaAndTable(table.schema(), table.table());
- if (!F.eq(space0, space)) {
- int cacheId = CU.cacheId(space0);
+ int cacheId = CU.cacheId(cacheName);
- caches.add(cacheId);
-
- if (extraCaches == null)
- extraCaches = new ArrayList<>();
-
- extraCaches.add(cacheId);
- }
+ caches0.add(cacheId);
}
-
- twoStepQry.spaces(spaces);
- }
- else {
- caches = Collections.singletonList(cctx.cacheId());
- extraCaches = null;
}
+ else
+ caches0.add(cctx.cacheId());
//Prohibit usage indices with different numbers of segments in same query.
+ List<Integer> caches = new ArrayList<>(caches0);
+
checkCacheIndexSegmentation(caches);
twoStepQry.caches(caches);
- twoStepQry.extraCaches(extraCaches);
twoStepQry.local(qry.isLocal());
meta = meta(stmt.getMetaData());
@@ -1756,6 +1741,18 @@ public class IgniteH2Indexing implements GridQueryIndexing {
}
/**
+ * Get cache for schema and table.
+ *
+ * @param schemaName Schema name.
+ * @param tblName Table name.
+ * @return Cache name.
+ */
+ private String cacheNameForSchemaAndTable(String schemaName, String tblName) {
+ // TODO: This need to be changed.
+ return space(schemaName);
+ }
+
+ /**
* @throws IllegalStateException if segmented indices used with non-segmented indices.
*/
private void checkCacheIndexSegmentation(List<Integer> caches) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/78259fe8/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 3d81cb5..56fc090 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
@@ -575,6 +575,7 @@ public class GridReduceQueryExecutor {
if (cctx.isReplicated() && parts != null) {
boolean failIfReplicatedOnly = true;
+ // TOD: Use normal caches
for (Integer cacheId : extraSpaces) {
if (!cacheContext(cacheId).isReplicated()) {
failIfReplicatedOnly = false;
@@ -590,10 +591,13 @@ public class GridReduceQueryExecutor {
if (qry.isLocal())
nodes = singletonList(ctx.discovery().localNode());
else {
+ // TODO: Use normal caches
if (isPreloadingActive(cctx, extraSpaces)) {
if (isReplicatedOnly)
+ // TODO: Use normal caches
nodes = replicatedUnstableDataNodes(cctx, extraSpaces);
else {
+ // TODO: Use normal caches
partsMap = partitionedUnstableDataNodes(cctx, extraSpaces);
if (partsMap != null) {
@@ -632,6 +636,7 @@ public class GridReduceQueryExecutor {
final boolean skipMergeTbl = !qry.explain() && qry.skipMergeTable();
+ // TODO: Use normal caches
final int segmentsPerIndex = qry.explain() || isReplicatedOnly ? 1 :
findFirstPartitioned(cctx, extraSpaces).config().getQueryParallelism();