本文整理匯總了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;