Search in sources :

Example 31 with Substitution

use of fr.lirmm.graphik.graal.api.core.Substitution in project graal by graphik-team.

the class SubstitutionTest method aggregateTest1.

@Theory
public void aggregateTest1(Substitution s1, Substitution s2) {
    s1.put(Y, A);
    s1.put(Z, A);
    s2.put(X, Y);
    s2.put(Y, Z);
    Substitution aggregation = s1.aggregate(s2);
    Assert.assertNotNull(aggregation);
    Assert.assertEquals(A, aggregation.createImageOf(X));
    Assert.assertEquals(A, aggregation.createImageOf(Y));
    Assert.assertEquals(A, aggregation.createImageOf(Z));
}
Also used : Substitution(fr.lirmm.graphik.graal.api.core.Substitution) Theory(org.junit.experimental.theories.Theory)

Example 32 with Substitution

use of fr.lirmm.graphik.graal.api.core.Substitution in project graal by graphik-team.

the class SubstitutionTest method aggregateImpossibleTest1.

@Theory
public void aggregateImpossibleTest1(Substitution s1, Substitution s2) {
    s1.put(X, A);
    s2.put(X, B);
    Substitution aggregation = s1.aggregate(s2);
    Assert.assertNull(aggregation);
}
Also used : Substitution(fr.lirmm.graphik.graal.api.core.Substitution) Theory(org.junit.experimental.theories.Theory)

Example 33 with Substitution

use of fr.lirmm.graphik.graal.api.core.Substitution in project graal by graphik-team.

the class SubstitutionTest method aggregateImpossibleTest2.

@Theory
public void aggregateImpossibleTest2(Substitution s1, Substitution s2) {
    s1.put(X, Z);
    s1.put(Y, Z);
    s2.put(X, A);
    s2.put(Y, B);
    Substitution aggregation = s1.aggregate(s2);
    Assert.assertNull(aggregation);
}
Also used : Substitution(fr.lirmm.graphik.graal.api.core.Substitution) Theory(org.junit.experimental.theories.Theory)

Example 34 with Substitution

use of fr.lirmm.graphik.graal.api.core.Substitution in project graal by graphik-team.

the class SubstitutionTest method compositionTest1.

@Theory
public void compositionTest1(Substitution s1, Substitution s2) {
    s1.put(X, Y);
    s1.put(S, T);
    s2.put(Y, Z);
    s2.put(U, V);
    Substitution comp = s2.compose(s1);
    System.out.println(comp);
    Assert.assertEquals(Z, comp.createImageOf(X));
    Assert.assertEquals(Z, comp.createImageOf(Y));
    Assert.assertEquals(Z, comp.createImageOf(Z));
    Assert.assertEquals(T, comp.createImageOf(S));
    Assert.assertEquals(V, comp.createImageOf(U));
}
Also used : Substitution(fr.lirmm.graphik.graal.api.core.Substitution) Theory(org.junit.experimental.theories.Theory)

Example 35 with Substitution

use of fr.lirmm.graphik.graal.api.core.Substitution in project graal by graphik-team.

the class AbstractHomomorphism method exist.

// /////////////////////////////////////////////////////////////////////////
// PUBLIC METHODS
// /////////////////////////////////////////////////////////////////////////
@Override
public boolean exist(T1 q, T2 a) throws HomomorphismException {
    CloseableIterator<Substitution> results = this.execute(q, a);
    boolean val;
    try {
        val = results.hasNext();
    } catch (IteratorException e) {
        throw new HomomorphismException(e);
    }
    results.close();
    return val;
}
Also used : IteratorException(fr.lirmm.graphik.util.stream.IteratorException) HomomorphismException(fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException) Substitution(fr.lirmm.graphik.graal.api.core.Substitution)

Aggregations

Substitution (fr.lirmm.graphik.graal.api.core.Substitution)158 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)58 Test (org.junit.Test)55 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)46 Theory (org.junit.experimental.theories.Theory)44 Atom (fr.lirmm.graphik.graal.api.core.Atom)41 Term (fr.lirmm.graphik.graal.api.core.Term)36 LinkedList (java.util.LinkedList)27 Variable (fr.lirmm.graphik.graal.api.core.Variable)25 LinkedListAtomSet (fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet)24 Rule (fr.lirmm.graphik.graal.api.core.Rule)23 HomomorphismException (fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException)19 DefaultInMemoryGraphStore (fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore)18 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)16 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)15 RuleSet (fr.lirmm.graphik.graal.api.core.RuleSet)14 LinkedListRuleSet (fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet)14 AtomSet (fr.lirmm.graphik.graal.api.core.AtomSet)13 AtomSetException (fr.lirmm.graphik.graal.api.core.AtomSetException)13 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)13