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

Save index condition masks into table filter.

上级 4574944c
...@@ -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;
} }
......
...@@ -87,6 +87,7 @@ public class TableFilter implements ColumnResolver { ...@@ -87,6 +87,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, this, sortOrder); item = table.getBestPlanItem(s, masks, this, 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
...@@ -267,7 +269,7 @@ public class TableFilter implements ColumnResolver { ...@@ -267,7 +269,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
*/ */
...@@ -278,6 +280,7 @@ public class TableFilter implements ColumnResolver { ...@@ -278,6 +280,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());
...@@ -796,6 +799,10 @@ public class TableFilter implements ColumnResolver { ...@@ -796,6 +799,10 @@ public class TableFilter implements ColumnResolver {
} }
} }
public int[] getMasks() {
return masks;
}
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论