本文整理汇总了C++中NdbScanOperation::updateCurrentTuple方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbScanOperation::updateCurrentTuple方法的具体用法?C++ NdbScanOperation::updateCurrentTuple怎么用?C++ NdbScanOperation::updateCurrentTuple使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NdbScanOperation
的用法示例。
在下文中一共展示了NdbScanOperation::updateCurrentTuple方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scan_update
//.........这里部分代码省略.........
filter.end() <0)
{
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* Start scan (NoCommit since we are only reading at this stage);
*/
if(myTrans->execute(NdbTransaction::NoCommit) != 0)
{
err = myTrans->getNdbError();
if(err.status == NdbError::TemporaryError){
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
milliSleep(50);
continue;
}
std::cout << myTrans->getNdbError().code << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
/**
* start of loop: nextResult(true) means that "parallelism" number of
* rows are fetched from NDB and cached in NDBAPI
*/
while((check = myScanOp->nextResult(true)) == 0){
do {
/**
* Get update operation
*/
NdbOperation * myUpdateOp = myScanOp->updateCurrentTuple();
if (myUpdateOp == 0)
{
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
return -1;
}
updatedRows++;
/**
* do the update
*/
myUpdateOp->setValue(update_column, after_color);
/**
* nextResult(false) means that the records
* cached in the NDBAPI are modified before
* fetching more rows from NDB.
*/
} while((check = myScanOp->nextResult(false)) == 0);
/**
* NoCommit when all cached tuple have been updated
*/
if(check != -1)
{
check = myTrans->execute(NdbTransaction::NoCommit);
}
/**
* Check for errors
*/
err = myTrans->getNdbError();
if(check == -1)
示例2: allocRows
//.........这里部分代码省略.........
return NDBT_FAILED;
}
}
}
check = pTrans->execute(NoCommit, AbortOnError);
check = (check == -1 ? -1 : !ordered ? check : sOp->nextResult(true));
if( check == -1 ) {
const NdbError err = pTrans->getNdbError();
ERR(err);
closeTransaction(pNdb);
if (err.status == NdbError::TemporaryError){
NdbSleep_MilliSleep(50);
retryAttempt++;
continue;
}
return NDBT_FAILED;
}
if(ordered && check != 0){
g_err << check << " - Row: " << r << " not found!!" << endl;
closeTransaction(pNdb);
return NDBT_FAILED;
}
for(b = 0; b<batch && (b+r)<records; b++){
if (calc.verifyRowValues(rows[b]) != 0){
closeTransaction(pNdb);
return NDBT_FAILED;
}
int updates = calc.getUpdatesValue(rows[b]) + 1;
NdbOperation* pUpdOp;
if(!ordered){
pUpdOp = pTrans->getNdbIndexOperation(idxName, tab.getName());
check = (pUpdOp == 0 ? -1 : pUpdOp->updateTuple());
} else {
pUpdOp = sOp->updateCurrentTuple();
}
if (pUpdOp == NULL) {
ERR(pTrans->getNdbError());
closeTransaction(pNdb);
return NDBT_FAILED;
}
if( check == -1 ) {
ERR(pTrans->getNdbError());
closeTransaction(pNdb);
return NDBT_FAILED;
}
if(!ordered)
{
if (equalForRow(pUpdOp, r+b) != 0)
{
closeTransaction(pNdb);
return NDBT_FAILED;
}
}
for(a = 0; a<tab.getNoOfColumns(); a++){
if (tab.getColumn(a)->getPrimaryKey() == false){
if(setValueForAttr(pUpdOp, a, r+b, updates ) != 0){
ERR(pTrans->getNdbError());
closeTransaction(pNdb);
return NDBT_FAILED;
}
}
}
}
check = pTrans->execute(Commit, AbortOnError);
if( check == -1 ) {
const NdbError err = pTrans->getNdbError();
ERR(err);
closeTransaction(pNdb);
if (err.status == NdbError::TemporaryError){
NdbSleep_MilliSleep(50);
retryAttempt++;
continue;
}
ndbout << "r = " << r << endl;
return NDBT_FAILED;
} else {
updated += batch;
m_latest_gci = pTrans->getGCI();
}
closeTransaction(pNdb);
r+= batch; // Read next record
}
g_info << "|- " << updated << " records updated" << endl;
return NDBT_OK;
}