@Override public Set<Variable> getReferencedVariables() { Set<Variable> vars = new LinkedHashSet<Variable>(); for (Function atom : body) { TermUtils.addReferencedVariablesTo(vars, atom); } return vars; } }
public static void addReferencedVariablesTo(Collection<Variable> vars, Term t) { if (t instanceof Function) { addReferencedVariablesTo(vars, (Function)t); } else if (t instanceof Variable) { vars.add((Variable)t); } else /* (t instanceof BNode) || (t instanceof URIConstant) || (t instanceof ValueConstant) */ { // no-op } }
public static void addReferencedVariablesTo(Collection<Variable> vars, Term t) { if (t instanceof Function) { addReferencedVariablesTo(vars, (Function)t); } else if (t instanceof Variable) { vars.add((Variable)t); } else /* (t instanceof BNode) || (t instanceof IRIConstant) || (t instanceof ValueConstant) */ { // no-op } }
public static void addReferencedVariablesTo(Collection<Variable> vars, Function f) { for (Term t : f.getTerms()) { if (t instanceof Variable) vars.add((Variable)t); else if (t instanceof Function) addReferencedVariablesTo(vars, (Function)t); // else (t instanceof BNode) || (t instanceof IRIConstant) || (t instanceof ValueConstant) // no-op } }
public static void addReferencedVariablesTo(Collection<Variable> vars, Function f) { for (Term t : f.getTerms()) { if (t instanceof Variable) vars.add((Variable)t); else if (t instanceof Function) addReferencedVariablesTo(vars, (Function)t); // else (t instanceof BNode) || (t instanceof URIConstant) || (t instanceof ValueConstant) // no-op } }
@Override public Set<Variable> getVariables() { Set<Variable> variables = new HashSet<>(); for (Term t : getTerms()) { TermUtils.addReferencedVariablesTo(variables, t); } return variables; }
@Override public Set<Variable> getVariables() { Set<Variable> variables = new HashSet<>(); for (Term t : getTerms()) { TermUtils.addReferencedVariablesTo(variables, t); } return variables; }
final String template = term.getValue(); List<Variable> varList = new ArrayList<>(); TermUtils.addReferencedVariablesTo(varList, uriFunction);
boolean intersects = false; Set<Variable> atomVars = new HashSet<>(); TermUtils.addReferencedVariablesTo(atomVars, atom); for (Variable t : atomVars) if (ccTerms.contains(t)) {
Function atom = (Function) atoms.get(i); if (atom.isDataFunction()) { TermUtils.addReferencedVariablesTo(currentLevelVariables, atom); } else if (atom.isAlgebraFunction()) { currentLevelVariables.addAll(getDefinedVariables(atom.getTerms()));
/**** * Gets all the variables that are defined in this list of atoms, except in * atom i * * @param atoms * @return */ private static Set<Variable> getDefinedVariables(List<Term> atoms) { Set<Variable> currentLevelVariables = new HashSet<>(); for (Term l : atoms) { Function atom = (Function) l; if (atom.isOperation()) { continue; } else if (atom.isAlgebraFunction()) { currentLevelVariables.addAll(getDefinedVariables(atom.getTerms())); } else { TermUtils.addReferencedVariablesTo(currentLevelVariables, atom); } } return currentLevelVariables; }
TermUtils.addReferencedVariablesTo(atomVariables, equality); continue; Set<Variable> variables = new HashSet<>(); TermUtils.addReferencedVariablesTo(variables, atom); boolean belongsUp = false;
TermUtils.addReferencedVariablesTo(vars, f); Variable v = vars.iterator().next(); ccs.add(getConnectedComponent(pairs, allLoops, nonDLAtoms, v));
Collection<Variable> vars = new ArrayList<>(); for (Function atom : body) TermUtils.addReferencedVariablesTo(vars, atom); int maxlen = vars.stream() .map(v -> v.getName().length())
if (atom.isDataFunction()) { Set<Variable> variables = new LinkedHashSet<>(); TermUtils.addReferencedVariablesTo(variables, atom); return variables;
/** * Collects (recursively) the set of variables that participate in data atoms * (either in this atom directly or in nested ones, excluding those on the * right-hand side of left joins. * * @param vars * @param atom * @return */ private void collectVariableReferencesWithLeftJoin(Set<Variable> vars, Function atom) { if (atom.isDataFunction()) { TermUtils.addReferencedVariablesTo(vars, atom); } else if (atom.isAlgebraFunction()) { Predicate functionSymbol = atom.getFunctionSymbol(); if (functionSymbol.equals(datalogFactory.getSparqlJoinPredicate())) { // if it's a join, we need to collect all the variables of each nested atom convert(atom.getTerms()).stream() .filter(f -> !f.isOperation()) .forEach(f -> collectVariableReferencesWithLeftJoin(vars, f)); } else if (functionSymbol.equals(datalogFactory.getSparqlLeftJoinPredicate())) { // if it's a left join, only of the first data/algebra atom (the left atom) collectVariableReferencesWithLeftJoin(vars, (Function) atom.getTerm(0)); } } }
/** * Collects (recursively) the set of variables that participate in data atoms * (either in this atom directly or in nested ones, excluding those on the * right-hand side of left joins. * * @param vars * @param atom * @return */ private void collectVariableReferencesWithLeftJoin(Set<Variable> vars, Function atom) { if (atom.isDataFunction()) { TermUtils.addReferencedVariablesTo(vars, atom); } else if (atom.isAlgebraFunction()) { Predicate functionSymbol = atom.getFunctionSymbol(); if (functionSymbol == DatalogAlgebraOperatorPredicates.SPARQL_JOIN) { // if it's a join, we need to collect all the variables of each nested atom convert(atom.getTerms()).stream() .filter(f -> !f.isOperation()) .forEach(f -> collectVariableReferencesWithLeftJoin(vars, f)); } else if (functionSymbol == DatalogAlgebraOperatorPredicates.SPARQL_LEFTJOIN) { // if it's a left join, only of the first data/algebra atom (the left atom) collectVariableReferencesWithLeftJoin(vars, (Function) atom.getTerm(0)); } } }