1 #ifndef _NDB_BENCH_TPCC_H_
2 #define _NDB_BENCH_TPCC_H_
6 #include "../record/encoder.h"
7 #include "../record/inline_str.h"
10 #define CUSTOMER_KEY_FIELDS(x, y) \
14 #define CUSTOMER_VALUE_FIELDS(x, y) \
16 y(inline_str_fixed<2>,c_credit) \
17 y(inline_str_8<16>,c_last) \
18 y(inline_str_8<16>,c_first) \
19 y(float,c_credit_lim) \
21 y(float,c_ytd_payment) \
22 y(int32_t,c_payment_cnt) \
23 y(int32_t,c_delivery_cnt) \
24 y(inline_str_8<20>,c_street_1) \
25 y(inline_str_8<20>,c_street_2) \
26 y(inline_str_8<20>,c_city) \
27 y(inline_str_fixed<2>,c_state) \
28 y(inline_str_fixed<9>,c_zip) \
29 y(inline_str_fixed<16>,c_phone) \
31 y(inline_str_fixed<2>,c_middle) \
32 y(inline_str_16<500>,c_data)
33 DO_STRUCT(customer, CUSTOMER_KEY_FIELDS, CUSTOMER_VALUE_FIELDS)
35 #define CUSTOMER_NAME_IDX_KEY_FIELDS(x, y) \
38 y(inline_str_fixed<16>,c_last) \
39 y(inline_str_fixed<16>,c_first)
40 #define CUSTOMER_NAME_IDX_VALUE_FIELDS(x, y) \
42 DO_STRUCT(customer_name_idx, CUSTOMER_NAME_IDX_KEY_FIELDS, CUSTOMER_NAME_IDX_VALUE_FIELDS)
44 #define DISTRICT_KEY_FIELDS(x, y) \
47 #define DISTRICT_VALUE_FIELDS(x, y) \
50 y(int32_t,d_next_o_id) \
51 y(inline_str_8<10>,d_name) \
52 y(inline_str_8<20>,d_street_1) \
53 y(inline_str_8<20>,d_street_2) \
54 y(inline_str_8<20>,d_city) \
55 y(inline_str_fixed<2>,d_state) \
56 y(inline_str_fixed<9>,d_zip)
57 DO_STRUCT(district, DISTRICT_KEY_FIELDS, DISTRICT_VALUE_FIELDS)
59 #define HISTORY_KEY_FIELDS(x, y) \
66 #define HISTORY_VALUE_FIELDS(x, y) \
68 y(inline_str_8<24>,h_data)
69 DO_STRUCT(history, HISTORY_KEY_FIELDS, HISTORY_VALUE_FIELDS)
71 #define ITEM_KEY_FIELDS(x, y) \
73 #define ITEM_VALUE_FIELDS(x, y) \
74 x(inline_str_8<24>,i_name) \
76 y(inline_str_8<50>,i_data) \
78 DO_STRUCT(item, ITEM_KEY_FIELDS, ITEM_VALUE_FIELDS)
80 #define NEW_ORDER_KEY_FIELDS(x, y) \
84 // need dummy b/c our btree cannot have empty values.
85 // we also size value so that it can fit a key
86 #define NEW_ORDER_VALUE_FIELDS(x, y) \
87 x(inline_str_fixed<12>,no_dummy)
88 DO_STRUCT(new_order, NEW_ORDER_KEY_FIELDS, NEW_ORDER_VALUE_FIELDS)
90 #define OORDER_KEY_FIELDS(x, y) \
94 #define OORDER_VALUE_FIELDS(x, y) \
96 y(int32_t,o_carrier_id) \
100 DO_STRUCT(oorder, OORDER_KEY_FIELDS, OORDER_VALUE_FIELDS)
102 #define OORDER_C_ID_IDX_KEY_FIELDS(x, y) \
107 #define OORDER_C_ID_IDX_VALUE_FIELDS(x, y) \
109 DO_STRUCT(oorder_c_id_idx, OORDER_C_ID_IDX_KEY_FIELDS, OORDER_C_ID_IDX_VALUE_FIELDS)
111 #define ORDER_LINE_KEY_FIELDS(x, y) \
116 #define ORDER_LINE_VALUE_FIELDS(x, y) \
118 y(uint32_t,ol_delivery_d) \
120 y(int32_t,ol_supply_w_id) \
121 y(int8_t,ol_quantity)
122 DO_STRUCT(order_line, ORDER_LINE_KEY_FIELDS, ORDER_LINE_VALUE_FIELDS)
124 #define STOCK_KEY_FIELDS(x, y) \
127 #define STOCK_VALUE_FIELDS(x, y) \
128 x(int16_t,s_quantity) \
130 y(int32_t,s_order_cnt) \
131 y(int32_t,s_remote_cnt)
132 DO_STRUCT(stock, STOCK_KEY_FIELDS, STOCK_VALUE_FIELDS)
134 #define STOCK_DATA_KEY_FIELDS(x, y) \
137 #define STOCK_DATA_VALUE_FIELDS(x, y) \
138 x(inline_str_8<50>,s_data) \
139 y(inline_str_fixed<24>,s_dist_01) \
140 y(inline_str_fixed<24>,s_dist_02) \
141 y(inline_str_fixed<24>,s_dist_03) \
142 y(inline_str_fixed<24>,s_dist_04) \
143 y(inline_str_fixed<24>,s_dist_05) \
144 y(inline_str_fixed<24>,s_dist_06) \
145 y(inline_str_fixed<24>,s_dist_07) \
146 y(inline_str_fixed<24>,s_dist_08) \
147 y(inline_str_fixed<24>,s_dist_09) \
148 y(inline_str_fixed<24>,s_dist_10)
149 DO_STRUCT(stock_data, STOCK_DATA_KEY_FIELDS, STOCK_DATA_VALUE_FIELDS)
151 #define WAREHOUSE_KEY_FIELDS(x, y) \
153 #define WAREHOUSE_VALUE_FIELDS(x, y) \
156 y(inline_str_8<10>,w_name) \
157 y(inline_str_8<20>,w_street_1) \
158 y(inline_str_8<20>,w_street_2) \
159 y(inline_str_8<20>,w_city) \
160 y(inline_str_fixed<2>,w_state) \
161 y(inline_str_fixed<9>,w_zip)
162 DO_STRUCT(warehouse, WAREHOUSE_KEY_FIELDS, WAREHOUSE_VALUE_FIELDS)
164 #define TPCC_TABLE_LIST(x) \
166 x(customer_name_idx) \
178 template <typename Database, bool AllowReadOnlyScans>
179 class tpcc_bench_runner;
181 template <typename Database>
183 template <typename D, bool B>
184 friend class tpcc_bench_runner;
186 #define DEFN_TBL_ACCESSOR_X(name) \
190 typename Database::template IndexType< \
194 > tbl_ ## name ## _vec; \
196 inline ALWAYS_INLINE typename Database::template IndexType<schema< name >>::type * \
197 tbl_ ## name(unsigned int wid) \
199 INVARIANT(wid >= 1); \
200 return (tbl_ ## name ## _vec[wid - 1]).get(); \
203 TPCC_TABLE_LIST(DEFN_TBL_ACCESSOR_X)
205 #undef DEFN_TBL_ACCESSOR_X