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

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 NDBT_DATA_SET_HPP
  14. #define NDBT_DATA_SET_HPP
  15. #include "NDBT_Table.hpp"
  16. #include <NdbApi.hpp>
  17. class NDBT_DataSet;
  18. class NDBT_DataSetFactory {
  19. public:
  20.   NDBT_DataSet * createEmpty(const NDBT_Table & table, 
  21.      const char * columns[]);
  22.   
  23.   NDBT_DataSet * createRandom(const NDBT_DataSet & table, 
  24.       const char * columns[],
  25.       int rows);
  26.   
  27.   NDBT_DataSet * createXXX(int noOfDS, const NDBT_DataSet ** datasets);
  28. };
  29. class NDBT_DataSet {
  30.   friend class NDBT_DataSetFactory;
  31. public:
  32.   /**
  33.    * Rows in the data set
  34.    */
  35.   void setRows(int rows);
  36.   void addRows(int rows);
  37.   
  38.   int getNoOfRows() const;
  39.   /**
  40.    * Columns for a row in the data set
  41.    */
  42.   int getNoOfColumns() const;
  43.   int getNoOfPKs() const;
  44.   
  45.   const NDBT_Attribute * getColumn(int index);
  46.   const NDBT_Attribute * getColumn(const char * name);
  47.   
  48.   /**
  49.    * Data status in dataset
  50.    */
  51.   bool hasPK(int row);
  52.   bool hasData(int row);
  53.   /**
  54.    * Do all rows in the dataset have a PK
  55.    */
  56.   bool hasPK();
  57.   
  58.   /**
  59.    * Do all rows in the dataset has data
  60.    */
  61.   bool hasData();
  62.   
  63.   /**
  64.    * Getters for data
  65.    */
  66.   Uint32 getUInt(int row, int index) const;
  67.   Uint32 getUInt(int row, const char * attribute) const;
  68.   
  69.   Int32 getInt(int row, int index) const;
  70.   Int32 getInt(int row, const char * attribute) const;
  71.   
  72.   const char * getString(int row, int index) const;
  73.   const char * getString(int row, const char * attribute) const;
  74.   bool getIsNull(int row, int index) const;
  75.   bool getIsNull(int row, const char * attribute) const;
  76.   
  77.   /**
  78.    * Setters for data
  79.    */
  80.   void set(int row, int index, Int32 value);
  81.   void set(int row, const char * attr, Int32 value);
  82.   
  83.   void set(int row, int index, Uint32 value);
  84.   void set(int row, const char * attr, Uint32 value);
  85.   
  86.   void set(int row, int index, const char * value);
  87.   void set(int row, const char * attr, const char * value);
  88.   /**
  89.    * Comparators
  90.    */
  91.   /**
  92.    * Is this dataset identical to other dataset
  93.    *
  94.    * If either of the datasets have "undefined" rows the answer is false
  95.    */
  96.   bool equal(const NDBT_DataSet & other) const;
  97.   
  98.   /**
  99.    * Do these dataset have identical PK's
  100.    *
  101.    * I.e noOfRows equal
  102.    *
  103.    * and for each row there is a corresponding row in the other ds
  104.    *     with the same pk
  105.    */
  106.   bool equalPK(const NDBT_DataSet & other) const;
  107. private:
  108.   NDBT_Attribute * columns;
  109.   
  110.   Uint32 noOfRows;
  111.   Uint32 noOfPKs;
  112.   
  113.   Uint32 * pks;
  114.   Uint32 * columnSizes;
  115.   
  116.   char * pkData;
  117.   char * data;
  118.   char * pk(int row, int pkIndex);
  119.   char * column(int row, int columnIndex);
  120.   Uint32 * hasPK;
  121.   Uint32 * hasData;
  122. };
  123. #endif