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));
}
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);
}
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);
}
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);
}
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);
}
Aggregations