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


Java JoinNode.setJoinStrategy方法代码示例

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


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

示例1: TableNode

import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //导入方法依赖的package包/类
@Test
public void test_join条件下推_子表_case1_下推NAME() {
    TableNode table1 = new TableNode("TABLE1");
    TableNode table2 = new TableNode("TABLE2");
    table1.alias("A");
    table1.orderBy("ID");
    table2.alias("B");

    JoinNode join = table1.join(table2);
    join.setJoinStrategy(JoinStrategy.INDEX_NEST_LOOP);
    join.orderBy("A.ID");
    join.orderBy("A.NAME");
    join.build();

    OrderByPusher.optimize(join);

    Assert.assertEquals(2, table1.getOrderBys().size());
    Assert.assertEquals("TABLE1.ID", table1.getOrderBys().get(0).getColumn().toString());
    Assert.assertEquals("TABLE1.NAME", table1.getOrderBys().get(1).getColumn().toString());
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:21,代码来源:OrderByPusherTest.java

示例2: convertPlanToAst

import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //导入方法依赖的package包/类
public static JoinNode convertPlanToAst(IJoin join) {
    JoinNode node = new JoinNode();
    node.setRightNode(convertPlanToAst(join.getRightNode()));
    node.setLeftNode(convertPlanToAst(join.getLeftNode()));
    node.setJoinStrategy(join.getJoinStrategy());
    if (join.getLeftOuter() && join.getRightOuter()) {
        node.setInnerJoin();
    } else if (join.getLeftOuter()) {
        node.setLeftOuterJoin();
    } else if (join.getRightOuter()) {
        node.setRightOuterJoin();
    } else {
        node.setOuterJoin();
    }

    int size = join.getLeftJoinOnColumns().size();
    for (int i = 0; i < size; i++) {
        node.addJoinKeys(join.getLeftJoinOnColumns().get(i), join.getRightJoinOnColumns().get(i));
    }
    node.setOrderBys(join.getOrderBys());
    node.setLimitFrom(join.getLimitFrom());
    node.setLimitTo(join.getLimitTo());
    node.setConsistent(join.getConsistent());
    node.setResultFilter(join.getValueFilter());
    node.having(join.getHavingFilter());
    node.setAlias(join.getAlias());
    node.setGroupBys(join.getGroupBys());
    node.setSubQuery(join.isSubQuery());
    node.setOtherJoinOnFilter(join.getOtherJoinOnFilter());
    node.select((join.getColumns()));
    node.setAllWhereFilter(join.getWhereFilter());
    node.setExistAggregate(join.isExistAggregate());
    node.executeOn(join.getDataNode());
    node.setSubqueryOnFilterId(join.getSubqueryOnFilterId());
    node.setSubqueryFilter(join.getSubqueryFilter());
    node.build();
    node = node.deepCopy();
    return node;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:40,代码来源:OptimizerUtils.java

示例3: TableNode

import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //导入方法依赖的package包/类
@Test
public void test_Join左是子查询_右是TableNode_转化为最左树() {
    TableNode table1 = new TableNode("TABLE1");
    QueryNode query = new QueryNode(table1);
    query.build();

    TableNode table2 = new TableNode("TABLE2");

    JoinNode join = table1.join(table2, "NAME", "NAME");
    join.setJoinStrategy(JoinStrategy.INDEX_NEST_LOOP);
    join.query("TABLE1.NAME = 1 AND TABLE1.ID > 3 AND TABLE1.SCHOOL = 1");// 原本条件应该是加在join下的,这里省区推导的过程
    join.select("(TABLE2.ID + TABLE2.NAME) AS NEWNAME"); // 设置为函数
    join.orderBy("TABLE1.SCHOOL", false);// 增加一个隐藏列
    join.groupBy("NEWNAME");
    join.build();

    QueryTreeNode qn = FilterPusher.optimize(join);// 先把条件推导子节点上,构建子节点join
    build(table1);
    build(table2);
    qn = qn.convertToJoinIfNeed();

    Assert.assertTrue(qn instanceof JoinNode);
    Assert.assertEquals("TABLE2$_NAME.ID = TABLE2.ID", ((JoinNode) qn).getJoinFilter().get(0).toString());

    Assert.assertTrue(((JoinNode) qn).getLeftNode() instanceof JoinNode);
    Assert.assertEquals("TABLE1.NAME = TABLE2$_NAME.NAME",
        ((JoinNode) ((JoinNode) qn).getLeftNode()).getJoinFilter().get(0).toString());

    Assert.assertTrue(((JoinNode) ((JoinNode) qn).getLeftNode()).getLeftNode() instanceof JoinNode);
    JoinNode jn = (JoinNode) ((JoinNode) ((JoinNode) qn).getLeftNode()).getLeftNode();
    Assert.assertEquals("TABLE1._NAME.NAME = 1", jn.getLeftNode().getKeyFilter().toString());
    Assert.assertEquals("TABLE1._NAME.ID > 3", jn.getLeftNode().getResultFilter().toString());
    Assert.assertEquals("TABLE1.SCHOOL = 1", jn.getRightNode().getResultFilter().toString());
    Assert.assertEquals("TABLE1._NAME.ID = TABLE1.ID", jn.getJoinFilter().get(0).toString());
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:36,代码来源:JoinChooserTest.java


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