/*** * This method introduces new variable names in each data atom and * equalities to account for JOIN operations. This method is called before * generating SQL queries and allows to avoid cross refrences in nested * JOINs, which generate wrong ON or WHERE conditions. * * * @param query */ public static void pullOutEqualities(CQIE query) { Substitution substitutions = new SubstitutionImpl(); int[] newVarCounter = { 1 }; Set<Function> booleanAtoms = new HashSet<>(); List<Function> equalities = new LinkedList<>(); pullOutEqualities(query.getBody(), substitutions, equalities, newVarCounter, false); List<Function> body = query.getBody(); body.addAll(equalities); /* * All new variables have been generated, the substitutions also, we * need to apply them to the equality atoms and to the head of the * query. */ SubstitutionUtilities.applySubstitution(query, substitutions, false); }
pullOutEqualities(subterms, substitutions, eqList, newVarCounter, true); else pullOutEqualities(subterms, substitutions, eqList, newVarCounter, false);