/**
* Tester
* @param args
*/
public static void main(String[] vargs) throws Exception {
ArgumentsParser args = ArgumentsParser.load(vargs);
args.require(
ArgumentsParser.PARAM_CATALOG,
ArgumentsParser.PARAM_WORKLOAD,
ArgumentsParser.PARAM_MAPPINGS_OUTPUT
);
LOG.info("Starting " + MappingCalculator.class.getSimpleName());
if (debug.val)
LOG.debug("Workload Procedures Distribution:\n" + args.workload.getProcedureHistogram());
MappingCalculator cc = new MappingCalculator(args.catalog_db);
int ctr = 0;
for (AbstractTraceElement<?> element : args.workload) {
if (element instanceof TransactionTrace) {
try {
cc.processTransaction((TransactionTrace)element);
} catch (Exception ex) {
throw new Exception("Failed to process " + element, ex);
}
ctr++;
}
} // FOR
LOG.info("Finished processing " + ctr + " TransactionTraces. Now calculating correlation coeffcients...");
cc.calculate();
// System.err.println("Dumping out correlations...");
//
// for (Procedure catalog_proc : args.catalog_db.getProcedures()) {
// if (!catalog_proc.getName().equals("neworder")) continue;
// System.err.println(cc.getProcedureCorrelations(catalog_proc));
// } // FOR
double threshold = 1.0d;
if (args.hasDoubleParam(ArgumentsParser.PARAM_MAPPINGS_THRESHOLD)) {
threshold = args.getDoubleParam(ArgumentsParser.PARAM_MAPPINGS_THRESHOLD);
}
ParameterMappingsSet pc = cc.getParameterMappings(threshold);
File output_path = args.getFileParam(ArgumentsParser.PARAM_MAPPINGS_OUTPUT);
assert(!pc.isEmpty());
if (debug.val) LOG.debug("DEBUG DUMP:\n" + pc.debug());
pc.save(output_path);
LOG.info(String.format("Wrote %s to '%s'", pc.getClass().getSimpleName(), output_path));
}