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


Java MergeNode.getChildren方法代码示例

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


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

示例1: buildMergeQuery

import com.taobao.tddl.optimizer.core.ast.query.MergeNode; //导入方法依赖的package包/类
private static QueryTreeNode buildMergeQuery(QueryNode query, MergeNode mergeNode, Map<String, Object> extraCmd) {
    List<QueryNode> mergeQuerys = new LinkedList<QueryNode>();

    for (ASTNode child : mergeNode.getChildren()) {
        // 在未做shard之前就有存在mergeNode的可能,要识别出来
        // 比如OR条件,可能会被拆分为两个Query的Merge,这个经过build之后,会是Merge套Merge或者是Merge套Query
        if (!(child instanceof MergeNode) && child.getExtra() != null) {
            QueryNode newQuery = query.copySelf();// 只复制自己,不复制子节点
            newQuery.setChild((QueryTreeNode) child);
            newQuery.executeOn(child.getDataNode());
            newQuery.setExtra(child.getExtra());
            newQuery.setBroadcast(child.isBroadcast());
            mergeQuerys.add(newQuery);
        }
    }

    if (mergeQuerys.size() > 1) {
        MergeNode merge = new MergeNode();
        merge.setAlias(query.getAlias());
        merge.setSubQuery(query.isSubQuery());
        merge.setSubAlias(query.getSubAlias());
        // 复制子节点的limit/to信息
        merge.setLimitFrom(query.getLimitFrom());
        merge.setLimitTo(query.getLimitTo());
        merge.setSubqueryOnFilterId(query.getSubqueryOnFilterId());
        for (QueryNode q : mergeQuerys) {
            merge.merge(q);
        }

        merge.executeOn(mergeQuerys.get(0).getDataNode()).setExtra(mergeQuerys.get(0).getExtra());
        merge.build();
        return merge;
    } else if (mergeQuerys.size() == 1) {
        return mergeQuerys.get(0);
    } else {
        return query;
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:39,代码来源:DataNodeChooser.java

示例2: buildMergeQuery

import com.taobao.tddl.optimizer.core.ast.query.MergeNode; //导入方法依赖的package包/类
private static QueryTreeNode buildMergeQuery(QueryNode query, MergeNode mergeNode) {
    List<QueryNode> mergeQuerys = new LinkedList<QueryNode>();
    for (ASTNode child : mergeNode.getChildren()) {
        // 在未做shard之前就有存在mergeNode的可能,要识别出来
        // 比如OR条件,可能会被拆分为两个Query的Merge,这个经过build之后,会是Merge套Merge或者是Merge套Query
        if (!(child instanceof MergeNode) && child.getExtra() != null) {
            QueryNode newQuery = query.copy();
            newQuery.setChild((QueryTreeNode) child);
            newQuery.executeOn(child.getDataNode());
            newQuery.setExtra(child.getExtra());
            newQuery.setBroadcast(child.isBroadcast());
            mergeQuerys.add(newQuery);
        }
    }

    if (mergeQuerys.size() > 1) {
        MergeNode merge = new MergeNode();
        merge.setAlias(query.getAlias());
        merge.setSubQuery(query.isSubQuery());
        merge.setSubAlias(query.getSubAlias());
        for (QueryNode q : mergeQuerys) {
            merge.merge(q);
        }

        merge.executeOn(mergeQuerys.get(0).getDataNode()).setExtra(mergeQuerys.get(0).getExtra());
        merge.build();
        return merge;
    } else if (mergeQuerys.size() == 1) {
        return mergeQuerys.get(0);
    } else {
        return query;
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:34,代码来源:DataNodeChooser.java

示例3: estimate

import com.taobao.tddl.optimizer.core.ast.query.MergeNode; //导入方法依赖的package包/类
@Override
public Cost estimate(QueryTreeNode query) throws StatisticsUnavailableException {
    MergeNode merge = (MergeNode) query;
    Cost cost = new Cost();

    long rowCount = 0;
    long io = 0;
    long networkCost = 0;
    long scanRowCount = 0;
    if (!(merge.getChildren().get(0) instanceof QueryTreeNode)) {
        return cost;
    }

    for (ASTNode sub : merge.getChildren()) {
        Cost subCost = CostEsitimaterFactory.estimate((QueryTreeNode) sub);
        rowCount += subCost.getRowCount();
        scanRowCount += subCost.getScanCount();
        // 如果两个不在一个节点上,就会产生网络开销,需要把sub的数据传送到merge节点上
        if (merge.getDataNode() != null) {
            if (!merge.getDataNode().equals(sub.getDataNode())) {
                networkCost += subCost.getRowCount();
            }
        }
    }

    if (query.getLimitFrom() != null
        && (query.getLimitFrom() instanceof Long || query.getLimitFrom() instanceof Long)
        && (Long) query.getLimitFrom() != 0 && query.getLimitTo() != null
        && (query.getLimitTo() instanceof Long || query.getLimitTo() instanceof Long)
        && (Long) query.getLimitTo() != 0) {
        rowCount = ((Long) query.getLimitTo() - (Long) query.getLimitFrom());
    }

    cost.setRowCount(rowCount);
    cost.setDiskIO(io);
    cost.setNetworkCost(networkCost);
    cost.setIsOnFly(true);
    cost.setScanCount(scanRowCount);
    return cost;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:41,代码来源:MergeNodeCostEstimater.java

示例4: estimate

import com.taobao.tddl.optimizer.core.ast.query.MergeNode; //导入方法依赖的package包/类
@Override
public Cost estimate(QueryTreeNode query) {
    MergeNode merge = (MergeNode) query;
    Cost cost = new Cost();

    long rowCount = 0;
    long io = 0;
    long networkCost = 0;
    long scanRowCount = 0;
    if (!(merge.getChildren().get(0) instanceof QueryTreeNode)) {
        return cost;
    }

    for (ASTNode sub : merge.getChildren()) {
        Cost subCost = CostEsitimaterFactory.estimate((QueryTreeNode) sub);
        rowCount += subCost.getRowCount();
        scanRowCount += subCost.getScanCount();
        // 如果两个不在一个节点上,就会产生网络开销,需要把sub的数据传送到merge节点上
        if (merge.getDataNode() != null) {
            if (!merge.getDataNode().equals(sub.getDataNode())) {
                networkCost += subCost.getRowCount();
            }
        }
    }

    if (query.getLimitFrom() != null && query.getLimitTo() != null) {
        Object from = query.getLimitFrom();
        if (from instanceof IBindVal) {
            from = ((IBindVal) from).getValue();
        }
        Object to = query.getLimitTo();
        if (to instanceof IBindVal) {
            to = ((IBindVal) from).getValue();
        }
        if (from instanceof Long && to instanceof Long) {
            rowCount = ((Long) query.getLimitTo() - (Long) query.getLimitFrom());
        }
    }

    cost.setRowCount(rowCount);
    cost.setDiskIO(io);
    cost.setNetworkCost(networkCost);
    cost.setIsOnFly(true);
    cost.setScanCount(scanRowCount);
    return cost;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:47,代码来源:MergeNodeCostEstimater.java


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