use of fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore in project graal by graphik-team.
the class TestUtil method getAtomSet.
public static AtomSet[] getAtomSet() {
if (neo4jStore != null) {
neo4jStore.close();
}
try {
if (defaultRDBMSStore != null) {
defaultRDBMSStore.close();
}
if (plainTableRDBMSStore != null) {
plainTableRDBMSStore.close();
}
defaultRDBMSStore = new AdHocRdbmsStore(new HSQLDBDriver(DEFAULT_RDBMS_TEST, null));
plainTableRDBMSStore = new NaturalRDBMSStore(new HSQLDBDriver(PLAIN_TABLE_RDBMS_TEST, null));
defaultRDBMSStore.clear();
plainTableRDBMSStore.clear();
rm(NEO4J_TEST);
neo4jStore = new Neo4jStore(NEO4J_TEST);
if (sailStore != null) {
sailStore.close();
}
try {
sailStore = new RDF4jStore(new SailRepository(new MemoryStore()));
} catch (AtomSetException e) {
Assert.assertTrue("Error while creating SailStore", false);
}
return new AtomSet[] { new DefaultInMemoryGraphStore(), new LinkedListAtomSet(), defaultRDBMSStore, plainTableRDBMSStore, neo4jStore, sailStore };
} catch (SQLException e) {
throw new Error(e);
} catch (AtomSetException e) {
throw new Error(e);
}
}
use of fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore in project graal by graphik-team.
the class BackjumpTest method test1.
/*
* X1 --(p15)--> X5 --(p56)--> X6 \ (p12)--> X2 --(p24)--> X4 \ (p23)--> X3
*
* solutions: X1 X2 X3 X4 X5 X6
* b b c d a a
* b b d d a a
* b d a a a a
*/
@Test
public void test1() throws HomomorphismException, IteratorException, ParseException, AtomSetException {
InMemoryAtomSet data = new DefaultInMemoryGraphStore();
data.addAll(DlgpParser.parseAtomSet("p12(a,a), p12(b,b), p12(b,c), p12(b,d)."));
data.addAll(DlgpParser.parseAtomSet("p23(a,a), p23(b,c), p23(b,d), p23(c,a), p23(d,a)."));
data.addAll(DlgpParser.parseAtomSet("p24(a,a), p24(b,d), p24(d,a)."));
data.addAll(DlgpParser.parseAtomSet("p15(b,a), p15(b,b)."));
data.addAll(DlgpParser.parseAtomSet("p56(a,a)."));
ConjunctiveQuery query = DlgpParser.parseQuery("?(X1,X2,X3,X4,X5,X6) :- p12(X1,X2), p23(X2,X3), p24(X2,X4), p15(X1,X5), p56(X5,X6).");
BCC bcc = new BCC();
Homomorphism<ConjunctiveQuery, AtomSet> h = new BacktrackHomomorphism(bcc.getBCCScheduler(), AllDomainBootstrapper.instance(), NoForwardChecking.instance(), bcc.getBCCBackJumping());
h.setProfiler(new CPUTimeProfiler());
CloseableIterator<Substitution> results = h.execute(query, data);
int i = 0;
while (results.hasNext()) {
results.next();
++i;
}
Assert.assertEquals(3, i);
Assert.assertEquals(49, h.getProfiler().get("#calls"));
}
use of fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore in project graal by graphik-team.
the class ForwardCheckingTest method NFC2Test.
@Test
public void NFC2Test() throws HomomorphismException, IteratorException, ParseException {
Profiler profiler = new CPUTimeProfiler();
Predicate[] predicates = { new Predicate("p2", 2), new Predicate("p3", 3), new Predicate("p4", 4) };
InMemoryAtomSet data = new DefaultInMemoryGraphStore();
TestUtil.addNAtoms(data, 13, predicates, 5, new Random(0));
ConjunctiveQuery query = DlgpParser.parseQuery("?(X5,X6,X7,X8) :- p4(X5,X6,X7,X8), p4(X8,X7,X6,X5), p3(X7,X8,X9), p2(X7,X11).");
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();
Assert.assertEquals(1, profiler.get("#calls"));
}
use of fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore in project graal by graphik-team.
the class ForwardCheckingTest method FCTest2.
@Test
public void FCTest2() throws HomomorphismException, IteratorException, ParseException, AtomSetException {
Profiler profiler = new CPUTimeProfiler();
InMemoryAtomSet data = new DefaultInMemoryGraphStore();
data.addAll(DlgpParser.parseAtomSet("p(a,b), p(a,c), q(a,a), q(a,b)."));
ConjunctiveQuery query = DlgpParser.parseQuery("?(X,Y,Z) :- p(X,Z), q(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();
Assert.assertEquals(7, profiler.get("#calls"));
}
use of fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore in project graal by graphik-team.
the class ForwardCheckingTest method test1.
@Test
public void test1() throws HomomorphismException, IteratorException, ParseException, AtomSetException {
InMemoryAtomSet data = new DefaultInMemoryGraphStore();
data.addAll(DlgpParser.parseAtomSet("p(a,b)."));
ConjunctiveQuery query = DlgpParser.parseQuery("?(X,Y,Z) :- p(X,Y), p(X,Z).");
Homomorphism<ConjunctiveQuery, AtomSet> h = new BacktrackHomomorphism(new NFC2());
CloseableIterator<Substitution> results = h.execute(query, data);
while (results.hasNext()) {
results.next();
}
results.close();
}
Aggregations