Commit 353076ad authored by unknown's avatar unknown

wl2126 - ndb - bug fix in set_new_bound & testScanPerf


ndb/src/ndbapi/NdbScanOperation.cpp:
  Bugfix in set_new_bound
ndb/test/ndbapi/testScanPerf.cpp:
  Add batch size (and -r 3), which is multi_read_range
parent d45ee63e
...@@ -1630,7 +1630,7 @@ NdbIndexScanOperation::set_new_bound() ...@@ -1630,7 +1630,7 @@ NdbIndexScanOperation::set_new_bound()
Uint32 bound_head = * m_first_bound_word; Uint32 bound_head = * m_first_bound_word;
bound_head |= (theTupKeyLen - m_this_bound_start) << 16; bound_head |= (theTupKeyLen - m_this_bound_start) << 16;
* m_first_bound_word = bound_head; * m_first_bound_word = bound_head;
m_first_bound_word = theKEYINFOptr; m_first_bound_word = theKEYINFOptr + theTotalNrOfKeyWordInSignal;;
m_this_bound_start = theTupKeyLen; m_this_bound_start = theTupKeyLen;
} }
...@@ -38,10 +38,10 @@ struct Parameter { ...@@ -38,10 +38,10 @@ struct Parameter {
#define P_ROWS 7 #define P_ROWS 7
#define P_LOOPS 8 #define P_LOOPS 8
#define P_CREATE 9 #define P_CREATE 9
#define P_LOAD 10
#define P_RESET 11 #define P_RESET 11
#define P_MULTI 12
#define P_MAX 12 #define P_MAX 13
static static
Parameter Parameter
...@@ -57,7 +57,8 @@ g_paramters[] = { ...@@ -57,7 +57,8 @@ g_paramters[] = {
{ "iterations", 3, 1, ~0 }, { "iterations", 3, 1, ~0 },
{ "create_drop", 1, 0, 1 }, { "create_drop", 1, 0, 1 },
{ "data", 1, 0, 1 }, { "data", 1, 0, 1 },
{ "q-reset bounds", 0, 1, 0 } { "q-reset bounds", 0, 1, 0 },
{ "multi read range", 1000, 1, ~0 }
}; };
static Ndb* g_ndb = 0; static Ndb* g_ndb = 0;
...@@ -67,10 +68,7 @@ static char g_tablename[256]; ...@@ -67,10 +68,7 @@ static char g_tablename[256];
static char g_indexname[256]; static char g_indexname[256];
int create_table(); int create_table();
int load_table();
int run_scan(); int run_scan();
int clear_table();
int drop_table();
int int
main(int argc, const char** argv){ main(int argc, const char** argv){
...@@ -117,14 +115,8 @@ main(int argc, const char** argv){ ...@@ -117,14 +115,8 @@ main(int argc, const char** argv){
BaseString::snprintf(g_indexname, sizeof(g_indexname), "IDX_%s", T); BaseString::snprintf(g_indexname, sizeof(g_indexname), "IDX_%s", T);
if(create_table()) if(create_table())
goto error; goto error;
if(load_table())
goto error;
if(run_scan()) if(run_scan())
goto error; goto error;
if(clear_table())
goto error;
if(drop_table())
goto error;
} }
if(g_ndb) delete g_ndb; if(g_ndb) delete g_ndb;
...@@ -139,6 +131,7 @@ create_table(){ ...@@ -139,6 +131,7 @@ create_table(){
NdbDictionary::Dictionary* dict = g_ndb->getDictionary(); NdbDictionary::Dictionary* dict = g_ndb->getDictionary();
assert(dict); assert(dict);
if(g_paramters[P_CREATE].value){ if(g_paramters[P_CREATE].value){
g_ndb->getDictionary()->dropTable(g_tablename);
const NdbDictionary::Table * pTab = NDBT_Tables::getTable(g_tablename); const NdbDictionary::Table * pTab = NDBT_Tables::getTable(g_tablename);
assert(pTab); assert(pTab);
NdbDictionary::Table copy = * pTab; NdbDictionary::Table copy = * pTab;
...@@ -167,46 +160,18 @@ create_table(){ ...@@ -167,46 +160,18 @@ create_table(){
g_index = dict->getIndex(g_indexname, g_tablename); g_index = dict->getIndex(g_indexname, g_tablename);
assert(g_table); assert(g_table);
assert(g_index); assert(g_index);
return 0;
}
int
drop_table(){
if(!g_paramters[P_CREATE].value)
return 0;
if(g_ndb->getDictionary()->dropTable(g_table->getName()) != 0){
g_err << "Failed to drop table: " << g_table->getName() << endl;
return -1;
}
g_table = 0;
return 0;
}
int if(g_paramters[P_CREATE].value)
load_table(){ {
if(!g_paramters[P_LOAD].value) int rows = g_paramters[P_ROWS].value;
return 0; HugoTransactions hugoTrans(* g_table);
if (hugoTrans.loadTable(g_ndb, rows)){
int rows = g_paramters[P_ROWS].value; g_err.println("Failed to load %s with %d rows",
HugoTransactions hugoTrans(* g_table); g_table->getName(), rows);
if (hugoTrans.loadTable(g_ndb, rows)){ return -1;
g_err.println("Failed to load %s with %d rows", g_table->getName(), rows); }
return -1;
} }
return 0;
}
int
clear_table(){
if(!g_paramters[P_LOAD].value)
return 0;
int rows = g_paramters[P_ROWS].value;
UtilTransactions utilTrans(* g_table);
if (utilTrans.clearTable(g_ndb, rows) != 0){
g_err.println("Failed to clear table %s", g_table->getName());
return -1;
}
return 0; return 0;
} }
...@@ -226,7 +191,7 @@ run_scan(){ ...@@ -226,7 +191,7 @@ run_scan(){
Uint32 tot = g_paramters[P_ROWS].value; Uint32 tot = g_paramters[P_ROWS].value;
if(g_paramters[P_BOUND].value == 2 || g_paramters[P_FILT].value == 2) if(g_paramters[P_BOUND].value >= 2 || g_paramters[P_FILT].value == 2)
iter *= g_paramters[P_ROWS].value; iter *= g_paramters[P_ROWS].value;
NdbScanOperation * pOp = 0; NdbScanOperation * pOp = 0;
...@@ -293,11 +258,24 @@ run_scan(){ ...@@ -293,11 +258,24 @@ run_scan(){
#else #else
pIOp->setBound((Uint32)0, NdbIndexScanOperation::BoundEQ, &row); pIOp->setBound((Uint32)0, NdbIndexScanOperation::BoundEQ, &row);
#endif #endif
if(g_paramters[P_RESET].value == 2)
goto execute;
break;
}
case 3: { // read multi
int multi = g_paramters[P_MULTI].value;
int tot = g_paramters[P_ROWS].value;
for(; multi > 0 && i < iter; --multi, i++)
{
int row = rand() % tot;
pIOp->setBound((Uint32)0, NdbIndexScanOperation::BoundEQ, &row);
pIOp->set_new_bound();
}
if(g_paramters[P_RESET].value == 2)
goto execute;
break; break;
} }
} }
if(g_paramters[P_RESET].value == 1)
goto execute;
} }
assert(pOp); assert(pOp);
assert(rs); assert(rs);
...@@ -333,6 +311,9 @@ run_scan(){ ...@@ -333,6 +311,9 @@ run_scan(){
for(int i = 0; i<g_table->getNoOfColumns(); i++){ for(int i = 0; i<g_table->getNoOfColumns(); i++){
pOp->getValue(i); pOp->getValue(i);
} }
if(g_paramters[P_RESET].value == 1)
g_paramters[P_RESET].value = 2;
execute: execute:
int rows = 0; int rows = 0;
check = pTrans->execute(NoCommit); check = pTrans->execute(NoCommit);
...@@ -376,7 +357,8 @@ run_scan(){ ...@@ -376,7 +357,8 @@ run_scan(){
} }
} }
g_err.println("Avg time: %d ms = %u rows/sec", sum_time/iter, g_err.println("Avg time: %d ms = %u rows/sec",
(1000*tot*iter)/sum_time); sum_time/iter,
(1000*iter)/sum_time);
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment