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


Java ISelectable.getColumnName方法代码示例

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


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

示例1: 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

示例2: getColumnMetaWithLogicTables

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
public static List<ColumnMeta> getColumnMetaWithLogicTables(List<ISelectable> columns) {
    List<ColumnMeta> _columns = new ArrayList<ColumnMeta>(columns.size());
    for (ISelectable c : columns) {
        ColumnMeta ic = new ColumnMeta(getLogicTableName(c.getTableName()),
            c.getColumnName(),
            c.getDataType(),
            c.getAlias(),
            true);
        _columns.add(ic);

        // if (ic.getDataType() == null)
        // throw new RuntimeException("fuck!");
    }
    return _columns;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:16,代码来源:ExecUtils.java

示例3: putRetColumnInMeta

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
void putRetColumnInMeta(ISelectable column, List<ColumnMeta> metaColumns) {
    String columnName;

    columnName = column.getColumnName();
    DataType type = null;

    // 函数在Map和Reduce过程中的返回类型可以不同
    // 如Avg,map过程返回String
    // reduce过程中返回数字类型
    if (this.isMerge()) {
        type = column.getDataType();
    } else {
        if (column instanceof IFunction) {

            if (((IFunction) column).getFunctionType().equals(FunctionType.Aggregate)) {
                type = ((AggregateFunction) ((IFunction) column).getExtraFunction()).getMapReturnType();
            } else {
                type = column.getDataType();
            }
        } else {
            type = column.getDataType();
        }
    }

    ColumnMeta cm = new ColumnMeta(ExecUtils.getLogicTableName(column.getTableName()),
        columnName,
        type,
        column.getAlias(),
        true);
    metaColumns.add(cm);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:32,代码来源:AggregateCursor.java

示例4: getSelectableFromChild

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
@Override
public ISelectable getSelectableFromChild(ISelectable c) {
    if (c instanceof IFunction) {
        return c;
    }

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

    QueryTreeNode left = this.getNode().getLeftNode();
    QueryTreeNode right = this.getNode().getRightNode();
    ISelectable resFromLeft = null;
    ISelectable resFromRight = null;
    boolean isLeft = left.hasColumn(c);
    boolean isRight = right.hasColumn(c);
    if (isLeft && isRight) {
        throw new IllegalArgumentException("Column '" + c.getColumnName() + "' is ambiguous in JoinNode");
    }

    if (isLeft) {// 可能在select/from中
        resFromLeft = this.getColumnFromOtherNode(c, left);
        if (resFromLeft == null) {// 如果不在select中,添加到select进行join传递
            left.addColumnsSelected(c.copy());
            resFromLeft = this.getColumnFromOtherNode(c, left);
        }
    }

    if (isRight) {// 可能在select/from中
        resFromRight = this.getColumnFromOtherNode(c, right);
        if (resFromRight == null) {// 如果不在select中,添加到select进行join传递
            right.addColumnsSelected(c.copy());
            resFromRight = this.getColumnFromOtherNode(c, right);
        }
    }

    return resFromLeft == null ? resFromRight : resFromLeft;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:39,代码来源:JoinNodeBuilder.java

示例5: build

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
@Override
public void build() {
    super.build();
    if (this.getDuplicateUpdateColumns() != null) {
        for (ISelectable s : this.getDuplicateUpdateColumns()) {
            ISelectable res = null;
            for (Object obj : table.getColumnsReferedForParent()) {
                ISelectable querySelected = (ISelectable) obj;
                if (s.isSameName(querySelected)) { // 尝试查找对应的字段信息
                    res = querySelected;
                    break;
                }
            }

            if (res == null) {
                throw new IllegalArgumentException("column: " + s.getColumnName() + " is not existed in "
                                                   + table.getName());
            }

            s.setTableName(res.getTableName());
            s.setDataType(res.getDataType());
            s.setAutoIncrement(res.isAutoIncrement());
        }

        convertTypeToSatifyColumnMeta(this.getDuplicateUpdateColumns(), this.getDuplicateUpdateValues());
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:28,代码来源:InsertNode.java

示例6: isSameName

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
@Override
public boolean isSameName(ISelectable select) {
    String cn1 = this.getColumnName();
    String cn2 = select.getColumnName();
    if (TStringUtil.isNotEmpty(select.getAlias())) {
        cn2 = select.getAlias();
    }

    return TStringUtil.equals(cn1, cn2);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:11,代码来源:Column.java

示例7: isSameName

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
@Override
public boolean isSameName(ISelectable select) {
    String cn1 = this.getColumnName();
    if (TStringUtil.isNotEmpty(this.getAlias())) {
        cn1 = this.getAlias();
    }

    String cn2 = select.getColumnName();
    if (TStringUtil.isNotEmpty(select.getAlias())) {
        cn2 = select.getAlias();
    }

    return TStringUtil.equals(cn1, cn2);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:15,代码来源:Function.java

示例8: getSelectableFromChild

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
public ISelectable getSelectableFromChild(ISelectable c) {
    if (c instanceof IFunction) {
        return c;
    }

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

    QueryTreeNode left = this.getNode().getLeftNode();
    QueryTreeNode right = this.getNode().getRightNode();
    ISelectable resFromLeft = null;
    ISelectable resFromRight = null;
    boolean isLeft = left.hasColumn(c);
    boolean isRight = right.hasColumn(c);
    if (isLeft && isRight) {
        throw new IllegalArgumentException("Column '" + c.getColumnName() + "' is ambiguous in JoinNode");
    }

    if (isLeft) {// 可能在select/from中
        resFromLeft = this.getColumnFromOtherNode(c, left);
        if (resFromLeft == null) {// 如果不在select中,添加到select进行join传递
            left.addColumnsSelected(c.copy());
            resFromLeft = this.getColumnFromOtherNode(c, left);
        }
    }

    if (isRight) {// 可能在select/from中
        resFromRight = this.getColumnFromOtherNode(c, right);
        if (resFromRight == null) {// 如果不在select中,添加到select进行join传递
            right.addColumnsSelected(c.copy());
            resFromRight = this.getColumnFromOtherNode(c, right);
        }
    }

    return resFromLeft == null ? resFromRight : resFromLeft;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:38,代码来源:JoinNodeBuilder.java

示例9: toDataNodeExecutor

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
@Override
public IDataNodeExecutor toDataNodeExecutor() throws QueryException {
    IUpdate update = ASTNodeFactory.getInstance().createUpdate();
    for (ISelectable updateColumn : this.getColumns()) {
        if (this.getNode().getTableMeta().getPrimaryIndex().getPartitionColumns().contains(updateColumn)) {
            throw new IllegalArgumentException("column :" + updateColumn.getColumnName() + " 是分库键,不允许修改");
        }

        if (this.getNode().getTableMeta().getPrimaryKeyMap().containsKey(updateColumn.getColumnName())) {
            throw new IllegalArgumentException("column :" + updateColumn.getColumnName() + " 是主键,不允许修改");
        }
    }

    update.setConsistent(true);
    update.executeOn(this.getNode().getDataNode());
    update.setQueryTree(this.getNode().toDataNodeExecutor());
    update.setUpdateColumns(this.getUpdateColumns());
    update.setUpdateValues(values);
    if (this.getNode().getActualTableName() != null) {
        update.setTableName(this.getNode().getActualTableName());
    } else if (this.getNode() instanceof KVIndexNode) {
        update.setTableName(((KVIndexNode) this.getNode()).getIndexName());
    } else {
        update.setTableName(this.getNode().getTableName());
    }
    update.setIndexName(this.getNode().getIndexUsed().getName());
    return update;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:29,代码来源:UpdateNode.java

示例10: 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

示例11: getColumnMetaTable

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

示例12: toDataNodeExecutor

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
@Override
public IPut toDataNodeExecutor(int shareIndex) {
    IInsert insert = ASTNodeFactory.getInstance().createInsert();
    if (this.getDuplicateUpdateColumns() != null) {
        List<String> partitionColumns = OptimizerContext.getContext()
            .getRule()
            .getSharedColumns(this.getNode().getTableMeta().getTableName());

        for (ISelectable updateColumn : this.getDuplicateUpdateColumns()) {
            if (partitionColumns.contains(updateColumn.getColumnName())) {
                throw new IllegalArgumentException("column :" + updateColumn.getColumnName()
                                                   + " is partition key , can't be modify");
            }

            if (this.getNode().getTableMeta().getPrimaryKeyMap().containsKey(updateColumn.getColumnName())) {
                throw new IllegalArgumentException("column :" + updateColumn.getColumnName()
                                                   + " is primary key , can't be modify");
            }
        }
    }

    if (this.getNode().getActualTableName() != null) {
        insert.setTableName(this.getNode().getActualTableName());
    } else if (this.getNode() instanceof KVIndexNode) {
        insert.setTableName(((KVIndexNode) this.getNode()).getIndexName());
    } else {
        insert.setTableName(this.getNode().getTableName());
    }
    insert.setIndexName((this.getNode()).getIndexUsed().getName());
    insert.setConsistent(true);
    insert.setUpdateColumns(this.getColumns());
    insert.setUpdateValues(this.getValues());
    if (this.getSelectNode() != null) {
        insert.setQueryTree((IQueryTree) this.getSelectNode().toDataNodeExecutor());
    }

    insert.setIgnore(this.isIgnore());
    insert.setQuick(this.isQuick());
    insert.setLowPriority(this.lowPriority);
    insert.setHighPriority(this.highPriority);
    insert.setDelayed(this.isDelayed());

    insert.setDuplicateUpdateColumns(this.getDuplicateUpdateColumns());
    insert.setDuplicateUpdateValues(this.getDuplicateUpdateValues());
    insert.setMultiValues(this.isMultiValues());
    insert.setMultiValues(this.getMultiValues());

    insert.executeOn(this.getNode().getDataNode());
    insert.setBatchIndexs(this.getBatchIndexs());
    insert.setExistSequenceVal(this.isExistSequenceVal());
    return insert;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:53,代码来源:InsertNode.java

示例13: toDataNodeExecutor

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
@Override
public IPut toDataNodeExecutor(int shareIndex) {
    IUpdate update = ASTNodeFactory.getInstance().createUpdate();
    for (ISelectable updateColumn : this.getColumns()) {
        List<String> partiionColumns = OptimizerContext.getContext()
            .getRule()
            .getSharedColumns(this.getNode().getTableMeta().getTableName());

        if (partiionColumns.contains(updateColumn.getColumnName())) {
            throw new IllegalArgumentException("column :" + updateColumn.getColumnName() + " 是分库键,不允许修改");
        }

        if (this.getNode().getTableMeta().getPrimaryKeyMap().containsKey(updateColumn.getColumnName())) {
            throw new IllegalArgumentException("column :" + updateColumn.getColumnName() + " 是主键,不允许修改");
        }
    }

    update.setConsistent(true);
    update.executeOn(this.getNode().getDataNode());
    update.setQueryTree((IQueryTree) this.getNode().toDataNodeExecutor());
    update.setUpdateColumns(this.getUpdateColumns());
    update.setUpdateValues(values);

    update.setIgnore(this.isIgnore());
    update.setQuick(this.isQuick());
    update.setLowPriority(this.lowPriority);
    update.setHighPriority(this.highPriority);
    update.setDelayed(this.isDelayed());

    if (this.getNode().getActualTableName() != null) {
        update.setTableName(this.getNode().getActualTableName());
    } else if (this.getNode() instanceof KVIndexNode) {
        update.setTableName(((KVIndexNode) this.getNode()).getIndexName());
    } else {
        update.setTableName(this.getNode().getTableName());
    }
    update.setIndexName(this.getNode().getIndexUsed().getName());
    update.setBatchIndexs(this.getBatchIndexs());
    update.setMultiValues(this.isMultiValues());
    update.setMultiValues(this.getMultiValues());
    update.setExistSequenceVal(this.isExistSequenceVal());
    return update;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:44,代码来源:UpdateNode.java

示例14: build

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
@Override
public void build() {
    if (this.table != null) {
        table.build();
    }

    if ((this.getColumns() == null || this.getColumns().isEmpty())
        && (this.getValues() == null || this.getValues().isEmpty())) {
        return;
    }

    if (columns == null || columns.isEmpty()) { // 如果字段为空,默认为所有的字段数据的,比如insert所有字段
        columns = OptimizerUtils.columnMetaListToIColumnList(this.getTableMeta().getAllColumns(),
            this.getTableMeta().getTableName());
    }

    if (columns.size() != values.size()) {
        if (!columns.isEmpty()) {
            throw new IllegalArgumentException("The size of the columns and values is not matched."
                                               + " columns' size is " + columns.size() + ". values' size is "
                                               + values.size());
        }

    }

    for (ISelectable s : this.getColumns()) {
        ISelectable res = null;
        for (Object obj : table.getColumnsReferedForParent()) {
            ISelectable querySelected = (ISelectable) obj;
            if (s.isSameName(querySelected)) { // 尝试查找对应的字段信息
                res = querySelected;
                break;
            }
        }

        if (res == null) {
            throw new IllegalArgumentException("column: " + s.getColumnName() + " is not existed in either "
                                               + table.getName() + " or select clause");
        }
    }

    convertTypeToSatifyColumnMeta(this.getColumns(), this.getValues());
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:44,代码来源:DMLNode.java


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