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


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

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


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

示例1: require

static
void
lookup(){
  {
    NdbOperation* op = g_trans->getNdbOperation("artists");
    require2(g_trans, op);
    require2(op, op->readTuple() == 0);
    require2(op, op->equal("artistid", g_artistid) == 0);
    require2(op, op->getValue("name"));
  }
  
  {
    NdbOperation* op = g_trans->getNdbOperation("subgenres");
    require2(g_trans, op);
    require2(op, op->readTuple() == 0);
    require2(op, op->equal("subgenreid", g_subgenreid) == 0);
    require2(op, op->getValue("name"));
  }

  static int loop = 0;
  if(loop++ >= 16){
    loop = 0;
    require(g_trans->execute(NoCommit) == 0);
  }
  //require(g_trans->restart() == 0);
}
开发者ID:Suker-Xu,项目名称:david-mysql-tools,代码行数:26,代码来源:slow_select.cpp

示例2:

void
T5_Callback_1(int result, NdbConnection * pCON, void * threadData){
  ThreadData * td = (ThreadData *)threadData;  
  if (result == -1) {
    CHECK_ALLOWED_ERROR("T5-1: execute", td, pCON->getNdbError());
    td->pNDB->closeTransaction(pCON);
    start_T5(td->pNDB, td, stat_async);
    return;
  }//if

  DEBUG3("T5(%.*s, %.2d): - Callback 1", 
	 SUBSCRIBER_NUMBER_LENGTH, 
	 td->transactionData.number, 
	 td->transactionData.server_id);
  
  NdbOperation * MyOp = pCON->getNdbOperation(GROUP_TABLE);
  CHECK_NULL(MyOp, "T5-2: getNdbOperation", td,
	     pCON->getNdbError());
  
  MyOp->readTuple();
  MyOp->equal(IND_GROUP_ID,
	      (char*)&td->transactionData.group_id);
  MyOp->getValue(IND_GROUP_ALLOW_DELETE, 
		 (char *)&td->transactionData.permission);
  if (stat_async == 1) {
    pCON->executeAsynchPrepare( NoCommit , T5_Callback_2, td);
  } else {
    int result = pCON->execute( NoCommit );
    T5_Callback_2(result, pCON, (void*)td);
    return;
  }//if
}
开发者ID:4T-Shirt,项目名称:mysql,代码行数:32,代码来源:ndb_async2.cpp

示例3: handleUpdate

void DatasetTableTailer::handleUpdate(NdbRecAttr* value[]) {
    int datasetPK = value[DS_ID_PK]->int32_value();
    int datasetId = -1;
    int projectId = -1;
    if(value[DS_INODE_ID]->isNULL() == -1){
        const NdbDictionary::Dictionary* database = getDatabase(mNdbConnection);
        const NdbDictionary::Table* table = getTable(database, TABLE.mTableName);
        NdbTransaction* transaction = startNdbTransaction(mNdbConnection);
        NdbOperation* op = getNdbOperation(transaction, table);
        
        op->readTuple(NdbOperation::LM_CommittedRead);
        
        op->equal(_dataset_cols[8].c_str(), datasetPK);
        
        NdbRecAttr* datasetIdCol = getNdbOperationValue(op, _dataset_cols[DS_INODE_ID]);
        NdbRecAttr* projectIdCol = getNdbOperationValue(op, _dataset_cols[DS_PROJ_ID]);
        
        executeTransaction(transaction, NdbTransaction::Commit);        
        datasetId = datasetIdCol->int32_value();
        projectId = projectIdCol->int32_value();
        
        transaction->close();
    }
    
    if(datasetId == -1 || projectId == -1){
        LOG_ERROR("Couldn't resolve projectId[" << projectId << "] or datasetId[" << datasetId << "]");
        return;
    }
    
     
    string data = createJSONUpSert(projectId, value);
    if (mElasticSearch->addDataset(projectId, datasetId, data)) {
        LOG_INFO("Update Dataset[" << datasetId << "]: Succeeded");
    }
}
开发者ID:hopshadoop,项目名称:ePipe,代码行数:35,代码来源:DatasetTableTailer.cpp

