private boolean testPlan(TableFilter[] list) { Plan p = new Plan(list, list.length, condition); double costNow = p.calculateCost(session); if (cost < 0 || costNow < cost) { cost = costNow; bestPlan = p; return true; } return false; }
public void setDataType(Column col) { dataType = col.getType(); precision = col.getPrecision(); displaySize = col.getDisplaySize(); scale = col.getScale(); }
protected static TableMate getTableMate(TableFilter filter) { if (filter.isFromTableMate()) { return (TableMate) filter.getTable(); } throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, filter.getTable().getName()); }
/** * Create a new range with the given start and end expressions. * * @param schema the schema (always the main schema) * @param min the start expression * @param max the end expression * @param noColumns whether this table has no columns */ public RangeTable(Schema schema, Expression min, Expression max, boolean noColumns) { super(schema, NAME); Column[] cols = noColumns ? new Column[0] : new Column[] { new Column("X", Value.LONG) }; this.min = min; this.max = max; setColumns(cols); }
@Override public String getSQL() { if (isTemporary()) { return "(\n" + StringUtils.indent(querySQL) + ")"; } return super.getSQL(); }
@Override public PlanItem getBestPlanItem(Session session, int[] masks, TableFilter filter) { PlanItem item = new PlanItem(); Query q = getCachedQuery(session, masks); item.cost = q.getCost(); return item; }
public int getColumnIndex(Column col) { for (int i = 0, len = columns.length; i < len; i++) { if (columns[i].equals(col)) { return i; } } return -1; }
public TableView(Schema schema, int id, String name, String querySQL, ArrayList<Parameter> params, String[] columnNames, Session session, boolean recursive) { super(schema, name); init(querySQL, params, columnNames, session, recursive); }
public void setFullCondition(Expression condition) { this.fullCondition = condition; if (join != null) { join.setFullCondition(condition); } }
/** * Remove a sequence from the table. Sequences are used as identity columns. * * @param sequence the sequence to remove */ public final void removeSequence(Sequence sequence) { remove(sequences, sequence); }
@Override public void setEvaluatable(TableFilter tableFilter, boolean b) { if (columnResolver != null && tableFilter == columnResolver.getTableFilter()) { evaluatable = b; } }
private synchronized void init(String querySQL, ArrayList<Parameter> params, String[] columnNames, Session session, boolean recursive) { this.querySQL = querySQL; this.columnNames = columnNames; this.recursive = recursive; initColumnsAndTables(session); }
@Override public void accept(TableFilter f) { f.setNullRow(); } });
/** * @return the shardingColumns */ public Column[] getRuleColumns() { check(); return ruleColumns; }
/** * Add a sequence to this table. * * @param sequence the sequence to add */ public void addSequence(Sequence sequence) { sequences = add(sequences, sequence); }
/** * Map the columns using the column names and the specified table. * * @param indexColumns the column list with column names set * @param table the table from where to map the column names to columns */ public static void mapColumns(IndexColumn[] indexColumns, Table table) { for (IndexColumn col : indexColumns) { col.column = table.getColumn(col.columnName); } }
/** * Get the table alias name. If no alias is specified, the table name is * returned. * * @return the alias name */ @Override public String getTableAlias() { if (alias != null) { return alias; } return table.getName(); }