Search in sources :

Example 6 with EquivalentFragmentSet

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);
}
Also used : EquivalentFragmentSet(ai.grakn.graql.internal.gremlin.EquivalentFragmentSet) Test(org.junit.Test)

Example 7 with EquivalentFragmentSet

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);
}
Also used : Label(ai.grakn.concept.Label) EquivalentFragmentSet(ai.grakn.graql.internal.gremlin.EquivalentFragmentSet) Test(org.junit.Test)

Example 8 with EquivalentFragmentSet

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);
}
Also used : Label(ai.grakn.concept.Label) EquivalentFragmentSet(ai.grakn.graql.internal.gremlin.EquivalentFragmentSet) Test(org.junit.Test)

Aggregations

EquivalentFragmentSet (ai.grakn.graql.internal.gremlin.EquivalentFragmentSet)8 Test (org.junit.Test)7 Label (ai.grakn.concept.Label)6 VarPatternAdmin (ai.grakn.graql.admin.VarPatternAdmin)1