示例4: read_and_verify_rows

void read_and_verify_rows(Ndb* pMyNdb, bool pre) {

    int               check = -1 ;
    int               loop_count_ops = nRecords;
    char              expectedCOL1[NUMBEROFRECORDS] = {0} ;
    char              expectedCOL2[NUMBEROFRECORDS] = {0} ;
    NdbConnection     *pMyTransaction = NULL ;
    NdbOperation      *MyOp = NULL ;
    NdbRecAttr*       tTmp = NULL ;
    int               readValue[MAXATTR] = {0} ;

    ndbout << "Verifying records...\n"<< endl;

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

        pMyTransaction = pMyNdb->startTransaction();
        if (!pMyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL);

        MyOp = pMyTransaction->getNdbOperation(tableName);
        if (!MyOp) error_handler( pMyTransaction->getNdbError(), NO_FAIL);


        check = MyOp->readTuple();
        if( check == -1 ) error_handler( MyOp->getNdbError(), NO_FAIL);

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

        for (int count_attributes = 1; count_attributes < MAXATTR; count_attributes++) {

            tTmp = MyOp->getValue( (char*)attrName[count_attributes], (char*)&readValue[count_attributes] );
            if(!tTmp) error_handler( MyOp->getNdbError(), NO_FAIL);
        }

        if( pMyTransaction->execute( Commit ) == -1 ) {
            error_handler(pMyTransaction->getNdbError(), NO_FAIL);
        } else {
            if (pre) {
                expectedCOL1[count] = readValue[1];
                expectedCOL2[count] = readValue[2];
            }

            ndbout << attrName[1] << "\t " << readValue[1] << "\t "
                   << attrName[2] << "\t " << readValue[2] << endl;
        }

        pMyNdb->closeTransaction(pMyTransaction);

    }

    ndbout << "\nOK\n" << endl;

    return;

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

示例5:

void
T5_Callback_1(int result, NdbConnection * pCON, void * threadData) {
    ThreadData * td = (ThreadData *)threadData;
    if (result == -1) {
        CHECK_ALLOWED_ERROR("T5-1: execute", td, pCON->getNdbError());
        td->pNDB->closeTransaction(pCON);
        start_T5(td->pNDB, td, stat_async);
        return;
    }//if

    DEBUG3("T5(%.*s, %.2d): - Callback 1",
           SUBSCRIBER_NUMBER_LENGTH,
           td->transactionData.number,
           td->transactionData.server_id);

    if (td->ndbRecordSharedData)
    {
        char* rowPtr= (char*) &td->transactionData;
        const NdbRecord* record= td->ndbRecordSharedData->
                                 groupTableAllowDeleteNdbRecord;
        Uint32 m=0;
        unsigned char* mask= (unsigned char*) &m;

        SET_MASK(mask, IND_GROUP_ALLOW_DELETE);

        const NdbOperation* MyOp= pCON->readTuple(record, rowPtr, record, rowPtr,
                                  NdbOperation::LM_Read,
                                  mask);

        CHECK_NULL((void*)MyOp, "T5-2: readTuple", td,
                   pCON->getNdbError());
    }
    else
    {
        NdbOperation * MyOp = pCON->getNdbOperation(GROUP_TABLE);
        CHECK_NULL(MyOp, "T5-2: getNdbOperation", td,
                   pCON->getNdbError());

        MyOp->readTuple();
        MyOp->equal(IND_GROUP_ID,
                    (char*)&td->transactionData.group_id);
        MyOp->getValue(IND_GROUP_ALLOW_DELETE,
                       (char *)&td->transactionData.permission);
    }

    if (stat_async == 1) {
        pCON->executeAsynchPrepare( NoCommit , T5_Callback_2, td);
    } else {
        int result = pCON->execute( NoCommit );
        T5_Callback_2(result, pCON, (void*)td);
        return;
    }//if
}
开发者ID:jimodb,项目名称:codes,代码行数:53,代码来源:ndb_async2.cpp

示例6: assert

