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


C++ NdbOperation::getValue方法代码示例

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


在下文中一共展示了NdbOperation::getValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: scan_rows

void scan_rows(Ndb* pMyNdb, int opType, int tupleType, int scanType) {

    int           check = -1 ;
    int           loop_count_ops = nRecords ;
    int           eOf = -1 ;
    int           readValue = 0 ;
    int           readValue2 = 0 ;
    int           scanCount = 0 ;
    TTYPE         fail = NO_FAIL ;

    for (int count=0 ; count < loop_count_ops ; count++)    {
        NdbConnection* MyTransaction = pMyNdb->startTransaction();
        if (!MyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL);

        NdbOperation*  MyOperation = MyTransaction->getNdbOperation(tableName);
        if (!MyOperation) error_handler(pMyNdb->getNdbError(), NO_FAIL);

        if (opType == 1)
            // Open for scan read, Creates the SCAN_TABREQ and if needed
            // SCAN_TABINFO signals.
            check = MyOperation->openScanRead(1);
        else if (opType == 2)
            // Open for scan with update of rows.
            check = MyOperation->openScanExclusive(1);

        // Create ATTRINFO signal(s) for interpreted program used for
        // defining search criteria and column values that should be returned.

        scanCount = count+1 ;

        switch(tupleType) {
        case 1:
            fail = t_exitMethods(scanCount, MyOperation,  opType);
            break;
        case 2:
            fail = t_incValue(scanCount, MyOperation);
            break;
        case 3:
            fail = t_subValue(scanCount, MyOperation);
            break;
        case 4:
            fail = t_readAttr(scanCount, MyOperation);
            break;
        case 5:
            fail = t_writeAttr(scanCount, MyOperation);
            break;
        case 6:
            fail = t_loadConst(scanCount, MyOperation,  opType);
            break;
        case 7:
            fail = t_branch(scanCount, MyOperation);
            break;
        case 8:
            fail = t_branchIfNull(scanCount, MyOperation);
            break;
        case 9:
            fail = t_addReg(scanCount, MyOperation);
            break;
        case 10:
            fail = t_subReg(scanCount, MyOperation);
            break;
        case 11:
            fail = t_subroutineWithBranchLabel(scanCount, MyOperation);
            break;
        default:
            break ;
        }

        if(11 != tupleType) MyOperation->getValue(attrName[1], (char*)&readValue);

        // Sends the SCAN_TABREQ, (SCAN_TABINFO) and ATTRINFO signals and then
        // reads the answer in TRANSID_AI. Confirmation is received through SCAN_TABCONF or
        // SCAN_TABREF if failure.
        check = MyTransaction->executeScan();
        if (check == -1) {
            //ndbout << endl << "executeScan returned: " << MyTransaction->getNdbError() << endl;
            error_handler(MyTransaction->getNdbError(), fail) ;
            pMyNdb->closeTransaction(MyTransaction);
        } else {
            // Sends the SCAN_NEXTREQ signal(s) and reads the answer in TRANS_ID signals.
            // SCAN_TABCONF or SCAN_TABREF is the confirmation.
            while ((eOf = MyTransaction->nextScanResult()) == 0) {
                ndbout << readValue <<"; ";
                // Here we call takeOverScanOp for update of the tuple.
            }
            ndbout << endl ;

            pMyNdb->closeTransaction(MyTransaction);
            if (eOf == -1) {
                ndbout << endl << "nextScanResult returned: "<< MyTransaction->getNdbError() << endl;
            } else {
                ndbout << "OK" << endl;
            }
        }
    }
    return;

};
开发者ID:colingpt,项目名称:mysql-5.5.36,代码行数:98,代码来源:interpreterInTup.cpp

示例2: update_rows

