use of ai.grakn.graql.internal.gremlin.EquivalentFragmentSet in project grakn by graknlabs.
the class LabelFragmentSetTest method whenOptimisingQueryWithGeneratedVarLabel_EliminateLabelFragmentSet.
@Test
public void whenOptimisingQueryWithGeneratedVarLabel_EliminateLabelFragmentSet() {
EquivalentFragmentSet labelFragment = label(null, generatedVar, ImmutableSet.of(EXISTING_LABEL));
Set<EquivalentFragmentSet> originalFragmentSets = ImmutableSet.of(labelFragment, isa(null, Graql.var("abc"), Graql.var("def"), true));
Collection<EquivalentFragmentSet> fragmentSets = Sets.newHashSet(originalFragmentSets);
LabelFragmentSet.REDUNDANT_LABEL_ELIMINATION_OPTIMISATION.apply(fragmentSets, graph);
assertEquals(Sets.difference(originalFragmentSets, ImmutableSet.of(labelFragment)), fragmentSets);
}
use of ai.grakn.graql.internal.gremlin.EquivalentFragmentSet in project grakn by graknlabs.
the class RolePlayerFragmentSetTest method whenLabelDoesNotReferToARelationType_DoNotApplyRelationTypeOptimisation.
@Test
public void whenLabelDoesNotReferToARelationType_DoNotApplyRelationTypeOptimisation() {
Label movie = Label.of("movie");
Collection<EquivalentFragmentSet> fragmentSets = Sets.newHashSet(EquivalentFragmentSets.rolePlayer(null, a, b, c, null), EquivalentFragmentSets.isa(null, a, d, true), EquivalentFragmentSets.label(null, d, ImmutableSet.of(movie)));
Collection<EquivalentFragmentSet> expected = Sets.newHashSet(fragmentSets);
RolePlayerFragmentSet.RELATION_TYPE_OPTIMISATION.apply(fragmentSets, sampleKB.tx());
assertEquals(expected, fragmentSets);
}
use of ai.grakn.graql.internal.gremlin.EquivalentFragmentSet in project grakn by graknlabs.
the class RolePlayerFragmentSetTest method whenRoleIsNotInGraph_DoNotApplyRoleOptimisation.
@Test
public void whenRoleIsNotInGraph_DoNotApplyRoleOptimisation() {
Label magician = Label.of("magician");
Collection<EquivalentFragmentSet> fragmentSets = Sets.newHashSet(EquivalentFragmentSets.rolePlayer(null, a, b, c, d), EquivalentFragmentSets.label(null, d, ImmutableSet.of(magician)));
Collection<EquivalentFragmentSet> expected = Sets.newHashSet(fragmentSets);
RolePlayerFragmentSet.ROLE_OPTIMISATION.apply(fragmentSets, sampleKB.tx());
assertEquals(expected, fragmentSets);
}
Aggregations