本文整理汇总了C++中NdbConnection::getNdbIndexScanOperation方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbConnection::getNdbIndexScanOperation方法的具体用法?C++ NdbConnection::getNdbIndexScanOperation怎么用?C++ NdbConnection::getNdbIndexScanOperation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NdbConnection
的用法示例。
在下文中一共展示了NdbConnection::getNdbIndexScanOperation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: filter
int
run_read() {
int iter = g_paramters[P_LOOPS].value;
NDB_TICKS start1, stop;
int sum_time= 0;
const Uint32 rows = g_paramters[P_ROWS].value;
const Uint32 range = g_paramters[P_RANGE].value;
start1 = NdbTick_CurrentMillisecond();
NdbConnection * pTrans = g_ndb->startTransaction();
if(!pTrans) {
g_err << "Failed to start transaction" << endl;
err(g_ndb->getNdbError());
return -1;
}
NdbOperation * pOp;
NdbScanOperation * pSp;
NdbIndexOperation * pUp;
NdbIndexScanOperation * pIp;
Uint32 start_row = rand() % (rows - range);
Uint32 stop_row = start_row + range;
/**
* 0 - serial pk
* 1 - batch pk
* 2 - serial uniq
* 3 - batch uniq
* 4 - index eq
* 5 - range scan
* 6 - interpreted scan
*/
int check = 0;
void* res = (void*)~0;
const Uint32 pk = 0;
Uint32 cnt = 0;
for(; start_row < stop_row; start_row++) {
switch(g_paramters[P_OPER].value) {
case 0:
pOp = pTrans->getNdbOperation(g_table);
check = pOp->readTuple();
check = pOp->equal(pk, start_row);
break;
case 1:
for(; start_row<stop_row; start_row++) {
pOp = pTrans->getNdbOperation(g_table);
check = pOp->readTuple();
check = pOp->equal(pk, start_row);
for(int j = 0; j<g_tab->getNoOfColumns(); j++) {
res = pOp->getValue(j);
assert(res);
}
}
break;
case 2:
pOp = pTrans->getNdbIndexOperation(g_unique, g_table);
check = pOp->readTuple();
check = pOp->equal(pk, start_row);
break;
case 3:
for(; start_row<stop_row; start_row++) {
pOp = pTrans->getNdbIndexOperation(g_unique, g_table);
check = pOp->readTuple();
check = pOp->equal(pk, start_row);
for(int j = 0; j<g_tab->getNoOfColumns(); j++) {
res = pOp->getValue(j);
assert(res);
}
}
break;
case 4:
pOp = pSp = pIp = pTrans->getNdbIndexScanOperation(g_ordered,g_table);
pIp->readTuples(NdbScanOperation::LM_CommittedRead, 0, 0);
check = pIp->setBound(pk, NdbIndexScanOperation::BoundEQ, &start_row);
break;
case 5:
pOp = pSp = pIp = pTrans->getNdbIndexScanOperation(g_ordered,g_table);
pIp->readTuples(NdbScanOperation::LM_CommittedRead, 0, 0);
check = pIp->setBound(pk, NdbIndexScanOperation::BoundLE, &start_row);
check = pIp->setBound(pk, NdbIndexScanOperation::BoundGT, &stop_row);
start_row = stop_row;
break;
case 6:
pOp = pSp = pIp = pTrans->getNdbIndexScanOperation(g_ordered,g_table);
pIp->readTuples(NdbScanOperation::LM_CommittedRead, 0, 0, true);
check = pIp->setBound(pk, NdbIndexScanOperation::BoundLE, &start_row);
check = pIp->setBound(pk, NdbIndexScanOperation::BoundGT, &stop_row);
start_row = stop_row;
break;
case 7:
pOp = pSp = pTrans->getNdbScanOperation(g_table);
pSp->readTuples(NdbScanOperation::LM_CommittedRead, 0, 0);
NdbScanFilter filter(pOp) ;
filter.begin(NdbScanFilter::AND);
filter.ge(pk, start_row);
filter.lt(pk, stop_row);
filter.end();
start_row = stop_row;
//.........这里部分代码省略.........
示例2: filter
int
run_scan(){
int iter = g_paramters[P_LOOPS].value;
NDB_TICKS start1, stop;
int sum_time= 0;
int sample_rows = 0;
int tot_rows = 0;
NDB_TICKS sample_start = NdbTick_CurrentMillisecond();
Uint32 tot = g_paramters[P_ROWS].value;
if(g_paramters[P_BOUND].value >= 2 || g_paramters[P_FILT].value == 2)
iter *= g_paramters[P_ROWS].value;
NdbScanOperation * pOp = 0;
NdbIndexScanOperation * pIOp = 0;
NdbConnection * pTrans = 0;
int check = 0;
for(int i = 0; i<iter; i++){
start1 = NdbTick_CurrentMillisecond();
pTrans = pTrans ? pTrans : g_ndb->startTransaction();
if(!pTrans){
g_err << "Failed to start transaction" << endl;
err(g_ndb->getNdbError());
return -1;
}
int par = g_paramters[P_PARRA].value;
int bat = 0; // g_paramters[P_BATCH].value;
NdbScanOperation::LockMode lm;
switch(g_paramters[P_LOCK].value){
case 0:
lm = NdbScanOperation::LM_CommittedRead;
break;
case 1:
lm = NdbScanOperation::LM_Read;
break;
case 2:
lm = NdbScanOperation::LM_Exclusive;
break;
default:
abort();
}
if(g_paramters[P_ACCESS].value == 0){
pOp = pTrans->getNdbScanOperation(g_tablename);
assert(pOp);
pOp->readTuples(lm, bat, par);
} else {
if(g_paramters[P_RESET].value == 0 || pIOp == 0)
{
pOp= pIOp= pTrans->getNdbIndexScanOperation(g_indexname, g_tablename);
bool ord = g_paramters[P_ACCESS].value == 2;
pIOp->readTuples(lm, bat, par, ord);
}
else
{
pIOp->reset_bounds();
}
switch(g_paramters[P_BOUND].value){
case 0: // All
break;
case 1: // None
pIOp->setBound((Uint32)0, NdbIndexScanOperation::BoundEQ, 0);
break;
case 2: { // 1 row
default:
assert(g_table->getNoOfPrimaryKeys() == 1); // only impl. so far
int tot = g_paramters[P_ROWS].value;
int row = rand() % tot;
#if 0
fix_eq_bound(pIOp, row);
#else
pIOp->setBound((Uint32)0, NdbIndexScanOperation::BoundEQ, &row);
#endif
if(g_paramters[P_RESET].value == 2)
goto execute;
break;
}
case 3: { // read multi
int multi = g_paramters[P_MULTI].value;
int tot = g_paramters[P_ROWS].value;
for(; multi > 0 && i < iter; --multi, i++)
{
int row = rand() % tot;
pIOp->setBound((Uint32)0, NdbIndexScanOperation::BoundEQ, &row);
pIOp->end_of_bound(i);
}
if(g_paramters[P_RESET].value == 2)
goto execute;
break;
}
}
}
assert(pOp);
switch(g_paramters[P_FILT].value){
//.........这里部分代码省略.........