21 #include <ndb_limits.h>
22 #include <SimulatedBlock.hpp>
23 #include <AttributeDescriptor.hpp>
24 #include <AttributeHeader.hpp>
25 #include <ArrayPool.hpp>
26 #include <DataBuffer.hpp>
27 #include <DLFifoList.hpp>
28 #include <md5_hash.hpp>
31 #include <dbtup/Dbtup.hpp>
34 #include <NdbPack.hpp>
37 #include <signaldata/DictTabInfo.hpp>
38 #include <signaldata/TuxContinueB.hpp>
39 #include <signaldata/TupFrag.hpp>
40 #include <signaldata/AlterIndxImpl.hpp>
41 #include <signaldata/DropTab.hpp>
42 #include <signaldata/TuxMaint.hpp>
43 #include <signaldata/AccScan.hpp>
44 #include <signaldata/TuxBound.hpp>
45 #include <signaldata/NextScan.hpp>
46 #include <signaldata/AccLock.hpp>
47 #include <signaldata/DumpStateOrd.hpp>
48 #include <signaldata/IndexStatSignal.hpp>
53 #include <OutputStream.hpp>
60 #define jam() jamLine(10000 + __LINE__)
61 #define jamEntry() jamEntryLine(10000 + __LINE__)
64 #define jam() jamLine(20000 + __LINE__)
65 #define jamEntry() jamEntryLine(20000 + __LINE__)
67 #ifdef DBTUX_MAINT_CPP
68 #define jam() jamLine(30000 + __LINE__)
69 #define jamEntry() jamEntryLine(30000 + __LINE__)
72 #define jam() jamLine(40000 + __LINE__)
73 #define jamEntry() jamEntryLine(40000 + __LINE__)
76 #define jam() jamLine(50000 + __LINE__)
77 #define jamEntry() jamEntryLine(50000 + __LINE__)
80 #define jam() jamLine(60000 + __LINE__)
81 #define jamEntry() jamEntryLine(60000 + __LINE__)
83 #ifdef DBTUX_SEARCH_CPP
84 #define jam() jamLine(70000 + __LINE__)
85 #define jamEntry() jamEntryLine(70000 + __LINE__)
88 #define jam() jamLine(80000 + __LINE__)
89 #define jamEntry() jamEntryLine(80000 + __LINE__)
92 #define jam() jamLine(90000 + __LINE__)
93 #define jamEntry() jamEntryLine(90000 + __LINE__)
95 #ifdef DBTUX_DEBUG_CPP
96 #define jam() jamLine(100000 + __LINE__)
97 #define jamEntry() jamEntryLine(100000 + __LINE__)
100 #define jam() jamLine(__LINE__)
101 #define jamEntry() jamEntryLine(__LINE__)
113 friend Uint32 Dbtux_mt_buildIndexFragment_wrapper_C(
void*);
123 STATIC_CONST( MaxIndexFragments = MAX_FRAG_PER_NODE );
124 STATIC_CONST( MaxIndexAttributes = MAX_ATTRIBUTES_IN_INDEX );
125 STATIC_CONST( MaxAttrDataSize = 2 * MAX_ATTRIBUTES_IN_INDEX + MAX_KEY_SIZE_IN_WORDS );
126 STATIC_CONST( MaxXfrmDataSize = MaxAttrDataSize * MAX_XFRM_MULTIPLY);
128 STATIC_CONST( DescPageSize = 512 );
130 STATIC_CONST( MaxTreeNodeSize = MAX_TTREE_NODE_SIZE );
131 STATIC_CONST( MaxPrefSize = MAX_TTREE_PREF_SIZE );
132 STATIC_CONST( ScanBoundSegmentSize = 7 );
133 STATIC_CONST( MaxAccLockOps = MAX_PARALLEL_OP_PER_SCAN );
134 STATIC_CONST( MaxTreeDepth = 32 );
137 STATIC_CONST( DebugBufferBytes = (MaxAttrDataSize << 2) );
139 BLOCK_DEFINES(
Dbtux);
145 STATIC_CONST( AttributeHeaderSize = 1 );
150 typedef Uint32 TupAddr;
151 STATIC_CONST( NullTupAddr = (Uint32)-1 );
167 TupLoc(Uint32 pageId, Uint16 pageOffset);
168 Uint32 getPageId()
const;
169 void setPageId(Uint32 pageId);
170 Uint32 getPageOffset()
const;
171 void setPageOffset(Uint32 pageOffset);
172 bool operator==(
const TupLoc& loc)
const;
173 bool operator!=(
const TupLoc& loc)
const;
181 #define NullTupLoc TupLoc()
192 friend struct TreeEnt;
195 unsigned m_tupVersion : 15;
198 bool eqtuple(
const TreeEnt ent)
const;
199 bool eq(
const TreeEnt ent)
const;
200 int cmp(
const TreeEnt ent)
const;
202 STATIC_CONST( TreeEntSize =
sizeof(TreeEnt) >> 2 );
203 static const TreeEnt NullTreeEnt;
217 friend struct TreeNode;
221 unsigned m_balance : 2;
227 STATIC_CONST( NodeHeadSize =
sizeof(TreeNode) >> 2 );
234 friend struct TreeHead;
243 Uint32* getPref(TreeNode* node)
const;
244 TreeEnt* getEntList(TreeNode* node)
const;
255 friend struct TreePos;
273 friend struct DescPage;
278 Uint32 m_data[DescPageSize];
285 Uint32 c_descPageList;
291 enum { Magic = 0xDE5C };
293 STATIC_CONST( DescHeadSize =
sizeof(DescHead) >> 2 );
297 STATIC_CONST( KeyTypeSize =
sizeof(
KeyType) >> 2 );
353 friend struct ScanOp;
377 Uint32 m_savePointId;
382 Uint8 m_readCommitted;
385 ScanBound m_scanBound[2];
421 Uint32 m_fragId[MaxIndexFragments];
422 Uint32 m_fragPtrI[MaxIndexFragments];
429 Uint32 m_statFragPtrI;
430 Uint32 m_statLoadTime;
439 RSS_AP_SNAPSHOT(c_indexPool);
456 Uint32 m_tupIndexFragPtrI;
457 Uint32 m_tupTableFragPtrI;
458 Uint32 m_accTableFragPtrI;
469 RSS_AP_SNAPSHOT(c_fragPool);
481 Uint32 m_numAttrsRecvd;
489 RSS_AP_SNAPSHOT(c_fragOpPool);
498 friend struct NodeHandle;
503 NodeHandle(Frag& frag);
504 NodeHandle(
const NodeHandle& node);
505 NodeHandle& operator=(
const NodeHandle& node);
509 TupLoc getLink(
unsigned i);
510 unsigned getChilds();
514 Uint32 getNodeScan();
516 void setLink(
unsigned i, TupLoc loc);
517 void setSide(
unsigned i);
518 void setOccup(
unsigned n);
519 void setBalance(
int b);
520 void setNodeScan(Uint32 scanPtrI);
523 TreeEnt getEnt(
unsigned pos);
530 friend struct StatOp;
543 Uint32 m_sampleCount;
548 enum { MaxKeyCount = MAX_INDEX_STAT_KEY_COUNT };
549 enum { MaxKeySize = MAX_INDEX_STAT_KEY_SIZE };
550 enum { MaxValueCount = MAX_INDEX_STAT_VALUE_COUNT };
551 enum { MaxValueSize = MAX_INDEX_STAT_VALUE_SIZE };
564 Uint32 m_keyDataBuf1[1 + MaxKeySize];
565 Uint32 m_keyDataBuf2[1 + MaxKeySize];
566 Uint32 m_keyDataBuf[1 + MaxKeySize];
567 Uint32 m_valueDataBuf[1 + MaxValueCount];
571 Uint32 m_unq[MaxKeyCount];
579 StatOp(
const Index&);
583 RSS_AP_SNAPSHOT(c_statOpPool);
587 friend struct StatMon;
590 Uint32 m_requestType;
592 Uint32 m_loopIndexId;
603 void execCONTINUEB(
Signal* signal);
604 void execSTTOR(
Signal* signal);
605 void execREAD_CONFIG_REQ(
Signal* signal);
606 void execNODE_STATE_REP(
Signal* signal);
609 void readKeyAttrs(TuxCtx&,
const Frag& frag, TreeEnt ent, KeyData& keyData, Uint32 count);
610 void readTablePk(
const Frag& frag, TreeEnt ent, Uint32* pkData,
unsigned& pkSize);
611 void unpackBound(TuxCtx&,
const ScanBound& bound, KeyBoundC& searchBound);
612 void findFrag(
const Index&
index, Uint32 fragId, FragPtr& fragPtr);
617 void execCREATE_TAB_REQ(
Signal*);
618 void execTUXFRAGREQ(
Signal* signal);
619 void execTUX_ADD_ATTRREQ(
Signal* signal);
620 void execALTER_INDX_IMPL_REQ(
Signal* signal);
621 void execDROP_TAB_REQ(
Signal* signal);
622 void execDROP_FRAG_REQ(
Signal* signal);
623 bool allocDescEnt(IndexPtr indexPtr);
624 void freeDescEnt(IndexPtr indexPtr);
625 void abortAddFragOp(
Signal* signal);
626 void dropIndex(
Signal* signal, IndexPtr indexPtr, Uint32 senderRef, Uint32 senderData);
631 void execTUX_MAINT_REQ(
Signal* signal);
636 int allocNode(TuxCtx&, NodeHandle& node);
637 void freeNode(NodeHandle& node);
638 void selectNode(NodeHandle& node, TupLoc loc);
639 void insertNode(NodeHandle& node);
640 void deleteNode(NodeHandle& node);
641 void freePreallocatedNode(Frag& frag);
642 void setNodePref(
struct TuxCtx &, NodeHandle& node);
644 void nodePushUp(TuxCtx&, NodeHandle& node,
unsigned pos,
const TreeEnt& ent, Uint32 scanList);
645 void nodePushUpScans(NodeHandle& node,
unsigned pos);
646 void nodePopDown(TuxCtx&, NodeHandle& node,
unsigned pos, TreeEnt& en, Uint32* scanList);
647 void nodePopDownScans(NodeHandle& node,
unsigned pos);
648 void nodePushDown(TuxCtx&, NodeHandle& node,
unsigned pos, TreeEnt& ent, Uint32& scanList);
649 void nodePushDownScans(NodeHandle& node,
unsigned pos);
650 void nodePopUp(TuxCtx&, NodeHandle& node,
unsigned pos, TreeEnt& ent, Uint32 scanList);
651 void nodePopUpScans(NodeHandle& node,
unsigned pos);
652 void nodeSlide(TuxCtx&, NodeHandle& dstNode, NodeHandle& srcNode,
unsigned cnt,
unsigned i);
654 void addScanList(NodeHandle& node,
unsigned pos, Uint32 scanList);
655 void removeScanList(NodeHandle& node,
unsigned pos, Uint32& scanList);
656 void moveScanList(NodeHandle& node,
unsigned pos);
657 void linkScan(NodeHandle& node, ScanOpPtr scanPtr);
658 void unlinkScan(NodeHandle& node, ScanOpPtr scanPtr);
659 bool islinkScan(NodeHandle& node, ScanOpPtr scanPtr);
665 void treeAdd(TuxCtx&, Frag& frag, TreePos treePos, TreeEnt ent);
666 void treeAddFull(TuxCtx&, Frag& frag, NodeHandle lubNode,
unsigned pos, TreeEnt ent);
667 void treeAddNode(TuxCtx&, Frag& frag, NodeHandle lubNode,
unsigned pos, TreeEnt ent, NodeHandle parentNode,
unsigned i);
668 void treeAddRebalance(TuxCtx&, Frag& frag, NodeHandle node,
unsigned i);
670 void treeRemove(Frag& frag, TreePos treePos);
671 void treeRemoveInner(Frag& frag, NodeHandle lubNode,
unsigned pos);
672 void treeRemoveSemi(Frag& frag, NodeHandle node,
unsigned i);
673 void treeRemoveLeaf(Frag& frag, NodeHandle node);
674 void treeRemoveNode(Frag& frag, NodeHandle node);
675 void treeRemoveRebalance(Frag& frag, NodeHandle node,
unsigned i);
677 void treeRotateSingle(TuxCtx&, Frag& frag, NodeHandle& node,
unsigned i);
678 void treeRotateDouble(TuxCtx&, Frag& frag, NodeHandle& node,
unsigned i);
683 void execACC_SCANREQ(
Signal* signal);
684 void execTUX_BOUND_INFO(
Signal* signal);
685 void execNEXT_SCANREQ(
Signal* signal);
686 void execACC_CHECK_SCAN(
Signal* signal);
687 void execACCKEYCONF(
Signal* signal);
688 void execACCKEYREF(
Signal* signal);
689 void execACC_ABORTCONF(
Signal* signal);
690 void scanFirst(ScanOpPtr scanPtr);
691 void scanFind(ScanOpPtr scanPtr);
692 void scanNext(ScanOpPtr scanPtr,
bool fromMaintReq);
693 bool scanCheck(ScanOpPtr scanPtr, TreeEnt ent);
694 bool scanVisible(ScanOpPtr scanPtr, TreeEnt ent);
695 void scanClose(
Signal* signal, ScanOpPtr scanPtr);
696 void abortAccLockOps(
Signal* signal, ScanOpPtr scanPtr);
697 void addAccLockOp(ScanOpPtr scanPtr, Uint32 accLockOp);
698 void removeAccLockOp(ScanOpPtr scanPtr, Uint32 accLockOp);
699 void releaseScanOp(ScanOpPtr& scanPtr);
704 void findNodeToUpdate(TuxCtx&, Frag& frag,
const KeyDataC& searchKey, TreeEnt searchEnt, NodeHandle& currNode);
705 bool findPosToAdd(TuxCtx&, Frag& frag,
const KeyDataC& searchKey, TreeEnt searchEnt, NodeHandle& currNode, TreePos& treePos);
706 bool findPosToRemove(TuxCtx&, Frag& frag,
const KeyDataC& searchKey, TreeEnt searchEnt, NodeHandle& currNode, TreePos& treePos);
707 bool searchToAdd(TuxCtx&, Frag& frag,
const KeyDataC& searchKey, TreeEnt searchEnt, TreePos& treePos);
708 bool searchToRemove(TuxCtx&, Frag& frag,
const KeyDataC& searchKey, TreeEnt searchEnt, TreePos& treePos);
709 void findNodeToScan(Frag& frag,
unsigned dir,
const KeyBoundC& searchBound, NodeHandle& currNode);
710 void findPosToScan(Frag& frag,
unsigned idir,
const KeyBoundC& searchBound, NodeHandle& currNode, Uint16* pos);
711 void searchToScan(Frag& frag,
unsigned idir,
const KeyBoundC& searchBound, TreePos& treePos);
716 int cmpSearchKey(TuxCtx&,
const KeyDataC& searchKey,
const KeyDataC& entryKey, Uint32 cnt);
717 int cmpSearchBound(TuxCtx&,
const KeyBoundC& searchBound,
const KeyDataC& entryKey, Uint32 cnt);
722 void execREAD_PSEUDO_REQ(
Signal* signal);
724 void statRecordsInRange(ScanOpPtr scanPtr, Uint32* out);
725 Uint32 getEntriesBeforeOrAfter(Frag& frag, TreePos pos,
unsigned idir);
726 unsigned getPathToNode(NodeHandle node, Uint16* path);
728 int statScanInit(StatOpPtr,
const Uint32* data, Uint32 len, Uint32* usedLen);
729 int statScanAddRow(StatOpPtr, TreeEnt ent);
730 void statScanReadKey(StatOpPtr, Uint32* out);
731 void statScanReadValue(StatOpPtr, Uint32* out);
732 void execINDEX_STAT_REP(
Signal*);
734 void execINDEX_STAT_IMPL_REQ(
Signal*);
735 void statMonStart(
Signal*, StatMon&);
736 void statMonStop(
Signal*, StatMon&);
737 void statMonConf(
Signal*, StatMon&);
739 void statMonSendContinueB(
Signal*);
740 void statMonExecContinueB(
Signal*);
741 void statMonCheck(
Signal*, StatMon&);
742 void statMonRep(
Signal*, StatMon&);
747 void execDUMP_STATE_ORD(
Signal* signal);
759 void printTree(
Signal* signal, Frag& frag, NdbOut& out);
760 void printNode(
struct TuxCtx&, Frag&, NdbOut& out, TupLoc loc, PrintPar& par);
761 friend class NdbOut& operator<<(NdbOut&,
const TupLoc&);
762 friend class NdbOut& operator<<(NdbOut&,
const TreeEnt&);
763 friend class NdbOut& operator<<(NdbOut&,
const TreeNode&);
764 friend class NdbOut& operator<<(NdbOut&,
const TreeHead&);
765 friend class NdbOut& operator<<(NdbOut&,
const TreePos&);
766 friend class NdbOut& operator<<(NdbOut&,
const KeyType&);
767 friend class NdbOut& operator<<(NdbOut&,
const ScanOp&);
768 friend class NdbOut& operator<<(NdbOut&,
const Index&);
769 friend class NdbOut& operator<<(NdbOut&,
const Frag&);
770 friend class NdbOut& operator<<(NdbOut&,
const FragOp&);
771 friend class NdbOut& operator<<(NdbOut&,
const NodeHandle&);
772 friend class NdbOut& operator<<(NdbOut&,
const StatOp&);
773 friend class NdbOut& operator<<(NdbOut&,
const StatMon&);
785 STATIC_CONST( DataFillByte = 0xa2 );
786 STATIC_CONST( NodeFillByte = 0xa4 );
789 void execDBINFO_SCANREQ(
Signal* signal);
792 Uint32 c_internalStartPhase;
793 Uint32 c_typeOfStart;
812 Uint32* c_dataBuffer;
822 bool c_indexStatAutoUpdate;
823 Uint32 c_indexStatSaveSize;
824 Uint32 c_indexStatSaveScale;
825 Uint32 c_indexStatTriggerPct;
826 Uint32 c_indexStatTriggerScale;
827 Uint32 c_indexStatUpdateDelay;
830 Uint32 getDescSize(
const Index&
index);
831 DescHead& getDescHead(
const Index&
index);
832 KeyType* getKeyTypes(DescHead& descHead);
833 const KeyType* getKeyTypes(
const DescHead& descHead);
837 void getTupAddr(
const Frag& frag, TreeEnt ent, Uint32& lkey1, Uint32& lkey2);
838 static unsigned min(
unsigned x,
unsigned y);
839 static unsigned max(
unsigned x,
unsigned y);
850 Dbtux::TupLoc::TupLoc() :
851 m_pageId1(RNIL >> 16),
852 m_pageId2(RNIL & 0xFFFF),
858 Dbtux::TupLoc::TupLoc(Uint32 pageId, Uint16 pageOffset) :
859 m_pageId1(pageId >> 16),
860 m_pageId2(pageId & 0xFFFF),
861 m_pageOffset(pageOffset)
866 Dbtux::TupLoc::getPageId()
const
868 return (m_pageId1 << 16) | m_pageId2;
872 Dbtux::TupLoc::setPageId(Uint32 pageId)
874 m_pageId1 = (pageId >> 16);
875 m_pageId2 = (pageId & 0xFFFF);
879 Dbtux::TupLoc::getPageOffset()
const
881 return (Uint32)m_pageOffset;
885 Dbtux::TupLoc::setPageOffset(Uint32 pageOffset)
887 m_pageOffset = (Uint16)pageOffset;
891 Dbtux::TupLoc::operator==(
const TupLoc& loc)
const
894 m_pageId1 == loc.m_pageId1 &&
895 m_pageId2 == loc.m_pageId2 &&
896 m_pageOffset == loc.m_pageOffset;
900 Dbtux::TupLoc::operator!=(
const TupLoc& loc)
const
902 return ! (*
this == loc);
908 Dbtux::TreeEnt::TreeEnt() :
915 Dbtux::TreeEnt::eqtuple(
const TreeEnt ent)
const
918 m_tupLoc == ent.m_tupLoc;
922 Dbtux::TreeEnt::eq(
const TreeEnt ent)
const
925 m_tupLoc == ent.m_tupLoc &&
926 m_tupVersion == ent.m_tupVersion;
930 Dbtux::TreeEnt::cmp(
const TreeEnt ent)
const
932 if (m_tupLoc.getPageId() < ent.m_tupLoc.getPageId())
934 if (m_tupLoc.getPageId() > ent.m_tupLoc.getPageId())
936 if (m_tupLoc.getPageOffset() < ent.m_tupLoc.getPageOffset())
938 if (m_tupLoc.getPageOffset() > ent.m_tupLoc.getPageOffset())
946 const unsigned version_wrap_limit = (1 << (ZTUP_VERSION_BITS - 1));
947 if (m_tupVersion < ent.m_tupVersion) {
948 if (
unsigned(ent.m_tupVersion - m_tupVersion) < version_wrap_limit)
953 if (m_tupVersion > ent.m_tupVersion) {
954 if (
unsigned(m_tupVersion - ent.m_tupVersion) < version_wrap_limit)
965 Dbtux::TreeNode::TreeNode() :
972 m_link[0] = NullTupLoc;
973 m_link[1] = NullTupLoc;
974 m_link[2] = NullTupLoc;
980 Dbtux::TreeHead::TreeHead() :
990 Dbtux::TreeHead::getPref(TreeNode* node)
const
992 Uint32* ptr = (Uint32*)node + NodeHeadSize;
996 inline Dbtux::TreeEnt*
997 Dbtux::TreeHead::getEntList(TreeNode* node)
const
999 Uint32* ptr = (Uint32*)node + NodeHeadSize + m_prefSize;
1000 return (TreeEnt*)ptr;
1006 Dbtux::TreePos::TreePos() :
1016 Dbtux::DescPage::DescPage() :
1020 for (
unsigned i = 0;
i < DescPageSize;
i++) {
1022 m_data[
i] = 0x13571357;
1032 Dbtux::ScanBound::ScanBound() :
1042 Dbtux::ScanOp::ScanOp() :
1070 Dbtux::Index::Index() :
1071 m_state(NotDefined),
1081 m_statFragPtrI(RNIL),
1083 m_storeNullKey(false)
1085 for (
unsigned i = 0;
i < MaxIndexFragments;
i++) {
1087 m_fragPtrI[
i] = RNIL;
1100 m_scanList(scanOpPool),
1101 m_tupIndexFragPtrI(RNIL),
1102 m_tupTableFragPtrI(RNIL),
1103 m_accTableFragPtrI(RNIL),
1113 Dbtux::FragOp::FragOp() :
1120 m_numAttrsRecvd(ZNIL)
1127 Dbtux::NodeHandle::NodeHandle(Frag& frag) :
1135 Dbtux::NodeHandle::NodeHandle(
const NodeHandle& node) :
1136 m_frag(node.m_frag),
1142 inline Dbtux::NodeHandle&
1143 Dbtux::NodeHandle::operator=(
const NodeHandle& node)
1145 ndbassert(&m_frag == &node.m_frag);
1147 m_node = node.m_node;
1152 Dbtux::NodeHandle::isNull()
1157 inline Dbtux::TupLoc
1158 Dbtux::NodeHandle::getLink(
unsigned i)
1161 return m_node->m_link[
i];
1165 Dbtux::NodeHandle::getChilds()
1167 return (m_node->m_link[0] != NullTupLoc) + (m_node->m_link[1] != NullTupLoc);
1171 Dbtux::NodeHandle::getSide()
1173 return m_node->m_side;
1177 Dbtux::NodeHandle::getOccup()
1179 return m_node->m_occup;
1183 Dbtux::NodeHandle::getBalance()
1185 return (
int)m_node->m_balance - 1;
1189 Dbtux::NodeHandle::getNodeScan()
1191 return m_node->m_nodeScan;
1195 Dbtux::NodeHandle::setLink(
unsigned i, TupLoc loc)
1199 m_node->m_link[
i] = loc;
1208 Dbtux::NodeHandle::setSide(
unsigned i)
1221 Dbtux::NodeHandle::setOccup(
unsigned n)
1223 TreeHead& tree = m_frag.m_tree;
1224 ndbrequire(n <= tree.m_maxOccup);
1225 m_node->m_occup =
n;
1229 Dbtux::NodeHandle::setBalance(
int b)
1231 ndbrequire(abs(b) <= 1);
1232 m_node->m_balance = (unsigned)(b + 1);
1236 Dbtux::NodeHandle::setNodeScan(Uint32 scanPtrI)
1238 m_node->m_nodeScan = scanPtrI;
1242 Dbtux::NodeHandle::getPref()
1244 TreeHead& tree = m_frag.m_tree;
1245 return tree.getPref(m_node);
1248 inline Dbtux::TreeEnt
1249 Dbtux::NodeHandle::getEnt(
unsigned pos)
1251 TreeHead& tree = m_frag.m_tree;
1252 TreeEnt* entList = tree.getEntList(m_node);
1253 const unsigned occup = m_node->m_occup;
1254 ndbrequire(pos < occup);
1255 return entList[pos];
1261 Dbtux::StatOp::Value::Value()
1265 for (i = 0; i < MaxKeyCount; i++)
1270 Dbtux::StatOp::StatOp(
const Index&
index) :
1278 m_haveSample(false),
1285 m_keySpec(index.m_keySpec),
1286 m_keyData1(m_keySpec, false, 2),
1287 m_keyData2(m_keySpec, false, 2),
1288 m_keyData(m_keySpec, false, 2),
1289 m_valueData(m_valueSpec, false, 2),
1293 m_valueSpec.set_buf(m_valueSpecBuf, MaxValueCount);
1294 m_keyData1.set_buf(m_keyDataBuf1,
sizeof(m_keyDataBuf1));
1295 m_keyData2.set_buf(m_keyDataBuf2,
sizeof(m_keyDataBuf2));
1296 m_keyData.set_buf(m_keyDataBuf,
sizeof(m_keyDataBuf));
1297 m_valueData.set_buf(m_valueDataBuf,
sizeof(m_valueDataBuf));
1303 Dbtux::StatMon::StatMon() :
1308 memset(&m_req, 0,
sizeof(m_req));
1315 Dbtux::PrintPar::PrintPar() :
1331 Dbtux::getDescSize(
const Index& index)
1335 index.m_numAttrs * KeyTypeSize +
1336 index.m_numAttrs * AttributeHeaderSize;
1339 inline Dbtux::DescHead&
1340 Dbtux::getDescHead(
const Index& index)
1342 DescPagePtr pagePtr;
1343 pagePtr.i = index.m_descPage;
1344 c_descPagePool.getPtr(pagePtr);
1345 ndbrequire(index.m_descOff < DescPageSize);
1346 Uint32* ptr = &pagePtr.p->m_data[index.m_descOff];
1347 DescHead* descHead =
reinterpret_cast<DescHead*
>(ptr);
1348 ndbrequire(descHead->m_magic == DescHead::Magic);
1353 Dbtux::getKeyTypes(DescHead& descHead)
1355 Uint32* ptr =
reinterpret_cast<Uint32*
>(&descHead);
1356 ptr += DescHeadSize;
1357 return reinterpret_cast<KeyType*
>(ptr);
1361 Dbtux::getKeyTypes(
const DescHead& descHead)
1363 const Uint32* ptr =
reinterpret_cast<const Uint32*
>(&descHead);
1364 ptr += DescHeadSize;
1365 return reinterpret_cast<const KeyType*
>(ptr);
1369 Dbtux::getKeyAttrs(DescHead& descHead)
1371 Uint32* ptr =
reinterpret_cast<Uint32*
>(&descHead);
1372 ptr += DescHeadSize;
1373 ptr += descHead.m_numAttrs * KeyTypeSize;
1378 Dbtux::getKeyAttrs(
const DescHead& descHead)
1380 const Uint32* ptr =
reinterpret_cast<const Uint32*
>(&descHead);
1381 ptr += DescHeadSize;
1382 ptr += descHead.m_numAttrs * KeyTypeSize;
1388 Dbtux::getTupAddr(
const Frag& frag, TreeEnt ent, Uint32& lkey1, Uint32& lkey2)
1390 const Uint32 tableFragPtrI = frag.m_tupTableFragPtrI;
1391 const TupLoc tupLoc = ent.m_tupLoc;
1392 c_tup->tuxGetTupAddr(tableFragPtrI, tupLoc.getPageId(),tupLoc.getPageOffset(),
1398 Dbtux::min(
unsigned x,
unsigned y)
1400 return x < y ? x : y;
1404 Dbtux::max(
unsigned x,
unsigned y)
1406 return x > y ? x : y;
1412 Dbtux::cmpSearchKey(TuxCtx& ctx,
const KeyDataC& searchKey,
const KeyDataC& entryKey, Uint32 cnt)
1416 int ret = searchKey.cmp(entryKey, cnt, num_eq);
1418 if (debugFlags & DebugMaint) {
1419 debugOut <<
"cmpSearchKey: ret:" <<
ret;
1420 debugOut <<
" search:" << searchKey.print(ctx.c_debugBuffer, DebugBufferBytes);
1421 debugOut <<
" entry:" << entryKey.print(ctx.c_debugBuffer, DebugBufferBytes);
1429 Dbtux::cmpSearchBound(TuxCtx& ctx,
const KeyBoundC& searchBound,
const KeyDataC& entryKey, Uint32 cnt)
1433 int ret = searchBound.cmp(entryKey, cnt, num_eq);
1435 if (debugFlags & DebugScan) {
1436 debugOut <<
"cmpSearchBound: res:" <<
ret;
1437 debugOut <<
" search:" << searchBound.print(ctx.c_debugBuffer, DebugBufferBytes);
1438 debugOut <<
" entry:" << entryKey.print(ctx.c_debugBuffer, DebugBufferBytes);