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


Java TableNode.setResultFilter方法代码示例

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


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

示例1: build

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
private void build(TableNode table) {
    table.build();

    Map<String, Object> extraCmd = new HashMap<String, Object>();
    extraCmd.put(ConnectionProperties.CHOOSE_INDEX, true);
    IndexMeta index = IndexChooser.findBestIndex(table.getTableMeta(),
        new ArrayList<ISelectable>(),
        FilterUtils.toDNFNode(table.getWhereFilter()),
        table.getTableName(),
        extraCmd);

    table.useIndex(index);

    Map<FilterType, IFilter> result = FilterSpliter.splitByIndex(FilterUtils.toDNFNode(table.getWhereFilter()),
        table);

    table.setKeyFilter(result.get(FilterType.IndexQueryKeyFilter));
    table.setIndexQueryValueFilter(result.get(FilterType.IndexQueryValueFilter));
    table.setResultFilter(result.get(FilterType.ResultFilter));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:21,代码来源:JoinChooserTest.java

示例2: build

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
private void build(TableNode table) {
    table.build();

    Map<String, Object> extraCmd = new HashMap<String, Object>();
    extraCmd.put(ExtraCmd.CHOOSE_INDEX, true);
    IndexMeta index = IndexChooser.findBestIndex(table.getTableMeta(),
        new ArrayList<ISelectable>(),
        FilterUtils.toDNFNode(table.getWhereFilter()),
        table.getTableName(),
        extraCmd);

    table.useIndex(index);

    Map<FilterType, IFilter> result = FilterSpliter.splitByIndex(FilterUtils.toDNFNode(table.getWhereFilter()),
        table);

    table.setKeyFilter(result.get(FilterType.IndexQueryKeyFilter));
    table.setIndexQueryValueFilter(result.get(FilterType.IndexQueryValueFilter));
    table.setResultFilter(result.get(FilterType.ResultFilter));
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:21,代码来源:JoinChooserTest.java

示例3: buildTableFilter

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
private static void buildTableFilter(TableNode tableNode) {
    List<List<IFilter>> DNFNodes = FilterUtils.toDNFNodesArray(tableNode.getWhereFilter());
    if (DNFNodes.size() == 1) {
        // 即使索引没有选择主键,但是有的filter依旧会在s主键上进行,作为valueFilter,所以要把主键也传进去
        Map<FilterType, IFilter> filters = FilterSpliter.splitByIndex(DNFNodes.get(0), tableNode);
        tableNode.setKeyFilter(filters.get(FilterType.IndexQueryKeyFilter));
        tableNode.setResultFilter(filters.get(FilterType.ResultFilter));
        tableNode.setIndexQueryValueFilter(filters.get(FilterType.IndexQueryValueFilter));
        tableNode.query((IFilter) null);// 清空where
    } else {
        // 如果存在多个合取方式的的or组合时,无法区分出key/indexValue/result,直接下推
        tableNode.setResultFilter(tableNode.getWhereFilter());
        tableNode.query((IFilter) null);// 清空where
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:16,代码来源:JoinChooser.java

示例4: buildTableFilter

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
private static void buildTableFilter(TableNode tableNode) {
    List<List<IFilter>> DNFNodes = FilterUtils.toDNFNodesArray(tableNode.getWhereFilter());
    if (DNFNodes.size() == 1) {
        // 即使索引没有选择主键,但是有的filter依旧会在s主键上进行,作为valueFilter,所以要把主键也传进去
        Map<FilterType, IFilter> filters = FilterSpliter.splitByIndex(DNFNodes.get(0), tableNode);
        tableNode.setKeyFilter(filters.get(FilterType.IndexQueryKeyFilter));
        tableNode.setResultFilter(filters.get(FilterType.ResultFilter));
        tableNode.setIndexQueryValueFilter(filters.get(FilterType.IndexQueryValueFilter));
    } else {
        // 如果存在多个合取方式的的or组合时,无法区分出key/indexValue/result,直接下推
        tableNode.setResultFilter(tableNode.getWhereFilter());
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:14,代码来源:JoinChooser.java

示例5: splitByDNF

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
/**
 * 根据where中的所有条件按照or进行分隔,生成多个query请求. (主要考虑部分存储引擎不支持or语法)
 */
public static List<QueryTreeNode> splitByDNF(TableNode node, Map<String, Object> extraCmd) {
    if (node.getWhereFilter() == null) {
        return new LinkedList<QueryTreeNode>();
    }

    if (!FilterUtils.isDNF(node.getWhereFilter())) {
        throw new IllegalArgumentException("not dnf!!! fuck!!\n" + node.getWhereFilter());
    }

    List<QueryTreeNode> subQueries = new LinkedList<QueryTreeNode>();
    List<List<IFilter>> DNFNodes = FilterUtils.toDNFNodesArray(node.getWhereFilter());
    // 判断是否要处理OR转化为index merge,比如mysql可以push
    // 比如hbase/bdb这一类,OR条件目前只能是主键索引,由执行器层面去解决
    // 如果涉及多字段时就需要拆分为index merge,同时做uniq
    boolean needCopy = (DNFNodes.size() > 1);
    if (isOptimizeIndexMerge(extraCmd) || DNFNodes.size() == 1) {
        for (List<IFilter> DNFNode : DNFNodes) {
            List columns = Arrays.asList(FilterUtils.toColumnFiltersMap(DNFNode).keySet().toArray());
            String tablename = node.getTableName();
            IndexMeta index = IndexChooser.findBestIndex(node.getTableMeta(), columns, DNFNode, tablename, extraCmd);
            if (index == null) {
                index = node.getTableMeta().getPrimaryIndex();
            }
            // 如果找不到对应条件的主键,可能需要全表扫描
            TableNode subQuery = node;
            if (needCopy) {
                subQuery = node.deepCopy();
            }

            subQuery.useIndex(index);
            if (index == null) {// 如果无主键进行全表扫描
                subQuery.setFullTableScan(true);
            } else {
                subQuery.query((IFilter) null);// 清空where
            }

            Map<FilterType, IFilter> filters = splitByIndex(DNFNode, subQuery);
            subQuery.setKeyFilter(filters.get(FilterType.IndexQueryKeyFilter));
            subQuery.setIndexQueryValueFilter(filters.get(FilterType.IndexQueryValueFilter));
            subQuery.setResultFilter(filters.get(FilterType.ResultFilter));
            subQueries.add(subQuery);
        }
    } else {
        node.useIndex(node.getTableMeta().getPrimaryIndex());// 默认选中主键
        node.setResultFilter(node.getWhereFilter());
    }

    return subQueries;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:53,代码来源:FilterSpliter.java

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

示例7: splitByDNF

import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
/**
 * 根据where中的所有条件按照or进行分隔,生成多个query请求. (主要考虑部分存储引擎不支持or语法)
 */
public static List<QueryTreeNode> splitByDNF(TableNode node, Map<String, Object> extraCmd) throws QueryException {
    if (node.getWhereFilter() == null) {
        return new LinkedList<QueryTreeNode>();
    }

    if (!FilterUtils.isDNF(node.getWhereFilter())) {
        throw new IllegalArgumentException("not dnf!!! fuck!!\n" + node.getWhereFilter());
    }

    List<QueryTreeNode> subQueries = new LinkedList<QueryTreeNode>();
    List<List<IFilter>> DNFNodes = FilterUtils.toDNFNodesArray(node.getWhereFilter());
    // 判断是否要处理OR转化为index merge,比如mysql可以push
    // 比如hbase/bdb这一类,OR条件目前只能是主键索引,由执行器层面去解决
    // 如果涉及多字段时就需要拆分为index merge,同时做uniq
    boolean needCopy = (DNFNodes.size() > 1);
    if (isOptimizeIndexMerge(extraCmd) || DNFNodes.size() == 1) {
        for (List<IFilter> DNFNode : DNFNodes) {
            List columns = Arrays.asList(FilterUtils.toColumnFiltersMap(DNFNode).keySet().toArray());
            String tablename = node.getTableName();
            IndexMeta index = IndexChooser.findBestIndex(node.getTableMeta(), columns, DNFNode, tablename, extraCmd);
            if (index == null) {
                index = node.getTableMeta().getPrimaryIndex();
            }
            // 如果找不到对应条件的主键,可能需要全表扫描
            TableNode subQuery = node;
            if (needCopy) {
                subQuery = node.deepCopy();
            }

            subQuery.useIndex(index);
            if (index == null) {// 如果无主键进行全表扫描
                subQuery.setFullTableScan(true);
            }

            Map<FilterType, IFilter> filters = splitByIndex(DNFNode, subQuery);
            subQuery.setKeyFilter(filters.get(FilterType.IndexQueryKeyFilter));
            subQuery.setIndexQueryValueFilter(filters.get(FilterType.IndexQueryValueFilter));
            subQuery.setResultFilter(filters.get(FilterType.ResultFilter));
            subQueries.add(subQuery);
        }
    } else {
        node.useIndex(node.getTableMeta().getPrimaryIndex());// 默认选中主键
        node.setResultFilter(node.getWhereFilter());
    }

    return subQueries;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:51,代码来源:FilterSpliter.java


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