void  update_rows(Ndb* pMyNdb, int tupleType, int opType) {
    /****************************************************************
    *    Update rows in SimpleTable
    *    Only updates the first 3 cols.
    ***************************************************************/

    int check = -1 ;
    int loop_count_ops = nRecords ;
    int readValue[MAXATTR] = {0} ;
    TTYPE ret_val = NO_FAIL ;
    NdbConnection     *MyTransaction = NULL ;
    NdbOperation      *MyOperation = NULL ;

    ndbout << "Updating records ..." << endl << endl;

    for (int count=0 ; count < loop_count_ops ; count++) {

        MyTransaction = pMyNdb->startTransaction();
        if (!MyTransaction) {
            error_handler(pMyNdb->getNdbError(), NO_FAIL);
            return;
        }//if

        MyOperation = MyTransaction->getNdbOperation(tableName);
        if (MyOperation == NULL) {
            error_handler(pMyNdb->getNdbError(), NO_FAIL);
            return;
        }//if

        //   if (operationType == 3)
        check = MyOperation->interpretedUpdateTuple();
        // else if (operationType == 4)
        // check = MyOperation->interpretedDirtyUpdate();
        if( check == -1 )
            error_handler(MyTransaction->getNdbError(), NO_FAIL);

        check = MyOperation->equal( attrName[0], (char*)&pkValue[count] );
        if( check == -1 )
            error_handler(MyTransaction->getNdbError(), NO_FAIL);

        switch(tupleType) {
        case 1:
            ret_val = t_exitMethods(count+1, MyOperation,  opType);
            break;
        case 2:
            ret_val = t_incValue(count+1, MyOperation);
            break;
        case 3:
            ret_val = t_subValue(count+1, MyOperation);
            break;
        case 4:
            ret_val = t_readAttr(count+1, MyOperation);
            break;
        case 5:
            ret_val = t_writeAttr(count+1, MyOperation);
            break;
        case 6:
            ret_val = t_loadConst(count+1, MyOperation,  opType);
            break;
        case 7:
            ret_val = t_branch(count+1, MyOperation);
            break;
        case 8:
            ret_val = t_branchIfNull(count+1, MyOperation);
            break;
        case 9:
            ret_val = t_addReg(count+1, MyOperation);
            break;
        case 10:
            ret_val = t_subReg(count+1, MyOperation);
            break;
        case 11:
            ret_val = t_subroutineWithBranchLabel(count+1, MyOperation);
            break;
        default:
            break ;
        }

        MyOperation->getValue("COL1", (char*)&readValue);

        if (MyTransaction->execute( Commit ) == -1 ) {
            error_handler(MyTransaction->getNdbError(), ret_val);
        } else if (NO_FAIL == ret_val ) {
            ndbout << "OK" << endl;
        } else {
            bTestPassed = -1;
            ndbout << "Test passed when expected to fail" << endl;
        }//if
        pMyNdb->closeTransaction(MyTransaction);

    }

    ndbout << "Finished updating records" << endl;
    return;
};
开发者ID:colingpt,项目名称:mysql-5.5.36,代码行数:95,代码来源:interpreterInTup.cpp

示例3: runTestBug19537

