4336 Pekka Nousiainen 2011-04-24
wl#4163 b04_maxent.diff
move max entry from node head to node end
modified:
storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp
storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
storage/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp
storage/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp
4335 Pekka Nousiainen 2011-04-24
wl#4163 b03_minmax.diff
remove pointless method getMinMax()
modified:
storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp
storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
storage/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp
storage/ndb/src/kernel/blocks/dbtux/DbtuxSearch.cpp
4334 Pekka Nousiainen 2011-04-24
wl#4163 b02_accsize.diff
remove obsolete enum AccSize
modified:
storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp
storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
storage/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp
4333 Pekka Nousiainen 2011-04-24
wl#4163 b01_findfrg.diff
common findFrag()
modified:
storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp
storage/ndb/src/kernel/blocks/dbtux/DbtuxBuild.cpp
storage/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp
storage/ndb/src/kernel/blocks/dbtux/DbtuxMaint.cpp
storage/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp
4332 Pekka Nousiainen 2011-04-24 [merge]
merge to wl4163
modified:
storage/ndb/test/ndbapi/testDict.cpp
=== modified file 'storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp'
--- a/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp 2011-04-19 09:01:07 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp 2011-04-24 16:20:23 +0000
@@ -219,16 +219,11 @@ private:
static const TreeEnt NullTreeEnt;
/*
- * Tree node has 1) fixed part 2) a prefix of index key data for min
- * entry 3) max and min entries 4) rest of entries 5) one extra entry
- * used as work space.
+ * Tree node has 3 parts:
*
- * struct TreeNode part 1, size 6 words
- * min prefix part 2, size TreeHead::m_prefSize
- * max entry part 3
- * min entry part 3
- * rest of entries part 4
- * work entry part 5
+ * 1) struct TreeNode - the header (6 words)
+ * 2) some key values for min entry - the min prefix
+ * 3) list of TreeEnt (each 2 words)
*
* There are 3 links to other nodes: left child, right child, parent.
* Occupancy (number of entries) is at least 1 except temporarily when
@@ -248,17 +243,6 @@ private:
STATIC_CONST( NodeHeadSize = sizeof(TreeNode) >> 2 );
/*
- * Tree node "access size" was for an early version with signal
- * interface to TUP. It is now used only to compute sizes.
- */
- enum AccSize {
- AccNone = 0,
- AccHead = 1, // part 1
- AccPref = 2, // parts 1-3
- AccFull = 3 // parts 1-5
- };
-
- /*
* Tree header. There is one in each fragment. Contains tree
* parameters and address of root node.
*/
@@ -273,7 +257,6 @@ private:
TupLoc m_root; // root node
TreeHead();
// methods
- unsigned getSize(AccSize acc) const;
Data getPref(TreeNode* node) const;
TreeEnt* getEntList(TreeNode* node) const;
};
@@ -562,7 +545,6 @@ private:
// access other parts of the node
Data getPref();
TreeEnt getEnt(unsigned pos);
- TreeEnt getMinMax(unsigned i);
// for ndbrequire and ndbassert
void progError(int line, int cause, const char* file);
};
@@ -583,6 +565,7 @@ private:
void readTablePk(const Frag& frag, TreeEnt ent, Data pkData, unsigned& pkSize);
void copyAttrs(TuxCtx&, const Frag& frag, ConstData data1, Data data2, unsigned maxlen2 = MaxAttrDataSize);
void unpackBound(const ScanBound& bound, Data data);
+ void findFrag(const Index& index, Uint32 fragId, FragPtr& fragPtr);
/*
* DbtuxMeta.cpp
@@ -929,22 +912,6 @@ Dbtux::TreeHead::TreeHead() :
{
}
-inline unsigned
-Dbtux::TreeHead::getSize(AccSize acc) const
-{
- switch (acc) {
- case AccNone:
- return 0;
- case AccHead:
- return NodeHeadSize;
- case AccPref:
- return NodeHeadSize + m_prefSize + 2 * TreeEntSize;
- case AccFull:
- return m_nodeSize;
- }
- return 0;
-}
-
inline Dbtux::Data
Dbtux::TreeHead::getPref(TreeNode* node) const
{
@@ -1201,15 +1168,7 @@ Dbtux::NodeHandle::getEnt(unsigned pos)
TreeEnt* entList = tree.getEntList(m_node);
const unsigned occup = m_node->m_occup;
ndbrequire(pos < occup);
- return entList[(1 + pos) % occup];
-}
-
-inline Dbtux::TreeEnt
-Dbtux::NodeHandle::getMinMax(unsigned i)
-{
- const unsigned occup = m_node->m_occup;
- ndbrequire(i <= 1 && occup != 0);
- return getEnt(i == 0 ? 0 : occup - 1);
+ return entList[pos];
}
// parameters for methods
=== modified file 'storage/ndb/src/kernel/blocks/dbtux/DbtuxBuild.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxBuild.cpp 2011-01-30 20:56:00 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxBuild.cpp 2011-04-24 13:10:50 +0000
@@ -83,15 +83,7 @@ Dbtux::mt_buildIndexFragment(mt_BuildInd
const Uint32 fragId = req->fragId;
// get the fragment
FragPtr fragPtr;
- fragPtr.i = RNIL;
- for (unsigned i = 0; i < indexPtr.p->m_numFrags; i++) {
- jam();
- if (indexPtr.p->m_fragId[i] == fragId) {
- jam();
- c_fragPool.getPtr(fragPtr, indexPtr.p->m_fragPtrI[i]);
- break;
- }
- }
+ findFrag(*indexPtr.p, fragId, fragPtr);
ndbrequire(fragPtr.i != RNIL);
Frag& frag = *fragPtr.p;
=== modified file 'storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2011-02-01 23:27:25 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2011-04-24 16:20:23 +0000
@@ -286,7 +286,7 @@ Dbtux::printNode(TuxCtx & ctx,
{ ConstData data1 = node.getPref();
Uint32 data2[MaxPrefSize];
memset(data2, DataFillByte, MaxPrefSize << 2);
- readKeyAttrs(ctx, frag, node.getMinMax(0), 0, ctx.c_searchKey);
+ readKeyAttrs(ctx, frag, node.getEnt(0), 0, ctx.c_searchKey);
copyAttrs(ctx, frag, ctx.c_searchKey, data2, tree.m_prefSize);
for (unsigned n = 0; n < tree.m_prefSize; n++) {
if (data1[n] != data2[n]) {
@@ -320,7 +320,8 @@ Dbtux::printNode(TuxCtx & ctx,
if (node.getLink(i) == NullTupLoc)
continue;
const TreeEnt ent1 = cpar[i].m_minmax[1 - i];
- const TreeEnt ent2 = node.getMinMax(i);
+ const unsigned pos = (i == 0 ? 0 : node.getOccup() - 1);
+ const TreeEnt ent2 = node.getEnt(pos);
unsigned start = 0;
readKeyAttrs(ctx, frag, ent1, start, ctx.c_searchKey);
readKeyAttrs(ctx, frag, ent2, start, ctx.c_entryKey);
@@ -337,9 +338,10 @@ Dbtux::printNode(TuxCtx & ctx,
par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
par.m_occup = node.getOccup();
for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
- par.m_minmax[i] = node.getMinMax(i);
- else
+ if (node.getLink(i) == NullTupLoc) {
+ const unsigned pos = (i == 0 ? 0 : node.getOccup() - 1);
+ par.m_minmax[i] = node.getEnt(pos);
+ } else
par.m_minmax[i] = cpar[i].m_minmax[i];
}
}
@@ -387,9 +389,6 @@ operator<<(NdbOut& out, const Dbtux::Tre
out << " [prefSize " << dec << tree.m_prefSize << "]";
out << " [minOccup " << dec << tree.m_minOccup << "]";
out << " [maxOccup " << dec << tree.m_maxOccup << "]";
- out << " [AccHead " << dec << tree.getSize(Dbtux::AccHead) << "]";
- out << " [AccPref " << dec << tree.getSize(Dbtux::AccPref) << "]";
- out << " [AccFull " << dec << tree.getSize(Dbtux::AccFull) << "]";
out << " [root " << hex << tree.m_root << "]";
out << "]";
return out;
@@ -528,9 +527,8 @@ operator<<(NdbOut& out, const Dbtux::Nod
unsigned numpos = node.m_node->m_occup;
data = (const Uint32*)node.m_node + Dbtux::NodeHeadSize + tree.m_prefSize;
const Dbtux::TreeEnt* entList = (const Dbtux::TreeEnt*)data;
- // print entries in logical order
- for (unsigned pos = 1; pos <= numpos; pos++)
- out << " " << entList[pos % numpos];
+ for (unsigned pos = 0; pos < numpos; pos++)
+ out << " " << entList[pos];
out << "]";
out << "]";
return out;
=== modified file 'storage/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp 2011-02-01 23:27:25 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp 2011-04-24 13:10:50 +0000
@@ -366,4 +366,20 @@ Dbtux::unpackBound(const ScanBound& boun
}
}
+void
+Dbtux::findFrag(const Index& index, Uint32 fragId, FragPtr& fragPtr)
+{
+ const Uint32 numFrags = index.m_numFrags;
+ for (Uint32 i = 0; i < numFrags; i++) {
+ jam();
+ if (index.m_fragId[i] == fragId) {
+ jam();
+ fragPtr.i = index.m_fragPtrI[i];
+ c_fragPool.getPtr(fragPtr);
+ return;
+ }
+ }
+ fragPtr.i = RNIL;
+}
+
BLOCK_FUNCTIONS(Dbtux)
=== modified file 'storage/ndb/src/kernel/blocks/dbtux/DbtuxMaint.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxMaint.cpp 2011-02-01 21:05:11 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxMaint.cpp 2011-04-24 13:10:50 +0000
@@ -63,15 +63,7 @@ Dbtux::execTUX_MAINT_REQ(Signal* signal)
const Uint32 fragId = req->fragId;
// get the fragment
FragPtr fragPtr;
- fragPtr.i = RNIL;
- for (unsigned i = 0; i < indexPtr.p->m_numFrags; i++) {
- jam();
- if (indexPtr.p->m_fragId[i] == fragId) {
- jam();
- c_fragPool.getPtr(fragPtr, indexPtr.p->m_fragPtrI[i]);
- break;
- }
- }
+ findFrag(*indexPtr.p, fragId, fragPtr);
ndbrequire(fragPtr.i != RNIL);
Frag& frag = *fragPtr.p;
// set up index keys for this operation
=== modified file 'storage/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp 2011-02-01 23:27:25 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp 2011-04-24 16:20:23 +0000
@@ -313,21 +313,20 @@ Dbtux::execTUXFRAGREQ(Signal* signal)
tree.m_nodeSize = MAX_TTREE_NODE_SIZE;
tree.m_prefSize = MAX_TTREE_PREF_SIZE;
const unsigned maxSlack = MAX_TTREE_NODE_SLACK;
- // size up to and including first 2 entries
- const unsigned pref = tree.getSize(AccPref);
- if (! (pref <= tree.m_nodeSize)) {
+ // size of header and min prefix
+ const unsigned fixedSize = NodeHeadSize + tree.m_prefSize;
+ if (! (fixedSize <= tree.m_nodeSize)) {
jam();
errorCode = (TuxFragRef::ErrorCode)TuxAddAttrRef::InvalidNodeSize;
break;
}
- const unsigned slots = (tree.m_nodeSize - pref) / TreeEntSize;
- // leave out work space entry
- tree.m_maxOccup = 2 + slots - 1;
+ const unsigned slots = (tree.m_nodeSize - fixedSize) / TreeEntSize;
+ tree.m_maxOccup = slots;
// min occupancy of interior node must be at least 2
if (! (2 + maxSlack <= tree.m_maxOccup)) {
jam();
- errorCode = (TuxFragRef::ErrorCode)TuxAddAttrRef::InvalidNodeSize;
- break;
+ errorCode = (TuxFragRef::ErrorCode)TuxAddAttrRef::InvalidNodeSize;
+ break;
}
tree.m_minOccup = tree.m_maxOccup - maxSlack;
// root node does not exist (also set by ctor)
=== modified file 'storage/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp 2011-02-01 23:27:25 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp 2011-04-24 16:20:23 +0000
@@ -102,7 +102,7 @@ Dbtux::insertNode(NodeHandle& node)
TreeHead& tree = frag.m_tree;
memset(node.getPref(), DataFillByte, tree.m_prefSize << 2);
TreeEnt* entList = tree.getEntList(node.m_node);
- memset(entList, NodeFillByte, (tree.m_maxOccup + 1) * (TreeEntSize << 2));
+ memset(entList, NodeFillByte, tree.m_maxOccup * (TreeEntSize << 2));
#endif
}
@@ -156,7 +156,7 @@ Dbtux::setNodePref(TuxCtx & ctx, NodeHan
{
const Frag& frag = node.m_frag;
const TreeHead& tree = frag.m_tree;
- readKeyAttrs(ctx, frag, node.getMinMax(0), 0, ctx.c_entryKey);
+ readKeyAttrs(ctx, frag, node.getEnt(0), 0, ctx.c_entryKey);
copyAttrs(ctx, frag, ctx.c_entryKey, node.getPref(), tree.m_prefSize);
}
@@ -185,14 +185,11 @@ Dbtux::nodePushUp(TuxCtx & ctx, NodeHand
nodePushUpScans(node, pos);
// fix node
TreeEnt* const entList = tree.getEntList(node.m_node);
- entList[occup] = entList[0];
- TreeEnt* const tmpList = entList + 1;
for (unsigned i = occup; i > pos; i--) {
thrjam(ctx.jamBuffer);
- tmpList[i] = tmpList[i - 1];
+ entList[i] = entList[i - 1];
}
- tmpList[pos] = ent;
- entList[0] = entList[occup + 1];
+ entList[pos] = ent;
node.setOccup(occup + 1);
// add new scans
if (scanList != RNIL)
@@ -258,14 +255,11 @@ Dbtux::nodePopDown(TuxCtx& ctx, NodeHand
}
// fix node
TreeEnt* const entList = tree.getEntList(node.m_node);
- entList[occup] = entList[0];
- TreeEnt* const tmpList = entList + 1;
- ent = tmpList[pos];
+ ent = entList[pos];
for (unsigned i = pos; i < occup - 1; i++) {
thrjam(ctx.jamBuffer);
- tmpList[i] = tmpList[i + 1];
+ entList[i] = entList[i + 1];
}
- entList[0] = entList[occup - 1];
node.setOccup(occup - 1);
// fix prefix
if (occup != 1 && pos == 0)
@@ -326,16 +320,13 @@ Dbtux::nodePushDown(TuxCtx& ctx, NodeHan
}
// fix node
TreeEnt* const entList = tree.getEntList(node.m_node);
- entList[occup] = entList[0];
- TreeEnt* const tmpList = entList + 1;
- TreeEnt oldMin = tmpList[0];
+ TreeEnt oldMin = entList[0];
for (unsigned i = 0; i < pos; i++) {
thrjam(ctx.jamBuffer);
- tmpList[i] = tmpList[i + 1];
+ entList[i] = entList[i + 1];
}
- tmpList[pos] = ent;
+ entList[pos] = ent;
ent = oldMin;
- entList[0] = entList[occup];
// fix prefix
if (true)
setNodePref(ctx, node);
@@ -396,16 +387,13 @@ Dbtux::nodePopUp(TuxCtx& ctx, NodeHandle
}
// fix node
TreeEnt* const entList = tree.getEntList(node.m_node);
- entList[occup] = entList[0];
- TreeEnt* const tmpList = entList + 1;
TreeEnt newMin = ent;
- ent = tmpList[pos];
+ ent = entList[pos];
for (unsigned i = pos; i > 0; i--) {
thrjam(ctx.jamBuffer);
- tmpList[i] = tmpList[i - 1];
+ entList[i] = entList[i - 1];
}
- tmpList[0] = newMin;
- entList[0] = entList[occup];
+ entList[0] = newMin;
// add scans
if (scanList != RNIL)
addScanList(node, 0, scanList);
=== modified file 'storage/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp 2011-04-19 09:01:07 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp 2011-04-24 13:10:50 +0000
@@ -39,15 +39,7 @@ Dbtux::execACC_SCANREQ(Signal* signal)
c_indexPool.getPtr(indexPtr, req->tableId);
// get the fragment
FragPtr fragPtr;
- fragPtr.i = RNIL;
- for (unsigned i = 0; i < indexPtr.p->m_numFrags; i++) {
- jam();
- if (indexPtr.p->m_fragId[i] == req->fragmentNo) {
- jam();
- c_fragPool.getPtr(fragPtr, indexPtr.p->m_fragPtrI[i]);
- break;
- }
- }
+ findFrag(*indexPtr.p, req->fragmentNo, fragPtr);
ndbrequire(fragPtr.i != RNIL);
Frag& frag = *fragPtr.p;
// check for index not Online (i.e. Dropping)
=== modified file 'storage/ndb/src/kernel/blocks/dbtux/DbtuxSearch.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxSearch.cpp 2011-02-01 23:27:25 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxSearch.cpp 2011-04-24 16:12:04 +0000
@@ -53,14 +53,14 @@ Dbtux::searchToAdd(TuxCtx& ctx, Frag& fr
thrjam(ctx.jamBuffer);
// read and compare remaining attributes
ndbrequire(start < numAttrs);
- readKeyAttrs(ctx, frag, currNode.getMinMax(0), start, ctx.c_entryKey);
+ readKeyAttrs(ctx, frag, currNode.getEnt(0), start, ctx.c_entryKey);
ret = cmpSearchKey(ctx, frag, start, searchKey, ctx.c_entryKey);
ndbrequire(ret != NdbSqlUtil::CmpUnknown);
}
if (ret == 0) {
thrjam(ctx.jamBuffer);
// keys are equal, compare entry values
- ret = searchEnt.cmp(currNode.getMinMax(0));
+ ret = searchEnt.cmp(currNode.getEnt(0));
}
if (ret < 0) {
thrjam(ctx.jamBuffer);
@@ -185,14 +185,14 @@ Dbtux::searchToRemove(Frag& frag, ConstD
jam();
// read and compare remaining attributes
ndbrequire(start < numAttrs);
- readKeyAttrs(c_ctx, frag, currNode.getMinMax(0), start, c_ctx.c_entryKey);
+ readKeyAttrs(c_ctx, frag, currNode.getEnt(0), start, c_ctx.c_entryKey);
ret = cmpSearchKey(c_ctx, frag, start, searchKey, c_ctx.c_entryKey);
ndbrequire(ret != NdbSqlUtil::CmpUnknown);
}
if (ret == 0) {
jam();
// keys are equal, compare entry values
- ret = searchEnt.cmp(currNode.getMinMax(0));
+ ret = searchEnt.cmp(currNode.getEnt(0));
}
if (ret < 0) {
jam();
@@ -281,7 +281,7 @@ Dbtux::searchToScanAscending(Frag& frag,
if (ret == NdbSqlUtil::CmpUnknown) {
jam();
// read and compare all attributes
- readKeyAttrs(c_ctx, frag, currNode.getMinMax(0), 0, c_ctx.c_entryKey);
+ readKeyAttrs(c_ctx, frag, currNode.getEnt(0), 0, c_ctx.c_entryKey);
ret = cmpScanBound(frag, 0, boundInfo, boundCount, c_ctx.c_entryKey);
ndbrequire(ret != NdbSqlUtil::CmpUnknown);
}
@@ -368,7 +368,7 @@ Dbtux::searchToScanDescending(Frag& frag
if (ret == NdbSqlUtil::CmpUnknown) {
jam();
// read and compare all attributes
- readKeyAttrs(c_ctx, frag, currNode.getMinMax(0), 0, c_ctx.c_entryKey);
+ readKeyAttrs(c_ctx, frag, currNode.getEnt(0), 0, c_ctx.c_entryKey);
ret = cmpScanBound(frag, 1, boundInfo, boundCount, c_ctx.c_entryKey);
ndbrequire(ret != NdbSqlUtil::CmpUnknown);
}
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.1-telco-7.0-wl4163 branch (pekka:4332 to 4336) WL#4163 | Pekka Nousiainen | 24 Apr |