⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flexasynch.cpp

📁 mysql-5.0.22.tar.gz源码包
💻 CPP
📖 第 1 页 / 共 3 页
字号:
  }//case  case stUpdate: {    // Update Case    if (theWriteFlag == 1 && theDirtyFlag == 1) {      localNdbOperation->dirtyWrite();    } else if (theWriteFlag == 1) {      localNdbOperation->writeTuple();    } else if (theDirtyFlag == 1) {      localNdbOperation->dirtyUpdate();    } else {      localNdbOperation->updateTuple();    }//if    break;  }//case  case stDelete: {   // Delete Case    localNdbOperation->deleteTuple();    break;  }//case  default: {    error_handler(localNdbOperation->getNdbError());   }//default  }//switch  localNdbOperation->equal((Uint32)0,(char*)&attrValue[0]);  switch (aType) {  case stInsert:      // Insert case  case stUpdate:      // Update Case    {      for (countAttributes = 1;           countAttributes < loopCountAttributes; countAttributes++) {        localNdbOperation->setValue(countAttributes,                                     (char*)&attrValue[0]);      }//for      break;    }//case  case stRead: {      // Read Case    for (countAttributes = 1;         countAttributes < loopCountAttributes; countAttributes++) {      localNdbOperation->getValue(countAttributes,                                   (char*)&attrValue[0]);    }//for    break;  }//case  case stDelete: {    // Delete Case    break;  }//case  default: {    //goto error_handler; < epaulsa    error_handler(localNdbOperation->getNdbError());  }//default  }//switch  return;}//defineOperation()static void setAttrNames(){  int i;  for (i = 0; i < MAXATTR ; i++){    BaseString::snprintf(attrName[i], MAXSTRLEN, "COL%d", i);  }}static void setTableNames(){  // Note! Uses only uppercase letters in table name's  // so that we can look at the tables wits SQL  int i;  for (i = 0; i < MAXTABLES ; i++){    if (theStdTableNameFlag==0){      BaseString::snprintf(tableName[i], MAXSTRLEN, "TAB%d_%d", i,                (int)(NdbTick_CurrentMillisecond()/1000));    } else {      BaseString::snprintf(tableName[i], MAXSTRLEN, "TAB%d", i);    }  }}staticint createTables(Ndb* pMyNdb){  NdbSchemaCon          *MySchemaTransaction;  NdbSchemaOp           *MySchemaOp;  int                   check;  if (theTableCreateFlag == 0) {    for(int i=0; i < 1 ;i++) {      ndbout << "Creating " << tableName[i] << "..." << endl;      MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pMyNdb);            if(MySchemaTransaction == NULL &&          (!error_handler(MySchemaTransaction->getNdbError())))        return -1;            MySchemaOp = MySchemaTransaction->getNdbSchemaOp();             if(MySchemaOp == NULL &&         (!error_handler(MySchemaTransaction->getNdbError())))        return -1;      check = MySchemaOp->createTable( tableName[i]                                       ,8                       // Table Size                                       ,TupleKey                // Key Type                                       ,40                      // Nr of Pages                                       ,All                                       ,6                                       ,(tLoadFactor - 5)                                       ,(tLoadFactor)                                       ,1                                       ,!tempTable                                       );            if (check == -1 &&          (!error_handler(MySchemaTransaction->getNdbError())))        return -1;            check = MySchemaOp->createAttribute( (char*)attrName[0],                                           TupleKey,                                           32,                                           PKSIZE,                                           UnSigned,                                           MMBased,                                           NotNullAttribute );            if (check == -1 &&          (!error_handler(MySchemaTransaction->getNdbError())))        return -1;      for (int j = 1; j < tNoOfAttributes ; j++){        check = MySchemaOp->createAttribute( (char*)attrName[j],                                             NoKey,                                             32,                                             tAttributeSize,                                             UnSigned,                                             MMBased,                                             NotNullAttribute );        if (check == -1 &&            (!error_handler(MySchemaTransaction->getNdbError())))          return -1;      }            if (MySchemaTransaction->execute() == -1 &&          (!error_handler(MySchemaTransaction->getNdbError())))        return -1;            NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);    }  }    return 0;}staticbool error_handler(const NdbError & err){  ndbout << err << endl ;  switch(err.classification){  case NdbError::TemporaryResourceError:  case NdbError::OverloadError:  case NdbError::SchemaError:    ndbout << endl << "Attempting to recover and continue now..." << endl ;    return true;  }  return false ; // return false to abort}staticbool error_handler(const char* error_string, int error_int) {  ndbout << error_string << endl ;  if ((4008 == error_int) ||      (721 == error_int) ||      (266 == error_int)){    ndbout << endl << "Attempting to recover and continue now..." << endl ;    return true ; // return true to retry  }  return false ; // return false to abort}staticint readArguments(int argc, const char** argv){    int i = 1;  while (argc > 1){    if (strcmp(argv[i], "-t") == 0){      tNoOfThreads = atoi(argv[i+1]);      if ((tNoOfThreads < 1) || (tNoOfThreads > MAXTHREADS)){	ndbout_c("Invalid no of threads");        return -1;      }    } else if (strcmp(argv[i], "-p") == 0){      tNoOfParallelTrans = atoi(argv[i+1]);      if ((tNoOfParallelTrans < 1) || (tNoOfParallelTrans > MAXPAR)){	ndbout_c("Invalid no of parallell transactions");        return -1;      }    } else if (strcmp(argv[i], "-load_factor") == 0){      tLoadFactor = atoi(argv[i+1]);      if ((tLoadFactor < 40) || (tLoadFactor > 99)){	ndbout_c("Invalid load factor");        return -1;      }    } else if (strcmp(argv[i], "-c") == 0) {      tNoOfOpsPerTrans = atoi(argv[i+1]);      if (tNoOfOpsPerTrans < 1){	ndbout_c("Invalid no of operations per transaction");        return -1;      }    } else if (strcmp(argv[i], "-o") == 0) {      tNoOfTransactions = atoi(argv[i+1]);      if (tNoOfTransactions < 1){	ndbout_c("Invalid no of transactions");        return -1;      }    } else if (strcmp(argv[i], "-a") == 0){      tNoOfAttributes = atoi(argv[i+1]);      if ((tNoOfAttributes < 2) || (tNoOfAttributes > MAXATTR)){	ndbout_c("Invalid no of attributes");        return -1;      }    } else if (strcmp(argv[i], "-n") == 0){      theStdTableNameFlag = 1;      argc++;      i--;    } else if (strcmp(argv[i], "-l") == 0){      tNoOfLoops = atoi(argv[i+1]);      if ((tNoOfLoops < 0) || (tNoOfLoops > 100000)){	ndbout_c("Invalid no of loops");        return -1;      }    } else if (strcmp(argv[i], "-s") == 0){      tAttributeSize = atoi(argv[i+1]);      if ((tAttributeSize < 1) || (tAttributeSize > MAXATTRSIZE)){	ndbout_c("Invalid attributes size");        return -1;      }    } else if (strcmp(argv[i], "-local") == 0){      tLocalPart = atoi(argv[i+1]);      tLocal = true;      startTransGuess = true;      if ((tLocalPart < 0) || (tLocalPart > MAX_PARTS)){	ndbout_c("Invalid local part");        return -1;      }    } else if (strcmp(argv[i], "-simple") == 0){      theSimpleFlag = 1;      argc++;      i--;    } else if (strcmp(argv[i], "-adaptive") == 0){      tSendForce = 0;      argc++;      i--;    } else if (strcmp(argv[i], "-force") == 0){      tSendForce = 1;      argc++;      i--;    } else if (strcmp(argv[i], "-non_adaptive") == 0){      tSendForce = 2;      argc++;      i--;    } else if (strcmp(argv[i], "-write") == 0){      theWriteFlag = 1;      argc++;      i--;    } else if (strcmp(argv[i], "-dirty") == 0){      theDirtyFlag = 1;      argc++;      i--;    } else if (strcmp(argv[i], "-test") == 0){      theTestFlag = 1;      argc++;      i--;    } else if (strcmp(argv[i], "-no_table_create") == 0){      theTableCreateFlag = 1;      argc++;      i--;    } else if (strcmp(argv[i], "-temp") == 0){      tempTable = true;      argc++;      i--;    } else if (strcmp(argv[i], "-no_hint") == 0){      startTransGuess = false;      argc++;      i--;    } else {      return -1;    }        argc -= 2;    i = i + 2;  }//while  if (tLocal == true) {    if (tNoOfOpsPerTrans != 1) {      ndbout_c("Not valid to have more than one op per trans with local");    }//if    if (startTransGuess == false) {      ndbout_c("Not valid to use no_hint with local");    }//if  }//if  return 0;}staticvoidinput_error(){    ndbout_c("FLEXASYNCH");  ndbout_c("   Perform benchmark of insert, update and delete transactions");  ndbout_c("");  ndbout_c("Arguments:");  ndbout_c("   -t Number of threads to start, default 1");  ndbout_c("   -p Number of parallel transactions per thread, default 32");  ndbout_c("   -o Number of transactions per loop, default 500");  ndbout_c("   -l Number of loops to run, default 1, 0=infinite");  ndbout_c("   -load_factor Number Load factor in index in percent (40 -> 99)");  ndbout_c("   -a Number of attributes, default 25");  ndbout_c("   -c Number of operations per transaction");  ndbout_c("   -s Size of each attribute, default 1 ");  ndbout_c("      (PK is always of size 1, independent of this value)");  ndbout_c("   -simple Use simple read to read from database");  ndbout_c("   -dirty Use dirty read to read from database");  ndbout_c("   -write Use writeTuple in insert and update");  ndbout_c("   -n Use standard table names");  ndbout_c("   -no_table_create Don't create tables in db");  ndbout_c("   -temp Create table(s) without logging");  ndbout_c("   -no_hint Don't give hint on where to execute transaction coordinator");  ndbout_c("   -adaptive Use adaptive send algorithm (default)");  ndbout_c("   -force Force send when communicating");  ndbout_c("   -non_adaptive Send at a 10 millisecond interval");  ndbout_c("   -local Number of part, only use keys in one part out of 16");}  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -