当前位置: 首页>>代码示例>>Java>>正文


Java ISelectable.getTableName方法代码示例

本文整理汇总了Java中com.taobao.tddl.optimizer.core.expression.ISelectable.getTableName方法的典型用法代码示例。如果您正苦于以下问题:Java ISelectable.getTableName方法的具体用法?Java ISelectable.getTableName怎么用?Java ISelectable.getTableName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.taobao.tddl.optimizer.core.expression.ISelectable的用法示例。


在下文中一共展示了ISelectable.getTableName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSelectableFromChild

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
public ISelectable getSelectableFromChild(ISelectable c) {
    if (c.getTableName() != null) {
        if ((!c.getTableName().equals(this.getNode().getIndexName()))
            && (!c.getTableName().equals(this.getNode().getAlias()))) {
            return null;
        }
    }
    if (IColumn.STAR.equals(c.getColumnName())) {
        return c;
    }

    if (c instanceof IFunction) {
        c.setTableName(this.getNode().getIndexName());
        return c;
    }

    return this.getSelectableFromChild(c.getColumnName());
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:19,代码来源:KVIndexNodeBuilder.java

示例2: findOrderByInKey

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
private boolean findOrderByInKey(List<IOrderBy> orderBys, List<ColumnMeta> columns, ColumnMeta cm,
                                 Set<IOrderBy> hashOrderBys) {
    for (IOrderBy ob : orderBys) {
        ISelectable iSelectable = ob.getColumn();
        String orderByTable = iSelectable.getTableName();

        orderByTable = ExecUtils.getLogicTableName(orderByTable);

        if (cm != null && TStringUtil.equals(ExecUtils.getLogicTableName(cm.getTableName()), orderByTable)) {
            if (TStringUtil.equals(cm.getName(), iSelectable.getColumnName())) {
                ColumnMeta cm2 = new ColumnMeta(cm.getTableName(),
                    cm.getTableName() + "_ANDOR_TABLENAME_" + cm.getName(),
                    cm.getDataType(),
                    cm.getAlias(),
                    cm.isNullable());
                // 列名与order by Match.放到key里
                columns.add(cm2);
                hashOrderBys.add(ob);
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:25,代码来源:TempTableSortCursor.java

示例3: getSelectableFromChild

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
@Override
public ISelectable getSelectableFromChild(ISelectable c) {
    // 如果存在表名,则进行强校验,比如字段为A.ID,否则直接进行ID名字匹配
    if (c.getTableName() != null && !c.getTableName().equals(this.getNode().getTableName())
        && !c.getTableName().equals(this.getNode().getAlias())) {
        return null;
    }

    if (IColumn.STAR.equals(c.getColumnName())) {
        return c;
    }

    if (c instanceof IFunction) {
        c.setTableName(this.getNode().getTableName());
        return c;
    }

    if (SchemaManager.DUAL.equals(getNode().getTableName())) {
        throw new TddlRuntimeException(ErrorCode.ERR_PARSER, "can't not visit column in dual");
    }
    return this.getSelectableFromChild(c.getColumnName());
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:23,代码来源:TableNodeBuilder.java

示例4: findOrderByInKey

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
private boolean findOrderByInKey(List<IOrderBy> orderBys, List<ColumnMeta> columns, ColumnMeta cm,
                                 Set<IOrderBy> hashOrderBys) {
    for (IOrderBy ob : orderBys) {
        ISelectable iSelectable = ob.getColumn();
        String orderByTable = iSelectable.getTableName();

        orderByTable = ExecUtils.getLogicTableName(orderByTable);

        if (cm != null && TStringUtil.equals(ExecUtils.getLogicTableName(cm.getTableName()), orderByTable)) {
            if (TStringUtil.equals(cm.getName(), iSelectable.getColumnName())) {
                ColumnMeta cm2 = new ColumnMeta(cm.getTableName(),
                    cm.getTableName() + "." + cm.getName(),
                    cm.getDataType(),
                    cm.getAlias(),
                    cm.isNullable());
                // 列名与order by Match.放到key里
                columns.add(cm2);
                hashOrderBys.add(ob);
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:25,代码来源:TempTableSortCursor.java

示例5: getSelectableFromChild

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
public ISelectable getSelectableFromChild(ISelectable c) {
    // 如果存在表名,则进行强校验,比如字段为A.ID,否则直接进行ID名字匹配
    if (c.getTableName() != null && !c.getTableName().equals(this.getNode().getTableName())
        && !c.getTableName().equals(this.getNode().getAlias())) {
        return null;
    }

    if (IColumn.STAR.equals(c.getColumnName())) {
        return c;
    }

    if (c instanceof IFunction) {
        c.setTableName(this.getNode().getTableName());
        return c;
    }

    return this.getSelectableFromChild(c.getColumnName());
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:19,代码来源:TableNodeBuilder.java

示例6: getColumnMetas

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
public static List<ColumnMeta> getColumnMetas(List<ISelectable> columns) {
    List<ColumnMeta> _columns = new ArrayList<ColumnMeta>(columns.size());
    for (ISelectable c : columns) {
        ColumnMeta ic = new ColumnMeta(c.getTableName(), c.getColumnName(), c.getDataType(), c.getAlias(), true);
        _columns.add(ic);
    }
    return _columns;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:9,代码来源:ExecUtils.java

示例7: getReturnColumns

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
@Override
public List<ColumnMeta> getReturnColumns() throws TddlException {
    if (this.returnColumnMetas != null) {
        return this.returnColumnMetas;
    }
    returnColumnMetas = new ArrayList();
    for (ISelectable<ISelectable> cm : retColumns) {
        String tableName = tableAlias;
        if (tableName == null) {
            tableName = cm.getTableName();
        }
        returnColumnMetas.add(new ColumnMeta(tableName, cm.getColumnName(), cm.getDataType(), cm.getAlias(), true));
    }
    return returnColumnMetas;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:16,代码来源:ColumnAliasCursor.java

示例8: getColumnFromSelecteList

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
/**
 * 从select列表中查找
 */
private ISelectable getColumnFromSelecteList(ISelectable c) {
    ISelectable column = null;
    for (ISelectable selected : this.getNode().getColumnsSelected()) {
        boolean isThis = false;

        if (c.getTableName() != null && (!(node instanceof KVIndexNode))) {
            if (!c.getTableName().equals(selected.getTableName())) {
                continue;
            }
        }

        // 在当前select中查找,先比较column name,再比较alias name
        if (selected.getColumnName().equals(c.getColumnName())) {
            isThis = true;
        } else if (selected.getAlias() != null && selected.getAlias().equals(c.getColumnName())) {
            isThis = true;
        }

        if (isThis) {
            column = selected;
            return column;
        }
    }

    return column;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:30,代码来源:QueryTreeNodeBuilder.java

示例9: getColumnMeta

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
public static ColumnMeta getColumnMeta(Object o) {
    ISelectable c = (ISelectable) o;
    return new ColumnMeta(c.getTableName(), c.getColumnName(), c.getDataType(), c.getAlias(), true);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:5,代码来源:ExecUtils.java

示例10: initAliasSchema

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
private void initAliasSchema(List<ISelectable> retColumns, String tableAlias, ICursorMeta cursormeta)
                                                                                                     throws TddlException {
    if (schemaInited) {
        return;
    }
    colMessages = new ArrayList<ColumnMeta>(retColumns.size());
    List<Integer> indexes = new ArrayList<Integer>(colMessages.size());
    for (ISelectable col : retColumns) {
        ColumnMeta cm = null;
        String tableName = col.getTableName();
        if (tableAlias != null) {
            if (tableName == null || tableAlias.startsWith(tableName)) {
                // 如果以tableName作为开始,那么认为认为是相同名字,因此也做截断处理,取alias的.之前的数据。
                // 最好也让优化器协助,不允许在alias里面出现"."
                tableAlias = ExecUtils.getLogicTableName(tableAlias);
            }
        }
        if (!TStringUtil.isBlank(col.getAlias())) {
            if (TStringUtil.isBlank(tableAlias)) {
                cm = ExecUtils.getColumnMeta(col, col.getAlias());
            } else {
                cm = ExecUtils.getColumnMeta(col, tableAlias, col.getAlias());
            }
        } else {
            if (TStringUtil.isBlank(tableAlias)) {
                cm = ExecUtils.getColumnMeta(col);
            } else {
                cm = ExecUtils.getColumnMetaTable(col, tableAlias);
            }
        }
        Integer index = cursormeta.getIndex(col.getTableName(), col.getColumnName(), col.getAlias());

        if (index != null) {
            indexes.add(index);
            colMessages.add(cm);
        }
    }
    if (!TStringUtil.isBlank(tableAlias)) {
        // 如果没有就用下层的tableName
        newMeta = CursorMetaImp.buildNew(colMessages, indexes, cursormeta.getIndexRange());
        List<IOrderBy> obOld = getOrderBy();
        if (obOld != null) {
            List<IOrderBy> obNew = new ArrayList<IOrderBy>(obOld.size());
            for (IOrderBy orderBy : obOld) {
                IColumn icol = ExecUtils.getIColumn(orderBy.getColumn());
                IColumn icolNew = icol.copy();
                obNew.add(ASTNodeFactory.getInstance()
                    .createOrderBy()
                    .setColumn(icolNew.setTableName(tableAlias).setAlias(null))
                    .setDirection(orderBy.getDirection()));
            }
            setOrderBy(obNew);
        }
    } else {
        newMeta = CursorMetaImp.buildNew(colMessages, indexes, cursormeta.getIndexRange());
    }
    schemaInited = true;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:59,代码来源:ColumnAliasCursor.java

示例11: findColumnFromOtherNode

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
/**
 * 从select列表中查找字段
 */
protected ISelectable findColumnFromOtherNode(ISelectable c, QueryTreeNode other) {
    if (c == null) {
        return c;
    }

    if (c instanceof IBooleanFilter && ((IBooleanFilter) c).getOperation().equals(OPERATION.CONSTANT)) {
        return c;
    }

    ISelectable res = null;
    for (ISelectable selected : other.getColumnsSelected()) {
        boolean isThis = false;
        if (c.getTableName() != null) {
            boolean isSameName = c.getTableName().equals(other.getAlias())
                                 || c.getTableName().equals(selected.getTableName());
            if (other.isSubQuery() && other.getSubAlias() != null) {
                isSameName |= c.getTableName().equals(other.getSubAlias());
            }
            if (!isSameName) {
                continue;
            }
        }

        if (IColumn.STAR.equals(c.getColumnName())) {
            return c;
        }

        // 若列别名存在,只比较别名
        isThis = c.isSameName(selected);

        if (isThis) {
            if (res != null) {
                // 说明出现两个ID,需要明确指定TABLE
                throw new IllegalArgumentException("Column: '" + c.getFullName() + "' is ambiguous by exist ["
                                                   + selected.getFullName() + "," + res.getFullName() + "]");
            }
            res = selected;
        }
    }

    return res;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:46,代码来源:QueryTreeNodeBuilder.java

示例12: initAliasSchema

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
private void initAliasSchema(List<ISelectable> retColumns, String tableAlias, ICursorMeta cursormeta) {
    if (schemaInited) {
        return;
    }
    colMessages = new ArrayList<ColumnMeta>(retColumns.size());
    List<Integer> indexes = new ArrayList<Integer>(colMessages.size());
    for (ISelectable col : retColumns) {
        ColumnMeta cm = null;
        String tableName = col.getTableName();
        if (tableAlias != null) {
            if (tableName == null || tableAlias.startsWith(tableName)) {
                // 如果以tableName作为开始,那么认为认为是相同名字,因此也做截断处理,取alias的.之前的数据。
                // 最好也让优化器协助,不允许在alias里面出现"."
                tableAlias = ExecUtils.getLogicTableName(tableAlias);
            }
        }
        if (!TStringUtil.isBlank(col.getAlias())) {
            if (TStringUtil.isBlank(tableAlias)) {
                cm = ExecUtils.getColumnMeta(col, col.getAlias());
            } else {
                cm = ExecUtils.getColumnMeta(col, tableAlias, col.getAlias());
            }
        } else {
            if (TStringUtil.isBlank(tableAlias)) {
                cm = ExecUtils.getColumnMeta(col);
            } else {
                cm = ExecUtils.getColumnMetaTable(col, tableAlias);
            }
        }
        Integer index = cursormeta.getIndex(col.getTableName(), col.getColumnName());
        if (index == null) {
            index = cursormeta.getIndex(col.getTableName(), col.getAlias());
        }

        if (index != null) {
            indexes.add(index);
            colMessages.add(cm);
        }
    }
    if (!TStringUtil.isBlank(tableAlias)) {
        // 如果没有就用下层的tableName
        newMeta = CursorMetaImp.buildNew(colMessages, indexes, cursormeta.getIndexRange());
        List<IOrderBy> obOld = getOrderBy();
        if (obOld != null) {
            List<IOrderBy> obNew = new ArrayList<IOrderBy>(obOld.size());
            for (IOrderBy orderBy : obOld) {
                IColumn icol = ExecUtils.getIColumn(orderBy.getColumn());
                IColumn icolNew = icol.copy();
                obNew.add(ASTNodeFactory.getInstance()
                    .createOrderBy()
                    .setColumn(icolNew.setTableName(tableAlias).setAlias(null))
                    .setDirection(orderBy.getDirection()));
            }
            setOrderBy(obNew);
        }
    } else {
        newMeta = CursorMetaImp.buildNew(colMessages, indexes, cursormeta.getIndexRange());
    }
    schemaInited = true;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:61,代码来源:ColumnAliasCursor.java

示例13: findColumnFromOtherNode

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
/**
 * 从select列表中查找字段
 */
public ISelectable findColumnFromOtherNode(ISelectable c, QueryTreeNode other) {
    if (c == null) {
        return c;
    }

    if (c instanceof IBooleanFilter && ((IBooleanFilter) c).getOperation().equals(OPERATION.CONSTANT)) {
        return c;
    }

    ISelectable res = null;
    for (ISelectable selected : other.getColumnsSelected()) {
        boolean isThis = false;
        if (c.getTableName() != null) {
            boolean isSameName = c.getTableName().equals(other.getAlias())
                                 || c.getTableName().equals(selected.getTableName());
            if (other.isSubQuery() && other.getSubAlias() != null) {
                isSameName |= c.getTableName().equals(other.getSubAlias());
            }
            if (!isSameName) {
                continue;
            }
        }

        if (IColumn.STAR.equals(c.getColumnName())) {
            return c;
        }

        // 若列别名存在,只比较别名
        isThis = c.isSameName(selected);

        if (isThis) {
            if (res != null) {
                // 说明出现两个ID,需要明确指定TABLE
                throw new IllegalArgumentException("Column: '" + c.getFullName() + "' is ambiguous by exist ["
                                                   + selected.getFullName() + "," + res.getFullName() + "]");
            }
            res = selected;
        }
    }

    return res;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:46,代码来源:QueryTreeNodeBuilder.java


注:本文中的com.taobao.tddl.optimizer.core.expression.ISelectable.getTableName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。