Search in sources :

Example 6 with TripleStore

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

the class ConjunctiveQuery2Test method wrongArityQuery2.

@Theory
public void wrongArityQuery2(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,Y,Z).");
        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)

Example 7 with TripleStore

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

the class StoreTest method match3.

@Theory
public void match3(AtomSet store) throws AtomSetException, IteratorException, ParseException, HomomorphismException {
    Assume.assumeFalse(store instanceof TripleStore);
    Atom a1 = DlgpParser.parseAtom("<P>(a,a,a).");
    Atom a2 = DlgpParser.parseAtom("<P>(a,c,c).");
    store.add(DlgpParser.parseAtom("<P>(b,a,a)."));
    store.add(DlgpParser.parseAtom("<P>(a,a,a)."));
    store.add(DlgpParser.parseAtom("<P>(a,c,b)."));
    store.add(DlgpParser.parseAtom("<P>(a,c,c)."));
    store.add(DlgpParser.parseAtom("<Q>(b,a,c)."));
    store.add(DlgpParser.parseAtom("<Q>(a,b,b)."));
    Atom q = DlgpParser.parseAtom("<P>(a,X,X).");
    CloseableIterator<Atom> it = store.match(q);
    int cpt = 0;
    while (it.hasNext()) {
        ++cpt;
        Atom a = it.next();
        Assert.assertTrue(a.equals(a1) || a.equals(a2));
    }
    Assert.assertEquals(2, cpt);
}
Also used : TripleStore(fr.lirmm.graphik.graal.api.store.TripleStore) Atom(fr.lirmm.graphik.graal.api.core.Atom) Theory(org.junit.experimental.theories.Theory)

Example 8 with TripleStore

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

the class NoTripleStoreTest method termsOrder.

@Theory
public void termsOrder(AtomSet store) throws AtomSetException, IteratorException, ParseException {
    Assume.assumeFalse(store instanceof TripleStore);
    Atom a1 = DlgpParser.parseAtom("<P>(a,b,c,d,e,f).");
    Atom a2 = DlgpParser.parseAtom("<P>(f,e,d,c,b,a).");
    store.add(a1);
    store.add(a1);
    store.add(a2);
    CloseableIterator<Atom> it = store.iterator();
    while (it.hasNext()) {
        Atom a = it.next();
        Assert.assertTrue(a.equals(a1) || a.equals(a2));
    }
}
Also used : TripleStore(fr.lirmm.graphik.graal.api.store.TripleStore) Atom(fr.lirmm.graphik.graal.api.core.Atom) Theory(org.junit.experimental.theories.Theory)

Example 9 with TripleStore

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

the class NoTripleStoreTest method arityTest.

@Theory
public void arityTest(AtomSet store) throws AtomSetException, IteratorException, ParseException {
    Assume.assumeFalse(store instanceof TripleStore);
    Atom toAdd = DlgpParser.parseAtom("<P>(a).");
    Predicate toCheck = new Predicate("P", 2);
    store.add(toAdd);
    CloseableIterator<?> it = store.termsByPredicatePosition(toCheck, 1);
    Assert.assertFalse(it.hasNext());
    it = store.atomsByPredicate(toCheck);
    Assert.assertFalse(it.hasNext());
    it = store.match(DlgpParser.parseAtom("<p>(X,Y)."));
    Assert.assertFalse(it.hasNext());
}
Also used : TripleStore(fr.lirmm.graphik.graal.api.store.TripleStore) Atom(fr.lirmm.graphik.graal.api.core.Atom) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) Theory(org.junit.experimental.theories.Theory)

Example 10 with TripleStore

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

the class ConjunctiveQueryFixedBugTest method issue52Bis.

@Theory
public void issue52Bis(Homomorphism<ConjunctiveQuery, AtomSet> h, AtomSet store) {
    Assume.assumeFalse(store instanceof TripleStore);
    try {
        store.addAll(DlgpParser.parseAtomSet("<P0>(a,b),<P1>(b,a),<P1>(d,b),<R>(b,c,c),<R>(b,d,d)."));
        ConjunctiveQuery query = DlgpParser.parseQuery("?(X0,X1,X2,X3,X4,X5) :- <P0>(X0,X3), <R>(X3,X4,X5), <P1>(X4,X2), <P1>(X5,X1).");
        Assert.assertTrue(h.exist(query, store));
    } catch (Exception e) {
        Assert.assertTrue(e.getMessage(), false);
    }
}
Also used : TripleStore(fr.lirmm.graphik.graal.api.store.TripleStore) ConjunctiveQuery(fr.lirmm.graphik.graal.api.core.ConjunctiveQuery) DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) HomomorphismException(fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) IteratorException(fr.lirmm.graphik.util.stream.IteratorException) 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