Commit 3f89a4f3 authored by unknown's avatar unknown

ndb - major update HugoOperations/Transactions

     +more code reuse
     +easier testing of indexes


ndb/include/ndbapi/NdbDictionary.hpp:
  Remove unimplemented enums
ndb/test/include/HugoOperations.hpp:
  Pass index on constructor
ndb/test/include/HugoTransactions.hpp:
  Pass index on constructor
ndb/test/include/UtilTransactions.hpp:
  Pass index on constructor
ndb/test/src/HugoAsynchTransactions.cpp:
  Pass index on constructor
ndb/test/src/HugoOperations.cpp:
  Use getOperation to select operation type
ndb/test/src/HugoTransactions.cpp:
  Use HugoOpertaions to run transactions
ndb/test/src/UtilTransactions.cpp:
  Use HugoOpertaions to run transactions
parent 253dab84
......@@ -754,8 +754,6 @@ public:
Undefined = 0, ///< Undefined object type (initial value)
UniqueHashIndex = 3, ///< Unique un-ordered hash index
///< (only one currently supported)
HashIndex = 4, ///< Non-unique un-ordered hash index
UniqueOrderedIndex = 5, ///< Unique ordered index
OrderedIndex = 6 ///< Non-unique ordered index
};
......
......@@ -24,7 +24,9 @@
class HugoOperations : public UtilTransactions {
public:
HugoOperations(const NdbDictionary::Table&);
HugoOperations(const NdbDictionary::Table&,
const NdbDictionary::Index* idx = 0);
~HugoOperations();
int startTransaction(Ndb*);
int closeTransaction(Ndb*);
......@@ -98,8 +100,6 @@ protected:
struct RsPair { NdbResultSet* m_result_set; int records; };
Vector<RsPair> m_result_sets;
Vector<RsPair> m_executed_result_sets;
private:
NdbConnection* pTrans;
};
#endif
......@@ -25,7 +25,8 @@
class HugoTransactions : public HugoOperations {
public:
HugoTransactions(const NdbDictionary::Table&);
HugoTransactions(const NdbDictionary::Table&,
const NdbDictionary::Index* idx = 0);
~HugoTransactions();
int createEvent(Ndb*);
int eventOperation(Ndb*, void* stats,
......
......@@ -23,15 +23,11 @@ typedef int (ReadCallBackFn)(NDBT_ResultRow*);
class UtilTransactions {
public:
enum ScanLock {
SL_Read = 0,
SL_ReadHold = 1,
SL_Exclusive = 2
};
UtilTransactions(const NdbDictionary::Table&);
UtilTransactions(Ndb* ndb, const char * tableName);
UtilTransactions(const NdbDictionary::Table&,
const NdbDictionary::Index* idx = 0);
UtilTransactions(Ndb* ndb,
const char * tableName, const char * indexName = 0);
int clearTable(Ndb*,
int records = 0,
int parallelism = 0);
......@@ -114,6 +110,12 @@ private:
protected:
int m_defaultClearMethod;
const NdbDictionary::Table& tab;
const NdbDictionary::Index* idx;
NdbConnection* pTrans;
NdbOperation* getOperation(NdbConnection*,
NdbOperation::OperationType);
NdbScanOperation* getScanOperation(NdbConnection*);
};
#endif
......@@ -17,11 +17,12 @@
#include <NdbSleep.h>
#include <HugoAsynchTransactions.hpp>
HugoAsynchTransactions::HugoAsynchTransactions(const NdbDictionary::Table& _tab):
HugoTransactions(_tab),
transactionsCompleted(0),
numTransactions(0),
transactions(NULL){
HugoAsynchTransactions::HugoAsynchTransactions(const NdbDictionary::Table& _t)
: HugoTransactions(_t),
transactionsCompleted(0),
numTransactions(0),
transactions(NULL)
{
}
HugoAsynchTransactions::~HugoAsynchTransactions(){
......
......@@ -57,8 +57,10 @@ int HugoOperations::pkReadRecord(Ndb* pNdb,
int a;
allocRows(numRecords);
int check;
for(int r=0; r < numRecords; r++){
NdbOperation* pOp = pTrans->getNdbOperation(tab.getName());
NdbOperation* pOp = getOperation(pTrans, NdbOperation::ReadRequest);
if (pOp == NULL) {
ERR(pTrans->getNdbError());
return NDBT_FAILED;
......@@ -115,7 +117,7 @@ int HugoOperations::pkUpdateRecord(Ndb* pNdb,
allocRows(numRecords);
int check;
for(int r=0; r < numRecords; r++){
NdbOperation* pOp = pTrans->getNdbOperation(tab.getName());
NdbOperation* pOp = getOperation(pTrans, NdbOperation::UpdateRequest);
if (pOp == NULL) {
ERR(pTrans->getNdbError());
return NDBT_FAILED;
......@@ -157,7 +159,7 @@ int HugoOperations::pkInsertRecord(Ndb* pNdb,
int a, check;
for(int r=0; r < numRecords; r++){
NdbOperation* pOp = pTrans->getNdbOperation(tab.getName());
NdbOperation* pOp = getOperation(pTrans, NdbOperation::InsertRequest);
if (pOp == NULL) {
ERR(pTrans->getNdbError());
return NDBT_FAILED;
......@@ -198,7 +200,7 @@ int HugoOperations::pkDeleteRecord(Ndb* pNdb,
int a, check;
for(int r=0; r < numRecords; r++){
NdbOperation* pOp = pTrans->getNdbOperation(tab.getName());
NdbOperation* pOp = getOperation(pTrans, NdbOperation::DeleteRequest);
if (pOp == NULL) {
ERR(pTrans->getNdbError());
return NDBT_FAILED;
......@@ -222,65 +224,6 @@ int HugoOperations::pkDeleteRecord(Ndb* pNdb,
}
return NDBT_OK;
}
#if 0
NdbResultSet*
HugoOperations::scanReadRecords(Ndb* pNdb, ScanLock lock){
NDBT_ResultRow * m_tmpRow = new NDBT_ResultRow(tab);
NdbScanOperation* pOp = pTrans->getNdbScanOperation(tab.getName());
if (pOp == NULL) {
ERR(pTrans->getNdbError());
return 0;
}
int check = 0;
NdbResultSet * rs = 0;
switch(lock){
case SL_ReadHold:
rs = pOp->readTuples(NdbScanOperation::LM_Read, 1, 1);
break;
case SL_Exclusive:
rs = pOp->readTuples(NdbScanOperation::LM_Exclusive, 1, 1);
break;
case SL_Read:
default:
rs = pOp->readTuples(NdbScanOperation::LM_Dirty, 1, 1);
}
if( rs == 0) {
ERR(pTrans->getNdbError());
return 0;
}
check = pOp->interpret_exit_ok();
if( check == -1 ) {
ERR(pTrans->getNdbError());
return 0;
}
// Define attributes to read
for(int a = 0; a<tab.getNoOfColumns(); a++){
if((m_tmpRow->attributeStore(a) =
pOp->getValue(tab.getColumn(a)->getName())) == 0) {
ERR(pTrans->getNdbError());
return 0;
}
}
return rs;
}
int
HugoOperations::readTuples(NdbResultSet* rs){
int res = 0;
while((res = rs->nextResult()) == 0){
}
if(res != 1)
return NDBT_FAILED;
return NDBT_OK;
}
#endif
int HugoOperations::execute_Commit(Ndb* pNdb,
AbortOption eao){
......@@ -392,11 +335,11 @@ int HugoOperations::execute_Rollback(Ndb* pNdb){
return NDBT_OK;
}
HugoOperations::HugoOperations(const NdbDictionary::Table& _tab):
UtilTransactions(_tab),
calc(_tab),
pTrans(NULL){
HugoOperations::HugoOperations(const NdbDictionary::Table& _tab,
const NdbDictionary::Index* idx):
UtilTransactions(_tab, idx),
calc(_tab)
{
}
HugoOperations::~HugoOperations(){
......@@ -531,14 +474,12 @@ HugoOperations::verifyUpdatesValue(int updatesValue, int _numRows){
}
void HugoOperations::allocRows(int _numRows){
deallocRows();
if(_numRows <= 0){
g_info << "Illegal value for num rows : " << _numRows << endl;
abort();
}
for(int b=0; b<_numRows; b++){
for(int b=rows.size(); b<_numRows; b++){
rows.push_back(new NDBT_ResultRow(tab));
}
}
......
This diff is collapsed.
This diff is collapsed.
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