Search in sources :

Example 1 with Concludable

use of com.vaticle.typedb.core.logic.resolvable.Concludable in project grakn by graknlabs.

the class PlannerTest method test_planner_two_circular_relates_dependencies.

@Test
public void test_planner_two_circular_relates_dependencies() {
    Concludable concludable = Concludable.create(resolvedConjunction("{ $a($b); }", logicMgr)).iterator().next();
    Concludable concludable2 = Concludable.create(resolvedConjunction("{ $b($a); }", logicMgr)).iterator().next();
    Set<Resolvable<?>> resolvables = set(concludable, concludable2);
    List<Resolvable<?>> plan = Planner.plan(resolvables, new HashMap<>(), set());
    assertEquals(2, plan.size());
    assertEquals(set(concludable, concludable2), set(plan));
}
Also used : Concludable(com.vaticle.typedb.core.logic.resolvable.Concludable) Resolvable(com.vaticle.typedb.core.logic.resolvable.Resolvable) Test(org.junit.Test)

Example 2 with Concludable

use of com.vaticle.typedb.core.logic.resolvable.Concludable in project grakn by graknlabs.

the class PlannerTest method test_planner_multiple_dependencies.

@Test
public void test_planner_multiple_dependencies() {
    transaction.query().define(TypeQL.parseQuery("define employment sub relation, relates employee, relates employer;" + "person plays employment:employee;" + "company sub entity, plays employment:employer, owns name;"));
    transaction.commit();
    session.close();
    initialise(Arguments.Session.Type.DATA, Arguments.Transaction.Type.READ);
    EntityType person = conceptMgr.putEntityType("person");
    AttributeType name = conceptMgr.putAttributeType("name", AttributeType.ValueType.STRING);
    person.setOwns(name);
    EntityType company = conceptMgr.putEntityType("company");
    company.setOwns(name);
    conceptMgr.putRelationType("employment");
    Retrievable retrievable = new Retrievable(resolvedConjunction("{ $p isa person; }", logicMgr));
    Concludable concludable = Concludable.create(resolvedConjunction("{ $p has name $n; }", logicMgr)).iterator().next();
    Retrievable retrievable2 = new Retrievable(resolvedConjunction("{ $c isa company, has name $n; }", logicMgr));
    Concludable concludable2 = Concludable.create(resolvedConjunction("{ $e($c, $p2) isa employment; }", logicMgr)).iterator().next();
    Set<Resolvable<?>> resolvables = set(retrievable, retrievable2, concludable, concludable2);
    List<Resolvable<?>> plan = Planner.plan(resolvables, new HashMap<>(), set());
    assertEquals(list(retrievable, concludable, retrievable2, concludable2), plan);
}
Also used : EntityType(com.vaticle.typedb.core.concept.type.EntityType) Concludable(com.vaticle.typedb.core.logic.resolvable.Concludable) Retrievable(com.vaticle.typedb.core.logic.resolvable.Retrievable) AttributeType(com.vaticle.typedb.core.concept.type.AttributeType) Resolvable(com.vaticle.typedb.core.logic.resolvable.Resolvable) Test(org.junit.Test)

Example 3 with Concludable

use of com.vaticle.typedb.core.logic.resolvable.Concludable in project grakn by graknlabs.

the class PlannerTest method test_planner_prioritises_retrievable_without_dependencies.

@Test
public void test_planner_prioritises_retrievable_without_dependencies() {
    Concludable concludable = Concludable.create(resolvedConjunction("{ $p has name $n; }", logicMgr)).iterator().next();
    Retrievable retrievable = new Retrievable(resolvedConjunction("{ $p isa person; }", logicMgr));
    Set<Resolvable<?>> resolvables = set(concludable, retrievable);
    List<Resolvable<?>> plan = Planner.plan(resolvables, new HashMap<>(), set());
    assertEquals(list(retrievable, concludable), plan);
}
Also used : Concludable(com.vaticle.typedb.core.logic.resolvable.Concludable) Retrievable(com.vaticle.typedb.core.logic.resolvable.Retrievable) Resolvable(com.vaticle.typedb.core.logic.resolvable.Resolvable) Test(org.junit.Test)

Example 4 with Concludable

use of com.vaticle.typedb.core.logic.resolvable.Concludable in project grakn by graknlabs.

the class PlannerTest method test_planner_starts_at_independent_concludable.

@Test
public void test_planner_starts_at_independent_concludable() {
    Concludable concludable = Concludable.create(resolvedConjunction("{ $r($a, $b); }", logicMgr)).iterator().next();
    Concludable concludable2 = Concludable.create(resolvedConjunction("{ $r has $c; }", logicMgr)).iterator().next();
    Set<Resolvable<?>> resolvables = set(concludable, concludable2);
    List<Resolvable<?>> plan = Planner.plan(resolvables, new HashMap<>(), set());
    assertEquals(list(concludable, concludable2), plan);
}
Also used : Concludable(com.vaticle.typedb.core.logic.resolvable.Concludable) Resolvable(com.vaticle.typedb.core.logic.resolvable.Resolvable) Test(org.junit.Test)

Example 5 with Concludable

use of com.vaticle.typedb.core.logic.resolvable.Concludable in project grakn by graknlabs.

the class PlannerTest method test_planner_retrievable_dependent_upon_concludable.

@Test
public void test_planner_retrievable_dependent_upon_concludable() {
    Concludable concludable = Concludable.create(resolvedConjunction("{ $a has $b; }", logicMgr)).iterator().next();
    Retrievable retrievable = new Retrievable(resolvedConjunction("{ $c($b); }", logicMgr));
    Set<Resolvable<?>> resolvables = set(concludable, retrievable);
    List<Resolvable<?>> plan = Planner.plan(resolvables, new HashMap<>(), set());
    assertEquals(list(concludable, retrievable), plan);
}
Also used : Concludable(com.vaticle.typedb.core.logic.resolvable.Concludable) Retrievable(com.vaticle.typedb.core.logic.resolvable.Retrievable) Resolvable(com.vaticle.typedb.core.logic.resolvable.Resolvable) Test(org.junit.Test)

Aggregations

Concludable (com.vaticle.typedb.core.logic.resolvable.Concludable)9 Resolvable (com.vaticle.typedb.core.logic.resolvable.Resolvable)7 Test (org.junit.Test)7 Retrievable (com.vaticle.typedb.core.logic.resolvable.Retrievable)4 TypeDBException (com.vaticle.typedb.core.common.exception.TypeDBException)1 AttributeType (com.vaticle.typedb.core.concept.type.AttributeType)1 EntityType (com.vaticle.typedb.core.concept.type.EntityType)1 Actor (com.vaticle.typedb.core.concurrent.actor.Actor)1 Negated (com.vaticle.typedb.core.logic.resolvable.Negated)1 Negation (com.vaticle.typedb.core.pattern.Negation)1 AlphaEquivalence (com.vaticle.typedb.core.pattern.equivalence.AlphaEquivalence)1 ConcludableResolver (com.vaticle.typedb.core.reasoner.resolution.resolver.ConcludableResolver)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 Collectors.toMap (java.util.stream.Collectors.toMap)1