* testNewOrder
*/
@Test
public void testNewOrder() throws Exception {
Procedure catalog_proc = this.getProcedure(neworder.class);
AbstractHasher hasher = p_estimator.getHasher();
long txn_id = 1000;
for (short w_id = 1; w_id <= NUM_PARTITIONS; w_id++) {
short remote_w_id = (short)rng.numberExcluding(1, NUM_PARTITIONS, w_id);
// ORDER_LINE ITEMS
int num_items = rng.number(TPCCConstants.MIN_OL_CNT, TPCCConstants.MAX_OL_CNT);
int item_id[] = new int[num_items];
short supware[] = new short[num_items];
int quantity[] = new int[num_items];
for (int i = 0; i < num_items; i++) {
item_id[i] = rng.nextInt();
supware[i] = remote_w_id;
quantity[i] = rng.number(TPCCConstants.MIN_QUANTITY, TPCCConstants.MAX_QUANTITY);
} // FOR
Object args[] = {
w_id, // W_ID
(byte)rng.nextInt(10), // D_ID
rng.nextInt(), // C_ID
new TimestampType(), // TIMESTAMP
item_id, // ITEM_IDS
supware, // SUPPLY W_IDS
quantity // QUANTITIES
};
EstimatorState state = this.estimator.startTransaction(txn_id, catalog_proc, args);
assertNotNull(state);
assertEquals(txn_id, state.getTransactionId().longValue());
// System.err.printf("W_ID=%d / S_W_ID=%s\n", w_id, remote_w_id);
// Make sure that it identifies that we are a distributed transaction and
// that we expect to touch both the W_ID partition and the REMOTE_W_ID partition
Estimate est = state.getInitialEstimate();
assertNotNull(est);
PartitionSet partitions = est.getTouchedPartitions(thresholds);
assertEquals(2, partitions.size());
for (int expected : new int[]{ w_id, remote_w_id }) {
expected = hasher.hash(expected);
assertTrue(Integer.toString(expected) + "->" + partitions, partitions.contains(expected));
} // FOR
assertEquals(hasher.hash(w_id), state.getBasePartition());
txn_id++;
} // FOR
}