当前位置: 首页>>代码示例>>C++>>正文


C++ NdbConnection::getNdbIndexOperation方法代码示例

本文整理汇总了C++中NdbConnection::getNdbIndexOperation方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbConnection::getNdbIndexOperation方法的具体用法?C++ NdbConnection::getNdbIndexOperation怎么用?C++ NdbConnection::getNdbIndexOperation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NdbConnection的用法示例。


在下文中一共展示了NdbConnection::getNdbIndexOperation方法的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;
//.........这里部分代码省略.........
开发者ID:liuqian1990,项目名称:mariadb-10.0,代码行数:101,代码来源:testReadPerf.cpp

示例2: deleteIndex

static void deleteIndex(Ndb &myNdb, unsigned int noOfTuples, unsigned int noOfOperations, bool includePrimary, bool oneTrans, bool longKey)
{
  Uint64 tbefore, tafter, before, after;
  NdbConnection  *myTrans;  
  NdbIndexOperation   *myOp;   
  char indexName[] = "PNUMINDEX0000";
  char name[] = "Kalle0000000";
  
  tbefore = NdbTick_CurrentMillisecond();
  if (oneTrans) myTrans = myNdb.startTransaction();
  for (unsigned int i = 0; i<noOfTuples; i++) {
    for(unsigned int j = 1; 
	((j<=noOfOperations)&&(i<noOfTuples)); 
	(++j<=noOfOperations)?i++:i) { 
      if (!oneTrans) myTrans = myNdb.startTransaction();
      if (myTrans == NULL) 
        error_handler4(__LINE__, myNdb.getNdbError());
      
      myOp = myTrans->getNdbIndexOperation(indexName, "PERSON"); 
      if (myOp == NULL) 
        error_handler4(__LINE__, myTrans->getNdbError());
      
      myOp->deleteTuple();
      if (includePrimary) {
        sprintf(name, "Kalle%.7i", i);
        if (longKey)
          memcpy(longName, name, strlen(name)); 
        if (myOp->equal("NAME", (longKey)?longName:name) == -1) {
          error_handler4(__LINE__, myTrans->getNdbError());
          myNdb.closeTransaction(myTrans);
          break;
        }         
      } 
      if (myOp->equal("PNUM1", 17) == -1) {
        error_handler4(__LINE__, myTrans->getNdbError());
      myNdb.closeTransaction(myTrans);
      break;
      }          
      if (myOp->equal("PNUM3", 19) == -1) {
        error_handler4(__LINE__, myTrans->getNdbError());
        myNdb.closeTransaction(myTrans);
        break;
      }       
    }
    if (noOfOperations == 1)
      printf("Trying to delete person %s\n", name);
    else
      printf("Trying to delete %u persons\n", noOfOperations);
    before = NdbTick_CurrentMillisecond();
    if (myTrans->execute( (oneTrans) ? NoCommit : Commit ) == -1)
      {
        error_handler4(__LINE__, myTrans->getNdbError());
        myNdb.closeTransaction(myTrans);
        break;
      }
    after = NdbTick_CurrentMillisecond();
    if (noOfOperations == 1)
      printf("Deleted person %s, %u msec\n", name, (Uint32) after - before);
    else
      printf("Deleted %u persons, %u msec\n", noOfOperations, (Uint32) after - before);
    if (!oneTrans) myNdb.closeTransaction(myTrans);
  }
  if (oneTrans) {
    if (myTrans->execute( Commit ) == -1) {
      error_handler4(__LINE__, myTrans->getNdbError());
    }
    myNdb.closeTransaction(myTrans);
  }
  tafter = NdbTick_CurrentMillisecond();

  ndbout << "Deleted "<< noOfTuples << " tuples in " << ((oneTrans) ? 1 : noOfTuples) << " transaction(s), " << tafter - tbefore << " msec" << endl;        
}
开发者ID:4T-Shirt,项目名称:mysql,代码行数:72,代码来源:index.cpp


注:本文中的NdbConnection::getNdbIndexOperation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。