本文整理汇总了C++中NdbScanOperation::setInterpretedCode方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbScanOperation::setInterpretedCode方法的具体用法?C++ NdbScanOperation::setInterpretedCode怎么用?C++ NdbScanOperation::setInterpretedCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NdbScanOperation
的用法示例。
在下文中一共展示了NdbScanOperation::setInterpretedCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: code
int
select_count(Ndb* pNdb, const NdbDictionary::Table* pTab,
int parallelism,
Uint64* count_rows,
NdbOperation::LockMode lock) {
int retryAttempt = 0;
const int retryMax = 100;
int check;
NdbTransaction *pTrans;
NdbScanOperation *pOp;
const Uint32 codeWords= 1;
Uint32 codeSpace[ codeWords ];
NdbInterpretedCode code(NULL, // Table is irrelevant
&codeSpace[0],
codeWords);
if ((code.interpret_exit_last_row() != 0) ||
(code.finalise() != 0))
{
ERR(code.getNdbError());
return NDBT_FAILED;
}
while (true) {
if (retryAttempt >= retryMax) {
g_info << "ERROR: has retried this operation " << retryAttempt
<< " times, failing!" << endl;
return NDBT_FAILED;
}
pTrans = pNdb->startTransaction();
if (pTrans == NULL) {
const NdbError err = pNdb->getNdbError();
if (err.status == NdbError::TemporaryError) {
NdbSleep_MilliSleep(50);
retryAttempt++;
continue;
}
ERR(err);
return NDBT_FAILED;
}
pOp = pTrans->getNdbScanOperation(pTab->getName());
if (pOp == NULL) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
if( pOp->readTuples(NdbScanOperation::LM_Dirty) ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
check = pOp->setInterpretedCode(&code);
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
Uint64 tmp;
Uint32 row_size;
pOp->getValue(NdbDictionary::Column::ROW_COUNT, (char*)&tmp);
pOp->getValue(NdbDictionary::Column::ROW_SIZE, (char*)&row_size);
check = pTrans->execute(NdbTransaction::NoCommit);
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
Uint64 row_count = 0;
int eof;
while((eof = pOp->nextResult(true)) == 0) {
row_count += tmp;
}
if (eof == -1) {
const NdbError err = pTrans->getNdbError();
if (err.status == NdbError::TemporaryError) {
pNdb->closeTransaction(pTrans);
NdbSleep_MilliSleep(50);
retryAttempt++;
continue;
}
ERR(err);
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
pNdb->closeTransaction(pTrans);
if (count_rows != NULL) {
*count_rows = row_count;
}
//.........这里部分代码省略.........
示例2: runTestBug34107
int runTestBug34107(NDBT_Context* ctx, NDBT_Step* step){
const NdbDictionary::Table * pTab = ctx->getTab();
Ndb* pNdb = GETNDB(step);
const Uint32 okSize= 10000;
const Uint32 tooBig= 30000;
Uint32 codeBuff[tooBig];
int i;
for (i = 0; i <= 1; i++) {
g_info << "bug34107:" << (i == 0 ? " small" : " too big") << endl;
NdbConnection* pTrans = pNdb->startTransaction();
if (pTrans == NULL){
ERR(pNdb->getNdbError());
return NDBT_FAILED;
}
NdbScanOperation* pOp = pTrans->getNdbScanOperation(pTab->getName());
if (pOp == NULL) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
if (pOp->readTuples() == -1) {
ERR(pOp->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
/* Test kernel mechanism for dealing with too large program
* We need to provide our own program buffer as default
* NdbInterpretedCode buffer will not grow larger than
* NDB_MAX_SCANFILTER_SIZE
*/
NdbInterpretedCode code(NULL, // Table is irrelevant
codeBuff,
tooBig); // Size of codeBuff
int n = i == 0 ? okSize : tooBig;
int k;
for (k = 0; k < n; k++) {
// inserts 1 word ATTRINFO
if (code.interpret_exit_ok() == -1) {
ERR(code.getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
}
if (code.finalise() != 0)
{
ERR(code.getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
if (pOp->setInterpretedCode(&code) != 0)
{
ERR(pOp->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
if (pTrans->execute(NoCommit) == -1) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
int ret;
while ((ret = pOp->nextResult()) == 0)
;
g_info << "ret=" << ret << " err=" << pOp->getNdbError().code << endl;
if (i == 0 && ret != 1) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
if (i == 1 && ret != -1) {
g_err << "unexpected big filter success" << endl;
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
if (i == 1 && pOp->getNdbError().code != 874) {
g_err << "unexpected big filter error code, wanted 874" << endl;
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
pNdb->closeTransaction(pTrans);
}
//.........这里部分代码省略.........