本文整理匯總了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;
}
示例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");
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
示例14: getReplaceNode
import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
public PutNode getReplaceNode() {
return replaceNode;
}
示例15: getReplaceNode
import com.taobao.tddl.optimizer.core.ast.dml.PutNode; //導入依賴的package包/類
@Override
public PutNode getReplaceNode() {
visited();
return ((MySqlReplaceVisitor) visitor).getReplaceNode();
}