MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NDBT_DataSet.hpp
1 /*
2  Copyright (C) 2003, 2005, 2006 MySQL AB
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef NDBT_DATA_SET_HPP
20 #define NDBT_DATA_SET_HPP
21 
22 #include "NDBT_Table.hpp"
23 #include <NdbApi.hpp>
24 
25 class NDBT_DataSet;
26 
28 public:
29  NDBT_DataSet * createEmpty(const NDBT_Table & table,
30  const char * columns[]);
31 
32  NDBT_DataSet * createRandom(const NDBT_DataSet & table,
33  const char * columns[],
34  int rows);
35 
36  NDBT_DataSet * createXXX(int noOfDS, const NDBT_DataSet ** datasets);
37 };
38 
39 class NDBT_DataSet {
40  friend class NDBT_DataSetFactory;
41 public:
45  void setRows(int rows);
46  void addRows(int rows);
47 
48  int getNoOfRows() const;
49 
53  int getNoOfColumns() const;
54  int getNoOfPKs() const;
55 
56  const NDBT_Attribute * getColumn(int index);
57  const NDBT_Attribute * getColumn(const char * name);
58 
62  bool hasPK(int row);
63  bool hasData(int row);
64 
68  bool hasPK();
69 
73  bool hasData();
74 
78  Uint32 getUInt(int row, int index) const;
79  Uint32 getUInt(int row, const char * attribute) const;
80 
81  Int32 getInt(int row, int index) const;
82  Int32 getInt(int row, const char * attribute) const;
83 
84  const char * getString(int row, int index) const;
85  const char * getString(int row, const char * attribute) const;
86 
87  bool getIsNull(int row, int index) const;
88  bool getIsNull(int row, const char * attribute) const;
89 
93  void set(int row, int index, Int32 value);
94  void set(int row, const char * attr, Int32 value);
95 
96  void set(int row, int index, Uint32 value);
97  void set(int row, const char * attr, Uint32 value);
98 
99  void set(int row, int index, const char * value);
100  void set(int row, const char * attr, const char * value);
101 
111  bool equal(const NDBT_DataSet & other) const;
112 
121  bool equalPK(const NDBT_DataSet & other) const;
122 
123 private:
124  NDBT_Attribute * columns;
125 
126  Uint32 noOfRows;
127  Uint32 noOfPKs;
128 
129  Uint32 * pks;
130  Uint32 * columnSizes;
131 
132  char * pkData;
133  char * data;
134 
135  char * pk(int row, int pkIndex);
136  char * column(int row, int columnIndex);
137 
138  Uint32 * hasPK;
139  Uint32 * hasData;
140 };
141 
142 #endif