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


Java ISelectable类代码示例

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


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

示例1: replaceAliasInFilter

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入依赖的package包/类
private void replaceAliasInFilter(Object filter, String alias) {
    if (filter instanceof IFunction) {
        for (Object sub : ((IFunction) filter).getArgs()) {
            this.replaceAliasInFilter(sub, alias);
        }
    }

    if (filter instanceof ISelectable) {
        if (alias != null) {
            ((ISelectable) filter).setTableName(alias);
        }

        if (((ISelectable) filter).getAlias() != null) {
            ((ISelectable) filter).setColumnName(((ISelectable) filter).getAlias());
            ((ISelectable) filter).setAlias(null);
        }
    }

}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:20,代码来源:MergeNodeBuilder.java

示例2: buildColumnRefered

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入依赖的package包/类
private void buildColumnRefered() {
    List<ISelectable> columnRefered = new ArrayList();
    columnRefered.addAll(this.getNode().getColumnsSelected());

    for (IBooleanFilter f : this.getNode().getJoinFilter()) {
        ISelectable left = (ISelectable) f.getColumn();
        ISelectable right = (ISelectable) f.getValue();

        if (!columnRefered.contains(left)) {
            columnRefered.add(left);
        }

        if (!columnRefered.contains(right)) {
            columnRefered.add(right);
        }
    }

    for (IColumn c : this.columnInAggregate) {
        if (!columnRefered.contains(c)) {
            columnRefered.add(c);
        }
    }

    this.getNode().setColumnsRefered(columnRefered);
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:26,代码来源:JoinNodeBuilder.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: executeAgg

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入依赖的package包/类
protected ISchematicCursor executeAgg(ISchematicCursor cursor, IDataNodeExecutor executor,
                                      boolean closeResultCursor, IRepository repo, List<IFunction> aggregates,
                                      List<IOrderBy> groupBycols, ExecutionContext executionContext)
                                                                                                    throws TddlException {
    List<ISelectable> _retColumns = null;
    if (executor instanceof IQuery) {
        _retColumns = ((IQuery) executor).getColumns();
    } else if (executor instanceof IJoin) {
        _retColumns = ((IJoin) executor).getColumns();
    } else if (executor instanceof IMerge) {
        _retColumns = ((IMerge) executor).getColumns();
    }

    if (_retColumns != null) {
        if ((aggregates != null && !aggregates.isEmpty()) || (groupBycols != null && !groupBycols.isEmpty())) {
            cursor = repo.getCursorFactory().aggregateCursor(executionContext,
                cursor,
                aggregates,
                groupBycols,
                _retColumns,
                false);
        }
    }
    return cursor;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:26,代码来源:QueryHandlerCommon.java

示例5: initSchema

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入依赖的package包/类
private void initSchema(IRowSet firstRowSet, IFilter lf) {
    if (schemaInited) {
        return;
    }
    schemaInited = true;

    List<ColumnMeta> columnMetas = to.getParentCursorMeta().getColumns();
    List<ISelectable> iColumns = ExecUtils.getIColumnsWithISelectable(columnMetas.toArray(new ColumnMeta[0]));
    toComparator = ExecUtils.getComp(iColumns,
        iColumns,
        to.getParentCursorMeta(),
        firstRowSet.getParentCursorMeta());
    fromComparator = ExecUtils.getComp(iColumns,
        iColumns,
        from.getParentCursorMeta(),
        firstRowSet.getParentCursorMeta());
    // init(rangeFilters);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:19,代码来源:RangeCursor.java

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

示例7: copySelectables

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入依赖的package包/类
public static List<ISelectable> copySelectables(List<ISelectable> selects, String oldTableName, String tableName) {
    if (tableName == null) {
        return copySelectables(selects);
    }

    if (selects == null) {
        return null;
    }

    List<ISelectable> news = new ArrayList(selects.size());
    for (ISelectable s : selects) {
        ISelectable a = s.copy();
        if (a instanceof IColumn) {
            setColumn((IColumn) a, oldTableName, tableName);
        } else if (a instanceof IFilter) {
            setFilter((IFilter) a, oldTableName, tableName);
        } else if (a instanceof IFunction) {
            setFunction((IFunction) a, oldTableName, tableName);
        }

        news.add(a);
    }

    return news;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:26,代码来源:OptimizerUtils.java

示例8: getReturnType

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入依赖的package包/类
@Override
public DataType getReturnType() {
    Object[] args = function.getArgs().toArray();
    DataType type = null;
    if (args[0] instanceof ISelectable) {
        type = ((ISelectable) args[0]).getDataType();
    }
    if (type == null) {
        type = DataTypeUtil.getTypeOfObject(args[0]);
    }

    if (type == DataType.BigIntegerType || type == DataType.BigDecimalType) {
        return DataType.BigIntegerType;
    } else {
        return DataType.LongType;
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:18,代码来源:BitXor.java

示例9: visit

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入依赖的package包/类
@Override
public void visit(FunctionExpression node) {
    boolean argDistinct = isDistinct(node);
    IFunction ifunc = ASTNodeFactory.getInstance().createFunction();
    ifunc.setFunctionName(node.getFunctionName());
    List<Expression> expressions = node.getArguments();

    if (expressions != null) {
        ArrayList<Object> args = new ArrayList<Object>();
        for (Expression expr : expressions) {
            MySqlExprVisitor v = new MySqlExprVisitor(parent);
            expr.accept(v);
            Object cv = v.getColumnOrValue();
            if ((cv instanceof ISelectable)) {
                ((ISelectable) cv).setDistinct(argDistinct);
            }
            args.add(v.getColumnOrValue());
        }
        ifunc.setArgs(args);
    } else {
        ifunc.setArgs(new ArrayList());
    }

    ifunc.setColumnName(getSqlExprStr(node));
    columnOrValue = ifunc;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:27,代码来源:MySqlExprVisitor.java

示例10: getColumnsSelectedForParent

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入依赖的package包/类
/**
 * 列的tablename会设为表别名
 * 
 * @return
 */
public List<ISelectable> getColumnsSelectedForParent() {
    List<ISelectable> res = new ArrayList<ISelectable>(this.getColumnsSelected().size());
    for (ISelectable s : this.getColumnsSelected()) {
        ISelectable a = s.copy();
        if (this.getAlias() != null) {
            a.setTableName(this.getAlias());
        }

        if (s.getAlias() != null) {
            a.setColumnName(s.getAlias()); // 设置为alias name
            a.setAlias(null);
        }
        res.add(a);
    }
    return res;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:22,代码来源:QueryTreeNode.java

示例11: buildFunction

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入依赖的package包/类
public void buildFunction(IFunction f, boolean findInSelectList) {
    if (FunctionType.Aggregate == f.getFunctionType()) {
        setExistAggregate();
    }

    if (f.getArgs().size() == 0) {
        return;
    }

    List<Object> args = f.getArgs();
    for (int i = 0; i < args.size(); i++) {
        if (args.get(i) instanceof ISelectable) {
            args.set(i, this.buildSelectable((ISelectable) args.get(i), findInSelectList));
        }
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:17,代码来源:QueryTreeNodeBuilder.java

示例12: getSumType

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入依赖的package包/类
public DataType getSumType() {
    Object[] args = function.getArgs().toArray();
    DataType type = null;
    if (args[0] instanceof ISelectable) {
        type = ((ISelectable) args[0]).getDataType();
    }

    if (type == null) {
        type = DataTypeUtil.getTypeOfObject(args[0]);
    }
    if (type == DataType.IntegerType || type == DataType.ShortType) {
        return DataType.LongType;
    } else {
        return type;
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:17,代码来源:Avg.java

示例13: pushJoinOrder

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入依赖的package包/类
private static void pushJoinOrder(List<IOrderBy> orders, QueryTreeNode qn, boolean isUedForIndexJoinPK) {
    if (orders != null && !orders.isEmpty()) {
        for (IOrderBy order : orders) {
            if (qn.hasColumn(order.getColumn())) {
                qn.orderBy(order.getColumn(), order.getDirection());
            } else if (isUedForIndexJoinPK) {
                // 尝试忽略下表名查找一下
                ISelectable newC = order.getColumn().copy().setTableName(null);
                if (qn.hasColumn(newC)) {
                    qn.orderBy(order.getColumn(), order.getDirection());
                }
            }
        }

        qn.build();
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:18,代码来源:OrderByPusher.java

示例14: isInsertSelectOnPartition

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入依赖的package包/类
/**
 * 判断insert..select的分区规则是否一致
 */
private static PartitionJoinResult isInsertSelectOnPartition(QueryTreeNode left, QueryTreeNode right) {
    PartitionJoinResult leftResult = isJoinOnPartitionOneSide(new ArrayList<ISelectable>(), left);
    if (!leftResult.flag) {
        return leftResult;
    }

    PartitionJoinResult rightResult = isJoinOnPartitionOneSide(new ArrayList<ISelectable>(), right);
    if (!rightResult.flag) {
        return rightResult;
    }

    PartitionJoinResult result = new PartitionJoinResult();
    result.broadcast = leftResult.broadcast || rightResult.broadcast;
    result.flag = StringUtils.equalsIgnoreCase(leftResult.joinGroup, rightResult.joinGroup) || result.broadcast;
    result.joinGroup = leftResult.joinGroup;
    result.joinFilters = null;
    return result;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:22,代码来源:DataNodeChooser.java

示例15: tryPushColumn

import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入依赖的package包/类
private static boolean tryPushColumn(IFilter filter, boolean isColumn, QueryTreeNode qtn) {
    Object value = null;
    if (isColumn) {
        value = ((IBooleanFilter) filter).getColumn();
    } else {
        value = ((IBooleanFilter) filter).getValue();
    }

    if (value instanceof ISelectable) {
        ISelectable c = qtn.findColumn((ISelectable) value);
        if (c instanceof IColumn) {
            if (isColumn) {
                ((IBooleanFilter) filter).setColumn(c.copy());
            } else {
                ((IBooleanFilter) filter).setValue(c.copy());
            }
            return true;
        } else {
            return false;
        }
    } else {
        return true;
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:25,代码来源:FilterPusher.java


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