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, version 2.0, 7 as published by the Free Software Foundation. 8 9 This program is also distributed with certain software (including 10 but not limited to OpenSSL) that is licensed under separate terms, 11 as designated in a particular file or component or in included license 12 documentation. The authors of MySQL hereby grant you an additional 13 permission to link the program and your derivative works with the 14 separately licensed software that they have included with MySQL. 15 16 This program is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License, version 2.0, for more details. 20 21 You should have received a copy of the GNU General Public License 22 along with this program; if not, write to the Free Software 23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 */ 25 26 #ifndef NDBT_DATA_SET_HPP 27 #define NDBT_DATA_SET_HPP 28 29 #include "NDBT_Table.hpp" 30 #include <NdbApi.hpp> 31 32 class NDBT_DataSet; 33 34 class NDBT_DataSetFactory { 35 public: 36 NDBT_DataSet * createEmpty(const NDBT_Table & table, 37 const char * columns[]); 38 39 NDBT_DataSet * createRandom(const NDBT_DataSet & table, 40 const char * columns[], 41 int rows); 42 43 NDBT_DataSet * createXXX(int noOfDS, const NDBT_DataSet ** datasets); 44 }; 45 46 class NDBT_DataSet { 47 friend class NDBT_DataSetFactory; 48 public: 49 /** 50 * Rows in the data set 51 */ 52 void setRows(int rows); 53 void addRows(int rows); 54 55 int getNoOfRows() const; 56 57 /** 58 * Columns for a row in the data set 59 */ 60 int getNoOfColumns() const; 61 int getNoOfPKs() const; 62 63 const NDBT_Attribute * getColumn(int index); 64 const NDBT_Attribute * getColumn(const char * name); 65 66 /** 67 * Data status in dataset 68 */ 69 bool hasPK(int row); 70 bool hasData(int row); 71 72 /** 73 * Do all rows in the dataset have a PK 74 */ 75 bool hasPK(); 76 77 /** 78 * Do all rows in the dataset has data 79 */ 80 bool hasData(); 81 82 /** 83 * Getters for data 84 */ 85 Uint32 getUInt(int row, int index) const; 86 Uint32 getUInt(int row, const char * attribute) const; 87 88 Int32 getInt(int row, int index) const; 89 Int32 getInt(int row, const char * attribute) const; 90 91 const char * getString(int row, int index) const; 92 const char * getString(int row, const char * attribute) const; 93 94 bool getIsNull(int row, int index) const; 95 bool getIsNull(int row, const char * attribute) const; 96 97 /** 98 * Setters for data 99 */ 100 void set(int row, int index, Int32 value); 101 void set(int row, const char * attr, Int32 value); 102 103 void set(int row, int index, Uint32 value); 104 void set(int row, const char * attr, Uint32 value); 105 106 void set(int row, int index, const char * value); 107 void set(int row, const char * attr, const char * value); 108 109 /** 110 * Comparators 111 */ 112 113 /** 114 * Is this dataset identical to other dataset 115 * 116 * If either of the datasets have "undefined" rows the answer is false 117 */ 118 bool equal(const NDBT_DataSet & other) const; 119 120 /** 121 * Do these dataset have identical PK's 122 * 123 * I.e noOfRows equal 124 * 125 * and for each row there is a corresponding row in the other ds 126 * with the same pk 127 */ 128 bool equalPK(const NDBT_DataSet & other) const; 129 130 private: 131 NDBT_Attribute * columns; 132 133 Uint32 noOfRows; 134 Uint32 noOfPKs; 135 136 Uint32 * pks; 137 Uint32 * columnSizes; 138 139 char * pkData; 140 char * data; 141 142 char * pk(int row, int pkIndex); 143 char * column(int row, int columnIndex); 144 145 Uint32 * hasPK; 146 Uint32 * hasData; 147 }; 148 149 #endif 150