当前位置: 首页>>代码示例>>Java>>正文


Java IUpdate类代码示例

本文整理汇总了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));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:27,代码来源:BatchTest.java

示例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);
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:13,代码来源:Put.java

示例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));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:32,代码来源:BatchTest.java

示例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));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:32,代码来源:BatchTest.java

示例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;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:29,代码来源:UpdateNode.java

示例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;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:44,代码来源:UpdateNode.java

示例7: createUpdate

import com.taobao.tddl.optimizer.core.plan.dml.IUpdate; //导入依赖的package包/类
public IUpdate createUpdate() {
    return new Update();
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:4,代码来源:ASTNodeFactory.java

示例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;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:7,代码来源:Update.java

示例9: visit

import com.taobao.tddl.optimizer.core.plan.dml.IUpdate; //导入依赖的package包/类
public abstract void visit(IUpdate update); 
开发者ID:loye168,项目名称:tddl5,代码行数:2,代码来源:PlanVisitor.java


注:本文中的com.taobao.tddl.optimizer.core.plan.dml.IUpdate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。