for (int i1 = 0, cnt1 = queries1.size(); i1 < cnt1; i1++) {
stmt1 = queries1.get(i1);
if (stmt0.statement.getReadonly() && stmt1.statement.getReadonly()) continue;
ConflictPair cp = cache0.conflicts.get(stmt1.statement);
// If there isn't a ConflictPair, then there isn't a conflict
if (cp == null) {
continue;
}
// If the ConflictPair is marked as always conflicting, then
// we can stop right here
else if (cp.getAlwaysconflicting()) {
if (debug.val) LOG.debug(String.format("%s - Marked as always conflicting", cp.fullName()));
return (false);
}
// Otherwise, at this point we know that we have two queries that both
// reference the same table(s). Therefore, we need to evaluate the values
// of the primary keys referenced in the queries to see whether they conflict
cache1 = this.stmtCache.get(stmt1.statement);
mappings1 = this.catalogContext.paramMappings.get(stmt1.statement, stmt1.counter);
if (mappings1 == null) {
LOG.warn(String.format("The ParameterMappings for %s in candidate %s is null?\n%s",
stmt1, ts1, StringUtil.join("\n", queries1)));
return (false);
}
boolean allEqual = true;
for (Column col : cache0.colParams.keySet()) {
// If either StmtParameters are null, then that's a conflict!
StmtParameter param0 = cache0.colParams.get(col);
StmtParameter param1 = cache1.colParams.get(col);
// It's ok if we're missing one of the parameters that we need if
// the values are still not the same. It's only a problem if they're
// all the same because we have no idea know whether they're
// actually the same or not
if (param0 == null || param1 == null) {
if (trace.val)
LOG.trace(String.format("%s - Missing StmtParameters for %s [param0=%s / param1=%s]",
cp.fullName(), col.fullName(), param0, param1));
continue;
}
// Similarly, if we don't have a ParameterMapping then there is nothing
// else we can do. Again, this is ok as long as at least one of the
// pkey values are different.
ParameterMapping pm0 = CollectionUtil.first(mappings0.get(param0));
ParameterMapping pm1 = CollectionUtil.first(mappings1.get(param1));
if (pm0 == null) {
if (trace.val)
LOG.trace(String.format("%s - No ParameterMapping for %s",
cp.fullName(), param0.fullName()));
continue;
}
else if (pm1 == null) {
if (trace.val)
LOG.trace(String.format("%s - No ParameterMapping for %s",
cp.fullName(), param1.fullName()));
continue;
}
// If the values are not equal, then we can stop checking the
// other columns right away.
if (this.equalParameters(params0, pm0, params1, pm1) == false) {
if (trace.val)
LOG.trace(String.format("%s - Parameter values are equal for %s [param0=%s / param1=%s]",
cp.fullName(), col.fullName(), param0, param1));
allEqual = false;
break;
}
} // FOR (col)
// If all the parameters are equal, than means they are likely to be
// accessing the same row in the table. That's a conflict!
if (allEqual) {
if (debug.val)
LOG.debug(String.format("%s - All known parameter values are equal", cp.fullName()));
return (false);
}
} // FOR (stmt1)
} // FOR (stmt0)
return (true);