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

Save index condition masks into table filter.

上级 4574944c
......@@ -18,10 +18,19 @@ public class PlanItem {
*/
double cost;
private int[] masks;
private Index index;
private PlanItem joinPlan;
private PlanItem nestedJoinPlan;
void setMasks(int[] masks) {
this.masks = masks;
}
int[] getMasks() {
return masks;
}
void setIndex(Index index) {
this.index = index;
}
......
......@@ -87,6 +87,7 @@ public class TableFilter implements ColumnResolver {
private final Select select;
private String alias;
private Index index;
private int[] masks;
private int scanCount;
private boolean evaluatable;
......@@ -225,6 +226,7 @@ public class TableFilter implements ColumnResolver {
sortOrder = select.getSortOrder();
}
item = table.getBestPlanItem(s, masks, this, sortOrder);
item.setMasks(masks);
// The more index conditions, the earlier the table.
// This is to ensure joins without indexes run quickly:
// x (x.a=10); y (x.b=y.b) - see issue 113
......@@ -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
*/
......@@ -278,6 +280,7 @@ public class TableFilter implements ColumnResolver {
return;
}
setIndex(item.getIndex());
masks = item.getMasks();
if (nestedJoin != null) {
if (item.getNestedJoinPlan() != null) {
nestedJoin.setPlanItem(item.getNestedJoinPlan());
......@@ -796,6 +799,10 @@ public class TableFilter implements ColumnResolver {
}
}
public int[] getMasks() {
return masks;
}
public Index getIndex() {
return index;
}
......
......@@ -1096,6 +1096,7 @@ public class TestTableEngines extends TestBase {
@Override
public IndexLookupBatch createLookupBatch(final TableFilter filter) {
assert filter.getMasks() != null || "scan".equals(getName());
final int preferedSize = preferedBatchSize;
return preferedSize == 0 ? null : new IndexLookupBatch() {
List<SearchRow> searchRows = New.arrayList();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论