use of fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore in project graal by graphik-team.
the class KBBuilderTest method testSetStore.
/**
* Test method for {@link fr.lirmm.graphik.graal.kb.KBBuilder#setStore(fr.lirmm.graphik.graal.api.store.Store)}.
*/
@Test
public void testSetStore() {
// Given
KBBuilder kbb = new KBBuilder();
Store store = new DefaultInMemoryGraphStore();
// When
kbb.setStore(store);
KnowledgeBase kb = kbb.build();
// Then
Assert.assertTrue(kb.getFacts() == store);
}
use of fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore in project graal by graphik-team.
the class ConjunctiveQueryFixedBugTest method GraphAtomSetQuery.
/**
* Query using an DefaultInMemoryGraphAtomSet.
*
* @param h
* @param store
*/
@Theory
public void GraphAtomSetQuery(Homomorphism<ConjunctiveQuery, AtomSet> h, AtomSet store) {
try {
InMemoryAtomSet atomset = new DefaultInMemoryGraphStore();
atomset.add(DlgpParser.parseAtom("<P>(X)."));
ConjunctiveQuery query = new DefaultConjunctiveQuery(atomset);
CloseableIterator<Substitution> subReader;
subReader = h.execute(query, store);
Assert.assertFalse(subReader.hasNext());
subReader.close();
} catch (Exception e) {
Assert.assertTrue(e.getMessage(), false);
}
}
use of fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore in project graal by graphik-team.
the class ForwardCheckingTest method simpleFCTest1.
@Test
public void simpleFCTest1() throws HomomorphismException, IteratorException, ParseException, AtomSetException {
Profiler profiler = new CPUTimeProfiler();
InMemoryAtomSet data = new DefaultInMemoryGraphStore();
data.addAll(DlgpParser.parseAtomSet("p(a,b), q(b,c)."));
ConjunctiveQuery query = DlgpParser.parseQuery("?(X,Y,Z) :- p(X,Y), q(Y,Z).");
Homomorphism<ConjunctiveQuery, AtomSet> h = new BacktrackHomomorphism(new SimpleFC());
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 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.core.atomset.graph.DefaultInMemoryGraphStore 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();
}
Aggregations