當前位置: 首頁>>代碼示例>>Java>>正文


Java TableNode.executeOn方法代碼示例

本文整理匯總了Java中com.taobao.tddl.optimizer.core.ast.query.TableNode.executeOn方法的典型用法代碼示例。如果您正苦於以下問題:Java TableNode.executeOn方法的具體用法?Java TableNode.executeOn怎麽用?Java TableNode.executeOn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.taobao.tddl.optimizer.core.ast.query.TableNode的用法示例。


在下文中一共展示了TableNode.executeOn方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildMergeTableInOneDB

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //導入方法依賴的package包/類
/**
 * 構建單庫的執行節點
 */
private static OneDbNodeWithCount buildMergeTableInOneDB(TableNode table, TargetDB targetDB, int baseIndex,
                                                         boolean needCopy, boolean traceIn) {
    long totalRowCount = 0;
    OneDbNodeWithCount oneDbNodeWithCount = new OneDbNodeWithCount();
    Map<String, Field> tabMap = targetDB.getTableNameMap();
    int i = baseIndex;
    for (String targetTable : tabMap.keySet()) {
        TableNode node = table;
        if (needCopy) {
            node = table.copy();

            // tddl的traceSource在分庫不分表,和全表掃描時無法使用 mengshi
            if (traceIn && tabMap.get(targetTable) != null && tabMap.get(targetTable).getSourceKeys() != null) {
                traceSourceInFilter(node.getKeyFilter(), tabMap.get(targetTable).getSourceKeys(), false);
                traceSourceInFilter(node.getResultFilter(), tabMap.get(targetTable).getSourceKeys(), false);
            }
        }

        if (needCopy) {
            node.setActualTableName(targetTable);
            node.executeOn(targetDB.getDbIndex());
            node.setExtra(getIdentifierExtra((KVIndexNode) node, 0));// 設置標誌
            oneDbNodeWithCount.subs.add(node);
        } else {
            node.setActualTableName(targetTable, i);
            node.executeOn(targetDB.getDbIndex(), i);
            node.setExtra(getIdentifierExtra((KVIndexNode) node, i), i);// 設置標誌
            // 添加一個代理對象
            oneDbNodeWithCount.subs.add((QueryTreeNode) new NodeDelegate(node, i).getProxy());
            i = i + 1;
        }

        // 暫時先用邏輯表名,以後可能是索引名
        String indexName = null;
        if (node instanceof KVIndexNode) {
            indexName = ((KVIndexNode) node).getKvIndexName();
        } else {
            indexName = node.getTableMeta().getPrimaryIndex().getName();
        }
        node.setBroadcast(OptimizerContext.getContext().getRule().isBroadCast(indexName));
        totalRowCount += CostEsitimaterFactory.estimate(node).getRowCount();
    }

    oneDbNodeWithCount.totalRowCount = totalRowCount;
    return oneDbNodeWithCount;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:50,代碼來源:DataNodeChooser.java

示例2: buildMergeTableInOneDB

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //導入方法依賴的package包/類
/**
 * 構建單庫的執行節點
 */
private static OneDbNodeWithCount buildMergeTableInOneDB(TableNode table, TargetDB targetDB, boolean needCopy) {
    long totalRowCount = 0;
    OneDbNodeWithCount oneDbNodeWithCount = new OneDbNodeWithCount();
    Map<String, Field> tabMap = targetDB.getTableNameMap();
    for (String targetTable : tabMap.keySet()) {
        TableNode node = null;
        if (needCopy) {
            node = table.copy();
        } else {
            node = table;
        }

        // tddl的traceSource在分庫不分表,和全表掃描時無法使用 mengshi
        if (tabMap.get(targetTable) != null && tabMap.get(targetTable).getSourceKeys() != null) {
            if (node.getKeyFilter() != null) {
                IFilter keyFilterAfterTraceSource = (IFilter) node.getKeyFilter().copy();
                traceSourceInFilter(keyFilterAfterTraceSource, tabMap.get(targetTable).getSourceKeys());
                node.setKeyFilter(keyFilterAfterTraceSource);
            }

            if (node.getResultFilter() != null) {
                IFilter valueFilterAfterTraceSource = (IFilter) node.getResultFilter().copy();
                traceSourceInFilter(valueFilterAfterTraceSource, tabMap.get(targetTable).getSourceKeys());
                node.setResultFilter(valueFilterAfterTraceSource);
            }
        }

        node.setActualTableName(targetTable);
        node.executeOn(targetDB.getDbIndex());
        node.setExtra(getIdentifierExtra((KVIndexNode) node));// 設置標誌
        // 暫時先用邏輯表名,以後可能是索引名
        String indexName = null;
        if (node instanceof KVIndexNode) {
            indexName = ((KVIndexNode) node).getKvIndexName();
        } else {
            indexName = node.getTableMeta().getPrimaryIndex().getName();
        }
        node.setBroadcast(OptimizerContext.getContext().getRule().isBroadCast(indexName));

        totalRowCount += CostEsitimaterFactory.estimate(node).getRowCount();
        oneDbNodeWithCount.subs.add(node);
    }

    oneDbNodeWithCount.totalRowCount = totalRowCount;
    return oneDbNodeWithCount;
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:50,代碼來源:DataNodeChooser.java


注:本文中的com.taobao.tddl.optimizer.core.ast.query.TableNode.executeOn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。