Search in sources :

Example 6 with InIsaFragment

use of ai.grakn.graql.internal.gremlin.fragment.InIsaFragment in project grakn by graknlabs.

the class QueryPlannerTest method inferRelationshipTypeWithMoreThan2Roles.

@Test
public void inferRelationshipTypeWithMoreThan2Roles() {
    Pattern pattern;
    ImmutableList<Fragment> plan;
    pattern = and(x.isa(thingy1), y.isa(thingy2), z.isa(thingy3), var().rel(x).rel(y).rel(z));
    plan = getPlan(pattern);
    assertEquals(3L, plan.stream().filter(LabelFragment.class::isInstance).count());
    pattern = and(x.isa(thingy1), y.isa(thingy2), z.isa(thingy4), var().rel(x).rel(y).rel(z));
    plan = getPlan(pattern);
    // Relationship type can now be inferred, so one more relationship type label
    assertEquals(4L, plan.stream().filter(LabelFragment.class::isInstance).count());
    assertEquals(4L, plan.stream().filter(fragment -> fragment instanceof OutIsaFragment || fragment instanceof InIsaFragment).count());
}
Also used : InIsaFragment(ai.grakn.graql.internal.gremlin.fragment.InIsaFragment) Pattern(ai.grakn.graql.Pattern) LabelFragment(ai.grakn.graql.internal.gremlin.fragment.LabelFragment) OutIsaFragment(ai.grakn.graql.internal.gremlin.fragment.OutIsaFragment) OutIsaFragment(ai.grakn.graql.internal.gremlin.fragment.OutIsaFragment) NeqFragment(ai.grakn.graql.internal.gremlin.fragment.NeqFragment) LabelFragment(ai.grakn.graql.internal.gremlin.fragment.LabelFragment) InIsaFragment(ai.grakn.graql.internal.gremlin.fragment.InIsaFragment) Fragment(ai.grakn.graql.internal.gremlin.fragment.Fragment) Test(org.junit.Test)

Aggregations

Pattern (ai.grakn.graql.Pattern)6 Fragment (ai.grakn.graql.internal.gremlin.fragment.Fragment)6 InIsaFragment (ai.grakn.graql.internal.gremlin.fragment.InIsaFragment)6 LabelFragment (ai.grakn.graql.internal.gremlin.fragment.LabelFragment)6 NeqFragment (ai.grakn.graql.internal.gremlin.fragment.NeqFragment)6 OutIsaFragment (ai.grakn.graql.internal.gremlin.fragment.OutIsaFragment)6 Test (org.junit.Test)6