* @throws Exception
*/
public static ListOrderedSet<String> generateProcParameterOrder(final DesignerInfo info, final Database catalog_db, final Procedure catalog_proc, final DesignerHints hints) throws Exception {
// HACK: Reload the correlations file so that we can get the proper
// catalog objects
ParameterMappingsSet mappings = info.getMappings();
assert (mappings != null);
// ParameterCorrelations correlations = new ParameterCorrelations();
// assert(info.getCorrelationsFile() != null) :
// "The correlations file path was not set";
// correlations.load(info.getCorrelationsFile(), catalog_db);
// For each procedure, we need to generate a list of potential
// partitioning parameters
String proc_key = CatalogKey.createKey(catalog_proc);
assert (proc_key != null);
// For each ProcParameter, get a list of the correlations that can be
// mapped to the partitioning columns
// of tables. We will generate a total weight for each ProcParameter
final Map<ProcParameter, List<Double>> param_correlations = new HashMap<ProcParameter, List<Double>>();
// Get the list of tables accessed by this procedure
for (Table catalog_tbl : CatalogUtil.getReferencedTables(catalog_proc)) {
if (catalog_tbl.getIsreplicated())
continue;
Column catalog_col = catalog_tbl.getPartitioncolumn();
for (ProcParameter catalog_proc_param : catalog_proc.getParameters()) {
// Skip if this is an array
if (hints.enable_array_procparameter_candidates == false && catalog_proc_param.getIsarray())
continue;
if (!param_correlations.containsKey(catalog_proc_param)) {
param_correlations.put(catalog_proc_param, new ArrayList<Double>());
}
// Special Case: MultiProcParameter
if (catalog_proc_param instanceof MultiProcParameter) {
if (hints.enable_multi_partitioning) {
MultiProcParameter mpp = (MultiProcParameter) catalog_proc_param;
for (ProcParameter inner : mpp) {
// Divide the values by the number of attributes in
// mpp so that we take the average
Collection<ParameterMapping> pms = mappings.get(inner, catalog_col);
if (pms != null) {
for (ParameterMapping c : pms) {
param_correlations.get(catalog_proc_param).add(c.getCoefficient() / (double) mpp.size());
} // FOR (ParameterMapping)
}
} // FOR
}
} else {
Collection<ParameterMapping> pms = mappings.get(catalog_proc_param, catalog_col);
if (pms != null) {
for (ParameterMapping c : pms) {
param_correlations.get(catalog_proc_param).add(c.getCoefficient());
} // FOR (Correlation)
}