19 #include "HugoQueries.hpp"
20 #include <NDBT_Stats.hpp>
23 #include "../../src/ndbapi/NdbQueryOperation.hpp"
30 for (Uint32
i = 0;
i<query.getNoOfOperations();
i++)
33 op.m_query_op = query.getQueryOperation(
i);
35 if (op.m_query_op->getTable())
43 HugoQueries::~HugoQueries()
45 for (
size_t o = 0; o<m_ops.size(); o++)
47 while (m_ops[o].m_rows.size())
49 delete m_ops[o].m_rows.back();
50 m_ops[o].m_rows.erase(m_ops[o].m_rows.size() - 1);
53 delete m_ops[o].m_calc;
58 HugoQueries::allocRows(
int batch)
60 for (
size_t o = 0; o<m_ops.size(); o++)
67 while (m_ops[o].m_rows.size() < (size_t)batch)
76 HugoQueries::equalForParameters(
char *
buf,
95 Uint32 len = attr->getSizeInBytes();
98 calc.calcValue((Uint32)rowNo,
i, 0, buf, len, &real_len);
112 Uint32 len = attr->getSizeInBytes();
116 0,
buf, len, &real_len);
137 HugoQueries::runLookupQuery(
Ndb* pNdb,
142 int retryAttempt = 0;
144 m_rows_found.clear();
146 m_rows_found.fill(m_query_def->getNoOfOperations() - 1, zero);
149 g_info <<
"ERROR: Argument batch == 0 in runLookupQuery. Not allowed."
158 if(r + batch > records)
161 if (retryAttempt >= m_retryMax)
163 g_info <<
"ERROR: has retried this operation " << retryAttempt
164 <<
" times, failing!" << endl;
169 batch_rows_found.fill(m_query_def->getNoOfOperations() - 1, zero);
179 NdbSleep_MilliSleep(50);
187 for (
int b = 0; b<batch; b++)
189 char buf[NDB_MAX_TUPLE_SIZE];
191 equalForParameters(buf, m_ops[0], params, b + r);
201 for (
size_t o = 0; o<m_ops.size(); o++)
204 HugoQueries::getValueForQueryOp(pOp, m_ops[o].m_rows[b]);
206 queries.push_back(query);
209 int check = pTrans->
execute(NoCommit, AbortOnError);
216 NdbSleep_MilliSleep(50);
224 for (
int b = 0; b<batch; b++)
227 if (query->
nextResult() == NdbQuery::NextResult_gotRow)
229 for (
size_t o = 0; o<m_ops.size(); o++)
232 if (!pOp->isRowNULL())
234 batch_rows_found[o]++;
235 if (m_ops[o].m_calc->verifyRowValues(m_ops[o].m_rows[b]) != 0)
247 for (
size_t i = 0;
i<batch_rows_found.size();
i++)
248 m_rows_found[
i] += batch_rows_found[
i];
255 HugoQueries::runScanQuery(
Ndb * pNdb,
260 int retryAttempt = 0;
264 while (retryAttempt < m_retryMax)
266 m_rows_found.clear();
268 m_rows_found.fill(m_query_def->getNoOfOperations() - 1, zero);
276 NdbSleep_MilliSleep(50);
285 char buf[NDB_MAX_TUPLE_SIZE];
287 equalForParameters(buf, m_ops[0], params, 0);
296 for (
size_t o = 0; o<m_ops.size(); o++)
299 HugoQueries::getValueForQueryOp(pOp, m_ops[o].m_rows[0]);
302 int check = pTrans->
execute(NoCommit, AbortOnError);
309 NdbSleep_MilliSleep(50);
317 int r = rand() % 100;
318 if (r < abort && ((r & 1) == 0))
320 ndbout_c(
"Query aborted!");
323 m_rows_found.clear();
328 while ((res = query->
nextResult()) == NdbQuery::NextResult_gotRow)
330 if (r < abort && ((r & 1) == 1))
332 ndbout_c(
"Query aborted 2!");
335 m_rows_found.clear();
339 for (
size_t o = 0; o<m_ops.size(); o++)
342 if (!pOp->isRowNULL())
345 if (m_ops[o].m_calc->verifyRowValues(m_ops[o].m_rows[0]) != 0)
357 if (res == NdbQuery::NextResult_error)
362 NdbSleep_MilliSleep(50);
368 else if (res != NdbQuery::NextResult_scanComplete)
370 ndbout_c(
"Got %u from nextResult()", res);