use of fr.lirmm.graphik.util.stream.IteratorException in project graal by graphik-team.
the class RestrictedChaseRuleApplier method apply.
// /////////////////////////////////////////////////////////////////////////
// PUBLIC METHODS
// /////////////////////////////////////////////////////////////////////////
@Override
public boolean apply(Rule rule, T atomSet) throws RuleApplicationException {
try {
boolean res = false;
ConjunctiveQueryWithNegatedParts query = new RuleWrapper2ConjunctiveQueryWithNegatedParts(rule);
CloseableIterator<Substitution> results;
results = SmartHomomorphism.instance().execute(query, atomSet);
while (results.hasNext()) {
res = true;
Substitution proj = results.next();
// replace variables by fresh symbol
for (Variable t : rule.getExistentials()) {
proj.put(t, atomSet.getFreshSymbolGenerator().getFreshSymbol());
}
CloseableIteratorWithoutException<Atom> it = proj.createImageOf(rule.getHead()).iterator();
while (it.hasNext()) {
atomSet.add(it.next());
}
}
return res;
} catch (HomomorphismException e) {
throw new RuleApplicationException("", e);
} catch (AtomSetException e) {
throw new RuleApplicationException("", e);
} catch (IteratorException e) {
throw new RuleApplicationException("", e);
}
}
use of fr.lirmm.graphik.util.stream.IteratorException in project graal by graphik-team.
the class AbstractHomomorphismWithCompilation method exist.
@Override
public boolean exist(T1 q, T2 a, RulesCompilation compilation) throws HomomorphismException {
CloseableIterator<Substitution> results = this.execute(q, a, compilation);
boolean val;
try {
val = results.hasNext();
} catch (IteratorException e) {
throw new HomomorphismException(e);
}
results.close();
return val;
}
Aggregations