use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class ForwardCheckingTest method NFC2Test2.
@Test
public void NFC2Test2() throws HomomorphismException, IteratorException, ParseException {
Profiler profiler = new CPUTimeProfiler();
Predicate[] predicates = { new Predicate("p", 2), new Predicate("q", 2), new Predicate("r", 2) };
InMemoryAtomSet data = new DefaultInMemoryGraphStore();
TestUtil.addNAtoms(data, 32, predicates, 5, new Random(0));
ConjunctiveQuery query = DlgpParser.parseQuery("?(X,Y,Z) :- p(X,Y), q(X,Z), r(Y,Z).");
Homomorphism<ConjunctiveQuery, AtomSet> h = new BacktrackHomomorphism(new NFC2());
h.setProfiler(profiler);
CloseableIterator<Substitution> results = h.execute(query, data);
while (results.hasNext()) {
results.next();
}
results.close();
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class EqualityUtilsTest method testQuery1.
@Test
public void testQuery1() throws HomomorphismException, IteratorException, AtomSetException {
ConjunctiveQuery q = DlgpParser.parseQuery("?(X,Y) :- b(X), Y=a.");
InMemoryAtomSet store = new DefaultInMemoryGraphStore();
store.addAll(DlgpParser.parseAtomSet("b(a),b(b)."));
BacktrackHomomorphism h = new BacktrackHomomorphism();
CloseableIterator<Substitution> results = h.execute(q, store);
while (results.hasNext()) {
results.next();
}
results.close();
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class EqualityUtilsTest method testQuery2.
@Test
public void testQuery2() throws HomomorphismException, IteratorException, AtomSetException {
ConjunctiveQuery q = DlgpParser.parseQuery("?(X,Y) :- p(X,Y), X=Y.");
InMemoryAtomSet store = new DefaultInMemoryGraphStore();
store.addAll(DlgpParser.parseAtomSet("p(a,a),p(a,b),p(b,b)."));
BacktrackHomomorphism h = new BacktrackHomomorphism();
CloseableIterator<Substitution> results = h.execute(q, store);
while (results.hasNext()) {
results.next();
}
results.close();
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class HomomorphismTest method test2.
@Test
public void test2() throws HomomorphismException, IteratorException, AtomSetException {
InMemoryAtomSet data = new DefaultInMemoryGraphStore();
data.addAll(DlgpParser.parseAtomSet("p(a,b), q(b)."));
InMemoryAtomSet positivePart = new LinkedListAtomSet();
positivePart.addAll(DlgpParser.parseAtomSet("p(a,b)."));
InMemoryAtomSet negatedPart = new LinkedListAtomSet();
negatedPart.addAll(DlgpParser.parseAtomSet("q(b)."));
DefaultConjunctiveQueryWithNegatedParts query = new DefaultConjunctiveQueryWithNegatedParts(positivePart, Collections.singletonList(negatedPart));
BacktrackHomomorphismWithNegatedParts h = new BacktrackHomomorphismWithNegatedParts();
CloseableIterator<Substitution> res = h.execute(query, data);
Assert.assertFalse(res.hasNext());
res.close();
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class HomomorphismTest method test11.
@Test
public void test11() throws HomomorphismException, IteratorException, AtomSetException {
InMemoryAtomSet data = new DefaultInMemoryGraphStore();
data.addAll(DlgpParser.parseAtomSet("p(a,b)."));
InMemoryAtomSet positivePart = new LinkedListAtomSet();
positivePart.addAll(DlgpParser.parseAtomSet("p(a,b)."));
LinkedList<InMemoryAtomSet> parts = new LinkedList<InMemoryAtomSet>();
InMemoryAtomSet negatedPart = new LinkedListAtomSet();
negatedPart.addAll(DlgpParser.parseAtomSet("q(a)."));
parts.add(negatedPart);
negatedPart = new LinkedListAtomSet();
negatedPart.addAll(DlgpParser.parseAtomSet("q(b)."));
parts.add(negatedPart);
DefaultConjunctiveQueryWithNegatedParts query = new DefaultConjunctiveQueryWithNegatedParts(positivePart, parts);
BacktrackHomomorphismWithNegatedParts h = new BacktrackHomomorphismWithNegatedParts();
CloseableIterator<Substitution> res = h.execute(query, data);
Assert.assertTrue(res.hasNext());
res.next();
Assert.assertFalse(res.hasNext());
res.close();
}
Aggregations