21 #include <SimulatedBlock.hpp>
22 #include <signaldata/LqhKey.hpp>
23 #include <signaldata/ScanFrag.hpp>
24 #include <AttributeHeader.hpp>
25 #include <SLFifoList.hpp>
26 #include <DLFifoList.hpp>
28 #include <ArenaPool.hpp>
29 #include <DataBuffer2.hpp>
30 #include <Bitmask.hpp>
31 #include <signaldata/DbspjErr.hpp>
32 #include "../dbtup/tuppage.hpp"
47 NdbTick_CurrentMicrosecond(&sec, µ);
48 return Uint64(sec * 1000000 + micro);
63 void execLQHKEYREQ(
Signal* signal);
64 void execSCAN_FRAGREQ(
Signal* signal);
65 void execSCAN_NEXTREQ(
Signal* signal);
67 void execDIH_SCAN_TAB_REF(
Signal*);
68 void execDIH_SCAN_TAB_CONF(
Signal*);
69 void execDIH_SCAN_GET_NODES_REF(
Signal*);
70 void execDIH_SCAN_GET_NODES_CONF(
Signal*);
75 void execLQHKEYREF(
Signal* signal);
76 void execLQHKEYCONF(
Signal* signal);
77 void execSCAN_FRAGREF(
Signal* signal);
78 void execSCAN_FRAGCONF(
Signal* signal);
79 void execSCAN_HBREP(
Signal* signal);
80 void execTRANSID_AI(
Signal*signal);
85 void execDUMP_STATE_ORD(
Signal* signal){}
86 void execREAD_NODESCONF(
Signal*);
87 void execREAD_CONFIG_REQ(
Signal* signal);
88 void execSTTOR(
Signal* signal);
89 void execDBINFO_SCANREQ(
Signal* signal);
90 void execCONTINUEB(
Signal*);
91 void execNODE_FAILREP(
Signal*);
92 void execINCL_NODEREQ(
Signal*);
93 void execAPI_FAILREQ(
Signal*);
95 void sendSTTORRY(
Signal* signal);
120 void copyto_link(Uint32 * dst)
const {
121 dst[0] = m_page_id; dst[1] = m_page_pos;
123 void assign_from_link(
const Uint32 * src) {
128 void copyto_map(Uint16 * dst)
const {
129 dst[0] = Uint16(m_page_id);
130 dst[1] = Uint16(m_page_id >> 16);
134 void assign_from_map(
const Uint16 * src) {
136 m_page_id += Uint32(src[1]) << 16;
140 static bool map_is_null(
const Uint16 * src) {
141 return src[2] == 0xFFFF;
144 void setNull() { m_page_id = RNIL;}
145 bool isNull()
const {
return m_page_id == RNIL;}
148 static const RowRef NullRowRef;
156 Uint32 m_src_node_no;
157 Uint32 m_src_node_ptrI;
158 Uint32 m_src_correlation;
176 const Uint32 * m_data;
198 Uint32 m_last_row_page_id;
199 Uint16 m_first_row_page_pos;
200 Uint16 m_last_row_page_pos;
218 bool isNull()
const {
return m_map_ref.isNull(); }
220 void assign (RowRef ref) {
224 void copyto(RowRef& ref)
const {
232 memset(ptr, 0xFF, MAP_SIZE_PER_REF_16 * m_size *
sizeof(Uint16));
234 void store(Uint32 * _ptr, Uint32 pos,
RowRef ref) {
235 Uint16 * ptr = (Uint16*)_ptr;
236 ptr += MAP_SIZE_PER_REF_16 * pos;
240 static void load(
const Uint32 * _ptr, Uint32 pos, RowRef & ref) {
241 const Uint16 * ptr = (
const Uint16*)_ptr;
242 ptr += MAP_SIZE_PER_REF_16 * pos;
243 ref.assign_from_map(ptr);
245 static bool isNull(
const Uint32 * _ptr, Uint32 pos) {
246 const Uint16 * ptr = (
const Uint16*)_ptr;
247 ptr += MAP_SIZE_PER_REF_16 * pos;
248 return RowRef::map_is_null(ptr);
251 STATIC_CONST( MAP_SIZE_PER_REF_16 = 3 );
259 bool isNull()
const {
return m_ref.isNull(); }
260 void setNull() { m_ref.setNull(); }
275 bool isNull()
const {
return m_ref.isNull(); }
276 void setNull() { m_ref.setNull(); }
292 Uint32 m_savepointId;
293 Uint32 m_batch_size_rows;
319 Uint32 m_data[GLOBAL_PAGE_SIZE_WORDS - 7];
320 STATIC_CONST( SIZE = GLOBAL_PAGE_SIZE_WORDS - 7 );
344 struct Stack m_stack;
464 Uint32 m_api_resultRef;
465 Uint32 m_api_resultData;
477 Uint32 m_lqhKeyReq[LqhKeyReq::FixedSignalLength + 4];
482 Uint32 m_rows_received;
483 Uint32 m_rows_expecting;
484 Uint32 m_scanFragReq[ScanFragReq::SignalLength + 2];
485 Uint32 m_scanFragHandlePtrI;
494 SFH_WAIT_NEXTREQ = 2,
499 void init(Uint32 fid) {
502 m_state = SFH_NOT_STARTED;
508 Uint32 m_treeNodePtrI;
513 void reset_ranges() {
515 m_range_builder.m_range_cnt = m_range_builder.m_range_size = 0;
546 m_mean = m_sumSquare = 0.0;
551 void update(
double sample);
553 double getMean()
const {
return m_mean; }
555 double getStdDev()
const {
556 return m_noOfSamples < 2 ? 0.0 : sqrt(m_sumSquare/(m_noOfSamples - 1));
564 Uint32 m_noOfSamples;
569 Uint16 m_frags_complete;
570 Uint16 m_frags_outstanding;
576 Uint32 m_rows_received;
577 Uint32 m_rows_expecting;
578 Uint32 m_batch_chunks;
582 Uint32 m_parallelism;
602 Uint32 m_constPrunePtrI;
614 Uint32 m_scanFragReq[ScanFragReq::SignalLength + 2];
629 STATIC_CONST ( MAGIC = ~RT_SPJ_TREENODE );
632 : m_magic(MAGIC), m_state(
TN_END),
633 m_parentPtrI(RNIL), m_requestPtrI(0),
641 m_parentPtrI(RNIL), m_requestPtrI(request),
643 nextList(RNIL), prevList(RNIL)
646 m_send.m_correlation = 0;
647 m_send.m_keyInfoPtrI = RNIL;
648 m_send.m_attrInfoPtrI = RNIL;
651 const Uint32 m_magic;
652 const struct OpInfo* m_info;
689 T_ATTR_INTERPRETED = 0x1,
774 bool isLeaf()
const {
return (m_bits &
T_LEAF) != 0;}
781 const Uint32 m_requestPtrI;
782 TreeNodeBitMask m_ancestors;
783 Dependency_map::Head m_dependent_nodes;
784 PatternStore::Head m_keyPattern;
785 PatternStore::Head m_attrParamPattern;
793 SLFifoRowList m_row_list;
798 LookupData m_lookup_data;
799 ScanFragData m_scanfrag_data;
800 ScanIndexData m_scanindex_data;
810 Uint32 m_keyInfoPtrI;
811 Uint32 m_attrInfoPtrI;
830 Local_TreeNodeCursor_list;
840 ,RT_ROW_BUFFERS = 0x2
843 ,RT_NEED_PREPARE = 0x10
844 ,RT_NEED_COMPLETE = 0x20
845 ,RT_REPEAT_SCAN_RESULT = 0x40
855 RS_ABORTING = 0x1000,
871 Uint32 m_rootResultData;
879 Uint32 m_outstanding;
880 Uint16 m_lookup_node_data[MAX_NDB_NODES];
884 #ifdef SPJ_TRACE_TIME
885 Uint32 m_cnt_batches;
887 Uint32 m_sum_running;
888 Uint32 m_sum_waiting;
892 bool isScan()
const {
return (m_bits & RT_SCAN) != 0;}
893 bool isLookup()
const {
return (m_bits & RT_SCAN) == 0;}
895 bool equal(
const Request & key)
const {
897 m_senderData == key.m_senderData &&
898 m_transId[0] == key.m_transId[0] &&
899 m_transId[1] == key.m_transId[1];
902 Uint32 hashValue()
const {
903 return m_transId[0] ^ m_senderData;
924 CI_READS_RECEIVED = 0,
930 CI_LOCAL_READS_SENT = 1,
936 CI_REMOTE_READS_SENT = 2,
943 CI_READS_NOT_FOUND = 3,
949 CI_TABLE_SCANS_RECEIVED = 4,
955 CI_LOCAL_TABLE_SCANS_SENT = 5,
961 CI_RANGE_SCANS_RECEIVED = 6,
967 CI_LOCAL_RANGE_SCANS_SENT = 7,
973 CI_REMOTE_RANGE_SCANS_SENT = 8,
978 CI_SCAN_BATCHES_RETURNED = 9,
983 CI_SCAN_ROWS_RETURNED = 10,
988 CI_PRUNED_RANGE_SCANS_RECEIVED = 11,
994 CI_CONST_PRUNED_RANGE_SCANS_RECEIVED = 12,
1003 class MonotonicCounters {
1008 for(
int i = 0;
i < CI_END;
i++)
1014 Uint64 get_counter(CounterId
id)
const
1016 return m_counters[
id];
1019 void incr_counter(CounterId
id, Uint64 delta)
1021 m_counters[
id] += delta;
1025 Uint64 m_counters[CI_END];
1036 Request_pool m_request_pool;
1037 Request_hash m_scan_request_hash;
1038 Request_hash m_lookup_request_hash;
1040 TreeNode_pool m_treenode_pool;
1041 ScanFragHandle_pool m_scanfraghandle_pool;
1048 void sendTCKEYREF(
Signal* signal, Uint32 ref, Uint32 routeRef);
1049 void sendTCKEYCONF(
Signal* signal, Uint32 len, Uint32 ref, Uint32 routeRef);
1066 const OpInfo* getOpInfo(Uint32 op);
1082 void releaseRequestBuffers(
Ptr<Request> requestPtr,
bool reset);
1086 void nodeFail_checkRequests(
Signal*);
1095 Uint32* stackAlloc(RowBuffer& dst, RowRef&, Uint32 len);
1096 Uint32* varAlloc(RowBuffer& dst, RowRef&, Uint32 len);
1098 void add_to_list(SLFifoRowList & list, RowRef rowref);
1100 Uint32 * get_row_ptr(
const RowMap&, RowMapIterator pos);
1101 void setupRowPtr(
Ptr<TreeNode>, RowPtr& dst, RowRef,
const Uint32 * src);
1106 Uint32 * get_row_ptr_stack(RowRef pos);
1107 Uint32 * get_row_ptr_var(RowRef pos);
1113 bool next(SLFifoRowListIterator&);
1117 bool next(RowMapIterator&);
1124 Uint32 buildRowHeader(RowPtr::Header *,
const Uint32 *& src, Uint32 len);
1125 void getCorrelationData(
const RowPtr::Section & row, Uint32 col,
1126 Uint32& correlationNumber);
1127 void getCorrelationData(
const RowPtr::Linear & row, Uint32 col,
1128 Uint32& correlationNumber);
1129 Uint32 appendToPattern(Local_pattern_store &, DABuffer & tree, Uint32);
1130 Uint32 appendParamToPattern(Local_pattern_store&,
const RowPtr::Linear&,
1132 Uint32 appendParamHeadToPattern(Local_pattern_store&,
const RowPtr::Linear&,
1135 Uint32 appendTreeToSection(Uint32 & ptrI,
SectionReader &, Uint32);
1136 Uint32 appendColToSection(Uint32 & ptrI,
const RowPtr::Linear&, Uint32 col,
bool& hasNull);
1137 Uint32 appendColToSection(Uint32 & ptrI,
const RowPtr::Section&, Uint32 col,
bool& hasNull);
1138 Uint32 appendPkColToSection(Uint32 & ptrI,
const RowPtr::Section&,Uint32 col);
1139 Uint32 appendPkColToSection(Uint32 & ptrI,
const RowPtr::Linear&, Uint32 col);
1140 Uint32 appendAttrinfoToSection(Uint32 &,
const RowPtr::Linear&, Uint32 col,
bool& hasNull);
1141 Uint32 appendAttrinfoToSection(Uint32 &,
const RowPtr::Section&, Uint32 col,
bool& hasNull);
1142 Uint32 appendDataToSection(Uint32 & ptrI, Local_pattern_store&,
1143 Local_pattern_store::ConstDataBufferIterator&,
1144 Uint32 len,
bool& hasNull);
1145 Uint32 appendFromParent(Uint32 & ptrI, Local_pattern_store&,
1146 Local_pattern_store::ConstDataBufferIterator&,
1147 Uint32
level,
const RowPtr&,
bool& hasNull);
1148 Uint32 expand(Uint32 & ptrI, Local_pattern_store& p,
const RowPtr& r,
bool& hasNull){
1150 case RowPtr::RT_SECTION:
1151 return expandS(ptrI, p, r, hasNull);
1152 case RowPtr::RT_LINEAR:
1153 return expandL(ptrI, p, r, hasNull);
1155 return DbspjErr::InternalError;
1157 Uint32 expandS(Uint32 & ptrI, Local_pattern_store&,
const RowPtr&,
bool& hasNull);
1158 Uint32 expandL(Uint32 & ptrI, Local_pattern_store&,
const RowPtr&,
bool& hasNull);
1159 Uint32 expand(Uint32 & ptrI, DABuffer& pattern, Uint32 len,
1160 DABuffer & param, Uint32 cnt,
bool& hasNull);
1161 Uint32 expand(Local_pattern_store& dst,
Ptr<TreeNode> treeNodePtr,
1162 DABuffer & pattern, Uint32 len,
1163 DABuffer & param, Uint32 cnt);
1165 DABuffer & tree, Uint32 treeBits,
1166 DABuffer & param, Uint32 paramBits);
1168 Uint32 createEmptySection(Uint32 & ptrI);
1175 static const OpInfo g_LookupOpInfo;
1191 Uint32 handle_special_hash(Uint32 tableId, Uint32 dstHash[4],
1196 Uint32 computeHash(
Signal*, BuildKeyReq&, Uint32
table, Uint32 keyInfoPtrI);
1197 Uint32 computePartitionHash(
Signal*, BuildKeyReq&, Uint32
table, Uint32 keyInfoPtrI);
1198 Uint32 getNodes(
Signal*, BuildKeyReq&, Uint32 tableId);
1203 static const OpInfo g_ScanFragOpInfo;
1219 static const OpInfo g_ScanIndexOpInfo;
1223 DABuffer tree, Uint32 treeBits,
1224 DABuffer param, Uint32 paramBits);
1233 void scanIndex_send(
Signal* signal,
1239 Uint32& batchRange);
1240 void scanIndex_batchComplete(
Signal* signal);
1261 void releaseGlobal(
Signal*);
1268 Uint32 m_buffer0[8192];
1269 Uint32 m_buffer1[8192];