use of ai.grakn.graql.internal.gremlin.fragment.OutIsaFragment in project grakn by graknlabs.
the class QueryPlannerTest method sameLabelFragmentShouldNotBeAddedTwice.
@Test
public void sameLabelFragmentShouldNotBeAddedTwice() {
Pattern pattern;
ImmutableList<Fragment> plan;
pattern = and(x.isa(thingy2), y.isa(thingy4), z.isa(thingy2), var().rel(x).rel(y), var().rel(z).rel(y));
plan = getPlan(pattern);
// 2 thingy2 label, 1 thingy4, 1 inferred relationship label
assertEquals(4L, plan.stream().filter(LabelFragment.class::isInstance).count());
// 5 isa fragments: x, y, z, relationship between x and y, relationship between z and y
assertEquals(5L, plan.stream().filter(fragment -> fragment instanceof OutIsaFragment || fragment instanceof InIsaFragment).count());
}
use of ai.grakn.graql.internal.gremlin.fragment.OutIsaFragment 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());
}
Aggregations