use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testFinalAliasNeeded.
@Test
public void testFinalAliasNeeded() throws AtlasException {
GroovyExpression toOptimize = getVerticesExpression();
toOptimize = makeHasExpression(toOptimize, "name", "Fred");
toOptimize = getFactory().generateAliasExpression(toOptimize, "person");
toOptimize = makeOutExpression(toOptimize, "livesIn");
GroovyExpression isChicago = makeHasExpression(null, "name", "Chicago");
GroovyExpression isBoston = makeHasExpression(null, "name", "Boston");
toOptimize = getFactory().generateLogicalExpression(toOptimize, "or", Arrays.asList(isChicago, isBoston));
toOptimize = getFactory().generateAliasExpression(toOptimize, "city");
toOptimize = makeOutExpression(toOptimize, "state");
toOptimize = makeHasExpression(toOptimize, "name", "Massachusetts");
toOptimize = getFactory().generatePathExpression(toOptimize);
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
assertEquals(optimized.toString(), getExpectedGremlinForTestFinalAliasNeeded());
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testOrFollowedByAnd.
@Test
public void testOrFollowedByAnd() throws AtlasException {
GroovyExpression expr1 = makeHasExpression("name", "Fred");
GroovyExpression expr2 = makeHasExpression("name", "George");
GroovyExpression expr3 = makeHasExpression("age", "13");
GroovyExpression expr4 = makeHasExpression("age", "14");
GroovyExpression toOptimize = getFactory().generateLogicalExpression(getVerticesExpression(), "or", Arrays.asList(expr1, expr2));
toOptimize = getFactory().generateLogicalExpression(toOptimize, "and", Arrays.asList(expr3, expr4));
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
assertEquals(optimized.toString(), getExpectedGremlinForTestOrFollowedByAnd());
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testLongStringEndingWithOr.
@Test
public void testLongStringEndingWithOr() throws AtlasException {
GroovyExpression toOptimize = getVerticesExpression();
toOptimize = makeHasExpression(toOptimize, "name", "Fred");
toOptimize = makeHasExpression(toOptimize, "age", "13");
toOptimize = makeOutExpression(toOptimize, "livesIn");
toOptimize = makeHasExpression(toOptimize, "state", "Massachusetts");
GroovyExpression or1cond1 = makeHasExpression("p1", "e1");
GroovyExpression or1cond2 = makeHasExpression("p2", "e2");
toOptimize = getFactory().generateLogicalExpression(toOptimize, "or", Arrays.asList(or1cond1, or1cond2));
GroovyExpression or2cond1 = makeHasExpression("p3", "e3");
GroovyExpression or2cond2 = makeHasExpression("p4", "e4");
toOptimize = getFactory().generateLogicalExpression(toOptimize, "or", Arrays.asList(or2cond1, or2cond2));
toOptimize = makeHasExpression(toOptimize, "p5", "e5");
toOptimize = makeHasExpression(toOptimize, "p6", "e6");
GroovyExpression or3cond1 = makeHasExpression("p7", "e7");
GroovyExpression or3cond2 = makeHasExpression("p8", "e8");
toOptimize = getFactory().generateLogicalExpression(toOptimize, "or", Arrays.asList(or3cond1, or3cond2));
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
assertEquals(optimized.toString(), getExpectedGremlinForTestLongStringEndingWithOr());
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testOrFollowedByOr.
@Test
public void testOrFollowedByOr() throws AtlasException {
GroovyExpression expr1 = makeHasExpression("name", "Fred");
GroovyExpression expr2 = makeHasExpression("name", "George");
GroovyExpression expr3 = makeHasExpression("age", "13");
GroovyExpression expr4 = makeHasExpression("age", "14");
GroovyExpression toOptimize = getFactory().generateLogicalExpression(getVerticesExpression(), "or", Arrays.asList(expr1, expr2));
toOptimize = getFactory().generateLogicalExpression(toOptimize, "or", Arrays.asList(expr3, expr4));
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
assertEquals(optimized.toString(), getExpectedGremlinForTestOrFollowedByOr());
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testAndFollowedByAnd.
@Test
public void testAndFollowedByAnd() throws AtlasException {
GroovyExpression expr1 = makeHasExpression("name", "Fred");
GroovyExpression expr2 = makeHasExpression("name", "George");
GroovyExpression expr3 = makeHasExpression("age", "13");
GroovyExpression expr4 = makeHasExpression("age", "14");
GroovyExpression toOptimize = getFactory().generateLogicalExpression(getVerticesExpression(), "and", Arrays.asList(expr1, expr2));
toOptimize = getFactory().generateLogicalExpression(toOptimize, "and", Arrays.asList(expr3, expr4));
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
assertEquals(optimized.toString(), getExpectedGremlinForTestAndFollowedByAnd());
}
Aggregations