Zero  0.1.0
tpcc_input.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_INPUT_H
33 #define __TPCC_INPUT_H
34 
35 #include "tpcc_const.h"
36 #include "tpcc_struct.h"
37 #include "skewer.h"
38 #include "util/random_input.h"
39 
40 namespace tpcc {
41 
43 // related to dynamic skew
44  extern skewer_t w_skewer;
45 
46  extern bool _change_load;
47 
51 /*********************************************************************
52  *
53  * new_order_input_t
54  *
55  * Input for any NEW_ORDER transaction
56  *
57  *********************************************************************/
58 
59 // Forward declaration
60  struct no_item_nord_input_t;
61  struct with_item_nord_input_t;
62 
63  struct ol_item_info {
64  int _ol_i_id; /* input: NURand(8191,1,100000) */
65  short _ol_supply_wh_select; /* input: URand(1,100) */
66  int _ol_supply_wh_id; /* input: x==1 -> URand(1, SF) */
67  int _ol_quantity; /* input: URand(1,10) */
68 
69  int _item_amount; /* placeholder for the item amount */
70 
71  tpcc_stock_tuple _astock; /* placeholder for the stock tuple */
72  tpcc_item_tuple _aitem; /* placeholder for the item tuple */
73 
74  // Assignmet operator
75  ol_item_info& operator=(const ol_item_info& rhs);
76  }; // EOF: ol_item_info
77 
78 
80  int _wh_id; /* input: URand(1,SF) */
81  int _d_id; /* input: URand(1,10) */
82  int _c_id; /* input: NURand(1023,1,3000) */
83  int _ol_cnt; /* input: number of items URand(5,15) */
84  int _rbk; /* input: rollback URand(1,100) */
85 
86  time_t _tstamp; /* placeholder for the trx start time */
87  int _all_local; /* placeholder if all orders are on local WHs */
88  int _d_next_o_id; /* placeholder for the next O_ID of the selected district */
89 
90  tpcc_warehouse_tuple _awh; /* placeholder for the warehouse tuple */
91  tpcc_customer_tuple _acust; /* placeholder for the customer tuple */
92  tpcc_district_tuple _adist; /* placeholder for the district tuple */
93 
94  ol_item_info items[MAX_OL_PER_ORDER]; /* input: for each ol item */
95 
96  // If _supply_wh_id = _wh_id for each item
97  // then trx called home, else remote
98 
100  : _wh_id(0),
101  _d_id(0),
102  _c_id(0),
103  _ol_cnt(0),
104  _rbk(0),
105  _tstamp(0),
106  _all_local(1),
107  _d_next_o_id(-1) {};
108 
110 
111  // Assignment operator
113 
114  // Convertion functions
115  void get_no_item_input(no_item_nord_input_t& anoin);
116 
117  void get_with_item_input(with_item_nord_input_t& awin, const int idx);
118  }; // EOF: new_order_input_t
119 
120 
121 // IP: The following two structs are used by DoraNewOrder
122 // Instead of copying the whole NewOrder input the actions that do not use any
123 // item they use no_item_nord_input which contains only the basic fields.
124 // On the other hand, the actions that use only one item, they use with_item_nord_input
125 // which contains the basic fields and one item.
126 
127 // IP: General input for the no Item-related NewOrder actions
129  int _wh_id; /* input: URand(1,SF) */
130  int _d_id; /* input: URand(1,10) */
131  int _c_id; /* input: NURand(1023,1,3000) */
132  int _ol_cnt; /* input: number of items URand(5,15) */
133  int _rbk; /* input: rollback URand(1,100) */
134 
135  time_t _tstamp; /* placeholder for the trx start time */
136  int _all_local; /* placeholder if all orders are on local WHs */
137  int _d_next_o_id; /* placeholder for the next O_ID of the selected district */
138 
139  // Assignment operator
141  }; // EOF: no_item_nord_input_t
142 
143 // IP: General input for the Item-related NewOrder actions
145  int _wh_id; /* input: URand(1,SF) */
146  int _d_id; /* input: URand(1,10) */
147  int _c_id; /* input: NURand(1023,1,3000) */
148  int _ol_cnt; /* input: number of items URand(5,15) */
149  int _rbk; /* input: rollback URand(1,100) */
150 
151  time_t _tstamp; /* placeholder for the trx start time */
152  int _all_local; /* placeholder if all orders are on local WHs */
153  int _d_next_o_id; /* placeholder for the next O_ID of the selected district */
154 
155  int _ol_idx; /* input: The item index */
156 
157  ol_item_info item; /* only 1 item info */
158 
159  // Assignment operator
161  }; // EOF: with_item_nord_input_t
162 
163 
164 /*********************************************************************
165  *
166  * payment_input_t
167  *
168  * Input for any PAYMENT transaction
169  *
170  *********************************************************************/
171 
188  int _home_wh_id; /* input: URand(1,SF) */
189  int _home_d_id; /* input: URand(1,10) */
190  int _v_cust_wh_selection; /* input: URand(1,100) - 85%-15% */
191  int _remote_wh_id; /* input: URand(1,SF) */
192  int _remote_d_id; /* input: URand(1,10) */
193  int _v_cust_ident_selection; /* input: URand(1,100) - 60%-40% */
194  int _c_id; /* input: NURand(1023,1,3000) */
195  char _c_last[16]; /* input: NURand(255,0,999) */
196  double _h_amount; /* input: URand(1.00,5.000) */
197  int _h_date;
198 
199  // Construction/Destructions
201  : _home_wh_id(0),
202  _home_d_id(0),
203  _v_cust_wh_selection(0),
204  _remote_wh_id(0),
205  _remote_d_id(0),
206  _v_cust_ident_selection(0),
207  _c_id(0),
208  _h_amount(0),
209  _h_date(0) {
210  memset(_c_last, '\0', 16);
211  };
212 
214 
216  }; // EOF payment_input_t
217 
218 
219 
220 /*********************************************************************
221  *
222  * order_status_input_t
223  *
224  * Input for any ORDER_STATUS transaction
225  *
226  *********************************************************************/
227 
229  int _wh_id; /* input: URand(1,SF) */
230  int _d_id; /* input: URand(1,10) */
231  short _c_select; /* input: URand(1,100) - 60%-40% */
232  int _c_id; /* input: NURand(1023,1,3000) */
233  char _c_last[16]; /* input: NURand(255,0,999) */
234 
235  // placeholders for o_id, and o_ol_cnt
236  int _o_id;
237 
239 
240  // Construction/Destructions
242  : _wh_id(0),
243  _d_id(0),
244  _c_select(0),
245  _c_id(0),
246  _o_id(0),
247  _o_ol_cnt(0) {
248  memset(_c_last, '\0', 16);
249  };
250 
252 
253  // Assignment operator
255  }; // EOF order_status_input_t
256 
257 
258 
259 /*********************************************************************
260  *
261  * delivery_input_t
262  *
263  * Input for any DELIVERY transaction
264  *
265  *********************************************************************/
266 
268  int _wh_id; /* input: URand(1,SF) */
269  short _carrier_id; /* input: URand(1,10) */
270 
271 
272  // Construction/Destructions
274  : _wh_id(0),
275  _carrier_id(0) {};
276 
278 
279  // Assignment operator
281  }; // EOF delivery_input_t
282 
283 
284 
285 /*********************************************************************
286  *
287  * stock_level_input_t
288  *
289  * Input for any STOCK_LEVEL transaction
290  *
291  *********************************************************************/
292 
293  typedef vector<pair<int, int>> TwoIntVec;
294 
295  typedef TwoIntVec::iterator TwoIntVecIt;
296 
298  int _wh_id; /* input */
299  int _d_id; /* input */
300  short _threshold; /* input */
301 
302  // placeholders for o_id, and o_ol_cnt
304 
306 
307  TwoIntVec* _pvwi;
308 
309  // Construction/Destructions
311  : _wh_id(0),
312  _d_id(0),
313  _threshold(0),
314  _o_ol_cnt(0),
315  _pvwi(nullptr) {};
316 
318 
319  // Assignment operator
321  }; // EOF stock_level_input_t
322 
323 
324 
325 /*********************************************************************
326  *
327  * mbench_wh_input_t
328  *
329  * Input for any MBENCH_WH transaction
330  *
331  *********************************************************************/
332 
334  int _wh_id; /* input */
335  double _amount; /* input */
336 
337  // Construction/Destructions
339  : _wh_id(0),
340  _amount(0) {};
341 
343 
344  // Assignment operator
346  }; // EOF mbench_wh_input_t
347 
348 
349 
350 /*********************************************************************
351  *
352  * mbench_cust_input_t
353  *
354  * Input for any MBENCH_CUST transaction
355  *
356  *********************************************************************/
357 
359  int _wh_id; /* input */
360  int _d_id; /* input */
361  int _c_id; /* input */
362  double _amount; /* input */
363 
364  // Construction/Destructions
366  : _wh_id(0),
367  _d_id(0),
368  _c_id(0),
369  _amount(0) {};
370 
372 
373  // Assignment operator
375  }; // EOF mbench_cust_input_t
376 
377 
378 
379 /*********************************************************************
380  *
381  * populate_*_input_t
382  *
383  * Input for populating TPC-C DB
384  *
385  *********************************************************************/
386 
388  int _wh;
389  };
390 
392  int _unit;
393  int* _cids;
394  };
395 
402  int specificWH = 0, int tspread = 0);
403 
405  int specificWH = 0, int tspread = 0);
406 
408  int specificWH = 0, int tspread = 0);
409 
411  int specificWH = 0, int tspread = 0);
412 
414  int specificWH = 0, int tspread = 0);
415 
417  int specificWH = 0, int tspread = 0);
418 
420  int specificWH = 0, int tspread = 0);
421 };
422 
423 #endif // __TPCC_INPUT_H
time_t _tstamp
Definition: tpcc_input.h:135
skewer_t w_skewer
Definition: tpcc_input.cpp:75
int _wh_id
Definition: tpcc_input.h:145
int _wh_id
Definition: tpcc_input.h:334
: Constants needed by the TPC-C kit
int _wh_id
Definition: tpcc_input.h:268
delivery_input_t create_delivery_input(int sf, int specificWH, int tspread)
Definition: tpcc_input.cpp:477
int _all_local
Definition: tpcc_input.h:136
tpcc_customer_tuple _acust
Definition: tpcc_input.h:91
new_order_input_t()
Definition: tpcc_input.h:99
int _home_d_id
Definition: tpcc_input.h:189
int _wh_id
Definition: tpcc_input.h:298
int _v_cust_wh_selection
Definition: tpcc_input.h:190
int _ol_idx
Definition: tpcc_input.h:155
~new_order_input_t()
Definition: tpcc_input.h:109
ol_item_info item
Definition: tpcc_input.h:157
int _d_id
Definition: tpcc_input.h:130
mbench_cust_input_t create_mbench_cust_input(int sf, int specificWH, int tspread)
Definition: tpcc_input.cpp:620
TwoIntVec::iterator TwoIntVecIt
Definition: tpcc_input.h:295
Definition: tpcc_input.h:358
int _wh_id
Definition: tpcc_input.h:80
int _c_id
Definition: tpcc_input.h:361
mbench_wh_input_t()
Definition: tpcc_input.h:338
mbench_wh_input_t create_mbench_wh_input(int sf, int specificWH, int tspread)
Definition: tpcc_input.cpp:571
payment_input_t create_payment_input(int sf, int specificWH, int tspread)
Definition: tpcc_input.cpp:315
tpcc_stock_tuple _astock
Definition: tpcc_input.h:71
int _ol_supply_wh_id
Definition: tpcc_input.h:66
int _home_wh_id
PAYMENT transaction inputs:
Definition: tpcc_input.h:188
Definition: tpcc_input.h:228
int _d_id
Definition: tpcc_input.h:299
~stock_level_input_t()
Definition: tpcc_input.h:317
Definition: tpcc_input.h:267
Definition: skewer.h:67
int _c_id
Definition: tpcc_input.h:232
Definition: tpcc_input.h:391
int _item_amount
Definition: tpcc_input.h:69
int _d_id
Definition: tpcc_input.h:81
Definition: tpcc_struct.h:137
int _d_next_o_id
Definition: tpcc_input.h:137
stock_level_input_t()
Definition: tpcc_input.h:310
short _ol_supply_wh_select
Definition: tpcc_input.h:65
Definition: tpcc_client.cpp:33
int _ol_quantity
Definition: tpcc_input.h:67
int * _cids
Definition: tpcc_input.h:393
int _o_ol_cnt
Definition: tpcc_input.h:305
delivery_input_t()
Definition: tpcc_input.h:273
int _d_id
Definition: tpcc_input.h:230
int _remote_wh_id
Definition: tpcc_input.h:191
Definition: tpcc_struct.h:54
int _d_id
Definition: tpcc_input.h:360
int _ol_cnt
Definition: tpcc_input.h:148
double _amount
Definition: tpcc_input.h:362
tpcc_district_tuple _adist
Definition: tpcc_input.h:92
double _amount
Definition: tpcc_input.h:335
int _all_local
Definition: tpcc_input.h:87
int _o_ol_cnt
Definition: tpcc_input.h:238
tpcc_warehouse_tuple _awh
Definition: tpcc_input.h:90
int _c_id
Definition: tpcc_input.h:82
Definition: tpcc_input.h:128
~order_status_input_t()
Definition: tpcc_input.h:251
Definition: tpcc_input.h:333
Data structures for the TPC-C database.
Definition: tpcc_input.h:172
int _h_date
Definition: tpcc_input.h:197
int _all_local
Definition: tpcc_input.h:152
tpcc_item_tuple _aitem
Definition: tpcc_input.h:72
short _c_select
Definition: tpcc_input.h:231
int _unit
Definition: tpcc_input.h:392
new_order_input_t create_new_order_input(int sf, int specificWH, int tspread)
Definition: tpcc_input.cpp:213
int _d_id
Definition: tpcc_input.h:146
vector< pair< int, int > > TwoIntVec
Definition: tpcc_input.h:293
Definition: tpcc_struct.h:238
int _d_next_o_id
Definition: tpcc_input.h:153
~delivery_input_t()
Definition: tpcc_input.h:277
int _wh_id
Definition: tpcc_input.h:359
int _rbk
Definition: tpcc_input.h:149
Definition: tpcc_input.h:63
short _threshold
Definition: tpcc_input.h:300
const int MAX_OL_PER_ORDER
Definition: tpcc_const.h:55
ol_item_info & operator=(const ol_item_info &rhs)
Definition: tpcc_input.cpp:99
Definition: tpcc_struct.h:347
order_status_input_t create_order_status_input(int sf, int specificWH, int tspread)
Definition: tpcc_input.cpp:417
Definition for the class skewer.
Definition: tpcc_input.h:144
int _ol_cnt
Definition: tpcc_input.h:83
int _d_next_o_id
Definition: tpcc_input.h:88
mbench_cust_input_t()
Definition: tpcc_input.h:365
int _ol_cnt
Definition: tpcc_input.h:132
int _wh
Definition: tpcc_input.h:388
time_t _tstamp
Definition: tpcc_input.h:86
int _next_o_id
Definition: tpcc_input.h:303
int _remote_d_id
Definition: tpcc_input.h:192
int _c_id
Definition: tpcc_input.h:194
stock_level_input_t create_stock_level_input(int sf, int specificWH, int tspread)
Definition: tpcc_input.cpp:526
int _v_cust_ident_selection
Definition: tpcc_input.h:193
int _c_id
Definition: tpcc_input.h:131
Definition: tpcc_struct.h:326
Definition: tpcc_input.h:387
~mbench_cust_input_t()
Definition: tpcc_input.h:371
: Declaration of the (common) random functions, used for the workload inputs
Definition: tpcc_input.h:297
Definition: tpcc_input.h:79
TwoIntVec * _pvwi
Definition: tpcc_input.h:307
int _o_id
Definition: tpcc_input.h:236
int _wh_id
Definition: tpcc_input.h:129
time_t _tstamp
Definition: tpcc_input.h:151
order_status_input_t()
Definition: tpcc_input.h:241
payment_input_t()
Definition: tpcc_input.h:200
bool _change_load
Definition: tpcc_input.cpp:77
short _carrier_id
Definition: tpcc_input.h:269
double _h_amount
Definition: tpcc_input.h:196
int _wh_id
Definition: tpcc_input.h:229
int _rbk
Definition: tpcc_input.h:84
int _rbk
Definition: tpcc_input.h:133
~payment_input_t()
Definition: tpcc_input.h:213
int _c_id
Definition: tpcc_input.h:147
int _ol_i_id
Definition: tpcc_input.h:64
~mbench_wh_input_t()
Definition: tpcc_input.h:342