@Override public DatalogProgram clone() { DatalogProgramImpl clone = new DatalogProgramImpl(); for (CQIE query : rules) { clone.appendRule(query.clone()); } clone.modifiers = modifiers.clone(); return clone; }
@Override public DatalogProgram clone() { DatalogProgramImpl clone = new DatalogProgramImpl(); for (CQIE query : rules) { clone.appendRule(query.clone()); } clone.modifiers = modifiers.clone(); return clone; }
CQIE freshRule = rule.clone(); Function head = freshRule.getHead(); List<Term> headTerms = head.getTerms();
CQIE freshRule = rule.clone(); Function head = freshRule.getHead(); List<Term> headTerms = head.getTerms();
/** * This method will return a new query, resulting from the application of * the substitution function to the original query q. To do this, we will call the clone() * method of the original query and then will call applySubstitution to each atom * of the cloned query. * * @param q * @param substitution * @return */ public CQIE applySubstitution(CQIE q, Substitution substitution, boolean clone) { CQIE newq; if (clone) newq = q.clone(); else newq = q; Function head = newq.getHead(); applySubstitution(head, substitution); for (Function bodyatom : newq.getBody()) applySubstitution(bodyatom, substitution); return newq; }
outputMappings.add(newMapping.orElse(mapping.clone()));
private IQ preProcess(InternalSparqlQuery translation) throws OntopInvalidInputQueryException, EmptyQueryException { DatalogProgram program = translation.getProgram(); log.debug("Datalog program translated from the SPARQL query: \n{}", program); if(settings.isSameAsInMappingsEnabled()){ program = sameAsRewriter.getSameAsRewriting(program); log.debug("Datalog program after SameAs rewriting \n{}", program); } log.debug("Replacing equivalences..."); DatalogProgram newprogramEq = datalogFactory.getDatalogProgram(program.getQueryModifiers()); for (CQIE query : program.getRules()) { CQIE rule = query.clone(); // EQNormalizer cannot be removed because it is used in NULL propagation in OPTIONAL eqNormalizer.enforceEqualities(rule); newprogramEq.appendRule(rule); } if (newprogramEq.getRules().isEmpty()) throw new OntopInvalidInputQueryException("Error, the translation of the query generated 0 rules. " + "This is not possible for any SELECT query (other queries are not supported by the translator)."); return datalogConverter.convertDatalogProgram(newprogramEq, ImmutableList.of(), translation.getSignature()); }
/** * This method will return a new query, resulting from the application of * the substitution function to the original query q. To do this, we will call the clone() * method of the original query and then will call applySubstitution to each atom * of the cloned query. * * @param q * @param substitution * @return */ public static CQIE applySubstitution(CQIE q, Substitution substitution, boolean clone) { CQIE newq; if (clone) newq = q.clone(); else newq = q; Function head = newq.getHead(); applySubstitution(head, substitution); for (Function bodyatom : newq.getBody()) applySubstitution(bodyatom, substitution); return newq; }
/** * High-level method. * * Returns a new normalized rule. */ @Override public CQIE normalizeByPullingOutEqualities(final CQIE initialRule) { CQIE newRule = initialRule.clone(); // Mutable object final VariableDispatcher variableDispatcher = new VariableDispatcher(initialRule); /** * Result for the top atoms of the rule. */ PullOutEqLocalNormResult result = normalizeSameLevelAtoms(List.iterableList(newRule.getBody()), variableDispatcher); newRule.updateBody(new ArrayList(result.getAllAtoms().toCollection())); return newRule; }