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

All joined table filters are passed into Index.getCost

上级 4574944c
...@@ -130,7 +130,7 @@ public class Delete extends Prepared { ...@@ -130,7 +130,7 @@ public class Delete extends Prepared {
condition = condition.optimize(session); condition = condition.optimize(session);
condition.createIndexConditions(session, tableFilter); condition.createIndexConditions(session, tableFilter);
} }
PlanItem item = tableFilter.getBestPlanItem(session, 1); PlanItem item = tableFilter.getBestPlanItem(session, new TableFilter[]{tableFilter}, 0);
tableFilter.setPlanItem(item); tableFilter.setPlanItem(item);
tableFilter.prepare(); tableFilter.prepare();
} }
......
...@@ -389,7 +389,7 @@ public class ScriptCommand extends ScriptBase { ...@@ -389,7 +389,7 @@ public class ScriptCommand extends ScriptBase {
} }
private int generateInsertValues(int count, Table table) throws IOException { private int generateInsertValues(int count, Table table) throws IOException {
PlanItem plan = table.getBestPlanItem(session, null, null, null); PlanItem plan = table.getBestPlanItem(session, null, null, -1, null);
Index index = plan.getIndex(); Index index = plan.getIndex();
Cursor cursor = index.find(session, null, null); Cursor cursor = index.find(session, null, null);
Column[] columns = table.getColumns(); Column[] columns = table.getColumns();
......
...@@ -187,7 +187,7 @@ public class Update extends Prepared { ...@@ -187,7 +187,7 @@ public class Update extends Prepared {
e.mapColumns(tableFilter, 0); e.mapColumns(tableFilter, 0);
expressionMap.put(c, e.optimize(session)); expressionMap.put(c, e.optimize(session));
} }
PlanItem item = tableFilter.getBestPlanItem(session, 1); PlanItem item = tableFilter.getBestPlanItem(session, new TableFilter[] {tableFilter}, 0);
tableFilter.setPlanItem(item); tableFilter.setPlanItem(item);
tableFilter.prepare(); tableFilter.prepare();
} }
......
...@@ -52,8 +52,8 @@ public class FunctionIndex extends BaseIndex { ...@@ -52,8 +52,8 @@ public class FunctionIndex extends BaseIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
if (masks != null) { if (masks != null) {
throw DbException.getUnsupportedException("ALIAS"); throw DbException.getUnsupportedException("ALIAS");
} }
......
...@@ -113,8 +113,8 @@ public class HashIndex extends BaseIndex { ...@@ -113,8 +113,8 @@ public class HashIndex extends BaseIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
for (Column column : columns) { for (Column column : columns) {
int index = column.getColumnId(); int index = column.getColumnId();
int mask = masks[index]; int mask = masks[index];
......
...@@ -83,11 +83,12 @@ public interface Index extends SchemaObject { ...@@ -83,11 +83,12 @@ public interface Index extends SchemaObject {
* @param session the session * @param session the session
* @param masks per-column comparison bit masks, null means 'always false', * @param masks per-column comparison bit masks, null means 'always false',
* see constants in IndexCondition * see constants in IndexCondition
* @param filter the table filter * @param filters all joined table filters
* @param filter the current table filter index
* @param sortOrder the sort order * @param sortOrder the sort order
* @return the estimated cost * @return the estimated cost
*/ */
double getCost(Session session, int[] masks, TableFilter filter, double getCost(Session session, int[] masks, TableFilter[] filters, int filter,
SortOrder sortOrder); SortOrder sortOrder);
/** /**
......
...@@ -141,10 +141,10 @@ public class LinkedIndex extends BaseIndex { ...@@ -141,10 +141,10 @@ public class LinkedIndex extends BaseIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
return 100 + getCostRangeIndex(masks, rowCount + return 100 + getCostRangeIndex(masks, rowCount +
Constants.COST_ROW_OFFSET, filter, sortOrder); Constants.COST_ROW_OFFSET, filters == null ? null : filters[filter], sortOrder);
} }
@Override @Override
......
...@@ -52,13 +52,13 @@ public class MetaIndex extends BaseIndex { ...@@ -52,13 +52,13 @@ public class MetaIndex extends BaseIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
if (scan) { if (scan) {
return 10 * MetaTable.ROW_COUNT_APPROXIMATION; return 10 * MetaTable.ROW_COUNT_APPROXIMATION;
} }
return getCostRangeIndex(masks, MetaTable.ROW_COUNT_APPROXIMATION, return getCostRangeIndex(masks, MetaTable.ROW_COUNT_APPROXIMATION,
filter, sortOrder); filters == null ? null : filters[filter], sortOrder);
} }
@Override @Override
......
...@@ -142,9 +142,9 @@ public class MultiVersionIndex implements Index { ...@@ -142,9 +142,9 @@ public class MultiVersionIndex implements Index {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
return base.getCost(session, masks, filter, sortOrder); return base.getCost(session, masks, filters, filter, sortOrder);
} }
@Override @Override
......
...@@ -130,8 +130,8 @@ public class NonUniqueHashIndex extends BaseIndex { ...@@ -130,8 +130,8 @@ public class NonUniqueHashIndex extends BaseIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
for (Column column : columns) { for (Column column : columns) {
int index = column.getColumnId(); int index = column.getColumnId();
int mask = masks[index]; int mask = masks[index];
......
...@@ -217,10 +217,10 @@ public class PageBtreeIndex extends PageIndex { ...@@ -217,10 +217,10 @@ public class PageBtreeIndex extends PageIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
return 10 * getCostRangeIndex(masks, tableData.getRowCount(session), return 10 * getCostRangeIndex(masks, tableData.getRowCount(session),
filter, sortOrder); filters == null ? null : filters[filter], sortOrder);
} }
@Override @Override
......
...@@ -10,7 +10,6 @@ import java.util.HashMap; ...@@ -10,7 +10,6 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.Session; import org.h2.engine.Session;
...@@ -310,8 +309,8 @@ public class PageDataIndex extends PageIndex { ...@@ -310,8 +309,8 @@ public class PageDataIndex extends PageIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
long cost = 10 * (tableData.getRowCountApproximation() + long cost = 10 * (tableData.getRowCountApproximation() +
Constants.COST_ROW_OFFSET); Constants.COST_ROW_OFFSET);
return cost; return cost;
......
...@@ -96,10 +96,10 @@ public class PageDelegateIndex extends PageIndex { ...@@ -96,10 +96,10 @@ public class PageDelegateIndex extends PageIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
return 10 * getCostRangeIndex(masks, mainIndex.getRowCount(session), return 10 * getCostRangeIndex(masks, mainIndex.getRowCount(session),
filter, sortOrder); filters == null ? null : filters[filter], sortOrder);
} }
@Override @Override
......
...@@ -62,8 +62,8 @@ public class RangeIndex extends BaseIndex { ...@@ -62,8 +62,8 @@ public class RangeIndex extends BaseIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
return 1; return 1;
} }
......
...@@ -174,8 +174,8 @@ public class ScanIndex extends BaseIndex { ...@@ -174,8 +174,8 @@ public class ScanIndex extends BaseIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
return tableData.getRowCountApproximation() + Constants.COST_ROW_OFFSET; return tableData.getRowCountApproximation() + Constants.COST_ROW_OFFSET;
} }
......
...@@ -208,10 +208,10 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex { ...@@ -208,10 +208,10 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
return getCostRangeIndex(masks, table.getRowCountApproximation(), return getCostRangeIndex(masks, table.getRowCountApproximation(),
filter, sortOrder); filters == null ? null : filters[filter], sortOrder);
} }
@Override @Override
......
...@@ -318,10 +318,10 @@ public class TreeIndex extends BaseIndex { ...@@ -318,10 +318,10 @@ public class TreeIndex extends BaseIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks, TableFilter[] filters, int filter,
SortOrder sortOrder) { SortOrder sortOrder) {
return getCostRangeIndex(masks, tableData.getRowCountApproximation(), return getCostRangeIndex(masks, tableData.getRowCountApproximation(),
filter, sortOrder); filters == null ? null : filters[filter], sortOrder);
} }
@Override @Override
......
...@@ -115,7 +115,7 @@ public class ViewIndex extends BaseIndex implements SpatialIndex { ...@@ -115,7 +115,7 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
@Override @Override
public synchronized double getCost(Session session, int[] masks, public synchronized double getCost(Session session, int[] masks,
TableFilter filter, SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
if (recursive) { if (recursive) {
return 1000; return 1000;
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
package org.h2.mvstore.db; package org.h2.mvstore.db;
import java.util.List; import java.util.List;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.index.BaseIndex; import org.h2.index.BaseIndex;
import org.h2.index.Cursor; import org.h2.index.Cursor;
...@@ -89,10 +88,10 @@ public class MVDelegateIndex extends BaseIndex implements MVIndex { ...@@ -89,10 +88,10 @@ public class MVDelegateIndex extends BaseIndex implements MVIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
return 10 * getCostRangeIndex(masks, return 10 * getCostRangeIndex(masks, mainIndex.getRowCountApproximation(),
mainIndex.getRowCountApproximation(), filter, sortOrder); filters == null ? null : filters[filter], sortOrder);
} }
@Override @Override
......
...@@ -10,7 +10,6 @@ import java.util.Collections; ...@@ -10,7 +10,6 @@ import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.Database; import org.h2.engine.Database;
...@@ -217,8 +216,8 @@ public class MVPrimaryIndex extends BaseIndex { ...@@ -217,8 +216,8 @@ public class MVPrimaryIndex extends BaseIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
try { try {
long cost = 10 * (dataMap.sizeAsLongMax() + Constants.COST_ROW_OFFSET); long cost = 10 * (dataMap.sizeAsLongMax() + Constants.COST_ROW_OFFSET);
return cost; return cost;
......
...@@ -10,7 +10,6 @@ import java.util.Collections; ...@@ -10,7 +10,6 @@ import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.TreeSet; import java.util.TreeSet;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
...@@ -352,11 +351,11 @@ public class MVSecondaryIndex extends BaseIndex implements MVIndex { ...@@ -352,11 +351,11 @@ public class MVSecondaryIndex extends BaseIndex implements MVIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
try { try {
return 10 * getCostRangeIndex(masks, return 10 * getCostRangeIndex(masks, dataMap.sizeAsLongMax(),
dataMap.sizeAsLongMax(), filter, sortOrder); filters == null ? null : filters[filter], sortOrder);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
throw DbException.get(ErrorCode.OBJECT_CLOSED, e); throw DbException.get(ErrorCode.OBJECT_CLOSED, e);
} }
......
...@@ -7,7 +7,6 @@ package org.h2.mvstore.db; ...@@ -7,7 +7,6 @@ package org.h2.mvstore.db;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
...@@ -33,7 +32,6 @@ import org.h2.value.Value; ...@@ -33,7 +32,6 @@ import org.h2.value.Value;
import org.h2.value.ValueGeometry; import org.h2.value.ValueGeometry;
import org.h2.value.ValueLong; import org.h2.value.ValueLong;
import org.h2.value.ValueNull; import org.h2.value.ValueNull;
import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
...@@ -239,10 +237,10 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex { ...@@ -239,10 +237,10 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
return getCostRangeIndex(masks, table.getRowCountApproximation(), return getCostRangeIndex(masks, table.getRowCountApproximation(),
filter, sortOrder); filters == null ? null : filters[filter], sortOrder);
} }
@Override @Override
......
...@@ -106,9 +106,9 @@ public class Plan { ...@@ -106,9 +106,9 @@ public class Plan {
public double calculateCost(Session session) { public double calculateCost(Session session) {
double cost = 1; double cost = 1;
boolean invalidPlan = false; boolean invalidPlan = false;
int level = 1; for (int i = 0; i < allFilters.length; i++) {
for (TableFilter tableFilter : allFilters) { TableFilter tableFilter = allFilters[i];
PlanItem item = tableFilter.getBestPlanItem(session, level++); PlanItem item = tableFilter.getBestPlanItem(session, allFilters, i);
planItems.put(tableFilter, item); planItems.put(tableFilter, item);
cost += cost * item.cost; cost += cost * item.cost;
setEvaluatable(tableFilter, true); setEvaluatable(tableFilter, true);
......
...@@ -678,20 +678,21 @@ public abstract class Table extends SchemaObjectBase { ...@@ -678,20 +678,21 @@ public abstract class Table extends SchemaObjectBase {
* @param session the session * @param session the session
* @param masks per-column comparison bit masks, null means 'always false', * @param masks per-column comparison bit masks, null means 'always false',
* see constants in IndexCondition * see constants in IndexCondition
* @param filter the table filter * @param filters all joined table filters
* @param filter the current table filter index
* @param sortOrder the sort order * @param sortOrder the sort order
* @return the plan item * @return the plan item
*/ */
public PlanItem getBestPlanItem(Session session, int[] masks, public PlanItem getBestPlanItem(Session session, int[] masks,
TableFilter filter, SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
PlanItem item = new PlanItem(); PlanItem item = new PlanItem();
item.setIndex(getScanIndex(session)); item.setIndex(getScanIndex(session));
item.cost = item.getIndex().getCost(session, null, null, null); item.cost = item.getIndex().getCost(session, null, filters, filter, null);
ArrayList<Index> indexes = getIndexes(); ArrayList<Index> indexes = getIndexes();
if (indexes != null && masks != null) { if (indexes != null && masks != null) {
for (int i = 1, size = indexes.size(); i < size; i++) { for (int i = 1, size = indexes.size(); i < size; i++) {
Index index = indexes.get(i); Index index = indexes.get(i);
double cost = index.getCost(session, masks, filter, sortOrder); double cost = index.getCost(session, masks, filters, filter, sortOrder);
if (cost < item.cost) { if (cost < item.cost) {
item.cost = cost; item.cost = cost;
item.setIndex(index); item.setIndex(index);
......
...@@ -10,7 +10,6 @@ import java.util.ArrayList; ...@@ -10,7 +10,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.ListIterator;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import org.h2.command.Parser; import org.h2.command.Parser;
import org.h2.command.dml.Select; import org.h2.command.dml.Select;
...@@ -196,15 +195,16 @@ public class TableFilter implements ColumnResolver { ...@@ -196,15 +195,16 @@ public class TableFilter implements ColumnResolver {
* order. * order.
* *
* @param s the session * @param s the session
* @param level 1 for the first table in a join, 2 for the second, and so on * @param filters all joined table filters
* @param filter the current table filter index
* @return the best plan item * @return the best plan item
*/ */
public PlanItem getBestPlanItem(Session s, int level) { public PlanItem getBestPlanItem(Session s, TableFilter[] filters, int filter) {
PlanItem item; PlanItem item;
if (indexConditions.size() == 0) { if (indexConditions.size() == 0) {
item = new PlanItem(); item = new PlanItem();
item.setIndex(table.getScanIndex(s)); item.setIndex(table.getScanIndex(s));
item.cost = item.getIndex().getCost(s, null, null, null); item.cost = item.getIndex().getCost(s, null, filters, filter, null);
} else { } else {
int len = table.getColumns().length; int len = table.getColumns().length;
int[] masks = new int[len]; int[] masks = new int[len];
...@@ -224,22 +224,24 @@ public class TableFilter implements ColumnResolver { ...@@ -224,22 +224,24 @@ public class TableFilter implements ColumnResolver {
if (select != null) { if (select != null) {
sortOrder = select.getSortOrder(); sortOrder = select.getSortOrder();
} }
item = table.getBestPlanItem(s, masks, this, sortOrder); item = table.getBestPlanItem(s, masks, filters, filter, sortOrder);
// 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
item.cost -= item.cost * indexConditions.size() / 100 / level; item.cost -= item.cost * indexConditions.size() / 100 / (filter + 1);
} }
if (nestedJoin != null) { if (nestedJoin != null) {
setEvaluatable(nestedJoin); setEvaluatable(nestedJoin);
item.setNestedJoinPlan(nestedJoin.getBestPlanItem(s, level)); item.setNestedJoinPlan(nestedJoin.getBestPlanItem(s, filters, filter));
// TODO optimizer: calculate cost of a join: should use separate // TODO optimizer: calculate cost of a join: should use separate
// expected row number and lookup cost // expected row number and lookup cost
item.cost += item.cost * item.getNestedJoinPlan().cost; item.cost += item.cost * item.getNestedJoinPlan().cost;
} }
if (join != null) { if (join != null) {
setEvaluatable(join); setEvaluatable(join);
item.setJoinPlan(join.getBestPlanItem(s, level)); filter += nestedJoin == null ? 1 : 2;
assert filters[filter] == join;
item.setJoinPlan(join.getBestPlanItem(s, filters, filter));
// TODO optimizer: calculate cost of a join: should use separate // TODO optimizer: calculate cost of a join: should use separate
// expected row number and lookup cost // expected row number and lookup cost
item.cost += item.cost * item.getJoinPlan().cost; item.cost += item.cost * item.getJoinPlan().cost;
......
...@@ -225,9 +225,9 @@ public class TableView extends Table { ...@@ -225,9 +225,9 @@ public class TableView extends Table {
@Override @Override
public PlanItem getBestPlanItem(Session session, int[] masks, public PlanItem getBestPlanItem(Session session, int[] masks,
TableFilter filter, SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
PlanItem item = new PlanItem(); PlanItem item = new PlanItem();
item.cost = index.getCost(session, masks, filter, sortOrder); item.cost = index.getCost(session, masks, filters, filter, sortOrder);
final CacheKey cacheKey = new CacheKey(masks, session); final CacheKey cacheKey = new CacheKey(masks, session);
synchronized (this) { synchronized (this) {
...@@ -434,7 +434,7 @@ public class TableView extends Table { ...@@ -434,7 +434,7 @@ public class TableView extends Table {
throw DbException.get(ErrorCode.VIEW_IS_INVALID_2, throw DbException.get(ErrorCode.VIEW_IS_INVALID_2,
createException, getSQL(), msg); createException, getSQL(), msg);
} }
PlanItem item = getBestPlanItem(session, null, null, null); PlanItem item = getBestPlanItem(session, null, null, -1, null);
return item.getIndex(); return item.getIndex();
} }
......
...@@ -660,7 +660,7 @@ public class TestTableEngines extends TestBase { ...@@ -660,7 +660,7 @@ public class TestTableEngines extends TestBase {
@Override @Override
public double getCost(Session session, int[] masks, public double getCost(Session session, int[] masks,
TableFilter filter, SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
return 0; return 0;
} }
...@@ -914,8 +914,8 @@ public class TestTableEngines extends TestBase { ...@@ -914,8 +914,8 @@ public class TestTableEngines extends TestBase {
TreeSetIndex scan = new TreeSetIndex(this, "scan", TreeSetIndex scan = new TreeSetIndex(this, "scan",
IndexColumn.wrap(getColumns()), IndexType.createScan(false)) { IndexColumn.wrap(getColumns()), IndexType.createScan(false)) {
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
return getRowCount(session) + Constants.COST_ROW_OFFSET; return getRowCount(session) + Constants.COST_ROW_OFFSET;
} }
}; };
...@@ -1204,9 +1204,10 @@ public class TestTableEngines extends TestBase { ...@@ -1204,9 +1204,10 @@ public class TestTableEngines extends TestBase {
} }
@Override @Override
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks,
SortOrder sortOrder) { TableFilter[] filters, int filter, SortOrder sortOrder) {
return getCostRangeIndex(masks, set.size(), filter, sortOrder); return getCostRangeIndex(masks, set.size(), filters == null ?
null : filters[filter], sortOrder);
} }
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论