diff options
author | unknown <joreland@mysql.com> | 2005-01-10 14:40:54 +0100 |
---|---|---|
committer | unknown <joreland@mysql.com> | 2005-01-10 14:40:54 +0100 |
commit | 37b42d2dbb81245f9de4b15af86291927d1e19bf (patch) | |
tree | b0d9a77973b552c24c397b7bc37c1d15855140b5 /ndb/src/ndbapi/Ndb.cpp | |
parent | 17ec81284a6b1a092e3beb95fa3cacab571d7f8c (diff) | |
download | mariadb-git-37b42d2dbb81245f9de4b15af86291927d1e19bf.tar.gz |
wl2240 - ndb partitioning
1) Fix startTransaction with hint
2) Ship fragment data to API to make better guess
3) Expose both primary & backup replicas
To (in the future) be even more clever on choosing nodes for
transactions/operations
ndb/include/kernel/ndb_limits.h:
Set maxsize of array with fragment data
ndb/include/kernel/signaldata/DictTabInfo.hpp:
Send fragment data to API
ndb/src/common/debugger/signaldata/DictTabInfo.cpp:
Send fragment data to API
ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
Send fragment data to API
ndb/src/kernel/blocks/dbdict/Dbdict.hpp:
Send fragment data to API
ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
Use Uint16 for fragment info
Fix uninit variable
ndb/src/ndbapi/Ndb.cpp:
Impl. startTransaction with hint
ndb/src/ndbapi/NdbDictionaryImpl.cpp:
Add interface for retreiving replica nodes given a hash-value
ndb/src/ndbapi/NdbDictionaryImpl.hpp:
Add interface for retreiving replica nodes given a hash-value
ndb/src/ndbapi/ndb_cluster_connection.cpp:
remove Fragment2NodeMap and put it on table instead
ndb/src/ndbapi/ndb_cluster_connection_impl.hpp:
remove Fragment2NodeMap and put it on table instead
ndb/test/ndbapi/testNdbApi.cpp:
Test some more
Diffstat (limited to 'ndb/src/ndbapi/Ndb.cpp')
-rw-r--r-- | ndb/src/ndbapi/Ndb.cpp | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index aa3f188e885..ba878ac4336 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -307,18 +307,41 @@ Ndb::startTransaction(const NdbDictionary::Table *table, if (theInitState == Initialised) { theError.code = 0; checkFailedNode(); - /** - * If the user supplied key data - * We will make a qualified quess to which node is the primary for the - * the fragment and contact that node - */ + /** + * If the user supplied key data + * We will make a qualified quess to which node is the primary for the + * the fragment and contact that node + */ Uint32 nodeId; - if(keyData != 0) { - nodeId = 0; // guess not supported - // nodeId = m_ndb_cluster_connection->guess_primary_node(keyData, keyLen); + NdbTableImpl* impl; + if(table != 0 && keyData != 0 && (impl= &NdbTableImpl::getImpl(*table))) + { + Uint32 hashValue; + { + Uint32 buf[4]; + if((UintPtr(keyData) & 7) == 0 && (keyLen & 3) == 0) + { + md5_hash(buf, (const Uint64*)keyData, keyLen >> 2); + } + else + { + Uint64 tmp[1000]; + tmp[keyLen/8] = 0; + memcpy(tmp, keyData, keyLen); + md5_hash(buf, tmp, (keyLen+3) >> 2); + } + hashValue= buf[1]; + } + const Uint16 *nodes; + Uint32 cnt= impl->get_nodes(hashValue, &nodes); + if(cnt) + nodeId= nodes[0]; + else + nodeId= 0; } else { nodeId = 0; }//if + { NdbTransaction *trans= startTransactionLocal(0, nodeId); DBUG_PRINT("exit",("start trans: 0x%x transid: 0x%llx", |