public void testWeightedTxnEstimation() throws Exception {
int num_txns = 20;
int num_intervals = 5;
// Make a workload that has the same transaction in it multiple times
Workload new_workload = new Workload(catalog);
TransactionTrace multip_txn = CollectionUtil.first(multip_workload);
Procedure catalog_proc = multip_txn.getCatalogItem(catalog_db);
for (int i = 0; i < num_txns; i++) {
TransactionTrace clone = (TransactionTrace)multip_txn.clone();
clone.setTransactionId(i);
clone.setTimestamps(new Long((i/5)*1000), new Long((i/5)*1000 + 100));
// System.err.println(clone.debug(catalog_db) + "\n");
new_workload.addTransaction(catalog_proc, clone);
} // FOR
assertEquals(num_txns, new_workload.getTransactionCount());
TimeIntervalCostModel<SingleSitedCostModel> orig_costModel = new TimeIntervalCostModel<SingleSitedCostModel>(catalogContext, SingleSitedCostModel.class, num_intervals);
double cost0 = orig_costModel.estimateWorkloadCost(catalogContext, new_workload);
// Now change make a new workload that has the same multi-partition transaction
// but this time it only has one but with a transaction weight
// We should get back the exact same cost
// System.err.println("+++++++++++++++++++++++++++++++++++++++++++++");
new_workload = new Workload(catalog);
for (int i = 0; i < num_txns/5; i++) {
TransactionTrace clone = (TransactionTrace)multip_txn.clone();
clone.setTransactionId(i);
clone.setTimestamps(new Long((i*5)*1000), new Long((i*5)*1000 + 100));
clone.setWeight(5);
// System.err.println(clone.debug(catalog_db) + "\n");
new_workload.addTransaction(catalog_proc, clone);
} // FOR
TimeIntervalCostModel<SingleSitedCostModel> new_costModel = new TimeIntervalCostModel<SingleSitedCostModel>(catalogContext, SingleSitedCostModel.class, num_intervals);
double cost1 = new_costModel.estimateWorkloadCost(catalogContext, new_workload);
assert(cost1 > 0);