⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbtuxnode.cpp

📁 mysql-5.0.22.tar.gz源码包
💻 CPP
📖 第 1 页 / 共 2 页
字号:
voidDbtux::nodePushDownScans(NodeHandle& node, unsigned pos){  const unsigned occup = node.getOccup();  ScanOpPtr scanPtr;  scanPtr.i = node.getNodeScan();  do {    jam();    c_scanOpPool.getPtr(scanPtr);    TreePos& scanPos = scanPtr.p->m_scanPos;    ndbrequire(scanPos.m_loc == node.m_loc && scanPos.m_pos < occup);    // handled before    ndbrequire(scanPos.m_pos != 0);    if (scanPos.m_pos <= pos) {      jam();#ifdef VM_TRACE      if (debugFlags & DebugScan) {        debugOut << "Fix scan " << scanPtr.i << " " << *scanPtr.p << endl;        debugOut << "At pushDown pos=" << pos << " " << node << endl;      }#endif      scanPos.m_pos--;    }    scanPtr.i = scanPtr.p->m_nodeScan;  } while (scanPtr.i != RNIL);}/* * Remove and return entry at position.  Move entries less than the * removed one to the right.  Replace min entry by the input entry. * This is the opposite of nodePushDown. * *      X                        D *      v     ^                  ^ *      A B C D E _ _  =>  X A B C E _ _ *      0 1 2 3 4 5 6      0 1 2 3 4 5 6 * * Move scans at removed entry and add scans at the new entry. */voidDbtux::nodePopUp(NodeHandle& node, unsigned pos, TreeEnt& ent, Uint32 scanList){  Frag& frag = node.m_frag;  TreeHead& tree = frag.m_tree;  const unsigned occup = node.getOccup();  ndbrequire(occup <= tree.m_maxOccup && pos < occup);  if (node.getNodeScan() != RNIL) {    // move scans whose entry disappears    moveScanList(node, pos);    // fix other scans    if (node.getNodeScan() != RNIL)      nodePopUpScans(node, pos);  }  // 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];  for (unsigned i = pos; i > 0; i--) {    jam();    tmpList[i] = tmpList[i - 1];  }  tmpList[0] = newMin;  entList[0] = entList[occup];  // add scans  if (scanList != RNIL)    addScanList(node, 0, scanList);  // fix prefix  if (true)    setNodePref(node);}voidDbtux::nodePopUpScans(NodeHandle& node, unsigned pos){  const unsigned occup = node.getOccup();  ScanOpPtr scanPtr;  scanPtr.i = node.getNodeScan();  do {    jam();    c_scanOpPool.getPtr(scanPtr);    TreePos& scanPos = scanPtr.p->m_scanPos;    ndbrequire(scanPos.m_loc == node.m_loc && scanPos.m_pos < occup);    ndbrequire(scanPos.m_pos != pos);    if (scanPos.m_pos < pos) {      jam();#ifdef VM_TRACE      if (debugFlags & DebugScan) {        debugOut << "Fix scan " << scanPtr.i << " " << *scanPtr.p << endl;        debugOut << "At popUp pos=" << pos << " " << node << endl;      }#endif      scanPos.m_pos++;    }    scanPtr.i = scanPtr.p->m_nodeScan;  } while (scanPtr.i != RNIL);}/* * Move number of entries from another node to this node before the min * (i=0) or after the max (i=1).  Expensive but not often used. */voidDbtux::nodeSlide(NodeHandle& dstNode, NodeHandle& srcNode, unsigned cnt, unsigned i){  Frag& frag = dstNode.m_frag;  TreeHead& tree = frag.m_tree;  ndbrequire(i <= 1);  while (cnt != 0) {    TreeEnt ent;    Uint32 scanList = RNIL;    nodePopDown(srcNode, i == 0 ? srcNode.getOccup() - 1 : 0, ent, &scanList);    nodePushUp(dstNode, i == 0 ? 0 : dstNode.getOccup(), ent, scanList);    cnt--;  }}// scans linked to node/* * Add list of scans to node at given position. */voidDbtux::addScanList(NodeHandle& node, unsigned pos, Uint32 scanList){  ScanOpPtr scanPtr;  scanPtr.i = scanList;  do {    jam();    c_scanOpPool.getPtr(scanPtr);#ifdef VM_TRACE      if (debugFlags & DebugScan) {        debugOut << "Add scan " << scanPtr.i << " " << *scanPtr.p << endl;        debugOut << "To pos=" << pos << " " << node << endl;      }#endif    const Uint32 nextPtrI = scanPtr.p->m_nodeScan;    scanPtr.p->m_nodeScan = RNIL;    linkScan(node, scanPtr);    TreePos& scanPos = scanPtr.p->m_scanPos;    // set position but leave direction alone    scanPos.m_loc = node.m_loc;    scanPos.m_pos = pos;    scanPtr.i = nextPtrI;  } while (scanPtr.i != RNIL);}/* * Remove list of scans from node at given position.  The return * location must point to existing list (in fact RNIL always). */voidDbtux::removeScanList(NodeHandle& node, unsigned pos, Uint32& scanList){  ScanOpPtr scanPtr;  scanPtr.i = node.getNodeScan();  do {    jam();    c_scanOpPool.getPtr(scanPtr);    const Uint32 nextPtrI = scanPtr.p->m_nodeScan;    TreePos& scanPos = scanPtr.p->m_scanPos;    ndbrequire(scanPos.m_loc == node.m_loc);    if (scanPos.m_pos == pos) {      jam();#ifdef VM_TRACE      if (debugFlags & DebugScan) {        debugOut << "Remove scan " << scanPtr.i << " " << *scanPtr.p << endl;        debugOut << "Fron pos=" << pos << " " << node << endl;      }#endif      unlinkScan(node, scanPtr);      scanPtr.p->m_nodeScan = scanList;      scanList = scanPtr.i;      // unset position but leave direction alone      scanPos.m_loc = NullTupLoc;      scanPos.m_pos = ZNIL;    }    scanPtr.i = nextPtrI;  } while (scanPtr.i != RNIL);}/* * Move list of scans away from entry about to be removed.  Uses scan * method scanNext(). */voidDbtux::moveScanList(NodeHandle& node, unsigned pos){  ScanOpPtr scanPtr;  scanPtr.i = node.getNodeScan();  do {    jam();    c_scanOpPool.getPtr(scanPtr);    TreePos& scanPos = scanPtr.p->m_scanPos;    const Uint32 nextPtrI = scanPtr.p->m_nodeScan;    ndbrequire(scanPos.m_loc == node.m_loc);    if (scanPos.m_pos == pos) {      jam();#ifdef VM_TRACE      if (debugFlags & DebugScan) {        debugOut << "Move scan " << scanPtr.i << " " << *scanPtr.p << endl;        debugOut << "At pos=" << pos << " " << node << endl;      }#endif      scanNext(scanPtr, true);      ndbrequire(! (scanPos.m_loc == node.m_loc && scanPos.m_pos == pos));    }    scanPtr.i = nextPtrI;  } while (scanPtr.i != RNIL);}/* * Link scan to the list under the node.  The list is single-linked and * ordering does not matter. */voidDbtux::linkScan(NodeHandle& node, ScanOpPtr scanPtr){#ifdef VM_TRACE  if (debugFlags & DebugScan) {    debugOut << "Link scan " << scanPtr.i << " " << *scanPtr.p << endl;    debugOut << "To node " << node << endl;  }#endif  ndbrequire(! islinkScan(node, scanPtr) && scanPtr.p->m_nodeScan == RNIL);  scanPtr.p->m_nodeScan = node.getNodeScan();  node.setNodeScan(scanPtr.i);}/* * Unlink a scan from the list under the node. */voidDbtux::unlinkScan(NodeHandle& node, ScanOpPtr scanPtr){#ifdef VM_TRACE  if (debugFlags & DebugScan) {    debugOut << "Unlink scan " << scanPtr.i << " " << *scanPtr.p << endl;    debugOut << "From node " << node << endl;  }#endif  ScanOpPtr currPtr;  currPtr.i = node.getNodeScan();  ScanOpPtr prevPtr;  prevPtr.i = RNIL;  while (true) {    jam();    c_scanOpPool.getPtr(currPtr);    Uint32 nextPtrI = currPtr.p->m_nodeScan;    if (currPtr.i == scanPtr.i) {      jam();      if (prevPtr.i == RNIL) {        node.setNodeScan(nextPtrI);      } else {        jam();        prevPtr.p->m_nodeScan = nextPtrI;      }      scanPtr.p->m_nodeScan = RNIL;      // check for duplicates      ndbrequire(! islinkScan(node, scanPtr));      return;    }    prevPtr = currPtr;    currPtr.i = nextPtrI;  }}/* * Check if a scan is linked to this node.  Only for ndbrequire. */boolDbtux::islinkScan(NodeHandle& node, ScanOpPtr scanPtr){  ScanOpPtr currPtr;  currPtr.i = node.getNodeScan();  while (currPtr.i != RNIL) {    jam();    c_scanOpPool.getPtr(currPtr);    if (currPtr.i == scanPtr.i) {      jam();      return true;    }    currPtr.i = currPtr.p->m_nodeScan;  }  return false;}voidDbtux::NodeHandle::progError(int line, int cause, const char* file){  ErrorReporter::handleAssert("Dbtux::NodeHandle: assert failed", file, line);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -