You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2016/03/22 00:27:41 UTC
ignite git commit: ignite-1232 - npe fix + more sanity checks
Repository: ignite
Updated Branches:
refs/heads/ignite-1232 7f99f2a7c -> abdd443b5
ignite-1232 - npe fix + more sanity checks
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/abdd443b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/abdd443b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/abdd443b
Branch: refs/heads/ignite-1232
Commit: abdd443b578a958620b84b258bd5ef51e9f4a712
Parents: 7f99f2a
Author: S.Vladykin <sv...@gridgain.com>
Authored: Tue Mar 22 02:27:24 2016 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Tue Mar 22 02:27:24 2016 +0300
----------------------------------------------------------------------
.../query/h2/opt/GridH2CollocationModel.java | 41 ++++++++++++++------
1 file changed, 29 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/abdd443b/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 91ee94b..bc633a3 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
@@ -54,6 +54,9 @@ public final class GridH2CollocationModel {
private final int filter;
/** */
+ private final boolean view;
+
+ /** */
private int multiplier;
/** */
@@ -74,21 +77,24 @@ public final class GridH2CollocationModel {
/**
* @param upper Upper.
* @param filter Filter.
+ * @param view This model will be a subquery (or top level query) and must contain child filters.
*/
- private GridH2CollocationModel(GridH2CollocationModel upper, int filter) {
+ private GridH2CollocationModel(GridH2CollocationModel upper, int filter, boolean view) {
this.upper = upper;
this.filter = filter;
+ this.view = view;
}
/**
* @param upper Upper.
* @param filter Filter.
* @param unions Unions.
+ * @param view This model will be a subquery (or top level query) and must contain child filters.
* @return Created child collocation model.
*/
private static GridH2CollocationModel createChildModel(GridH2CollocationModel upper, int filter,
- List<GridH2CollocationModel> unions) {
- GridH2CollocationModel child = new GridH2CollocationModel(upper, filter);
+ List<GridH2CollocationModel> unions, boolean view) {
+ GridH2CollocationModel child = new GridH2CollocationModel(upper, filter, view);
if (unions != null) {
// Bind created child to unions.
@@ -114,6 +120,7 @@ public final class GridH2CollocationModel {
*/
private boolean childFilters(TableFilter[] childFilters) {
assert childFilters != null;
+ assert view;
Select select = childFilters[0].getSelect();
@@ -170,8 +177,9 @@ public final class GridH2CollocationModel {
if (type != null)
return;
- if (childFilters != null) {
- // We are at sub-query.
+ if (view) { // We are at (sub-)query model.
+ assert childFilters != null;
+
boolean collocated = true;
boolean partitioned = false;
int maxMultiplier = MULTIPLIER_COLLOCATED;
@@ -204,6 +212,7 @@ public final class GridH2CollocationModel {
}
else {
assert upper != null;
+ assert childFilters == null;
// We are at table instance.
GridH2Table tbl = (GridH2Table)upper.childFilters[filter].getTable();
@@ -462,10 +471,16 @@ public final class GridH2CollocationModel {
if (child == null && create && isChildTableOrView(i, null)) {
TableFilter f = childFilters[i];
- if (f.getTable().isView())
- child = buildCollocationModel(this, i, getSubQuery(f), null);
+ if (f.getTable().isView()) {
+ if (f.getIndex() == null) {
+ // If we don't have view index yet, then we just creating empty model and it must be filled later.
+ child = createChildModel(this, i, null, true);
+ }
+ else
+ child = buildCollocationModel(this, i, getSubQuery(f), null);
+ }
else
- child = createChildModel(this, i, null);
+ child = createChildModel(this, i, null, false);
assert child != null;
assert children[i] == child;
@@ -515,12 +530,14 @@ public final class GridH2CollocationModel {
cm = qctx.queryCollocationModel();
if (cm == null) {
- cm = createChildModel(null, -1, null);
+ cm = createChildModel(null, -1, null, true);
qctx.queryCollocationModel(cm);
}
}
+ assert cm.view;
+
Select select = filters[0].getSelect();
// Handle union. We have to rely on fact that select will be the same on uppermost select.
@@ -542,7 +559,7 @@ public final class GridH2CollocationModel {
// Nothing was found, need to create new child in union.
if (cm.select != select)
- cm = createChildModel(cm.upper, cm.filter, unions);
+ cm = createChildModel(cm.upper, cm.filter, unions, true);
}
cm.childFilters(filters);
@@ -591,7 +608,7 @@ public final class GridH2CollocationModel {
TableFilter[] filters = list.toArray(new TableFilter[list.size()]);
- GridH2CollocationModel cm = createChildModel(upper, filter, unions);
+ GridH2CollocationModel cm = createChildModel(upper, filter, unions, true);
cm.childFilters(filters);
@@ -601,7 +618,7 @@ public final class GridH2CollocationModel {
if (f.getTable().isView())
buildCollocationModel(cm, i, getSubQuery(f), null);
else if (f.getTable() instanceof GridH2Table)
- createChildModel(cm, i, null);
+ createChildModel(cm, i, null, false);
}
return upper != null ? upper : cm;