Search in sources :

Example 1 with IndexedByBodyPredicatesRuleSet

use of fr.lirmm.graphik.graal.core.ruleset.IndexedByBodyPredicatesRuleSet in project graal by graphik-team.

the class DefaultGraphOfRuleDependencies method computeDependencies.

protected void computeDependencies(DependencyChecker... checkers) {
    // preprocess
    IndexedByBodyPredicatesRuleSet index = new IndexedByBodyPredicatesRuleSet(this.graph.vertexSet());
    Iterable<Rule> candidates = null;
    Set<String> marked = new TreeSet<String>();
    for (Rule r1 : this.graph.vertexSet()) {
        marked.clear();
        CloseableIteratorWithoutException<Atom> it = r1.getHead().iterator();
        while (it.hasNext()) {
            Atom a = it.next();
            candidates = index.getRulesByBodyPredicate(a.getPredicate());
            if (candidates != null) {
                for (Rule r2 : candidates) {
                    if (marked.add(r2.getLabel())) {
                        Set<Substitution> unifiers = computeDependency(r1, r2, checkers);
                        if (!unifiers.isEmpty()) {
                            this.setDependency(r1, unifiers, r2);
                        }
                    }
                }
            }
        }
    }
}
Also used : IndexedByBodyPredicatesRuleSet(fr.lirmm.graphik.graal.core.ruleset.IndexedByBodyPredicatesRuleSet) Substitution(fr.lirmm.graphik.graal.api.core.Substitution) TreeSet(java.util.TreeSet) Rule(fr.lirmm.graphik.graal.api.core.Rule) Atom(fr.lirmm.graphik.graal.api.core.Atom)

Aggregations

Atom (fr.lirmm.graphik.graal.api.core.Atom)1 Rule (fr.lirmm.graphik.graal.api.core.Rule)1 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)1 IndexedByBodyPredicatesRuleSet (fr.lirmm.graphik.graal.core.ruleset.IndexedByBodyPredicatesRuleSet)1 TreeSet (java.util.TreeSet)1