use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testOrWithNoChildren.
@Test
public void testOrWithNoChildren() throws AtlasException {
GroovyExpression toOptimize = getVerticesExpression();
GroovyExpression expr1 = makeHasExpression(toOptimize, "name", "Fred");
toOptimize = getFactory().generateLogicalExpression(expr1, "or", Collections.<GroovyExpression>emptyList());
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
//or with no children matches no vertices
assertEquals(optimized.toString(), getExpectedGremlinFortestOrWithNoChildren());
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testPullHasExpressionsOutOfAnd.
@Test
public void testPullHasExpressionsOutOfAnd() throws AtlasException {
GroovyExpression expr1 = makeOutExpression(null, "out1");
GroovyExpression expr2 = makeOutExpression(null, "out2");
GroovyExpression expr3 = makeHasExpression("prop1", "Fred");
GroovyExpression expr4 = makeHasExpression("prop2", "George");
GroovyExpression toOptimize = getFactory().generateLogicalExpression(getVerticesExpression(), "and", Arrays.asList(expr1, expr2, expr3, expr4));
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
assertEquals(optimized.toString(), getExpectedGremlinForTestPullHasExpressionsOutOfHas());
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testToListWithExtraStuff.
@Test
public void testToListWithExtraStuff() throws AtlasException {
GroovyExpression expr1 = makeHasExpression("prop1", "Fred");
GroovyExpression expr2 = makeHasExpression("prop2", "George");
GroovyExpression toOptimize = getFactory().generateLogicalExpression(getVerticesExpression(), "or", Arrays.asList(expr1, expr2));
toOptimize = new FunctionCallExpression(TraversalStepType.END, toOptimize, "toList");
toOptimize = new FunctionCallExpression(toOptimize, "size");
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
assertEquals(optimized.toString(), getExpectedGremlinForTestToListWithExtraStuff());
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testAliasInOrExpr.
@Test
public void testAliasInOrExpr() throws AtlasException {
GroovyExpression expr1 = makeHasExpression("name", "Fred");
GroovyExpression expr2 = getFactory().generateAliasExpression(makeHasExpression("name", "George"), "george");
GroovyExpression toOptimize = getVerticesExpression();
toOptimize = getFactory().generateLogicalExpression(toOptimize, "or", Arrays.asList(expr1, expr2));
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
assertEquals(optimized.toString(), getExpectedGremlinForTestAliasInOrExpr());
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testInitialAlias.
@Test
public void testInitialAlias() throws AtlasException {
GroovyExpression expr1 = makeHasExpression("name", "Fred");
GroovyExpression expr2 = makeHasExpression("name", "George");
GroovyExpression toOptimize = getVerticesExpression();
toOptimize = getFactory().generateAliasExpression(toOptimize, "x");
toOptimize = getFactory().generateLogicalExpression(toOptimize, "or", Arrays.asList(expr1, expr2));
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
assertEquals(optimized.toString(), getExpectedGremlinForTestInitialAlias());
}
Aggregations