本文整理汇总了Java中com.taobao.tddl.executor.cursor.IAffectRowCursor类的典型用法代码示例。如果您正苦于以下问题:Java IAffectRowCursor类的具体用法?Java IAffectRowCursor怎么用?Java IAffectRowCursor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IAffectRowCursor类属于com.taobao.tddl.executor.cursor包,在下文中一共展示了IAffectRowCursor类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import com.taobao.tddl.executor.cursor.IAffectRowCursor; //导入依赖的package包/类
@Override
public ISchematicCursor handle(IDataNodeExecutor executor, ExecutionContext executionContext) throws TddlException {
if (executionContext.getParams() != null && executionContext.getParams().isBatch()) {
throw new ExecutorException("batch is not supported for :"
+ executionContext.getCurrentRepository().getClass());
}
long time = System.currentTimeMillis();
IPut put = (IPut) executor;
TableAndIndex ti = new TableAndIndex();
buildTableAndMeta(put, ti, executionContext);
int affect_rows = 0;
ITransaction transaction = executionContext.getTransaction();
ITable table = ti.table;
IndexMeta meta = ti.index;
try {
if (transaction == null) {// 客户端没有用事务,这里手动加上。
throw new IllegalAccessError("txn is null");
}
affect_rows = executePut(executionContext, put, table, meta);
} catch (Exception e) {
time = Monitor.monitorAndRenewTime(Monitor.KEY1, Monitor.KEY2_TDDL_EXECUTE, Monitor.Key3Fail, time);
throw new TddlNestableRuntimeException(e);
}
// 这里返回key->value的方式的东西,类似Key=affectRow val=1 这样的软编码
IAffectRowCursor affectrowCursor = executionContext.getCurrentRepository()
.getCursorFactory()
.affectRowCursor(executionContext, affect_rows);
time = Monitor.monitorAndRenewTime(Monitor.KEY1, Monitor.KEY2_TDDL_EXECUTE, Monitor.Key3Success, time);
return affectrowCursor;
}
示例2: getAffectRows
import com.taobao.tddl.executor.cursor.IAffectRowCursor; //导入依赖的package包/类
public int getAffectRows() throws SQLException {
if (this.resultCursor.getCursor() instanceof IAffectRowCursor) {
if (currentKVPair != null || next()) {
Integer index = currentKVPair.getParentCursorMeta().getIndex(null, ResultCursor.AFFECT_ROW, null);
return currentKVPair.getInteger(index);
} else {
return 0;
}
}
return -1;
}
示例3: handle
import com.taobao.tddl.executor.cursor.IAffectRowCursor; //导入依赖的package包/类
public ISchematicCursor handle(IDataNodeExecutor executor, ExecutionContext executionContext) throws TddlException {
long time = System.currentTimeMillis();
IPut put = (IPut) executor;
buildTableAndMeta(put, executionContext);
int affect_rows = 0;
ITransaction transaction = executionContext.getTransaction();
ITable table = executionContext.getTable();
IndexMeta meta = executionContext.getMeta();
boolean autoCommit = false;
try {
if (transaction == null) {// 客户端没有用事务,这里手动加上。
IRepository repo = executionContext.getCurrentRepository();
if ("True".equalsIgnoreCase(repo.getRepoConfig().getProperty(RepositoryConfig.IS_TRANSACTIONAL))) {
transaction = repo.beginTransaction(getDefalutTransactionConfig(repo));
executionContext.setTransaction(transaction);
autoCommit = true;
}
}
affect_rows = executePut(executionContext, put, table, meta);
if (autoCommit) {
commit(executionContext, transaction);
}
} catch (Exception e) {
time = Monitor.monitorAndRenewTime(Monitor.KEY1, Monitor.ServerPut, Monitor.Key3Fail, time);
if (autoCommit) {
rollback(executionContext, transaction);
}
throw new TddlException(e);
}
// 这里返回key->value的方式的东西,类似Key=affectRow val=1 这样的软编码
IAffectRowCursor affectrowCursor = executionContext.getCurrentRepository()
.getCursorFactory()
.affectRowCursor(executionContext, affect_rows);
time = Monitor.monitorAndRenewTime(Monitor.KEY1, Monitor.ServerPut, Monitor.Key3Success, time);
return affectrowCursor;
}
示例4: handle
import com.taobao.tddl.executor.cursor.IAffectRowCursor; //导入依赖的package包/类
@Override
public ISchematicCursor handle(IDataNodeExecutor executor, ExecutionContext executionContext) throws TddlException {
int size = OptimizerContext.getContext().getSchemaManager().getAllTables().size();
OptimizerContext.getContext().getSchemaManager().reload();
IAffectRowCursor c = executionContext.getCurrentRepository()
.getCursorFactory()
.affectRowCursor(executionContext, size);
return c;
}
示例5: executeUpdate
import com.taobao.tddl.executor.cursor.IAffectRowCursor; //导入依赖的package包/类
/**
* 执行一个update语句
*
* @param sqlAndParam
* @return
* @throws SQLException
*/
public IAffectRowCursor executeUpdate(ExecutionContext executionContext, IPut put, ITable table, IndexMeta meta)
throws SQLException;
示例6: affectRowCursor
import com.taobao.tddl.executor.cursor.IAffectRowCursor; //导入依赖的package包/类
IAffectRowCursor affectRowCursor(ExecutionContext context, int affectRow) throws TddlException;