/**
* @param args
*/
@SuppressWarnings("unchecked")
public static void main(String vargs[]) throws Exception {
final ArgumentsParser args = ArgumentsParser.load(vargs);
args.require(ArgumentsParser.PARAM_CATALOG,
ArgumentsParser.PARAM_MARKOV,
ArgumentsParser.PARAM_WORKLOAD,
ArgumentsParser.PARAM_MAPPINGS,
ArgumentsParser.PARAM_MARKOV_THRESHOLDS);
HStoreConf.initArgumentsParser(args);
final int num_partitions = args.catalogContext.numberOfPartitions;
final int base_partition = (args.workload_base_partitions.size() == 1 ? CollectionUtil.first(args.workload_base_partitions) : HStoreConstants.NULL_PARTITION_ID);
final int num_threads = ThreadUtil.getMaxGlobalThreads();
final boolean stop_on_error = true;
final boolean force_fullpath = true;
final boolean force_regenerate = true;
final boolean skip_processing = false;
final ObjectHistogram<Procedure> total_h = new ObjectHistogram<Procedure>();
final ObjectHistogram<Procedure> missed_h = new ObjectHistogram<Procedure>();
final ObjectHistogram<Procedure> accurate_h = new ObjectHistogram<Procedure>();
final ObjectHistogram<MarkovOptimization> optimizations_h = new ObjectHistogram<MarkovOptimization>();
final ObjectHistogram<Penalty> penalties_h = new ObjectHistogram<Penalty>();
final Map<Procedure, ObjectHistogram<MarkovOptimization>> proc_penalties_h = new ConcurrentHashMap<Procedure, ObjectHistogram<MarkovOptimization>>();
final AtomicInteger total = new AtomicInteger(0);
final AtomicInteger failures = new AtomicInteger(0);
final List<Runnable> runnables = new ArrayList<Runnable>();
final List<Thread> processing_threads = new ArrayList<Thread>();
final AtomicInteger thread_finished = new AtomicInteger(0);
// Only load the MarkovGraphs that we actually need
final int num_transactions = args.workload.getTransactionCount();
assert (num_transactions > 0) : "No TransactionTraces";
final int marker = Math.max(1, (int) (num_transactions * 0.10));
final Set<Procedure> procedures = args.workload.getProcedures(args.catalog_db);
PartitionSet partitions = null;
if (base_partition != HStoreConstants.NULL_PARTITION_ID) {
partitions = new PartitionSet(base_partition);
} else {
partitions = args.catalogContext.getAllPartitionIds();
}
final File input_path = args.getFileParam(ArgumentsParser.PARAM_MARKOV);
final Map<Integer, MarkovGraphsContainer> m = MarkovGraphsContainerUtil.load(args.catalogContext,
input_path, procedures, partitions);
assert (m != null);
final boolean global = m.containsKey(MarkovUtil.GLOBAL_MARKOV_CONTAINER_ID);
final Map<Integer, MarkovGraphsContainer> thread_markovs[] = (Map<Integer, MarkovGraphsContainer>[]) new Map<?, ?>[num_threads];