~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/test/include/NDBT_DataSet.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

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