static int
checkorphan(const Blob&b, int& res)
{
  int ret = 0;

  NdbTransaction* tx = 0;
  NdbOperation* op = 0;

  do
  {
    tx = g_ndb->startTransaction();
    CHK2(tx != 0, g_ndb->getNdbError());

    op = tx->getNdbOperation(g_tab);
    CHK2(op != 0, tx->getNdbError());

    const NdbOperation::LockMode lm = NdbOperation::LM_Read;
    CHK2(op->readTuple(lm) == 0, op->getNdbError());

    for (int i = 0; i < g_pkcount; i++)
    {
      Val& v = g_vallist[i];
      assert(v.ra != 0);
      assert(v.ra->isNULL() == 0);
      const char* data = v.ra->aRef();
      CHK2(op->equal(v.colname, data) == 0, op->getNdbError());
    }
    CHK1(ret == 0);

    // read something to be safe
    NdbRecAttr* ra0 = op->getValue(g_vallist[0].colname);
    assert(ra0 != 0);

    // not sure about the rules
    assert(tx->getNdbError().code == 0);
    tx->execute(Commit);
    if (tx->getNdbError().code == 626)
    {
      g_info << "parent not found" << endl;
      res = 1; // not found
    }
    else
    {
      CHK2(tx->getNdbError().code == 0, tx->getNdbError());
      res = 0; // found
    }
  }
  while (0);

  if (tx != 0)
    g_ndb->closeTransaction(tx);
  return ret;
}
开发者ID:,项目名称:,代码行数:53,代码来源:

示例7: runV2MultiWait_Producer

