now = new java.util.Date();
Oorder oorder = new Oorder();
NewOrder new_order = new NewOrder();
OrderLine order_line = new OrderLine();
jdbcIO myJdbcIO = new jdbcIO();
t = (whseKount * distWhseKount * custDistKount);
t = (t * 11) + (t / 3);
LOG.debug("whse=" + whseKount + ", dist=" + distWhseKount
+ ", cust=" + custDistKount);
LOG.debug("\nStart Order-Line-New Load for approx " + t
+ " rows @ " + now + " ...");
for (int w = 1; w <= whseKount; w++) {
for (int d = 1; d <= distWhseKount; d++) {
// TPC-C 4.3.3.1: o_c_id must be a permutation of [1, 3000]
int[] c_ids = new int[custDistKount];
for (int i = 0; i < custDistKount; ++i) {
c_ids[i] = i + 1;
}
// Collections.shuffle exists, but there is no
// Arrays.shuffle
for (int i = 0; i < c_ids.length - 1; ++i) {
int remaining = c_ids.length - i - 1;
int swapIndex = gen.nextInt(remaining) + i + 1;
assert i < swapIndex;
int temp = c_ids[swapIndex];
c_ids[swapIndex] = c_ids[i];
c_ids[i] = temp;
}
for (int c = 1; c <= custDistKount; c++) {
oorder.o_id = c;
oorder.o_w_id = w;
oorder.o_d_id = d;
oorder.o_c_id = c_ids[c - 1];
// o_carrier_id is set *only* for orders with ids < 2101
// [4.3.3.1]
if (oorder.o_id < FIRST_UNPROCESSED_O_ID) {
oorder.o_carrier_id = TPCCUtil.randomNumber(1, 10,
gen);
} else {
oorder.o_carrier_id = null;
}
oorder.o_ol_cnt = TPCCUtil.randomNumber(5, 15, gen);
oorder.o_all_local = 1;
oorder.o_entry_d = System.currentTimeMillis();
k++;
if (outputFiles == false) {
myJdbcIO.insertOrder(ordrPrepStmt, oorder);
} else {
String str = "";
str = str + oorder.o_id + ",";
str = str + oorder.o_w_id + ",";
str = str + oorder.o_d_id + ",";
str = str + oorder.o_c_id + ",";
str = str + oorder.o_carrier_id + ",";
str = str + oorder.o_ol_cnt + ",";
str = str + oorder.o_all_local + ",";
Timestamp entry_d = new java.sql.Timestamp(
oorder.o_entry_d);
str = str + entry_d;
out.println(str);
}
// 900 rows in the NEW-ORDER table corresponding to the
// last
// 900 rows in the ORDER table for that district (i.e.,
// with
// NO_O_ID between 2,101 and 3,000)
if (c >= FIRST_UNPROCESSED_O_ID) {
new_order.no_w_id = w;
new_order.no_d_id = d;
new_order.no_o_id = c;
k++;
if (outputFiles == false) {
myJdbcIO.insertNewOrder(nworPrepStmt, new_order);
} else {
String str = "";
str = str + new_order.no_w_id + ",";
str = str + new_order.no_d_id + ",";
str = str + new_order.no_o_id;
outNewOrder.println(str);
}
} // end new order
for (int l = 1; l <= oorder.o_ol_cnt; l++) {
order_line.ol_w_id = w;
order_line.ol_d_id = d;
order_line.ol_o_id = c;
order_line.ol_number = l; // ol_number
order_line.ol_i_id = TPCCUtil.randomNumber(1,
100000, gen);
if (order_line.ol_o_id < FIRST_UNPROCESSED_O_ID) {
order_line.ol_delivery_d = oorder.o_entry_d;
order_line.ol_amount = 0;
} else {
order_line.ol_delivery_d = null;
// random within [0.01 .. 9,999.99]
order_line.ol_amount = (float) (TPCCUtil
.randomNumber(1, 999999, gen) / 100.0);
}
order_line.ol_supply_w_id = order_line.ol_w_id;
order_line.ol_quantity = 5;
order_line.ol_dist_info = TPCCUtil.randomStr(24);
k++;
if (outputFiles == false) {
myJdbcIO.insertOrderLine(orlnPrepStmt,
order_line);
} else {
String str = "";
str = str + order_line.ol_w_id + ",";
str = str + order_line.ol_d_id + ",";