// Cast all the ProcParameters once in the beginning
Number xact_params[][] = new Number[xact_trace.getParams().length][];
for (int i = 0; i < xact_params.length; i++) {
ProcParameter catalog_proc_param = catalog_proc.getParameters().get("index", i);
assert(catalog_proc_param != null);
VoltType proc_param_type = VoltType.get(catalog_proc_param.getType());
try {
// Arrays
if (catalog_proc_param.getIsarray()) {
Object param_arr[] = xact_trace.getParam(i);
xact_params[i] = new Number[param_arr.length];
for (int ii = 0; ii < param_arr.length; ii++) {
xact_params[i][ii] = this.getParamAsNumber(proc_param_type, param_arr[ii]);
} // FOR
// Scalars (just store in the first element of the array
} else {
xact_params[i] = new Number[] {
this.getParamAsNumber(proc_param_type, xact_trace.getParam(i))
};
}
} catch (Exception ex) {
LOG.error("Failed to process " + CatalogUtil.getDisplayName(catalog_proc_param));
throw ex;
}
} // FOR
// Now run through all of the queries and calculate the correlation between StmtParameters and ProcParameters
for (QueryTrace query_trace : xact_trace.getQueries()) {
Statement catalog_stmt = query_trace.getCatalogItem(this.catalog_db);
QueryInstance query_instance = correlation.getQueryInstance(catalog_stmt);
Object query_params[] = query_trace.getParams();
// For each of the StmtParameter, update the correlation information for each of the ProcParameters
for (int i = 0; i < query_params.length; i++) {
StmtParameter catalog_stmt_param = catalog_stmt.getParameters().get(i);
assert(catalog_stmt_param != null);
VoltType stmt_param_type = VoltType.get(catalog_stmt_param.getJavatype());
assert(stmt_param_type != VoltType.INVALID);
Number stmt_param_val = this.getParamAsNumber(stmt_param_type, query_params[i]);
for (int ii = 0; ii < xact_params.length; ii++) {
ProcParameter catalog_proc_param = catalog_proc.getParameters().get(ii);
assert(catalog_proc_param != null) : "Missing ProcParameter in " + catalog_proc + " at index " + ii;
VoltType proc_param_type = VoltType.get(catalog_proc_param.getType());
assert(proc_param_type != VoltType.INVALID);
ProcParameterCorrelation ppc = query_instance.getProcParameterCorrelation(catalog_stmt_param, catalog_proc_param);
for (int iii = 0; iii < xact_params[ii].length; iii++) {
ppc.getAbstractCorrelation(iii).addOccurrence(stmt_param_val, xact_params[ii][iii]);