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


Java JoinNode.select方法代碼示例

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


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

示例1: KVIndexNode

import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //導入方法依賴的package包/類
@Test
public void test_insertSelect查詢_select為join查詢_生成merge_設置where條件() {
    KVIndexNode table1 = new KVIndexNode("TABLE1");

    KVIndexNode table2 = new KVIndexNode("TABLE2");
    table2.keyQuery("ID IN (2,3)");
    KVIndexNode table3 = new KVIndexNode("TABLE3");
    table3.keyQuery("ID IN (2,3)");
    JoinNode join = table2.join(table3, "ID", "ID");
    join.select("TABLE2.*");

    InsertNode insert = new InsertNode(table1);
    insert.setSelectNode(join);
    insert.build();
    ASTNode qtn = shard(insert);

    Assert.assertTrue(qtn instanceof MergeNode);
    Assert.assertTrue(((MergeNode) qtn).getChild() instanceof InsertNode);
    Assert.assertEquals(2, ((MergeNode) qtn).getChildren().size());
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:21,代碼來源:DataNodeChooserTest.java

示例2: TableNode

import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //導入方法依賴的package包/類
@Test
public void test_where條件下推_多級join() {
    TableNode table1 = new TableNode("TABLE1");
    TableNode table2 = new TableNode("TABLE2");
    TableNode table3 = new TableNode("TABLE3");

    JoinNode join = table1.join(table2);
    join.select("TABLE1.ID AS ID , TABLE1.NAME AS NAME");
    join.query("TABLE1.ID>5 AND TABLE2.ID<10 AND TABLE1.NAME = TABLE2.NAME");
    join.build();

    JoinNode nextJoin = join.join(table3);
    nextJoin.query("TABLE1.NAME = 6 AND TABLE1.ID = TABLE3.ID");
    nextJoin.build();
    FilterPusher.optimize(nextJoin);

    Assert.assertEquals("(TABLE1.NAME = 6 AND TABLE1.ID > 5)", ((JoinNode) nextJoin.getLeftNode()).getLeftNode()
        .getWhereFilter()
        .toString());
    Assert.assertEquals("(TABLE2.ID < 10 AND TABLE2.NAME = 6)", ((JoinNode) nextJoin.getLeftNode()).getRightNode()
        .getWhereFilter()
        .toString());
    Assert.assertEquals("TABLE1.ID = TABLE3.ID", nextJoin.getJoinFilter().get(0).toString());
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:25,代碼來源:FilterPusherTest.java

示例3: TableNode

import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //導入方法依賴的package包/類
@Test
public void test_join條件下推_子表_case5_函數不下推() {
    TableNode table1 = new TableNode("TABLE1");
    TableNode table2 = new TableNode("TABLE2");
    table1.alias("A");
    table2.alias("B");

    JoinNode join = table1.join(table2);
    join.setJoinStrategy(JoinStrategy.INDEX_NEST_LOOP);
    join.select("A.ID AS CID, (A.NAME + A.SCHOOL) AS NAME");
    join.orderBy("CID ");
    join.orderBy("NAME"); // 這裏的name為select中的函數
    join.build();

    OrderByPusher.optimize(join);

    Assert.assertEquals(0, table1.getOrderBys().size());
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:19,代碼來源:OrderByPusherTest.java

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

示例5: TableNode

import com.taobao.tddl.optimizer.core.ast.query.JoinNode; //導入方法依賴的package包/類
@Test
public void test_兩表join_orderby_groupby_limit條件() {
    TableNode table = new TableNode("TABLE1");
    JoinNode join = table.join("TABLE2", "ID", "ID");
    join.select(OptimizerUtils.createColumnFromString("TABLE1.ID AS JID"),
        OptimizerUtils.createColumnFromString("CONCAT(TABLE1.NAME,TABLE1.SCHOOL) AS JNAME"));
    join.orderBy("JID");
    join.groupBy("JNAME");
    join.having("COUNT(JID) > 0");
    IQueryTree qc = (IQueryTree) optimizer.optimizeAndAssignment(join, null, extraCmd);
    Assert.assertTrue(qc instanceof IMerge);
    Assert.assertEquals(QUERY_CONCURRENCY.CONCURRENT, ((IMerge) qc).getQueryConcurrency());// 串行
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:14,代碼來源:OptimizerTest.java

示例6: 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.select方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。