pb.addDefaultSchema();
pb.addDefaultPartitioning();
pb.addProcedures(InsertOrderLineBatched.class, ResetWarehouse.class);
pb.compile(catalog);
ServerThread server = new ServerThread(catalog, BackendTarget.NATIVE_EE_JNI);
server.start();
server.waitForInitialization();
Client client = ClientFactory.createClient();
client.createConnection(null, "localhost", HStoreConstants.DEFAULT_PORT, "program", "none");
Date generationDateTime = new Date();
long tm = System.currentTimeMillis();
System.out.println("making order line table...");
tm = System.currentTimeMillis();
// int BATCH_SIZE = parameters.districtsPerWarehouse * (parameters.customersPerDistrict / 30);
int BATCH_SIZE = 1000;
long[] b_ol_o_id = new long[BATCH_SIZE];
long[] b_ol_d_id = new long[BATCH_SIZE];
long[] b_ol_number = new long[BATCH_SIZE];
long[] b_ol_i_id = new long[BATCH_SIZE];
long[] b_ol_supply_w_id = new long[BATCH_SIZE];
Date[] b_ol_delivery_d = new Date[BATCH_SIZE];
long[] b_ol_quantity = new long[BATCH_SIZE];
double[] b_ol_amount = new double[BATCH_SIZE];
String[] b_ol_dist_info = new String[BATCH_SIZE];
int total = 0;
int batch_cnt = 0;
int w_id = 1;
int customersPerDistrictAfterInsertion = (int) (parameters.customersPerDistrict * 3.0);
for (int d_id = 1; d_id <= parameters.districtsPerWarehouse; ++d_id) {
for (int o_id = 1; o_id <= customersPerDistrictAfterInsertion; ++o_id) { //10% more
// Generate each OrderLine for the order
long o_ol_cnt = generator.number(TPCCConstants.MIN_OL_CNT, TPCCConstants.MAX_OL_CNT);
boolean newOrder =
parameters.customersPerDistrict - parameters.newOrdersPerDistrict < o_id;
for (int ol_number = 1; ol_number <= o_ol_cnt; ++ol_number) {
//generateOrderLine(w_id, d_id, o_id, ol_number, newOrder);
//(long ol_w_id, long ol_d_id, long ol_o_id, long ol_number, boolean newOrder)
b_ol_o_id[batch_cnt] = o_id;
b_ol_d_id[batch_cnt] = d_id;
b_ol_number[batch_cnt] = ol_number;
b_ol_i_id[batch_cnt] = generator.number(1, parameters.num_items);
b_ol_supply_w_id[batch_cnt] = w_id;
b_ol_delivery_d[batch_cnt] = generationDateTime;
b_ol_quantity[batch_cnt] = TPCCConstants.INITIAL_QUANTITY;
if (!newOrder) {
b_ol_amount[batch_cnt] = 0.00;
} else {
b_ol_amount[batch_cnt] = generator.fixedPoint(TPCCConstants.MONEY_DECIMALS, TPCCConstants.MIN_AMOUNT,
TPCCConstants.MAX_PRICE * TPCCConstants.MAX_OL_QUANTITY);
b_ol_delivery_d[batch_cnt] = null;
}
b_ol_dist_info[batch_cnt] = generator.astring(TPCCConstants.DIST, TPCCConstants.DIST);
++batch_cnt;
if (batch_cnt == BATCH_SIZE) {
total += BATCH_SIZE;
System.out.println ("loading: " + total + "/" + (parameters.districtsPerWarehouse * customersPerDistrictAfterInsertion * (TPCCConstants.MAX_OL_CNT - TPCCConstants.MIN_OL_CNT)));
client.callProcedure(InsertOrderLineBatched.class.getSimpleName(),
b_ol_o_id, b_ol_d_id, w_id, b_ol_number, b_ol_i_id,
b_ol_supply_w_id, b_ol_delivery_d, b_ol_quantity, b_ol_amount, b_ol_dist_info);
batch_cnt = 0;
}
}
}
}
System.out.println("created " + (System.currentTimeMillis() - tm) + "ms");
tm = System.currentTimeMillis();
//delete the 10% orderline
client.callProcedure(ResetWarehouse.class.getSimpleName(),
1L,
(long) parameters.districtsPerWarehouse,
(long) parameters.customersPerDistrict,
(long) parameters.newOrdersPerDistrict);
System.out.println("deleted " + (System.currentTimeMillis() - tm) + "ms");
tm = System.currentTimeMillis();
server.shutdown();
}