19 #include <ndb_global.h>
26 #include <NDBT_Thread.hpp>
27 #include <NDBT_Stats.hpp>
31 #include <HugoTransactions.hpp>
33 static NDBT_ThreadFunc hugoPkRead;
47 int main(
int argc,
const char** argv){
56 const char* _tabname = NULL;
61 {
"aborts",
'a', arg_integer, &_abort,
"percent of transactions that are aborted",
"abort%" },
62 {
"loops",
'l', arg_integer, &_loops,
"number of times to run this program(0=infinite loop)",
"loops" },
63 {
"threads",
't', arg_integer, &_threads,
"number of threads (default 1)",
"threads" },
64 {
"stats",
's', arg_flag, &_stats,
"report latency per batch",
"stats" },
65 {
"batch",
'b', arg_integer, &_batch,
"batch value(not 0)",
"batch" },
66 {
"records",
'r', arg_integer, &_records,
"Number of records",
"records" },
67 {
"rand", 0, arg_flag, &_rand,
"Read random records within range",
"rand"},
68 {
"usage",
'?', arg_flag, &_help,
"Print help",
"" }
70 int num_args =
sizeof(args) /
sizeof(args[0]);
74 "This program will read 'r' records from one table in Ndb. \n"\
75 "It will verify every column read by calculating the expected value.\n";
77 if(getarg(args, num_args, argc, argv, &optind) ||
78 argv[optind] == NULL || _records == 0 || _batch == 0 || _help) {
79 arg_printusage(args, num_args, argv[0], desc);
80 return NDBT_ProgramExit(NDBT_WRONGARGS);
82 _tabname = argv[optind];
89 return NDBT_ProgramExit(NDBT_FAILED);
92 Ndb MyNdb(&con,
"TEST_DB" );
94 if(MyNdb.init() != 0){
95 ERR(MyNdb.getNdbError());
96 return NDBT_ProgramExit(NDBT_FAILED);
99 while(MyNdb.waitUntilReady() != 0)
100 ndbout <<
"Waiting for ndb to become ready..." << endl;
105 ndbout <<
" Table " << _tabname <<
" does not exist!" << endl;
106 return NDBT_ProgramExit(NDBT_WRONGARGS);
113 if (ths.connect(&con,
"TEST_DB") == -1) {
114 ndbout <<
"connect failed: err=" << ths.get_err() << endl;
115 return NDBT_ProgramExit(NDBT_FAILED);
120 ths.set_input(&input);
122 input.records = _records;
123 input.batch = _batch;
124 input.stats = _stats;
132 while (i < _loops || _loops == 0) {
135 ths.set_func(hugoPkRead);
140 NDBT_ProgramExit(NDBT_FAILED);
147 for (n = 0; n < ths.get_count(); n++) {
150 latency += output->latency;
154 <<
"latency per batch (us): "
155 <<
" samples=" << latency.getCount()
156 <<
" min=" << (int)latency.getMin()
157 <<
" max=" << (int)latency.getMax()
158 <<
" mean=" << (int)latency.getMean()
159 <<
" stddev=" << (int)latency.getStddev()
165 return NDBT_ProgramExit(NDBT_OK);
174 output->latency.reset();
176 hugoTrans.setStatsLatency(&output->latency);
179 ret = hugoTrans.pkReadRecords(thr.get_ndb(),