use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testAliasInAndExpr.
@Test
public void testAliasInAndExpr() throws AtlasException {
GroovyExpression expr1 = makeHasExpression("name", "Fred");
GroovyExpression expr2 = getFactory().generateAliasExpression(makeHasExpression("name", "George"), "george");
GroovyExpression toOptimize = getVerticesExpression();
toOptimize = getFactory().generateLogicalExpression(toOptimize, "and", Arrays.asList(expr1, expr2));
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
//expression with alias cannot currently be pulled out of the and
assertEquals(optimized.toString(), getExpectedGremlinForTestAliasInAndExpr());
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testAndWithMultiCallArguments.
@Test
public void testAndWithMultiCallArguments() throws AtlasException {
GroovyExpression cond1 = makeHasExpression("p1", "e1");
GroovyExpression cond2 = makeHasExpression(cond1, "p2", "e2");
GroovyExpression cond3 = makeHasExpression("p3", "e3");
GroovyExpression cond4 = makeHasExpression(cond3, "p4", "e4");
GroovyExpression toOptimize = getFactory().generateLogicalExpression(getVerticesExpression(), "and", Arrays.asList(cond2, cond4));
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
assertEquals(optimized.toString(), getExpectedGremlinForTestAndWithMultiCallArguments());
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testAndOfOrs.
@Test
public void testAndOfOrs() throws AtlasException {
GroovyExpression or1Cond1 = makeHasExpression("p1", "e1");
GroovyExpression or1Cond2 = makeHasExpression("p2", "e2");
GroovyExpression or2Cond1 = makeHasExpression("p3", "e3");
GroovyExpression or2Cond2 = makeHasExpression("p4", "e4");
GroovyExpression or1 = getFactory().generateLogicalExpression(null, "or", Arrays.asList(or1Cond1, or1Cond2));
GroovyExpression or2 = getFactory().generateLogicalExpression(null, "or", Arrays.asList(or2Cond1, or2Cond2));
GroovyExpression toOptimize = getFactory().generateLogicalExpression(getVerticesExpression(), "and", Arrays.asList(or1, or2));
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
assertEquals(optimized.toString(), getExpectedGremlinForTestAndOfOrs());
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class AbstractGremlinQueryOptimizerTest method testOrGrouping.
@Test
public void testOrGrouping() 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(), "or", Arrays.asList(expr1, expr2, expr3, expr4));
GroovyExpression optimized = GremlinQueryOptimizer.getInstance().optimize(toOptimize);
assertEquals(optimized.toString(), getExpectedGremlinForTestOrGrouping());
}
use of org.apache.atlas.groovy.GroovyExpression in project incubator-atlas by apache.
the class Gremlin2ExpressionFactory method getOrderFieldParents.
@Override
public List<GroovyExpression> getOrderFieldParents() {
GroovyExpression itExpr = getItVariable();
List<GroovyExpression> result = new ArrayList<>(2);
result.add(new FieldExpression(itExpr, "a"));
result.add(new FieldExpression(itExpr, "b"));
return result;
}
Aggregations