use of org.apache.atlas.groovy.AbstractFunctionExpression in project incubator-atlas by apache.
the class ExpandOrsOptimization method addCallToUpdateResultVariable.
/**
* This method adds steps to the end of the initial traversal to add the vertices
* that were found into an intermediate variable (defined as a Set). If there is one alias,
* this set will contain the vertices associated with that Alias. If there are multiple
* aliases, the values in the set will be alias->vertex maps that have the vertex
* associated with the alias for each result.
* @param expr
* @param aliasNames
* @param context
* @return
*/
private GroovyExpression addCallToUpdateResultVariable(GroovyExpression expr, List<LiteralExpression> aliasNames, OptimizationContext context) {
GroovyExpression result = expr;
// If there is one range expression in the unoptimized gremlin,
// add a range expression here so that the intermediate variable will only contain
// the specified range of vertices.
AbstractFunctionExpression rangeExpression = context.getRangeExpression();
if (rangeExpression != null) {
int[] rangeParameters = factory.getRangeParameters(rangeExpression);
result = factory.generateRangeExpression(result, rangeParameters[0], rangeParameters[1]);
}
if (!aliasNames.isEmpty()) {
result = factory.generateSelectExpression(result, aliasNames, Collections.<GroovyExpression>emptyList());
}
return factory.generateFillExpression(result, context.getResultVariable());
}
use of org.apache.atlas.groovy.AbstractFunctionExpression in project incubator-atlas by apache.
the class FunctionGenerator method updateCurrentFunction.
/**
* Adds the caller of parentExpr to the current body of the last
* function that was created.
*
* @param parentExpr
*/
private void updateCurrentFunction(AbstractFunctionExpression parentExpr) {
GroovyExpression expr = parentExpr.getCaller();
if (expr instanceof AbstractFunctionExpression) {
AbstractFunctionExpression exprAsFunction = (AbstractFunctionExpression) expr;
GroovyExpression exprCaller = exprAsFunction.getCaller();
parentExpr.setCaller(exprCaller);
updateCurrentFunctionDefintion(exprAsFunction);
}
}
Aggregations