提交 46842ae5 authored 作者: S.Vladykin's avatar S.Vladykin

merged from master

...@@ -347,6 +347,33 @@ public class IndexCondition { ...@@ -347,6 +347,33 @@ public class IndexCondition {
return column; return column;
} }
/**
* Get expression.
*
* @return Expression.
*/
public Expression getExpression() {
return expression;
}
/**
* Get expression list.
*
* @return Expression list.
*/
public List<Expression> getExpressionList() {
return expressionList;
}
/**
* Get expression query.
*
* @return Expression query.
*/
public Query getExpressionQuery() {
return expressionQuery;
}
/** /**
* Check if the expression can be evaluated. * Check if the expression can be evaluated.
* *
......
...@@ -18,10 +18,19 @@ public class PlanItem { ...@@ -18,10 +18,19 @@ public class PlanItem {
*/ */
double cost; double cost;
private int[] masks;
private Index index; private Index index;
private PlanItem joinPlan; private PlanItem joinPlan;
private PlanItem nestedJoinPlan; private PlanItem nestedJoinPlan;
void setMasks(int[] masks) {
this.masks = masks;
}
int[] getMasks() {
return masks;
}
void setIndex(Index index) { void setIndex(Index index) {
this.index = index; this.index = index;
} }
......
...@@ -86,6 +86,7 @@ public class TableFilter implements ColumnResolver { ...@@ -86,6 +86,7 @@ public class TableFilter implements ColumnResolver {
private final Select select; private final Select select;
private String alias; private String alias;
private Index index; private Index index;
private int[] masks;
private int scanCount; private int scanCount;
private boolean evaluatable; private boolean evaluatable;
...@@ -225,6 +226,7 @@ public class TableFilter implements ColumnResolver { ...@@ -225,6 +226,7 @@ public class TableFilter implements ColumnResolver {
sortOrder = select.getSortOrder(); sortOrder = select.getSortOrder();
} }
item = table.getBestPlanItem(s, masks, filters, filter, sortOrder); item = table.getBestPlanItem(s, masks, filters, filter, sortOrder);
item.setMasks(masks);
// The more index conditions, the earlier the table. // The more index conditions, the earlier the table.
// This is to ensure joins without indexes run quickly: // This is to ensure joins without indexes run quickly:
// x (x.a=10); y (x.b=y.b) - see issue 113 // x (x.a=10); y (x.b=y.b) - see issue 113
...@@ -269,7 +271,7 @@ public class TableFilter implements ColumnResolver { ...@@ -269,7 +271,7 @@ public class TableFilter implements ColumnResolver {
} }
/** /**
* Set what plan item (index, cost) to use use. * Set what plan item (index, cost, masks) to use.
* *
* @param item the plan item * @param item the plan item
*/ */
...@@ -280,6 +282,7 @@ public class TableFilter implements ColumnResolver { ...@@ -280,6 +282,7 @@ public class TableFilter implements ColumnResolver {
return; return;
} }
setIndex(item.getIndex()); setIndex(item.getIndex());
masks = item.getMasks();
if (nestedJoin != null) { if (nestedJoin != null) {
if (item.getNestedJoinPlan() != null) { if (item.getNestedJoinPlan() != null) {
nestedJoin.setPlanItem(item.getNestedJoinPlan()); nestedJoin.setPlanItem(item.getNestedJoinPlan());
...@@ -798,6 +801,14 @@ public class TableFilter implements ColumnResolver { ...@@ -798,6 +801,14 @@ public class TableFilter implements ColumnResolver {
} }
} }
public int[] getMasks() {
return masks;
}
public ArrayList<IndexCondition> getIndexConditions() {
return indexConditions;
}
public Index getIndex() { public Index getIndex() {
return index; return index;
} }
......
...@@ -1096,6 +1096,7 @@ public class TestTableEngines extends TestBase { ...@@ -1096,6 +1096,7 @@ public class TestTableEngines extends TestBase {
@Override @Override
public IndexLookupBatch createLookupBatch(final TableFilter filter) { public IndexLookupBatch createLookupBatch(final TableFilter filter) {
assert filter.getMasks() != null || "scan".equals(getName());
final int preferedSize = preferedBatchSize; final int preferedSize = preferedBatchSize;
return preferedSize == 0 ? null : new IndexLookupBatch() { return preferedSize == 0 ? null : new IndexLookupBatch() {
List<SearchRow> searchRows = New.arrayList(); List<SearchRow> searchRows = New.arrayList();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论