/* Producer thread */
int runV2MultiWait_Producer(NDBT_Context* ctx, NDBT_Step* step,
                           int thd_id, int nthreads)
{
  int records = ctx->getNumRecords();
  HugoOperations hugoOps(*ctx->getTab());

  /* For three threads (2 producers + 1 consumer) we loop 0-7.
     producer 0 is slow if (loop & 1)  
     producer 1 is slow if (loop & 2)
     consumer is slow if (loop & 4)
  */
  for (int loop = 0; loop < V2_NLOOPS; loop++) 
  {
    ctx->getPropertyWait("LOOP", loop+1);
    bool slow = loop & (thd_id+1);
    for (int j=0; j < records; j++)
    {
      if(j % nthreads == thd_id) 
      {
        Ndb* ndb = global_ndb_pool->getNdb();
        NdbTransaction* trans = ndb->startTransaction();
        check(trans != NULL, (*ndb));
        ndb->setCustomData(trans);

        NdbOperation* readOp = trans->getNdbOperation(ctx->getTab());
        check(readOp != NULL, (*trans));
        check(readOp->readTuple() == 0, (*readOp));
        check(hugoOps.equalForRow(readOp, j) == 0, hugoOps);

        /* Read all other cols */
        for (int k=0; k < ctx->getTab()->getNoOfColumns(); k++)
        {
          check(readOp->getValue(ctx->getTab()->getColumn(k)) != NULL,
                (*readOp));
        }

        trans->executeAsynchPrepare(NdbTransaction::Commit,
                                    NULL,
                                    NULL,
                                    NdbOperation::AbortOnError);
        ndb->sendPreparedTransactions();
        global_poll_group->push(ndb);
        if(slow) 
        {
          int tm = myRandom48(3) * myRandom48(3);
          if(tm) NdbSleep_MilliSleep(tm);
        }
      }
    }
  } 
  return NDBT_OK;
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:53,代码来源:testAsynchMultiwait.cpp

示例8: QueryTransaction

int QueryTransaction(Ndb* pNdb, 
                     long iContextId,                       
                     long* piVersion, 
                     long* piLockFlag, 
                     long* piLockTime, 
                     long* piLockTimeUSec, 
                     char* pchContextData, 
                     NdbError& err)
{
    int iRes = -1;
    NdbConnection* pNdbConnection = pNdb->startTransaction(0, (const char*)&iContextId, 4);
    if(pNdbConnection)
    {
        NdbOperation* pNdbOperation = pNdbConnection->getNdbOperation(g_szTableName);
        if(pNdbOperation)
        {
            NdbRecAttr* pNdbRecAttrVersion;
            NdbRecAttr* pNdbRecAttrLockFlag;
            NdbRecAttr* pNdbRecAttrLockTime;
            NdbRecAttr* pNdbRecAttrLockTimeUSec;
            NdbRecAttr* pNdbRecAttrContextData;
            if(!pNdbOperation->readTuple()
            && !pNdbOperation->equal(c_szContextId, (Int32)iContextId)
            && (pNdbRecAttrVersion=pNdbOperation->getValue(c_szVersion, (char*)piVersion))
            && (pNdbRecAttrLockFlag=pNdbOperation->getValue(c_szLockFlag, (char*)piLockFlag))
            && (pNdbRecAttrLockTime=pNdbOperation->getValue(c_szLockTime, (char*)piLockTime))
            && (pNdbRecAttrLockTimeUSec=pNdbOperation->getValue(c_szLockTimeUSec, (char*)piLockTimeUSec))
            && (pNdbRecAttrContextData=pNdbOperation->getValue(c_szContextData, pchContextData)))
            {
                if(!pNdbConnection->execute(Commit))
                    iRes = 0;
                else 
                    err = pNdbConnection->getNdbError();
            } 
            else 
                err = pNdbOperation->getNdbError();
        } 
        else 
            err = pNdbConnection->getNdbError();

        pNdb->closeTransaction(pNdbConnection);
    } 
    else 
        err = pNdb->getNdbError();
    
    return iRes;
}
开发者ID:4T-Shirt,项目名称:mysql,代码行数:47,代码来源:msa.cpp

示例9: indexReadRecords

int HugoOperations::indexReadRecords(Ndb*, const char * idxName, int recordNo,
				     bool exclusive,
				     int numRecords){
    
  int a;
  allocRows(numRecords);
  int check;
  for(int r=0; r < numRecords; r++){
    NdbOperation* pOp = pTrans->getNdbIndexOperation(idxName, tab.getName());
    if (pOp == NULL) {
      NDB_ERR(pTrans->getNdbError());
      setNdbError(pTrans->getNdbError());
      return NDBT_FAILED;
    }
    
    if (exclusive == true)
      check = pOp->readTupleExclusive();
    else
      check = pOp->readTuple();
    if( check == -1 ) {
      NDB_ERR(pTrans->getNdbError());
      setNdbError(pTrans->getNdbError());
      return NDBT_FAILED;
    }
    
    // Define primary keys
    if (equalForRow(pOp, r+recordNo) != 0)
    {
      g_err << __LINE__ << " equal for row failed" << endl;
      return NDBT_FAILED;
    }
    
    // Define attributes to read  
    for(a = 0; a<tab.getNoOfColumns(); a++){
      if((rows[r]->attributeStore(a) = 
	  pOp->getValue(tab.getColumn(a))) == 0) {
	NDB_ERR(pTrans->getNdbError());
        setNdbError(pTrans->getNdbError());
	return NDBT_FAILED;
      }
    } 
  }
  return NDBT_OK;
}
开发者ID:carrotli,项目名称:ansql,代码行数:44,代码来源:HugoOperations.cpp

示例10:

void
T3_Callback_1(int result, NdbConnection * pCON, void * threadData){
  ThreadData * td = (ThreadData *)threadData;
  DEBUG3("T3(%.*s, %.2d): - Callback 1\n", SUBSCRIBER_NUMBER_LENGTH, 
	 td->transactionData.number, 
	 td->transactionData.server_id);

  CHECK_MINUS_ONE(result, "T3-1: NoCommit", pCON); 

  NdbOperation * MyOp = pCON->getNdbOperation(GROUP_TABLE);
  CHECK_NULL(MyOp, "T3-2: getNdbOperation", 
	     pCON);
    
  MyOp->readTuple();
  MyOp->equal(IND_GROUP_ID,
	      (char*)&td->transactionData.group_id);
  MyOp->getValue(IND_GROUP_ALLOW_READ, 
		 (char *)&td->transactionData.permission);
  pCON->executeAsynchPrepare( NoCommit, T3_Callback_2, td ); 
}
开发者ID:Cona19,项目名称:mysql5.6.24-improve,代码行数:20,代码来源:ndb_async1.cpp

示例11: verify_deleted

void verify_deleted(Ndb* pMyNdb) {

    int               check = -1 ;
    int               loop_count_ops = nRecords;
    NdbOperation*     pMyOperation = NULL ;

    ndbout << "Verifying deleted records..."<< flush;

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

        NdbConnection*  pMyTransaction = pMyNdb->startTransaction();
        if (!pMyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL);

        pMyOperation = pMyTransaction->getNdbOperation(tableName);
        if (!pMyOperation) error_handler(pMyNdb->getNdbError(), NO_FAIL);

        check = pMyOperation->readTuple();
        if( check == -1 ) error_handler( pMyTransaction->getNdbError(), NO_FAIL);

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

        // Exepect to receive an error
        if(pMyTransaction->execute(Commit) != -1)
            if( 626 == pMyTransaction->getNdbError().code) {
                ndbout << pMyTransaction->getNdbError() << endl ;
                ndbout << "OK" << endl ;
            } else {
                error_handler(pMyTransaction->getNdbError(), NO_FAIL) ;
            }

        pMyNdb->closeTransaction(pMyTransaction);
    }

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

示例12: tabRow

int 
UtilTransactions::readRowFromTableAndIndex(Ndb* pNdb,
					   NdbConnection* scanTrans,
					   const NdbDictionary::Index* pIndex,
					   NDBT_ResultRow& row ){


  NdbDictionary::Index::Type indexType= pIndex->getType();
  int                  retryAttempt = 0;
  const int            retryMax = 100;
  int                  check, a;
  NdbConnection	       *pTrans1=NULL;
  NdbOperation	       *pOp;

  int return_code= NDBT_FAILED;

  // Allocate place to store the result
  NDBT_ResultRow       tabRow(tab);
  NDBT_ResultRow       indexRow(tab);
  const char * indexName = pIndex->getName();

  while (true){
    if(retryAttempt)
      ndbout_c("retryAttempt %d", retryAttempt);
    if (retryAttempt >= retryMax){
      g_info << "ERROR: has retried this operation " << retryAttempt 
	     << " times, failing!" << endl;
	goto close_all;
    }

    pTrans1 = pNdb->hupp(scanTrans); //startTransaction();
    if (pTrans1 == NULL) {
      const NdbError err = pNdb->getNdbError();
      
      if (err.status == NdbError::TemporaryError){
	ERR(err);
	NdbSleep_MilliSleep(50);
	retryAttempt++;
	continue;
      }

      if(err.code == 0){
	return_code = NDBT_OK;
	goto close_all;
      }
      ERR(err);
      goto close_all;
    }

    /**
     * Read the record from TABLE
     */
    pOp = pTrans1->getNdbOperation(tab.getName());	
    if (pOp == NULL) {
      ERR(pTrans1->getNdbError());
      goto close_all;
    }
    
    check = pOp->readTuple();
    if( check == -1 ) {
      ERR(pTrans1->getNdbError());
      goto close_all;
    }
    
    // Define primary keys
#if VERBOSE
    printf("PK: ");
#endif
    for(a = 0; a<tab.getNoOfColumns(); a++){
      const NdbDictionary::Column* attr = tab.getColumn(a);
      if (attr->getPrimaryKey() == true){
	if (pOp->equal(attr->getName(), row.attributeStore(a)->aRef()) != 0){
	  ERR(pTrans1->getNdbError());
	  goto close_all;
	}
#if VERBOSE
	printf("%s = %d: ", attr->getName(), row.attributeStore(a)->aRef());
#endif
      }
    }
#if VERBOSE
    printf("\n");
#endif
    // Read all attributes
#if VERBOSE
    printf("Reading %u attributes: ", tab.getNoOfColumns());
#endif
    for(a = 0; a<tab.getNoOfColumns(); a++){
      if((tabRow.attributeStore(a) = 
	  pOp->getValue(tab.getColumn(a)->getName())) == 0) {
	ERR(pTrans1->getNdbError());
	goto close_all;
      }
#if VERBOSE
      printf("%s ", tab.getColumn(a)->getName());
#endif
    }
#if VERBOSE
    printf("\n");
#endif
//.........这里部分代码省略.........
开发者ID:4T-Shirt,项目名称:mysql,代码行数:101,代码来源:UtilTransactions.cpp

示例13: if

int 
UtilTransactions::verifyOrderedIndex(Ndb* pNdb,
				     const NdbDictionary::Index* pIndex,
				     int parallelism,
				     bool transactional){
  
  int                  retryAttempt = 0;
  const int            retryMax = 100;
  int                  check;
  NdbScanOperation     *pOp;
  NdbIndexScanOperation * iop = 0;

  NDBT_ResultRow       scanRow(tab);
  NDBT_ResultRow       pkRow(tab);
  NDBT_ResultRow       indexRow(tab);
  const char * indexName = pIndex->getName();

  int res;
  parallelism = 1;
  
  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){
	ERR(err);
	NdbSleep_MilliSleep(50);
	retryAttempt++;
	continue;
      }
      ERR(err);
      return NDBT_FAILED;
    }

    pOp = pTrans->getNdbScanOperation(tab.getName());	
    if (pOp == NULL) {
      ERR(pTrans->getNdbError());
      closeTransaction(pNdb);
      return NDBT_FAILED;
    }

    if( pOp->readTuples(NdbScanOperation::LM_Read, 0, parallelism) ) {
      ERR(pTrans->getNdbError());
      closeTransaction(pNdb);
      return NDBT_FAILED;
    }

    check = pOp->interpret_exit_ok();
    if( check == -1 ) {
      ERR(pTrans->getNdbError());
      closeTransaction(pNdb);
      return NDBT_FAILED;
    }

    if(get_values(pOp, scanRow))
    {
      abort();
    }

    check = pTrans->execute(NoCommit, AbortOnError);
    if( check == -1 ) {
      const NdbError err = pTrans->getNdbError();
      
      if (err.status == NdbError::TemporaryError){
	ERR(err);
	closeTransaction(pNdb);
	NdbSleep_MilliSleep(50);
	retryAttempt++;
	continue;
      }
      ERR(err);
      closeTransaction(pNdb);
      return NDBT_FAILED;
    }
        
    int eof;
    int rows = 0;
    while(check == 0 && (eof = pOp->nextResult()) == 0){
      rows++;

      bool null_found= false;
      for(int a = 0; a<(int)pIndex->getNoOfColumns(); a++){
	const NdbDictionary::Column *  col = pIndex->getColumn(a);
	if (scanRow.attributeStore(col->getName())->isNULL())
	{
	  null_found= true;
	  break;
	}
      }
      
      // Do pk lookup
      NdbOperation * pk = pTrans->getNdbOperation(tab.getName());
//.........这里部分代码省略.........
开发者ID:4T-Shirt,项目名称:mysql,代码行数:101,代码来源:UtilTransactions.cpp

示例14: ERR

inline
int 
ScanInterpretTest::addRowToCheckTrans(Ndb* pNdb, 
				      NdbConnection* pCheckTrans){

  NdbOperation* pOp = 
    pCheckTrans->getNdbOperation(restab.getName());	
  if (pOp == NULL) {
    ERR(pNdb->getNdbError());
    return NDBT_FAILED;
  }
  
  if(pOp->readTuple() != 0) {
    ERR(pNdb->getNdbError());
    return NDBT_FAILED;
  }
  
  // Copy pk attribute's to the new operation
  for (int a = 0; a<restab.getNoOfColumns(); a++){
    const NdbDictionary::Column* attr = restab.getColumn(a); 
    if (attr->getPrimaryKey() == true){
      NdbRecAttr* reca = row.attributeStore(a);
      int check = -1;
      switch (attr->getType()){
      case NdbDictionary::Column::Char:
      case NdbDictionary::Column::Varchar:
      case NdbDictionary::Column::Binary:
      case NdbDictionary::Column::Varbinary:{
	check = pOp->equal( attr->getName(), 
			       reca->aRef());
	break;
      }
      case NdbDictionary::Column::Int:{
	check = pOp->equal( attr->getName(), 
			       reca->int32_value());      
      }
	break;
      case NdbDictionary::Column::Bigint:{
	check = pOp->equal( attr->getName(), 
			       reca->int64_value());
      }
	break;
      case NdbDictionary::Column::Unsigned:{
	check = pOp->equal( attr->getName(), 
			       reca->u_32_value());
      }
	break;
      case NdbDictionary::Column::Bigunsigned:{
	check = pOp->equal( attr->getName(), 
			       reca->u_64_value());
      }
	break;
      default:
	check = -1;
	break;
      }
      if(check != 0){
	ERR(pNdb->getNdbError());
	return NDBT_FAILED;
      }
    }
  }

  return NDBT_OK;
}
开发者ID:4T-Shirt,项目名称:mysql,代码行数:65,代码来源:ScanInterpretTest.hpp

示例15: indexReadRecords

int 
HugoTransactions::indexReadRecords(Ndb* pNdb, 
				   const char * idxName,
				   int records,
				   int batch){
  int                  reads = 0;
  int                  r = 0;
  int                  retryAttempt = 0;
  int                  check, a;
  NdbOperation *pOp;
  NdbIndexScanOperation *sOp;

  const NdbDictionary::Index* pIndex
    = pNdb->getDictionary()->getIndex(idxName, tab.getName());
  
  const bool ordered = (pIndex->getType()==NdbDictionary::Index::OrderedIndex);

  if (batch == 0) {
    g_info << "ERROR: Argument batch == 0 in indexReadRecords(). "
	   << "Not allowed." << endl;
    return NDBT_FAILED;
  }
  
  if (ordered) {
    batch = 1;
  }

  allocRows(batch);
  
  while (r < records){
    if (retryAttempt >= m_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){
	ERR(err);
	NdbSleep_MilliSleep(50);
	retryAttempt++;
	continue;
      }
      ERR(err);
      return NDBT_FAILED;
    }
    
    for(int b=0; (b<batch) && (r+b < records); b++){
      if(!ordered){
	pOp = pTrans->getNdbIndexOperation(idxName, tab.getName());	
	if (pOp == NULL) {
	  ERR(pTrans->getNdbError());
	  closeTransaction(pNdb);
	  return NDBT_FAILED;
	}
	check = pOp->readTuple();
      } else {
	pOp = sOp = pTrans->getNdbIndexScanOperation(idxName, tab.getName());
	if (sOp == NULL) {
	  ERR(pTrans->getNdbError());
	  closeTransaction(pNdb);
	  return NDBT_FAILED;
	}
	check = sOp->readTuples();
      }
      
      if( check == -1 ) {
	ERR(pTrans->getNdbError());
	closeTransaction(pNdb);
	return NDBT_FAILED;
      }
      
      // Define primary keys
      if (equalForRow(pOp, r+b) != 0)
      {
        closeTransaction(pNdb);
        return NDBT_FAILED;
      }
      
      // Define attributes to read  
      for(a = 0; a<tab.getNoOfColumns(); a++){
	if((rows[b]->attributeStore(a) = 
	    pOp->getValue(tab.getColumn(a)->getName())) == 0) {
	  ERR(pTrans->getNdbError());
	  closeTransaction(pNdb);
	  return NDBT_FAILED;
	}
      }
    }

    check = pTrans->execute(Commit, AbortOnError);   
    check = (check == -1 ? -1 : !ordered ? check : sOp->nextResult(true));
    if( check == -1 ) {
      const NdbError err = pTrans->getNdbError();
      
      if (err.status == NdbError::TemporaryError){
	ERR(err);
//.........这里部分代码省略.........
开发者ID:Abner-Sun,项目名称:mysql5.1-vx-pre1,代码行数:101,代码来源:HugoTransactions.cpp


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