int runTestBug19537(NDBT_Context* ctx, NDBT_Step* step){
  int result = NDBT_OK;
  const NdbDictionary::Table * pTab = ctx->getTab();
  Ndb* pNdb = GETNDB(step);

  if (strcmp(pTab->getName(), "T1") != 0) {
    g_err << "runTestBug19537: skip, table != T1" << endl;
    return NDBT_OK;
  }


  NdbConnection* pTrans = pNdb->startTransaction();
  if (pTrans == NULL){
    ERR(pNdb->getNdbError());
    return NDBT_FAILED;
  }
  
  NdbOperation* pOp = pTrans->getNdbOperation(pTab->getName());
  if (pOp == NULL) {
    ERR(pTrans->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }
  
  if (pOp->interpretedUpdateTuple() == -1) {
    ERR(pOp->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }
  
  
  // Primary keys
  const Uint32 pkVal = 1;
  if (pOp->equal("KOL1", pkVal) == -1) {
    ERR(pTrans->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }
  
  // Load 64-bit constant into register 1 and
  // write from register 1 to 32-bit column KOL2
  const Uint64 reg_val = 0x0102030405060708ULL;

  const Uint32* reg_ptr32 = (const Uint32*)&reg_val;
  if (reg_ptr32[0] == 0x05060708 && reg_ptr32[1] == 0x01020304) {
    g_err << "runTestBug19537: platform is LITTLE endian" << endl;
  } else if (reg_ptr32[0] == 0x01020304 && reg_ptr32[1] == 0x05060708) {
    g_err << "runTestBug19537: platform is BIG endian" << endl;
  } else {
    g_err << "runTestBug19537: impossible platform"
          << hex << " [0]=" << reg_ptr32[0] << " [1]=" <<reg_ptr32[1] << endl;
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }

  if (pOp->load_const_u64(1, reg_val) == -1 ||
      pOp->write_attr("KOL2", 1) == -1) {
    ERR(pOp->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }

  if (pTrans->execute(Commit) == -1) {
    ERR(pTrans->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }

  // Read value via a new transaction

  pTrans = pNdb->startTransaction();
  if (pTrans == NULL){
    ERR(pNdb->getNdbError());
    return NDBT_FAILED;
  }
  
  pOp = pTrans->getNdbOperation(pTab->getName());
  if (pOp == NULL) {
    ERR(pTrans->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }
  
  Uint32 kol2 = 0x09090909;
  if (pOp->readTuple() == -1 ||
      pOp->equal("KOL1", pkVal) == -1 ||
      pOp->getValue("KOL2", (char*)&kol2) == 0) {
    ERR(pOp->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }

  if (pTrans->execute(Commit) == -1) {
    ERR(pTrans->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }

  // Expected conversion as in C - truncate to lower (logical) word

//.........这里部分代码省略.........
开发者ID:Abner-Sun,项目名称:mysql5.1-vx-pre1,代码行数:101,代码来源:testInterpreter.cpp

示例4: runTestIncValue32

int runTestIncValue32(NDBT_Context* ctx, NDBT_Step* step){
  int result = NDBT_OK;
  const NdbDictionary::Table * pTab = ctx->getTab();
  Ndb* pNdb = GETNDB(step);

  if (strcmp(pTab->getName(), "T1") != 0) {
    g_err << "runTestBug19537: skip, table != T1" << endl;
    return NDBT_OK;
  }


  NdbConnection* pTrans = pNdb->startTransaction();
  if (pTrans == NULL){
    ERR(pNdb->getNdbError());
    return NDBT_FAILED;
  }
  
  NdbOperation* pOp = pTrans->getNdbOperation(pTab->getName());
  if (pOp == NULL) {
    ERR(pTrans->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }
  
  int check = pOp->interpretedUpdateTuple();
  if( check == -1 ) {
    ERR(pTrans->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }
  
  
  // Primary keys
  Uint32 pkVal = 1;
  check = pOp->equal("KOL1", pkVal );
  if( check == -1 ) {
    ERR(pTrans->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }
  
  // Attributes
  
  // Update column
  Uint32 valToIncWith = 1;
  check = pOp->incValue("KOL2", valToIncWith);
  if( check == -1 ) {
    ERR(pTrans->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }

  NdbRecAttr* valueRec = pOp->getValue("KOL2");
  if( valueRec == NULL ) {
    ERR(pTrans->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }
  
  check = pTrans->execute(Commit);
  if( check == -1 ) {
    ERR(pTrans->getNdbError());
    pNdb->closeTransaction(pTrans);
    return NDBT_FAILED;
  }

  Uint32 value = valueRec->u_32_value();
    
  pNdb->closeTransaction(pTrans);


  return NDBT_OK;
}
开发者ID:Abner-Sun,项目名称:mysql5.1-vx-pre1,代码行数:73,代码来源:testInterpreter.cpp

示例5: run_slave_wait

static void run_slave_wait(struct Xxx &xxx, struct XxxR &xxxr)
{
  struct timeval old_end_time = xxxr.start_time, end_time;
  Ndb *ndb = xxx.ndb;
  const NdbDictionary::Table *myTable = xxx.table;
  int retry_sleep= 10; /* 10 milliseconds */
  int retries= 100;
  while (1)
  {
    Uint32 val;
    NdbTransaction *trans = ndb->startTransaction();
    if (trans == NULL)
      goto err;
    {
      NdbOperation *op = trans->getNdbOperation(myTable);
      if (op == NULL)
        APIERROR(trans->getNdbError());
      op->readTuple();
      op->equal(xxx.pk_col, xxxr.pk_val);
      op->getValue(xxx.col, (char *)&val);
      if (trans->execute(NdbTransaction::Commit))
        goto err;
    }
    /* read done, check time of read */
    gettimeofday(&end_time, 0);
    ndb->closeTransaction(trans);
    //fprintf(stderr, "read %u waiting for %u\n", val, xxxr.val);
    if (xxxr.val != val)
    {
      /* expected value not received yet */
      retries = 100;
      NdbSleep_MilliSleep(retry_sleep);
      old_end_time =  end_time;
      continue;
    }
    break;
err:
    const NdbError this_error= trans ?
      trans->getNdbError() : ndb->getNdbError();
    if (this_error.status == NdbError::TemporaryError)
    {
      if (retries--)
      {
        if (trans)
          ndb->closeTransaction(trans);
        NdbSleep_MilliSleep(retry_sleep);
        continue; // retry
      }
    }
    if (trans)
      ndb->closeTransaction(trans);
    APIERROR(this_error);
  }

  Int64 elapsed_usec1 =
    ((Int64)end_time.tv_sec - (Int64)xxxr.start_time.tv_sec)*1000*1000 +
    ((Int64)end_time.tv_usec - (Int64)xxxr.start_time.tv_usec);
  Int64 elapsed_usec2 =
    ((Int64)end_time.tv_sec - (Int64)old_end_time.tv_sec)*1000*1000 +
    ((Int64)end_time.tv_usec - (Int64)old_end_time.tv_usec);
  xxxr.latency =
    ((elapsed_usec1 - elapsed_usec2/2)+999)/1000;
}
开发者ID:A-eolus,项目名称:mysql,代码行数:63,代码来源:rep_latency.cpp

示例6: readTable

static void readTable(Ndb &myNdb, unsigned int noOfTuples, unsigned int noOfOperations, bool oneTrans, bool twoKey, bool longKey)
{
  Uint64 tbefore, tafter, before, after;
  NdbConnection  *myTrans;  
  NdbOperation   *myOp;   
  char name[] = "Kalle0000000";
  NdbRecAttr* myRecAttrArr[MAX_NO_PARALLEL_OPERATIONS];
  
  tbefore = NdbTick_CurrentMillisecond();
  if (oneTrans) myTrans = myNdb.startTransaction();
  for (unsigned int i = 0; i<noOfTuples; i++) {
    if (!oneTrans) myTrans = myNdb.startTransaction();
    for(unsigned int j = 1; 
	((j<=noOfOperations)&&(i<noOfTuples)); 
	(++j<=noOfOperations)?i++:i) { 
      if (myTrans == NULL) 
        error_handler4(__LINE__, myNdb.getNdbError());
      
      myOp = myTrans->getNdbOperation("PERSON"); 
      if (myOp == NULL) 
        error_handler4(__LINE__, myTrans->getNdbError());
      
      myOp->readTuple();
      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 (twoKey)
        if (myOp->equal("KEY2", i) == -1) {
          error_handler4(__LINE__, myTrans->getNdbError());
          myNdb.closeTransaction(myTrans);
          break;
        }      
      myRecAttrArr[j-1] = myOp->getValue("PNUM2", NULL);
    }
    if (noOfOperations == 1)
      printf("Trying to read person %s\n", name);
    else
      printf("Trying to read %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("Read person %s, %u msec\n", name, (Uint32) after - before);
    else
      printf("Read %u persons, %u msec\n", noOfOperations, (Uint32) after - before);
    for(unsigned int j = 0; j<noOfOperations; j++)
      printf("PNUM2 = %u\n", myRecAttrArr[j]->u_32_value());
    if (!oneTrans) myNdb.closeTransaction(myTrans);
  }
  if (oneTrans) {
    if (myTrans->execute( Commit ) == -1) {
      error_handler4(__LINE__, myTrans->getNdbError());
    }
    myNdb.closeTransaction(myTrans);
  }
  tafter = NdbTick_CurrentMillisecond();

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

示例7: memcpy

/**
 * Transaction 5 - T5
 * 
 * Delete session
 *
 * Input:
 *   SubscriberNumber
 *   ServerId
 *   ServerBit
 *   DoRollback
 * Output:
 *   ChangedBy
 *   ChangedTime
 *   Location
 *   BranchExecuted
 */
void
userTransaction_T5(UserHandle * uh,
		   SubscriberNumber   inNumber,
		   ServerId           inServerId,
		   ServerBit          inServerBit,
		   DoRollback         inDoRollback,
		   BranchExecuted   * outBranchExecuted){
  Ndb * pNDB = uh->pNDB;

  DEBUG3("T5(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId);

  NdbConnection * MyTransaction = 0;
  NdbOperation  * MyOperation = 0;

  char             outChangedBy   [sizeof(ChangedBy)  +(4-(sizeof(ChangedBy)   & 3))];
  char             outChangedTime [sizeof(ChangedTime)+(4-(sizeof(ChangedTime) & 3))];
  Location         outLocation;
  GroupId          groupId;
  ActiveSessions   sessions;
  Permission       permission;
  SubscriberSuffix inSuffix;

  int check;
  NdbRecAttr * check2;

  MyTransaction = pNDB->startTransaction();
  if (MyTransaction == NULL)	  
    error_handler("T5-1: startTranscation", pNDB->getNdbErrorString(), pNDB->getNdbError());
  
  MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
  CHECK_NULL(MyOperation, "T5-1: getNdbOperation", 
	     MyTransaction);
  
  MyOperation->interpretedUpdateTuple();
  MyOperation->equal(IND_SUBSCRIBER_NUMBER, 
		     inNumber);
  MyOperation->getValue(IND_SUBSCRIBER_LOCATION, 
		        (char *)&outLocation);
  MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, 
			&outChangedBy[0]);
  MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, 
                        &outChangedTime[0]);
  MyOperation->getValue(IND_SUBSCRIBER_GROUP,
		        (char *)&groupId);
  MyOperation->getValue(IND_SUBSCRIBER_SESSIONS,
		        (char *)&sessions);
  MyOperation->subValue(IND_SUBSCRIBER_SESSIONS, 
		        (uint32)inServerBit);
  MyTransaction->execute( NoCommit ); 
    /* Operation 2 */

  MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE);
  CHECK_NULL(MyOperation, "T5-2: getNdbOperation", 
	     MyTransaction);
    
  MyOperation->readTuple();
  MyOperation->equal(IND_GROUP_ID,
		     (char*)&groupId);
  MyOperation->getValue(IND_GROUP_ALLOW_DELETE, 
			(char *)&permission);
  check = MyTransaction->execute( NoCommit ); 
  CHECK_MINUS_ONE(check, "T5-2: NoCommit", 
		  MyTransaction);
  
  if(((permission & inServerBit) == inServerBit) &&
     ((sessions   & inServerBit) == inServerBit)){
  
    memcpy(inSuffix,
	   &inNumber[SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH], SUBSCRIBER_NUMBER_SUFFIX_LENGTH);
    
    DEBUG2("deleting(%.*s) - ", SUBSCRIBER_NUMBER_SUFFIX_LENGTH, inSuffix);

    /* Operation 3 */
    MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE);
    CHECK_NULL(MyOperation, "T5-3: getNdbOperation", 
	       MyTransaction);
    
    MyOperation->deleteTuple();
    MyOperation->equal(IND_SESSION_SUBSCRIBER,
		       (char*)inNumber);
    MyOperation->equal(IND_SESSION_SERVER,
		       (char*)&inServerId);
    /* Operation 4 */
        
//.........这里部分代码省略.........
开发者ID:SunguckLee,项目名称:MariaDB,代码行数:101,代码来源:ndb_user_transaction6.cpp

示例8: DEBUG

/**
 * Transaction 5 - T5
 *
 * Delete session
 *
 * Input:
 *   SubscriberNumber
 *   ServerId
 *   ServerBit
 *   DoRollback
 * Output:
 *   ChangedBy
 *   ChangedTime
 *   Location
 *   BranchExecuted
 */
int
T5(void * obj,
   const SubscriberNumber   inNumber,
   const SubscriberSuffix   inSuffix,
   const ServerId           inServerId,
   const ServerBit          inServerBit,
   ChangedBy          outChangedBy,
   ChangedTime        outChangedTime,
   Location         * outLocation,
   DoRollback         inDoRollback,
   BranchExecuted   * outBranchExecuted,
   BenchmarkTime    * outTransactionTime) {

    Ndb           * pNDB = (Ndb *) obj;
    NdbConnection * MyTransaction = 0;
    NdbOperation  * MyOperation = 0;

    GroupId        groupId;
    ActiveSessions sessions;
    Permission     permission;

    BenchmarkTime start;
    get_time(&start);

    int check;
    NdbRecAttr * check2;

    MyTransaction = pNDB->startTransaction();
    if (MyTransaction == NULL)
        error_handler("T5-1: startTranscation", pNDB->getNdbErrorString(), 0);

    MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
    CHECK_NULL(MyOperation, "T5-1: getNdbOperation",
               MyTransaction);


    check = MyOperation->readTupleExclusive();
    CHECK_MINUS_ONE(check, "T5-1: readTuple",
                    MyTransaction);

    check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
                               inNumber);
    CHECK_MINUS_ONE(check, "T5-1: equal subscriber",
                    MyTransaction);

    check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION,
                                   (char *)outLocation);
    CHECK_NULL(check2, "T5-1: getValue location",
               MyTransaction);

    check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY,
                                   outChangedBy);
    CHECK_NULL(check2, "T5-1: getValue changed_by",
               MyTransaction);

    check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME,
                                   outChangedTime);
    CHECK_NULL(check2, "T5-1: getValue changed_time",
               MyTransaction);

    check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP,
                                   (char *)&groupId);
    CHECK_NULL(check2, "T5-1: getValue group",
               MyTransaction);

    check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS,
                                   (char *)&sessions);
    CHECK_NULL(check2, "T5-1: getValue sessions",
               MyTransaction);

    check = MyTransaction->execute( NoCommit );
    CHECK_MINUS_ONE(check, "T5-1: NoCommit",
                    MyTransaction);

    /* Operation 2 */

    MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE);
    CHECK_NULL(MyOperation, "T5-2: getNdbOperation",
               MyTransaction);


    check = MyOperation->readTuple();
    CHECK_MINUS_ONE(check, "T5-2: readTuple",
                    MyTransaction);
//.........这里部分代码省略.........
开发者ID:bobsense,项目名称:packages,代码行数:101,代码来源:ndb_user_transaction2.cpp

示例9: 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:4T-Shirt,项目名称:mysql,代码行数:101,代码来源:testReadPerf.cpp

示例10: allocTransactions

int 
HugoAsynchTransactions::executeAsynchOperation(Ndb* pNdb,		      
					 int records,
					 int batch,
					 int trans,
					 int operations,
					 NDB_OPERATION theOperation,
					 ExecType theType) {

  int             check = 0;
  //  int             retryAttempt = 0;  // Not used at the moment
  //  int             retryMax = 5;      // Not used at the moment
  int             cTrans = 0;
  int             cRecords = 0;
  int             cIndex = 0;
  int a,t,r;

  transactionsCompleted = 0;
  allocTransactions(trans);

  for (int i = 0; i < batch; i++) { // For each batch
    while (cRecords < records*batch) {
      cTrans = 0;
      cIndex = 0;
      for (t = 0; t < trans; t++) { // For each transaction
	transactions[t] = pNdb->startTransaction();
	if (transactions[t] == NULL) {
	  ERR(pNdb->getNdbError());
	  return NDBT_FAILED;
	}	
	for (int k = 0; k < operations; k++) { // For each operation
	  NdbOperation* pOp = transactions[t]->getNdbOperation(tab.getName());
	  if (pOp == NULL) { 
	    ERR(transactions[t]->getNdbError());
	    pNdb->closeTransaction(transactions[t]);
	    return NDBT_FAILED;
	  }
	  
	  switch (theOperation) {
	  case NO_INSERT: 
	    // Insert
	    check = pOp->insertTuple();
	    if (check == -1) { 
	      ERR(transactions[t]->getNdbError());
	      pNdb->closeTransaction(transactions[t]);
	      return NDBT_FAILED;
	    }
	    
	    // Set a calculated value for each attribute in this table	 
	    for (a = 0; a < tab.getNoOfColumns(); a++) {
	      if (setValueForAttr(pOp, a, cRecords, 0 ) != 0) {	  
		ERR(transactions[t]->getNdbError());
		pNdb->closeTransaction(transactions[t]);	  
		return NDBT_FAILED;
	      }
	    } // For each attribute
	    break;
	  case NO_UPDATE:
	    // This is a special case and is handled in the calling client...
	    break;
	  break;
	  case NO_READ:
	    // Define primary keys
	    check = pOp->readTuple();
            if (equalForRow(pOp, cRecords) != 0)
            {
              ERR(transactions[t]->getNdbError());
              pNdb->closeTransaction(transactions[t]);
              return NDBT_FAILED;
            }	    
	    // Define attributes to read  
	    for (a = 0; a < tab.getNoOfColumns(); a++) {
	      if ((rows[cIndex]->attributeStore(a) = 
		   pOp->getValue(tab.getColumn(a)->getName())) == 0) {
		ERR(transactions[t]->getNdbError());
		pNdb->closeTransaction(transactions[t]);
		return NDBT_FAILED;
	      }
	    }	    	  
	    break;
	  case NO_DELETE:
	    // Delete
	    check = pOp->deleteTuple();
	    if (check == -1) { 
	      ERR(transactions[t]->getNdbError());
	      pNdb->closeTransaction(transactions[t]);
	      return NDBT_FAILED;
	    }

	    // Define primary keys
            if (equalForRow(pOp, cRecords) != 0)
            {
              ERR(transactions[t]->getNdbError());
              pNdb->closeTransaction(transactions[t]);
              return NDBT_FAILED;
            }    
	    break;
	  default:
	    // Should not happen...
	    pNdb->closeTransaction(transactions[t]);		
//.........这里部分代码省略.........
开发者ID:0x00xw,项目名称:mysql-2,代码行数:101,代码来源:HugoAsynchTransactions.cpp

示例11: allocRows

int 
HugoAsynchTransactions::pkUpdateRecordsAsynch(Ndb* pNdb, 
					int records,
					int batch,
					int trans,
					int operations) {

  g_info << "|- Updating records asynchronous..." << endl;

  int             check = 0;
  int             cTrans = 0;
  int             cReadRecords = 0;
  int             cReadIndex = 0;
  int             cRecords = 0;
  int             cIndex = 0;

  transactionsCompleted = 0;

  allocRows(trans*operations);
  allocTransactions(trans);
  int a, t, r;

  for (int i = 0; i < batch; i++) { // For each batch
    while (cRecords < records*batch) {
      cTrans = 0;
      cReadIndex = 0;
      for (t = 0; t < trans; t++) { // For each transaction
	transactions[t] = pNdb->startTransaction();
	if (transactions[t] == NULL) {
	  ERR(pNdb->getNdbError());
	  return NDBT_FAILED;
	}	
	for (int k = 0; k < operations; k++) { // For each operation
	  NdbOperation* pOp = transactions[t]->getNdbOperation(tab.getName());
	  if (pOp == NULL) { 
	    ERR(transactions[t]->getNdbError());
	    pNdb->closeTransaction(transactions[t]);
	    return NDBT_FAILED;
	  }
	  
	  // Read
	  // Define primary keys
	  check = pOp->readTupleExclusive();
          if (equalForRow(pOp, cReadRecords) != 0)
          {
            ERR(transactions[t]->getNdbError());
            pNdb->closeTransaction(transactions[t]);
            return NDBT_FAILED;
	  }	    
	  // Define attributes to read  
	  for (a = 0; a < tab.getNoOfColumns(); a++) {
	    if ((rows[cReadIndex]->attributeStore(a) = 
		 pOp->getValue(tab.getColumn(a)->getName())) == 0) {
	      ERR(transactions[t]->getNdbError());
	      pNdb->closeTransaction(transactions[t]);
	      return NDBT_FAILED;
	    }
	  }	    	  
	  cReadIndex++;
	  cReadRecords++;
	  
	} // For each operation
	
	// Let's prepare...
	transactions[t]->executeAsynchPrepare(NoCommit, &asynchCallback, 
					this);
	cTrans++;

	if (cReadRecords >= records) {
	  // No more transactions needed
	  break;
	}      
      } // For each transaction

      // Wait for all outstanding transactions
      pNdb->sendPollNdb(3000, 0, 0);

      // Verify the data!
      for (r = 0; r < trans*operations; r++) {
	if (calc.verifyRowValues(rows[r]) != 0) {
	  g_info << "|- Verify failed..." << endl;
	  // Close all transactions
	  for (int t = 0; t < cTrans; t++) {
	    pNdb->closeTransaction(transactions[t]);
	  }
	  return NDBT_FAILED;
	}
      }	

      // Update
      cTrans = 0;
      cIndex = 0;
      for (t = 0; t < trans; t++) { // For each transaction
	for (int k = 0; k < operations; k++) { // For each operation
	  NdbOperation* pOp = transactions[t]->getNdbOperation(tab.getName());
	  if (pOp == NULL) { 
	    ERR(transactions[t]->getNdbError());
	    pNdb->closeTransaction(transactions[t]);
	    return NDBT_FAILED;
	  }
//.........这里部分代码省略.........
开发者ID:0x00xw,项目名称:mysql-2,代码行数:101,代码来源:HugoAsynchTransactions.cpp


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