24 #include <HugoTransactions.hpp>
28 int main(
int argc,
const char** argv){
41 {
"records",
'r', arg_integer, &_records,
"Number of records",
"recs" },
42 {
"batch",
'b', arg_integer, &_batch,
"Number of operations in each transaction",
"batch" },
43 {
"loops",
'l', arg_integer, &_loops,
"Number of loops",
"" },
44 {
"database",
'd', arg_string, &db,
"Database",
"" },
45 {
"usage",
'?', arg_flag, &_help,
"Print help",
"" },
46 {
"rnd-rows", 0, arg_flag, &_rand,
"Rand number of records",
"recs" },
47 {
"one-trans", 0, arg_flag, &_onetrans,
"Insert as 1 trans",
"" },
48 {
"abort", 0, arg_integer, &_abort,
"Abort probability",
"" }
50 int num_args =
sizeof(args) /
sizeof(args[0]);
54 "This program will load one table in Ndb with calculated data. \n"\
55 "This means that it is possible to check the validity of the data \n"\
56 "at a later time. The last column in each table is used as an update \n"\
57 "counter, it's initialised to zero and should be incremented for each \n"\
58 "update of the record. \n";
60 if(getarg(args, num_args, argc, argv, &optind) ||
61 argv[optind] == NULL || _records == 0 || _help) {
62 arg_printusage(args, num_args, argv[0], desc);
63 return NDBT_ProgramExit(NDBT_WRONGARGS);
71 return NDBT_ProgramExit(NDBT_FAILED);
76 ndbout <<
"Cluster nodes not ready in 30 seconds." << endl;
77 return NDBT_ProgramExit(NDBT_FAILED);
80 Ndb MyNdb( &con, db ? db :
"TEST_DB" );
82 if(MyNdb.init() != 0){
83 ERR(MyNdb.getNdbError());
84 return NDBT_ProgramExit(NDBT_FAILED);
87 for(
int i = optind;
i<argc;
i++)
89 const char* _tabname = argv[
i];
92 NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
94 ndbout <<
" Table " << _tabname <<
" does not exist!" << endl;
95 return NDBT_ProgramExit(NDBT_WRONGARGS);
100 int rows = (_rand ? rand() % _records : _records);
101 int abort = (rand() % 100) < _abort ? 1 : 0;
103 ndbout <<
"load+abort" << endl;
104 if (hugoTrans.loadTable(&MyNdb,
107 true, 0, _onetrans, _loops, abort) != 0){
108 return NDBT_ProgramExit(NDBT_FAILED);
113 ndbout <<
"clearing..." << endl;
114 hugoTrans.clearTable(&MyNdb);
121 return NDBT_ProgramExit(NDBT_OK);