BuildIndx.hpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:8k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #ifndef BUILD_INDX_HPP
  14. #define BUILD_INDX_HPP
  15. #include "SignalData.hpp"
  16. #include <NodeBitmask.hpp>
  17. #include <signaldata/DictTabInfo.hpp>
  18. /**
  19.  * BuildIndxReq
  20.  *
  21.  * This signal is sent by DICT to TRIX(n)
  22.  * as a request to build a secondary index
  23.  */
  24. class BuildIndxReq {
  25.   friend bool printBUILD_INDX_REQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);
  26. public:
  27.   enum RequestType {
  28.     RT_UNDEFINED = 0,
  29.     RT_USER = 1,
  30.     RT_ALTER_INDEX = 2,
  31.     RT_SYSTEMRESTART = 3,
  32.     RT_DICT_PREPARE = 1 << 4,
  33.     RT_DICT_TC = 5 << 4,
  34.     RT_DICT_TRIX = 7 << 4,
  35.     RT_DICT_TUX = 8 << 4,
  36.     RT_DICT_COMMIT = 0xC << 4,
  37.     RT_DICT_ABORT = 0xF << 4,
  38.     RT_TRIX = 7 << 8
  39.   };
  40.   STATIC_CONST( SignalLength = 9 );
  41.   STATIC_CONST( INDEX_COLUMNS = 0 );
  42.   STATIC_CONST( KEY_COLUMNS = 1 );
  43.   STATIC_CONST( NoOfSections = 2 );
  44. private:
  45.   Uint32 m_userRef;             // user block reference
  46.   Uint32 m_connectionPtr;       // user "schema connection"
  47.   Uint32 m_requestInfo;
  48.   Uint32 m_buildId; // Suma subscription id
  49.   Uint32 m_buildKey; // Suma subscription key
  50.   Uint32 m_tableId;             // table being indexed
  51.   Uint32 m_indexType;           // from DictTabInfo::TableType
  52.   Uint32 m_indexId;             // table storing index
  53.   Uint32 m_parallelism; // number of parallel insert transactions
  54.   // extra
  55.   Uint32 m_opKey;
  56.   // Sent data ends here
  57.   Uint32 m_slack[25 - SignalLength - 1];
  58.   Uint32 m_sectionBuffer[MAX_ATTRIBUTES_IN_TABLE * 2];
  59. public:
  60.   Uint32 getUserRef() const {
  61.     return m_userRef;
  62.   }
  63.   void setUserRef(Uint32 val) {
  64.     m_userRef = val;
  65.   }
  66.   Uint32 getConnectionPtr() const {
  67.     return m_connectionPtr;
  68.   }
  69.   void setConnectionPtr(Uint32 val) {
  70.     m_connectionPtr = val;
  71.   }
  72.   BuildIndxReq::RequestType getRequestType() const {
  73.     const Uint32 val = BitmaskImpl::getField(1, &m_requestInfo, 0, 16);
  74.     return (BuildIndxReq::RequestType)val;
  75.   }
  76.   void setRequestType(BuildIndxReq::RequestType val) {
  77.     m_requestInfo = (Uint32)val;
  78.   }
  79.   Uint32 getRequestFlag() const {
  80.     const Uint32 val = BitmaskImpl::getField(1, &m_requestInfo, 16, 16);
  81.     return (BuildIndxReq::RequestType)val;
  82.   };
  83.   void addRequestFlag(Uint32 val) {
  84.     val |= BitmaskImpl::getField(1, &m_requestInfo, 16, 16);
  85.     BitmaskImpl::setField(1, &m_requestInfo, 16, 16, val);
  86.   };
  87.   Uint32 getTableId() const {
  88.     return m_tableId;
  89.   }
  90.   void setTableId(Uint32 val) {
  91.     m_tableId = val;
  92.   }
  93.   Uint32 getBuildId() const {
  94.     return m_buildId;
  95.   }
  96.   void setBuildId(Uint32 val) {
  97.     m_buildId = val;
  98.   }
  99.   Uint32 getBuildKey() const {
  100.     return m_buildKey;
  101.   }
  102.   void setBuildKey(Uint32 val) {
  103.     m_buildKey = val;
  104.   }
  105.   Uint32 getIndexType() const {
  106.     return m_indexType;
  107.   }
  108.   void setIndexType(Uint32 val) {
  109.     m_indexType = val;
  110.   }
  111.   Uint32 getIndexId() const {
  112.     return m_indexId;
  113.   }
  114.   void setIndexId(Uint32 val) {
  115.     m_indexId = val;
  116.   }
  117.   Uint32 getParallelism() const {
  118.     return m_parallelism;
  119.   }
  120.   void setParallelism(Uint32 val) {
  121.     m_parallelism = val;
  122.   }
  123.   Uint32 getOpKey() const {
  124.     return m_opKey;
  125.   }
  126.   void setOpKey(Uint32 val) {
  127.     m_opKey = val;
  128.   }
  129.   // Column order
  130.   void setColumnOrder(Uint32* indexBuf, Uint32 indexLen,
  131.       Uint32* keyBuf, Uint32 keyLen,
  132.       struct LinearSectionPtr orderPtr[]);
  133. };
  134. inline
  135. void BuildIndxReq::setColumnOrder(Uint32* indexBuf, Uint32 indexLen, 
  136.   Uint32* keyBuf, Uint32 keyLen,
  137.   struct LinearSectionPtr orderPtr[])
  138. {
  139.   printf("BuildIndxReq::setColumnOrder: indexLen %u, keyLen %un", indexLen, keyLen);
  140.   // Copy buffers
  141.   MEMCOPY_NO_WORDS(m_sectionBuffer, indexBuf, indexLen);
  142.   MEMCOPY_NO_WORDS(m_sectionBuffer + indexLen, keyBuf, keyLen);
  143.   orderPtr[INDEX_COLUMNS].p = m_sectionBuffer;
  144.   orderPtr[INDEX_COLUMNS].sz = indexLen;
  145.   orderPtr[KEY_COLUMNS].p = m_sectionBuffer + indexLen;
  146.   orderPtr[KEY_COLUMNS].sz = keyLen;
  147. }
  148. /**
  149.  * BuildIndxConf
  150.  *
  151.  * This signal is sent back to DICT from TRIX
  152.  * as confirmation of succesfull index build
  153.  * (BuildIndxReq).
  154.  */
  155. class BuildIndxConf {
  156.   friend bool printBUILD_INDX_CONF(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);
  157. public:
  158.   STATIC_CONST( InternalLength = 3 );
  159.   STATIC_CONST( SignalLength = 6 );
  160. private:
  161.   friend class BuildIndxRef;
  162.   Uint32 m_userRef;
  163.   Uint32 m_connectionPtr;
  164.   Uint32 m_requestInfo;
  165.   Uint32 m_tableId;
  166.   Uint32 m_indexType;
  167.   Uint32 m_indexId;
  168. public:
  169.   Uint32 getUserRef() const {
  170.     return m_userRef;
  171.   }
  172.   void setUserRef(Uint32 val) {
  173.     m_userRef = val;
  174.   }
  175.   Uint32 getConnectionPtr() const {
  176.     return m_connectionPtr;
  177.   }
  178.   void setConnectionPtr(Uint32 val) {
  179.     m_connectionPtr = val;
  180.   }
  181.   BuildIndxReq::RequestType getRequestType() const {
  182.     return (BuildIndxReq::RequestType)m_requestInfo;
  183.   }
  184.   void setRequestType(BuildIndxReq::RequestType val) {
  185.     m_requestInfo = (Uint32)val;
  186.   }
  187.   Uint32 getTableId() const {
  188.     return m_tableId;
  189.   }
  190.   void setTableId(Uint32 val) {
  191.     m_tableId = val;
  192.   }
  193.   Uint32 getIndexType() const {
  194.     return m_indexType;
  195.   }
  196.   void setIndexType(Uint32 val) {
  197.     m_indexType = val;
  198.   }
  199.   Uint32 getIndexId() const {
  200.     return m_indexId;
  201.   }
  202.   void setIndexId(Uint32 val) {
  203.     m_indexId = val;
  204.   }
  205. };
  206. /**
  207.  * BuildIndxRef
  208.  *
  209.  * This signal is sent back to API from DICT/TRIX
  210.  * as refusal of a failed index creation
  211.  * (BuildIndxReq). It is also sent as refusal
  212.  * from TC to TRIX and TRIX to DICT.
  213.  */
  214. class BuildIndxRef {
  215.   friend bool printBUILD_INDX_REF(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);
  216. public:
  217.   enum ErrorCode {
  218.     NoError = 0,
  219.     Busy = 701,
  220.     NotMaster = 702,
  221.     BadRequestType = 4247,
  222.     InvalidPrimaryTable = 4249,
  223.     InvalidIndexType = 4250,
  224.     IndexNotUnique = 4251,
  225.     AllocationFailure = 4252,
  226.     InternalError = 4346
  227.   };
  228.   STATIC_CONST( SignalLength = BuildIndxConf::SignalLength + 2 );
  229.   //Uint32 m_userRef;
  230.   //Uint32 m_connectionPtr;
  231.   //Uint32 m_requestInfo;
  232.   //Uint32 m_tableId;
  233.   //Uint32 m_indexType;
  234.   //Uint32 m_indexId;
  235.   BuildIndxConf m_conf;
  236.   Uint32 m_errorCode;
  237.   Uint32 masterNodeId;
  238. public:
  239.   BuildIndxConf* getConf() {
  240.     return &m_conf;
  241.   }
  242.   const BuildIndxConf* getConf() const {
  243.     return &m_conf;
  244.   }
  245.   Uint32 getUserRef() const {
  246.     return m_conf.getUserRef();
  247.   }
  248.   void setUserRef(Uint32 val) {
  249.     m_conf.setUserRef(val);
  250.   }
  251.   Uint32 getConnectionPtr() const {
  252.     return m_conf.getConnectionPtr();
  253.   }
  254.   void setConnectionPtr(Uint32 val) {
  255.     m_conf.setConnectionPtr(val);
  256.   }
  257.   BuildIndxReq::RequestType getRequestType() const {
  258.     return m_conf.getRequestType();
  259.   }
  260.   void setRequestType(BuildIndxReq::RequestType val) {
  261.     m_conf.setRequestType(val);
  262.   }
  263.   Uint32 getTableId() const {
  264.     return m_conf.getTableId();
  265.   }
  266.   void setTableId(Uint32 val) {
  267.     m_conf.setTableId(val);
  268.   }
  269.   Uint32 getIndexType() const {
  270.     return m_conf.getIndexType();
  271.   }
  272.   void setIndexType(Uint32 val) {
  273.     m_conf.setIndexType(val);
  274.   }
  275.   Uint32 getIndexId() const {
  276.     return m_conf.getIndexId();
  277.   }
  278.   void setIndexId(Uint32 val) {
  279.     m_conf.setIndexId(val);
  280.   }
  281.   BuildIndxRef::ErrorCode getErrorCode() const {
  282.     return (BuildIndxRef::ErrorCode)m_errorCode;
  283.   }
  284.   void setErrorCode(BuildIndxRef::ErrorCode val) {
  285.     m_errorCode = (Uint32)val;
  286.   }
  287. };
  288. #endif