use of fr.lirmm.graphik.graal.api.homomorphism.HomomorphismWithCompilation in project graal by graphik-team.
the class ConjunctiveQueryWithCompilation method issue34.
@Theory
public void issue34(Homomorphism<ConjunctiveQuery, AtomSet> hh, RulesCompilationFactory factory, AtomSet store) throws Exception {
Assume.assumeTrue(hh instanceof HomomorphismWithCompilation);
HomomorphismWithCompilation<ConjunctiveQuery, AtomSet> h = (HomomorphismWithCompilation<ConjunctiveQuery, AtomSet>) hh;
store.add(DlgpParser.parseAtom("<Q>(a,b)."));
RuleSet rules = new LinkedListRuleSet();
rules.add(DlgpParser.parseRule("<P>(X,Y) :- <Q>(Y,X)."));
RulesCompilation comp = factory.create();
comp.compile(rules.iterator());
StaticChase.executeChase(store, rules);
InMemoryAtomSet query1 = new LinkedListAtomSet();
query1.add(DlgpParser.parseAtom("<P>(a,Y)."));
CloseableIterator<Substitution> results = h.execute(new DefaultConjunctiveQuery(query1), store, comp);
Assert.assertFalse(results.hasNext());
results.close();
}
use of fr.lirmm.graphik.graal.api.homomorphism.HomomorphismWithCompilation in project graal by graphik-team.
the class ConjunctiveQueryWithCompilation method issue35.
@Theory
public void issue35(Homomorphism<ConjunctiveQuery, AtomSet> hh, RulesCompilationFactory factory, AtomSet store) throws Exception {
Assume.assumeFalse(store instanceof TripleStore);
Assume.assumeTrue(hh instanceof HomomorphismWithCompilation);
HomomorphismWithCompilation<ConjunctiveQuery, AtomSet> h = (HomomorphismWithCompilation<ConjunctiveQuery, AtomSet>) hh;
store.addAll(DlgpParser.parseAtomSet("<P>(a,a), <R>(a,b,b)."));
RuleSet rules = new LinkedListRuleSet();
rules.add(DlgpParser.parseRule("<Q>(X,Y,X) :- <P>(X,Y)."));
ConjunctiveQuery query = DlgpParser.parseQuery("? :- <Q>(X,Y,Y), <R>(X,Y,Z).");
RulesCompilation comp = factory.create();
comp.compile(rules.iterator());
StaticChase.executeChase(store, rules);
CloseableIterator<Substitution> results = h.execute(new DefaultConjunctiveQuery(query), store, comp);
Assert.assertFalse(results.hasNext());
results.close();
}
Aggregations