本文整理匯總了Java中com.taobao.tddl.optimizer.core.plan.dml.IUpdate類的典型用法代碼示例。如果您正苦於以下問題:Java IUpdate類的具體用法?Java IUpdate怎麽用?Java IUpdate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IUpdate類屬於com.taobao.tddl.optimizer.core.plan.dml包,在下文中一共展示了IUpdate類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testUpdate
import com.taobao.tddl.optimizer.core.plan.dml.IUpdate; //導入依賴的package包/類
@Test
public void testUpdate() {
String sql = "UPDATE TABLE1 SET NAME = ? WHERE ID = ?";
Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2 });
currentParameter.put(1, p1);
Parameters parameterSettings = new Parameters();
parameterSettings.getCurrentParameter().put(1,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello1" }));
parameterSettings.getCurrentParameter().put(2,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 1 }));
parameterSettings.addBatch();
parameterSettings.getCurrentParameter().put(1,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello2" }));
parameterSettings.getCurrentParameter().put(2,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 2 }));
parameterSettings.addBatch();
IDataNodeExecutor plan = optimizer.optimizeAndAssignment(sql, parameterSettings, null, false);
Assert.assertTrue(plan instanceof IMerge);
Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(0)).getBatchIndexs(), Arrays.asList(0));
Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(1)).getBatchIndexs(), Arrays.asList(1));
}
示例2: accept
import com.taobao.tddl.optimizer.core.plan.dml.IUpdate; //導入依賴的package包/類
@Override
public void accept(PlanVisitor visitor) {
if (this instanceof IInsert) {
visitor.visit((IInsert) this);
} else if (this instanceof IDelete) {
visitor.visit((IDelete) this);
} else if (this instanceof IUpdate) {
visitor.visit((IUpdate) this);
} else if (this instanceof IReplace) {
visitor.visit((IReplace) this);
}
}
示例3: ParameterContext
import com.taobao.tddl.optimizer.core.plan.dml.IUpdate; //導入依賴的package包/類
@Test
public void testUpdate_範圍查詢() {
String sql = "UPDATE TABLE1 SET NAME = ? WHERE ID > ? AND ID < ?";
Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2 });
currentParameter.put(1, p1);
Parameters parameterSettings = new Parameters();
parameterSettings.getCurrentParameter().put(1,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello1" }));
parameterSettings.getCurrentParameter().put(2,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 1 }));
parameterSettings.getCurrentParameter().put(3,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 3, 4 }));
parameterSettings.addBatch();
parameterSettings.getCurrentParameter().put(1,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello2" }));
parameterSettings.getCurrentParameter().put(2,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 2 }));
parameterSettings.getCurrentParameter().put(3,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 3, 5 }));
parameterSettings.addBatch();
IDataNodeExecutor plan = optimizer.optimizeAndAssignment(sql, parameterSettings, null, false);
Assert.assertTrue(plan instanceof IMerge);
Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(0)).getBatchIndexs(), Arrays.asList(0));
Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(1)).getBatchIndexs(), Arrays.asList(1));
Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(2)).getBatchIndexs(), Arrays.asList(0, 1));
}
示例4: IN
import com.taobao.tddl.optimizer.core.plan.dml.IUpdate; //導入依賴的package包/類
@Test
public void testUpdate_in查詢() {
String sql = "UPDATE TABLE1 SET NAME = ? WHERE ID IN (?,?)";
Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2 });
currentParameter.put(1, p1);
Parameters parameterSettings = new Parameters();
parameterSettings.getCurrentParameter().put(1,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello1" }));
parameterSettings.getCurrentParameter().put(2,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 2 }));
parameterSettings.getCurrentParameter().put(3,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 3, 3 }));
parameterSettings.addBatch();
parameterSettings.getCurrentParameter().put(1,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "hello2" }));
parameterSettings.getCurrentParameter().put(2,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, 3 }));
parameterSettings.getCurrentParameter().put(3,
new ParameterContext(ParameterMethod.setObject1, new Object[] { 3, 4 }));
parameterSettings.addBatch();
IDataNodeExecutor plan = optimizer.optimizeAndAssignment(sql, parameterSettings, null, false);
Assert.assertTrue(plan instanceof IMerge);
Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(0)).getBatchIndexs(), Arrays.asList(0));
Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(1)).getBatchIndexs(), Arrays.asList(1));
Assert.assertEquals(((IUpdate) ((IMerge) plan).getSubNodes().get(2)).getBatchIndexs(), Arrays.asList(0, 1));
}
示例5: toDataNodeExecutor
import com.taobao.tddl.optimizer.core.plan.dml.IUpdate; //導入依賴的package包/類
@Override
public IDataNodeExecutor toDataNodeExecutor() throws QueryException {
IUpdate update = ASTNodeFactory.getInstance().createUpdate();
for (ISelectable updateColumn : this.getColumns()) {
if (this.getNode().getTableMeta().getPrimaryIndex().getPartitionColumns().contains(updateColumn)) {
throw new IllegalArgumentException("column :" + updateColumn.getColumnName() + " 是分庫鍵,不允許修改");
}
if (this.getNode().getTableMeta().getPrimaryKeyMap().containsKey(updateColumn.getColumnName())) {
throw new IllegalArgumentException("column :" + updateColumn.getColumnName() + " 是主鍵,不允許修改");
}
}
update.setConsistent(true);
update.executeOn(this.getNode().getDataNode());
update.setQueryTree(this.getNode().toDataNodeExecutor());
update.setUpdateColumns(this.getUpdateColumns());
update.setUpdateValues(values);
if (this.getNode().getActualTableName() != null) {
update.setTableName(this.getNode().getActualTableName());
} else if (this.getNode() instanceof KVIndexNode) {
update.setTableName(((KVIndexNode) this.getNode()).getIndexName());
} else {
update.setTableName(this.getNode().getTableName());
}
update.setIndexName(this.getNode().getIndexUsed().getName());
return update;
}
示例6: toDataNodeExecutor
import com.taobao.tddl.optimizer.core.plan.dml.IUpdate; //導入依賴的package包/類
@Override
public IPut toDataNodeExecutor(int shareIndex) {
IUpdate update = ASTNodeFactory.getInstance().createUpdate();
for (ISelectable updateColumn : this.getColumns()) {
List<String> partiionColumns = OptimizerContext.getContext()
.getRule()
.getSharedColumns(this.getNode().getTableMeta().getTableName());
if (partiionColumns.contains(updateColumn.getColumnName())) {
throw new IllegalArgumentException("column :" + updateColumn.getColumnName() + " 是分庫鍵,不允許修改");
}
if (this.getNode().getTableMeta().getPrimaryKeyMap().containsKey(updateColumn.getColumnName())) {
throw new IllegalArgumentException("column :" + updateColumn.getColumnName() + " 是主鍵,不允許修改");
}
}
update.setConsistent(true);
update.executeOn(this.getNode().getDataNode());
update.setQueryTree((IQueryTree) this.getNode().toDataNodeExecutor());
update.setUpdateColumns(this.getUpdateColumns());
update.setUpdateValues(values);
update.setIgnore(this.isIgnore());
update.setQuick(this.isQuick());
update.setLowPriority(this.lowPriority);
update.setHighPriority(this.highPriority);
update.setDelayed(this.isDelayed());
if (this.getNode().getActualTableName() != null) {
update.setTableName(this.getNode().getActualTableName());
} else if (this.getNode() instanceof KVIndexNode) {
update.setTableName(((KVIndexNode) this.getNode()).getIndexName());
} else {
update.setTableName(this.getNode().getTableName());
}
update.setIndexName(this.getNode().getIndexUsed().getName());
update.setBatchIndexs(this.getBatchIndexs());
update.setMultiValues(this.isMultiValues());
update.setMultiValues(this.getMultiValues());
update.setExistSequenceVal(this.isExistSequenceVal());
return update;
}
示例7: createUpdate
import com.taobao.tddl.optimizer.core.plan.dml.IUpdate; //導入依賴的package包/類
public IUpdate createUpdate() {
return new Update();
}
示例8: copy
import com.taobao.tddl.optimizer.core.plan.dml.IUpdate; //導入依賴的package包/類
@Override
public IUpdate copy() {
IUpdate update = ASTNodeFactory.getInstance().createUpdate();
copySelfTo(update);
return update;
}
示例9: visit
import com.taobao.tddl.optimizer.core.plan.dml.IUpdate; //導入依賴的package包/類
public abstract void visit(IUpdate update);