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


Java PutNode類代碼示例

本文整理匯總了Java中com.taobao.tddl.optimizer.core.ast.dml.PutNode的典型用法代碼示例。如果您正苦於以下問題:Java PutNode類的具體用法?Java PutNode怎麽用?Java PutNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PutNode類屬於com.taobao.tddl.optimizer.core.ast.dml包,在下文中一共展示了PutNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shard

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
public static ASTNode shard(ASTNode dne, Map<Integer, ParameterContext> parameterSettings,
                            Map<String, Object> extraCmd) throws QueryException {
    if (dne instanceof DMLNode) {
        if (dne instanceof InsertNode) {
            return shardInsert((InsertNode) dne, parameterSettings, extraCmd);
        }
        if (dne instanceof UpdateNode) {
            return shardUpdate((UpdateNode) dne, parameterSettings, extraCmd);
        }
        if (dne instanceof DeleteNode) {
            return shardDelete((DeleteNode) dne, parameterSettings, extraCmd);
        }
        if (dne instanceof PutNode) {
            return shardPut((PutNode) dne, parameterSettings, extraCmd);
        }
    }
    if (dne instanceof QueryTreeNode) {
        return shardQuery((QueryTreeNode) dne, parameterSettings, extraCmd);
    }

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

示例2: shardPut

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
private static ASTNode shardPut(PutNode dne, Map<Integer, ParameterContext> parameterSettings,
                                Map<String, Object> extraCmd) {
    String indexName = null;
    if (dne.getNode() instanceof KVIndexNode) {
        indexName = ((KVIndexNode) dne.getNode()).getIndexName();
    } else {
        indexName = dne.getNode().getTableMeta().getPrimaryIndex().getName();
    }

    IFilter insertFilter = createFilter(dne.getColumns(), dne.getValues());
    List<TargetDB> dataNodeChoosed = shard(indexName, insertFilter, true);
    TargetDB itarget = dataNodeChoosed.get(0);
    dne.executeOn(itarget.getDbIndex());
    if (dataNodeChoosed.size() == 1 && itarget.getTableNameMap() != null && itarget.getTableNameMap().size() == 1) {
        KVIndexNode query = new KVIndexNode(indexName);
        query.executeOn(itarget.getDbIndex());
        query.setActualTableName(itarget.getTableNameMap().keySet().iterator().next());
        dne = query.put(dne.getColumns(), dne.getValues());
        dne.executeOn(query.getDataNode());
        dne.build();
        return dne;
    } else {
        throw new OptimizerException("insert not support muti tables");
    }
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:26,代碼來源:DataNodeChooser.java

示例3: buildOnePutNode

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
private static PutNode buildOnePutNode(PutNode dne, String indexName, String dbIndex, String tableName) {
    KVIndexNode query = new KVIndexNode(indexName);
    // 設置為物理的表
    query.executeOn(dbIndex);
    query.setActualTableName(tableName);

    PutNode put = dne.copySelf();
    put.setNode(query);
    put.executeOn(query.getDataNode());
    put.build();
    return put;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:13,代碼來源:DataNodeChooser.java

示例4: optimize

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
private ASTNode optimize(ASTNode node, Parameters parameterSettings, Map<String, Object> extraCmd) {
    // 先調用一次build,完成select字段信息的推導
    node.build();
    ASTNode optimized = node;
    try {
        if (node instanceof QueryTreeNode) {
            optimized = this.optimizeQuery((QueryTreeNode) node, extraCmd);
        }

        if (node instanceof InsertNode) {
            optimized = this.optimizeInsert((InsertNode) node, extraCmd);
        }

        else if (node instanceof DeleteNode) {
            optimized = this.optimizeDelete((DeleteNode) node, extraCmd);
        }

        else if (node instanceof UpdateNode) {
            optimized = this.optimizeUpdate((UpdateNode) node, extraCmd);
        }

        else if (node instanceof PutNode) {
            optimized = this.optimizePut((PutNode) node, extraCmd);
        }

    } catch (EmptyResultFilterException e) {
        e.setAstNode(optimized); // 設置上下文
        throw e;
    }

    return optimized;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:33,代碼來源:CostBasedOptimizer.java

示例5: optimizePut

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
private ASTNode optimizePut(PutNode put, Map<String, Object> extraCmd) {
    put.setNode((TableNode) put.getNode().convertToJoinIfNeed());
    if (put.getSelectNode() != null) {
        put.setSelectNode(optimizeQuery(put.getSelectNode(), extraCmd));
    }
    return put;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:8,代碼來源:CostBasedOptimizer.java

示例6: put

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
public PutNode put(String columns[], Object values[]) {
    List<ISelectable> cs = new LinkedList<ISelectable>();
    for (String name : columns) {
        ISelectable s = OptimizerUtils.createColumnFromString(name);
        cs.add(s);
    }

    List<Object> valueList = new ArrayList<Object>(Arrays.asList(values));
    return put(cs, valueList);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:11,代碼來源:TableNode.java

示例7: TABLE1

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
@Test
public void testReplace_多字段_多記錄() throws SqlParserException {
    String sql = "REPLACE INTO TABLE1(ID, NAME, SCHOOL) VALUES (1, 'sun', 'sysu'),(2, 'sun', 'sysu'),(3, 'sun', 'sysu')";

    PutNode in = put(sql);
    in.build();

    TableNode table1 = new TableNode("TABLE1");
    PutNode inExpected = table1.put("ID NAME SCHOOL",
        new Object[] { Arrays.asList(1, "sun", "sysu"), Arrays.asList(2, "sun", "sysu"),
                Arrays.asList(3, "sun", "sysu") });
    inExpected.build();

    assertEquals(in, inExpected);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:16,代碼來源:SqlParserTest.java

示例8: put

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
private PutNode put(String sql) throws SqlParserException {
    SqlAnalysisResult sm = parser.parse(sql, false);
    PutNode qn = null;
    if (sm.getSqlType() == SqlType.REPLACE) {
        qn = sm.getReplaceNode();
    }

    return qn;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:10,代碼來源:SqlParserTest.java

示例9: testPut

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
@Test
public void testPut() {
    TableNode table = new TableNode("TABLE1");
    Comparable values[] = { 2 };
    PutNode update = ((TableNode) table).put("ID", values);
    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(update, null, null);
    Assert.assertTrue(plan instanceof IPut);

    String sql = "INSERT INTO TABLE1(ID) VALUES(2)";
    plan = optimizer.optimizeAndAssignment(sql, null, null, false);
    Assert.assertTrue(plan instanceof IPut);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:13,代碼來源:DMLNodeChooserTest.java

示例10: TableNode

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
@Test
public void testPut_廣播表() {
    TableNode table = new TableNode("TABLE7");
    Comparable values[] = { 2 };
    PutNode update = ((TableNode) table).put("ID", values);
    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(update, null, null);
    Assert.assertTrue(plan instanceof IMerge);
    Assert.assertEquals(4, ((IMerge) plan).getSubNodes().size());

    String sql = "REPLACE INTO TABLE7(ID) VALUES(2)";
    plan = optimizer.optimizeAndAssignment(sql, null, null, false);
    Assert.assertTrue(plan instanceof IMerge);
    Assert.assertEquals(4, ((IMerge) plan).getSubNodes().size());
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:15,代碼來源:DMLNodeChooserTest.java

示例11: optimize

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
public ASTNode optimize(ASTNode node, Map<Integer, ParameterContext> parameterSettings, Map<String, Object> extraCmd)
                                                                                                                     throws QueryException {
    // 先調用一次build,完成select字段信息的推導
    node.build();
    ASTNode optimized = null;
    if (node instanceof QueryTreeNode) {
        optimized = this.optimizeQuery((QueryTreeNode) node, extraCmd);
    }

    if (node instanceof InsertNode) {
        optimized = this.optimizeInsert((InsertNode) node, extraCmd);
    }

    else if (node instanceof DeleteNode) {
        optimized = this.optimizeDelete((DeleteNode) node, extraCmd);
    }

    else if (node instanceof UpdateNode) {
        optimized = this.optimizeUpdate((UpdateNode) node, extraCmd);
    }

    else if (node instanceof PutNode) {
        optimized = this.optimizePut((PutNode) node, extraCmd);
    }

    return optimized;
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:28,代碼來源:CostBasedOptimizer.java

示例12: testPut

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
@Test
public void testPut() throws QueryException {
    TableNode table = new TableNode("TABLE1");
    Comparable values[] = { 2 };
    PutNode update = ((TableNode) table).put("ID", values);
    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(update, null, null);
    Assert.assertTrue(plan instanceof IPut);

    String sql = "INSERT INTO TABLE1(ID) VALUES(2)";
    plan = optimizer.optimizeAndAssignment(sql, null, null, false);
    Assert.assertTrue(plan instanceof IPut);
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:13,代碼來源:DMLNodeChooserTest.java

示例13: TableNode

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
@Test
public void testPut_全字段() throws QueryException {
    TableNode table = new TableNode("TABLE1");
    Comparable values[] = { 2, "sysu", "sun" };
    PutNode put = table.put("ID SCHOOL NAME", values);
    IDataNodeExecutor plan = optimizer.optimizeAndAssignment(put, null, null);
    Assert.assertTrue(plan instanceof IPut);

    String sql = "REPLACE INTO TABLE1(ID,SCHOOL,NAME) VALUES(2,'sysu','sun')";
    plan = optimizer.optimizeAndAssignment(sql, null, null, false);
    Assert.assertTrue(plan instanceof IPut);
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:13,代碼來源:DMLNodeChooserTest.java

示例14: getReplaceNode

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
public PutNode getReplaceNode() {
    return replaceNode;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:4,代碼來源:MySqlReplaceVisitor.java

示例15: getReplaceNode

import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
@Override
public PutNode getReplaceNode() {
    visited();
    return ((MySqlReplaceVisitor) visitor).getReplaceNode();
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:6,代碼來源:CobarSqlAnalysisResult.java


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