Search in sources :

Example 11 with TripleStore

use of fr.lirmm.graphik.graal.api.store.TripleStore 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();
}
Also used : RuleSet(fr.lirmm.graphik.graal.api.core.RuleSet) LinkedListRuleSet(fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet) DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) Substitution(fr.lirmm.graphik.graal.api.core.Substitution) TripleStore(fr.lirmm.graphik.graal.api.store.TripleStore) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) AtomSet(fr.lirmm.graphik.graal.api.core.AtomSet) LinkedListRuleSet(fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet) RulesCompilation(fr.lirmm.graphik.graal.api.core.RulesCompilation) ConjunctiveQuery(fr.lirmm.graphik.graal.api.core.ConjunctiveQuery) DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) HomomorphismWithCompilation(fr.lirmm.graphik.graal.api.homomorphism.HomomorphismWithCompilation) Theory(org.junit.experimental.theories.Theory)

Example 12 with TripleStore

use of fr.lirmm.graphik.graal.api.store.TripleStore in project graal by graphik-team.

the class ConjunctiveQuery2Test method NFC2Test.

@Theory
public void NFC2Test(Homomorphism<ConjunctiveQuery, AtomSet> h, AtomSet store) {
    Assume.assumeFalse(store instanceof TripleStore);
    try {
        store.addAll(DlgpParser.parseAtomSet("<P>(a,b,c)."));
        ConjunctiveQuery query = DlgpParser.parseQuery("?(X,Y) :- <P>(X,Y,Y).");
        CloseableIterator<Substitution> subReader = h.execute(query, store);
        Assert.assertFalse(subReader.hasNext());
        subReader.close();
    } catch (Exception e) {
        Assert.assertTrue(e.getMessage(), false);
    }
}
Also used : Substitution(fr.lirmm.graphik.graal.api.core.Substitution) TripleStore(fr.lirmm.graphik.graal.api.store.TripleStore) ConjunctiveQuery(fr.lirmm.graphik.graal.api.core.ConjunctiveQuery) Theory(org.junit.experimental.theories.Theory)

Example 13 with TripleStore

use of fr.lirmm.graphik.graal.api.store.TripleStore in project graal by graphik-team.

the class ConjunctiveQuery2Test method wrongArityQuery.

@Theory
public void wrongArityQuery(Homomorphism<ConjunctiveQuery, AtomSet> h, AtomSet store) {
    Assume.assumeFalse(store instanceof TripleStore);
    try {
        store.add(DlgpParser.parseAtom("<P>(a,b)."));
        ConjunctiveQuery query = DlgpParser.parseQuery("? :- <P>(X).");
        CloseableIterator<Substitution> subReader;
        subReader = h.execute(query, store);
        Assert.assertFalse(subReader.hasNext());
        subReader.close();
    } catch (Exception e) {
        Assert.assertTrue(e.getMessage(), false);
    }
}
Also used : Substitution(fr.lirmm.graphik.graal.api.core.Substitution) TripleStore(fr.lirmm.graphik.graal.api.store.TripleStore) ConjunctiveQuery(fr.lirmm.graphik.graal.api.core.ConjunctiveQuery) Theory(org.junit.experimental.theories.Theory)

Aggregations

TripleStore (fr.lirmm.graphik.graal.api.store.TripleStore)13 Theory (org.junit.experimental.theories.Theory)13 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)9 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)8 DefaultConjunctiveQuery (fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery)6 AtomSet (fr.lirmm.graphik.graal.api.core.AtomSet)5 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)5 RuleSet (fr.lirmm.graphik.graal.api.core.RuleSet)5 RulesCompilation (fr.lirmm.graphik.graal.api.core.RulesCompilation)5 LinkedListAtomSet (fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet)5 LinkedListRuleSet (fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet)5 Atom (fr.lirmm.graphik.graal.api.core.Atom)4 HomomorphismWithCompilation (fr.lirmm.graphik.graal.api.homomorphism.HomomorphismWithCompilation)4 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)2 AtomSetException (fr.lirmm.graphik.graal.api.core.AtomSetException)1 Term (fr.lirmm.graphik.graal.api.core.Term)1 HomomorphismException (fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException)1 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)1 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)1