本文整理汇总了Java中com.taobao.tddl.optimizer.core.ast.dml.DeleteNode类的典型用法代码示例。如果您正苦于以下问题:Java DeleteNode类的具体用法?Java DeleteNode怎么用?Java DeleteNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeleteNode类属于com.taobao.tddl.optimizer.core.ast.dml包,在下文中一共展示了DeleteNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPreparedDeleteSql
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的package包/类
@Test
public void testPreparedDeleteSql() throws SqlParserException {
String sql = "DELETE FROM TABLE1 WHERE ID>=? AND ID<=?";
DeleteNode dn = delete(sql);
Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 0, 3 });
ParameterContext p2 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 5 });
currentParameter.put(1, p1);
currentParameter.put(2, p2);
Parameters parameterSettings = new Parameters(currentParameter, false);
dn.assignment(parameterSettings);
dn.build();
TableNode table1 = new TableNode("TABLE1");
DeleteNode dnExpected = table1.delete();
table1.query("ID>=3 AND ID<=5");
dnExpected.build();
assertEquals(dn, dnExpected);
}
示例2: shard
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的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;
}
示例3: shardDelete
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的package包/类
private static ASTNode shardDelete(DeleteNode dne, Map<Integer, ParameterContext> parameterSettings,
Map<String, Object> extraCmd) throws QueryException {
QueryTreeNode qtn = shardQuery(dne.getNode(), parameterSettings, extraCmd);
List<ASTNode> subs = new ArrayList();
if (qtn instanceof MergeNode) {
subs.addAll(qtn.getChildren());
} else {
subs.add(qtn);
}
if (subs.size() == 1) {
return buildOneQueryDelete((QueryTreeNode) subs.get(0));
}
MergeNode deleteMerge = new MergeNode();
for (ASTNode sub : subs) {
deleteMerge.merge(buildOneQueryDelete((QueryTreeNode) sub));
}
deleteMerge.executeOn(deleteMerge.getChild().getDataNode());
return deleteMerge;
}
示例4: testPreparedDeleteSql
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的package包/类
@Test
public void testPreparedDeleteSql() throws SqlParserException, QueryException {
String sql = "DELETE FROM TABLE1 WHERE ID>=? AND ID<=?";
DeleteNode dn = delete(sql);
Map<Integer, ParameterContext> parameterSettings = null;
parameterSettings = new TreeMap<Integer, ParameterContext>();
ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 0, 3 });
ParameterContext p2 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, 5 });
parameterSettings.put(1, p1);
parameterSettings.put(2, p2);
dn.assignment(parameterSettings);
dn.build();
TableNode table1 = new TableNode("TABLE1");
DeleteNode dnExpected = table1.delete();
table1.query("ID>=3 AND ID<=5");
dnExpected.build();
assertEquals(dn, dnExpected);
}
示例5: buildOneQueryDelete
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的package包/类
private static DeleteNode buildOneQueryDelete(QueryTreeNode sub, DeleteNode dne, String dbIndex, String tableName) {
if (sub instanceof TableNode) {
// 不能使用QueryTreeNode.update()生成node
// 因为使用了代理模式后,update中会将this做为构造参数,而this并不是生成的代理类对象
((TableNode) sub).executeOn(dbIndex);
((TableNode) sub).setActualTableName(tableName);
return buildOneQueryDelete(sub, dne);
} else {
throw new NotSupportException("delete中暂不支持按照索引进行查询");
}
}
示例6: optimize
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的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;
}
示例7: delete
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的package包/类
@Test
public void testDelete_正常() throws SqlParserException {
String sql = "DELETE FROM TABLE1 WHERE ID>=5 AND ID<=5";
DeleteNode dn = delete(sql);
dn.build();
TableNode table1 = new TableNode("TABLE1");
DeleteNode dnExpected = table1.delete();
table1.query("ID>=5 AND ID<=5");
dnExpected.build();
assertEquals(dn, dnExpected);
}
示例8: TableNode
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的package包/类
@Test
public void testDelete_范围删除会生成merge() {
TableNode table = new TableNode("TABLE1");
DeleteNode delete = ((TableNode) table.query("ID>=5")).delete();
IDataNodeExecutor plan = optimizer.optimizeAndAssignment(delete, null, null);
Assert.assertTrue(plan instanceof IMerge);
Assert.assertEquals(8, ((IMerge) plan).getSubNodes().size());
String sql = "DELETE FROM TABLE1 WHERE ID>=5";
plan = optimizer.optimizeAndAssignment(sql, null, null, false);
Assert.assertTrue(plan instanceof IMerge);
Assert.assertEquals(8, ((IMerge) plan).getSubNodes().size());
}
示例9: buildOneQueryDelete
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的package包/类
private static DeleteNode buildOneQueryDelete(QueryTreeNode sub) {
if (sub instanceof TableNode) {
DeleteNode delete = ((TableNode) sub).delete();
delete.executeOn(sub.getDataNode());
return delete;
} else {
throw new NotSupportException("delete中暂不支持按照索引进行查询");
}
}
示例10: optimize
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的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;
}
示例11: delete
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的package包/类
@Test
public void testDelete_正常() throws SqlParserException, QueryException {
String sql = "DELETE FROM TABLE1 WHERE ID>=5 AND ID<=5";
DeleteNode dn = delete(sql);
dn.build();
TableNode table1 = new TableNode("TABLE1");
DeleteNode dnExpected = table1.delete();
table1.query("ID>=5 AND ID<=5");
dnExpected.build();
assertEquals(dn, dnExpected);
}
示例12: TableNode
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的package包/类
@Test
public void testDelete_范围删除会生成merge() throws QueryException {
TableNode table = new TableNode("TABLE1");
DeleteNode delete = ((TableNode) table.query("ID>=5")).delete();
IDataNodeExecutor plan = optimizer.optimizeAndAssignment(delete, null, null);
Assert.assertTrue(plan instanceof IMerge);
Assert.assertEquals(8, ((IMerge) plan).getSubNode().size());
String sql = "DELETE FROM TABLE1 WHERE ID>=5";
plan = optimizer.optimizeAndAssignment(sql, null, null, false);
Assert.assertTrue(plan instanceof IMerge);
Assert.assertEquals(8, ((IMerge) plan).getSubNode().size());
}
示例13: getDeleteNode
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的package包/类
public DeleteNode getDeleteNode() {
return deleteNode;
}
示例14: getDeleteNode
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的package包/类
@Override
public DeleteNode getDeleteNode() {
visited();
return ((MySqlDeleteVisitor) visitor).getDeleteNode();
}
示例15: shard
import com.taobao.tddl.optimizer.core.ast.dml.DeleteNode; //导入依赖的package包/类
public static ASTNode shard(ASTNode dne, Parameters parameterSettings, Map<String, Object> extraCmd) {
try {
// 针对非batch,绑定变量后,优化语法树
if (parameterSettings == null || parameterSettings != null && !parameterSettings.isBatch()) {
dne.assignment(parameterSettings);// null也要做一次,可能存在nextval
// 绑定变量后,再做一次
if (dne instanceof DMLNode) {
((DMLNode) dne).setNode((TableNode) FilterPreProcessor.optimize(((DMLNode) dne).getNode(),
false,
extraCmd));
} else if (dne instanceof QueryTreeNode) {
dne = FilterPreProcessor.optimize(((QueryTreeNode) dne), false, extraCmd);
}
}
if (dne instanceof LoadDataNode) {
return shardLoad((LoadDataNode) dne, parameterSettings, extraCmd);
}
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);
}
} else if (dne instanceof QueryTreeNode) {
return shardQuery((QueryTreeNode) dne, parameterSettings, extraCmd, true);
}
} catch (EmptyResultFilterException e) {
e.setAstNode(dne);
throw e;
}
return dne;
}