Zero  0.1.0
tpcc_struct.h
Go to the documentation of this file.
1 /* -*- mode:C++; c-basic-offset:4 -*-
2  Shore-kits -- Benchmark implementations for Shore-MT
3 
4  Copyright (c) 2007-2009
5  Data Intensive Applications and Systems Labaratory (DIAS)
6  Ecole Polytechnique Federale de Lausanne
7 
8  All Rights Reserved.
9 
10  Permission to use, copy, modify and distribute this software and
11  its documentation is hereby granted, provided that both the
12  copyright notice and this permission notice appear in all copies of
13  the software, derivative works or modified versions, and any
14  portions thereof, and that both notices appear in supporting
15  documentation.
16 
17  This code is distributed in the hope that it will be useful, but
18  WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS
20  DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
21  RESULTING FROM THE USE OF THIS SOFTWARE.
22 */
23 
32 #ifndef __TPCC_STRUCT_H
33 #define __TPCC_STRUCT_H
34 
35 #include <cstdlib>
36 #include <unistd.h>
37 #include <sys/time.h>
38 
39 #include "util/decimal.h"
40 
41 namespace tpcc {
42 
43 
44 /* use this for allocation of NULL-terminated strings */
45 #define STRSIZE(x)(x+1)
46 
47 
48 
49 /* exported structures */
50 
51 
52 // CUSTOMER
53 
55  int C_C_ID;
56  int C_D_ID;
57  int C_W_ID;
58  char C_FIRST[STRSIZE(16)];
59  char C_MIDDLE[STRSIZE(2)];
60  char C_LAST[STRSIZE(16)];
61  char C_STREET_1[STRSIZE(20)];
62  char C_STREET_2[STRSIZE(20)];
63  char C_CITY[STRSIZE(20)];
64  char C_STATE[STRSIZE(2)];
65  char C_ZIP[STRSIZE(9)];
66  char C_PHONE[STRSIZE(16)];
67  time_t C_SINCE;
68  char C_CREDIT[STRSIZE(2)];
75  char C_DATA_1[STRSIZE(250)];
76  char C_DATA_2[STRSIZE(250)];
77 
78  // c_str tuple_to_str() {
79  // return(c_str("CUST = %d|%d|%d|%s|%s|%s|%s|%s|%s|%s|%s|%s|%.2f|%s -",
80  // C_C_ID, C_D_ID, C_W_ID, C_FIRST, C_MIDDLE, C_LAST,
81  // C_STREET_1, C_STREET_2, C_CITY, C_STATE, C_ZIP,
82  // C_PHONE, C_SINCE, C_CREDIT));
83  // }
84 
85 
86  };
87 
89  int C_C_ID;
90 
91  int C_D_ID;
92 
93  int C_W_ID;
94 
95  bool operator==(const tpcc_customer_tuple_key& rhs) const {
96  return ((C_C_ID == rhs.C_C_ID) &&
97  (C_D_ID == rhs.C_D_ID) &&
98  (C_W_ID == rhs.C_W_ID));
99  }
100 
101  bool operator<(const tpcc_customer_tuple_key& rhs) const {
102  if ((C_C_ID < rhs.C_C_ID) ||
103  ((C_C_ID == rhs.C_C_ID) && (C_D_ID < rhs.C_D_ID)) ||
104  ((C_C_ID == rhs.C_C_ID) && (C_D_ID == rhs.C_D_ID) && (C_W_ID < rhs.C_W_ID))) {
105  return (true);
106  } else {
107  return (false);
108  }
109  }
110  };
111 
113  char C_FIRST[STRSIZE(16)];
114  char C_MIDDLE[STRSIZE(2)];
115  char C_LAST[STRSIZE(16)];
116  char C_STREET_1[STRSIZE(20)];
117  char C_STREET_2[STRSIZE(20)];
118  char C_CITY[STRSIZE(20)];
119  char C_STATE[STRSIZE(2)];
120  char C_ZIP[STRSIZE(9)];
121  char C_PHONE[STRSIZE(16)];
122  time_t C_SINCE;
123  char C_CREDIT[STRSIZE(2)];
130  char C_DATA_1[STRSIZE(250)];
131  char C_DATA_2[STRSIZE(250)];
132  };
133 
134 
135 // DISTRICT
136 
138  int D_ID;
139  int D_W_ID;
140  char D_NAME[STRSIZE(10)];
141  char D_STREET_1[STRSIZE(20)];
142  char D_STREET_2[STRSIZE(20)];
143  char D_CITY[STRSIZE(20)];
144  char D_STATE[STRSIZE(2)];
145  char D_ZIP[STRSIZE(9)];
149 
150 
151  // c_str tuple_to_str() {
152  // return(c_str("DISTR = %d|%d|%s|%s|%s|%s|%s|%s|%.2f|%.2f|%d",
153  // D_ID, D_W_ID, D_NAME, D_STREET_1, D_STREET_2,
154  // D_CITY, D_STATE, D_ZIP,
155  // D_TAX.to_double(), D_YTD.to_double(), D_NEXT_O_ID));
156  // }
157 
158  };
159 
161  int D_ID;
162  int D_W_ID;
163  };
164 
165 
166 
167 // HISTORY
168 
170  int H_C_ID;
171  int H_C_D_ID;
172  int H_C_W_ID;
173  int H_D_ID;
174  int H_W_ID;
175  time_t H_DATE;
177  char H_DATA[STRSIZE(25)];
178 
179  // c_str tuple_to_str() {
180  // return(c_str("HIST = %d|%d|%d|%d|%d|%.2f|%.2f|%s",
181  // H_C_ID, H_C_D_ID, H_C_W_ID, H_D_ID,
182  // H_W_ID, H_DATE, H_AMOUNT.to_double(),
183  // H_DATA));
184  // }
185  };
186 
188  int H_C_ID;
189 
190  int H_C_D_ID;
191 
192  int H_C_W_ID;
193 
194  int H_D_ID;
195 
196  int H_W_ID;
197 
198  time_t H_DATE;
199 
200  bool operator==(const tpcc_history_tuple_key& rhs) const {
201  return ((H_C_ID == rhs.H_C_ID) &&
202  (H_C_D_ID == rhs.H_C_D_ID) &&
203  (H_C_W_ID == rhs.H_C_W_ID) &&
204  (H_D_ID == rhs.H_D_ID) &&
205  (H_W_ID == rhs.H_W_ID) &&
206  (H_DATE == rhs.H_DATE));
207  }
208 
209  bool operator<(const tpcc_history_tuple_key& rhs) const {
210  if ((H_C_ID < rhs.H_C_ID) ||
211  ((H_C_ID == rhs.H_C_ID) && (H_C_D_ID < rhs.H_C_D_ID)) ||
212  ((H_C_ID == rhs.H_C_ID) && (H_C_D_ID == rhs.H_C_D_ID) &&
213  (H_C_W_ID < rhs.H_C_W_ID)) ||
214  ((H_C_ID == rhs.H_C_ID) && (H_C_D_ID == rhs.H_C_D_ID) &&
215  (H_C_W_ID == rhs.H_C_W_ID) && (H_D_ID < rhs.H_D_ID)) ||
216  ((H_C_ID == rhs.H_C_ID) && (H_C_D_ID == rhs.H_C_D_ID) &&
217  (H_C_W_ID == rhs.H_C_W_ID) && (H_D_ID == rhs.H_D_ID) &&
218  (H_W_ID < rhs.H_W_ID)) ||
219  ((H_C_ID == rhs.H_C_ID) && (H_C_D_ID == rhs.H_C_D_ID) &&
220  (H_C_W_ID == rhs.H_C_W_ID) && (H_D_ID == rhs.H_D_ID) &&
221  (H_W_ID == rhs.H_W_ID) && (H_DATE == rhs.H_DATE))
222  ) {
223  return (true);
224  } else {
225  return (false);
226  }
227  }
228  };
229 
232  char H_DATA[STRSIZE(25)];
233  };
234 
235 
236 // ITEM
237 
239  int I_ID;
240  int I_IM_ID;
241  char I_NAME[STRSIZE(24)];
242  int I_PRICE;
243  char I_DATA[STRSIZE(50)];
244  };
245 
247  int I_ID;
248  };
249 
250 
251 
252 // NEW_ORDER
253 
254  struct tpcc_new_order_tuple { // The whole record is the key
255  int NO_O_ID;
256  int NO_D_ID;
257  int NO_W_ID;
258  };
259 
260 
261 // ORDER
262 
264  int O_ID;
265  int O_C_ID;
266  int O_D_ID;
267  int O_W_ID;
268  time_t O_ENTRY_D;
270  int O_OL_CNT;
272  };
273 
275  int O_ID;
276  int O_C_ID;
277  int O_D_ID;
278  int O_W_ID;
279  };
280 
282  time_t O_ENTRY_D;
284  int O_OL_CNT;
286  };
287 
288 
289 
290 
291 // ORDERLINE
292 
294  int OL_O_ID;
295  int OL_D_ID;
296  int OL_W_ID;
298  int OL_I_ID;
303  char OL_DIST_INFO[STRSIZE(25)];
304  };
305 
307  int OL_O_ID;
308  int OL_D_ID;
309  int OL_W_ID;
311  };
312 
314  int OL_I_ID;
319  char OL_DIST_INFO[STRSIZE(25)];
320  };
321 
322 
323 
324 // STOCK
325 
327  int S_I_ID;
328  int S_W_ID;
332  int S_YTD;
333 
334  char S_DIST[10][STRSIZE(24)];
335 
336  char S_DATA[STRSIZE(50)];
337  };
338 
340  int S_I_ID;
341  int S_W_ID;
342  };
343 
344 
345 // WAREHOUSE
346 
348  int W_ID;
349  char W_NAME[STRSIZE(10)];
350  char W_STREET_1[STRSIZE(20)];
351  char W_STREET_2[STRSIZE(20)];
352  char W_CITY[STRSIZE(20)];
353  char W_STATE[STRSIZE(2)];
354  char W_ZIP[STRSIZE(9)];
357 
358  // c_str tuple_to_str() {
359  // return(c_str("WH= %d|%s|%s|%s|%s|%s|%s|%.2f|%.2f",
360  // W_ID, W_NAME, W_STREET_1, W_STREET_2,
361  // W_CITY, W_STATE, W_ZIP,
362  // W_TAX.to_double(), W_YTD.to_double()));
363  // }
364  };
365 
367  int W_ID;
368  };
369 };
370 
371 #endif // __TPCC_STRUCT_H
int C_D_ID
Definition: tpcc_struct.h:56
int O_C_ID
Definition: tpcc_struct.h:265
char C_CITY[STRSIZE(20)]
Definition: tpcc_struct.h:63
decimal W_YTD
Definition: tpcc_struct.h:356
decimal H_AMOUNT
Definition: tpcc_struct.h:176
int S_QUANTITY
Definition: tpcc_struct.h:330
decimal C_DISCOUNT
Definition: tpcc_struct.h:70
Definition: tpcc_struct.h:112
int H_C_ID
Definition: tpcc_struct.h:188
int O_W_ID
Definition: tpcc_struct.h:278
int S_I_ID
Definition: tpcc_struct.h:327
decimal C_BALANCE
Definition: tpcc_struct.h:126
int I_IM_ID
Definition: tpcc_struct.h:240
decimal C_YTD_PAYMENT
Definition: tpcc_struct.h:127
int O_OL_CNT
Definition: tpcc_struct.h:270
int W_ID
Definition: tpcc_struct.h:348
char C_CREDIT[STRSIZE(2)]
Definition: tpcc_struct.h:68
int I_ID
Definition: tpcc_struct.h:247
Definition: decimal.h:32
decimal C_LAST_PAYMENT
Definition: tpcc_struct.h:73
int NO_O_ID
Definition: tpcc_struct.h:255
Definition: tpcc_struct.h:169
decimal C_YTD_PAYMENT
Definition: tpcc_struct.h:72
decimal W_TAX
Definition: tpcc_struct.h:355
int OL_D_ID
Definition: tpcc_struct.h:308
decimal D_TAX
Definition: tpcc_struct.h:146
int O_CARRIER_ID
Definition: tpcc_struct.h:269
int S_ORDER_CNT
Definition: tpcc_struct.h:331
decimal C_CREDIT_LIM
Definition: tpcc_struct.h:69
int S_W_ID
Definition: tpcc_struct.h:328
int C_W_ID
Definition: tpcc_struct.h:57
int OL_W_ID
Definition: tpcc_struct.h:296
Definition: tpcc_struct.h:281
int OL_QUANTITY
Definition: tpcc_struct.h:301
Definition: tpcc_struct.h:306
int O_CARRIER_ID
Definition: tpcc_struct.h:283
int O_D_ID
Definition: tpcc_struct.h:266
int OL_I_ID
Definition: tpcc_struct.h:314
int OL_AMOUNT
Definition: tpcc_struct.h:302
Definition: tpcc_struct.h:339
int D_ID
Definition: tpcc_struct.h:161
Definition: tpcc_struct.h:137
int C_W_ID
Definition: tpcc_struct.h:93
int W_ID
Definition: tpcc_struct.h:367
int D_W_ID
Definition: tpcc_struct.h:139
decimal C_DISCOUNT
Definition: tpcc_struct.h:125
Definition: tpcc_client.cpp:33
bool operator==(const tpcc_customer_tuple_key &rhs) const
Definition: tpcc_struct.h:95
Definition: tpcc_struct.h:274
int O_ID
Definition: tpcc_struct.h:275
int OL_W_ID
Definition: tpcc_struct.h:309
int D_NEXT_O_ID
Definition: tpcc_struct.h:148
char C_STREET_1[STRSIZE(20)]
Definition: tpcc_struct.h:61
time_t O_ENTRY_D
Definition: tpcc_struct.h:282
time_t H_DATE
Definition: tpcc_struct.h:175
int C_PAYMENT_CNT
Definition: tpcc_struct.h:74
Definition: tpcc_struct.h:293
int D_ID
Definition: tpcc_struct.h:138
Definition: tpcc_struct.h:54
char C_DATA_2[STRSIZE(250)]
Definition: tpcc_struct.h:76
decimal C_CREDIT_LIM
Definition: tpcc_struct.h:124
int S_W_ID
Definition: tpcc_struct.h:341
int H_C_W_ID
Definition: tpcc_struct.h:192
char C_STATE[STRSIZE(2)]
Definition: tpcc_struct.h:64
Definition: tpcc_struct.h:160
time_t OL_DELIVERY_D
Definition: tpcc_struct.h:316
Definition: tpcc_struct.h:246
int D_W_ID
Definition: tpcc_struct.h:162
Definition: tpcc_struct.h:366
int O_D_ID
Definition: tpcc_struct.h:277
int OL_I_ID
Definition: tpcc_struct.h:298
int O_W_ID
Definition: tpcc_struct.h:267
int OL_QUANTITY
Definition: tpcc_struct.h:317
int H_W_ID
Definition: tpcc_struct.h:174
int OL_O_ID
Definition: tpcc_struct.h:294
int O_ALL_LOCAL
Definition: tpcc_struct.h:271
int OL_O_ID
Definition: tpcc_struct.h:307
char C_DATA_1[STRSIZE(250)]
Definition: tpcc_struct.h:75
Definition: tpcc_struct.h:187
char C_STREET_2[STRSIZE(20)]
Definition: tpcc_struct.h:62
int H_C_ID
Definition: tpcc_struct.h:170
#define STRSIZE(x)
Definition: tpcc_struct.h:45
time_t O_ENTRY_D
Definition: tpcc_struct.h:268
int H_C_D_ID
Definition: tpcc_struct.h:190
int O_ALL_LOCAL
Definition: tpcc_struct.h:285
bool operator==(const tpcc_history_tuple_key &rhs) const
Definition: tpcc_struct.h:200
int OL_NUMBER
Definition: tpcc_struct.h:310
int C_PAYMENT_CNT
Definition: tpcc_struct.h:129
int H_D_ID
Definition: tpcc_struct.h:194
Definition: tpcc_struct.h:238
bool operator<(const tpcc_customer_tuple_key &rhs) const
Definition: tpcc_struct.h:101
time_t C_SINCE
Definition: tpcc_struct.h:67
int I_ID
Definition: tpcc_struct.h:239
char C_ZIP[STRSIZE(9)]
Definition: tpcc_struct.h:65
char C_MIDDLE[STRSIZE(2)]
Definition: tpcc_struct.h:59
char C_PHONE[STRSIZE(16)]
Definition: tpcc_struct.h:66
int S_YTD
Definition: tpcc_struct.h:332
Definition: tpcc_struct.h:88
int NO_D_ID
Definition: tpcc_struct.h:256
int I_PRICE
Definition: tpcc_struct.h:242
Definition: tpcc_struct.h:347
int OL_D_ID
Definition: tpcc_struct.h:295
int OL_SUPPLY_W_ID
Definition: tpcc_struct.h:315
decimal C_LAST_PAYMENT
Definition: tpcc_struct.h:128
int NO_W_ID
Definition: tpcc_struct.h:257
char C_LAST[STRSIZE(16)]
Definition: tpcc_struct.h:60
int H_C_W_ID
Definition: tpcc_struct.h:172
int O_OL_CNT
Definition: tpcc_struct.h:284
int C_C_ID
Definition: tpcc_struct.h:55
time_t H_DATE
Definition: tpcc_struct.h:198
Definition: tpcc_struct.h:263
int OL_NUMBER
Definition: tpcc_struct.h:297
decimal H_AMOUNT
Definition: tpcc_struct.h:231
decimal C_BALANCE
Definition: tpcc_struct.h:71
int OL_SUPPLY_W_ID
Definition: tpcc_struct.h:299
Definition: tpcc_struct.h:254
int S_I_ID
Definition: tpcc_struct.h:340
int C_C_ID
Definition: tpcc_struct.h:89
int O_ID
Definition: tpcc_struct.h:264
time_t C_SINCE
Definition: tpcc_struct.h:122
int S_REMOTE_CNT
Definition: tpcc_struct.h:329
Definition: tpcc_struct.h:326
int C_D_ID
Definition: tpcc_struct.h:91
int OL_AMOUNT
Definition: tpcc_struct.h:318
time_t OL_DELIVERY_D
Definition: tpcc_struct.h:300
Definition: tpcc_struct.h:230
int H_C_D_ID
Definition: tpcc_struct.h:171
int H_D_ID
Definition: tpcc_struct.h:173
int O_C_ID
Definition: tpcc_struct.h:276
decimal D_YTD
Definition: tpcc_struct.h:147
Definition: tpcc_struct.h:313
bool operator<(const tpcc_history_tuple_key &rhs) const
Definition: tpcc_struct.h:209
int H_W_ID
Definition: tpcc_struct.h:196
char C_FIRST[STRSIZE(16)]
Definition: tpcc_struct.h:58