use of org.apache.atlas.groovy.FunctionCallExpression in project incubator-atlas by apache.
the class Gremlin2ExpressionFactory method getAliasesRequiredByExpression.
public List<String> getAliasesRequiredByExpression(GroovyExpression expr) {
if (!(expr instanceof FunctionCallExpression)) {
return Collections.emptyList();
}
FunctionCallExpression fc = (FunctionCallExpression) expr;
if (!fc.getFunctionName().equals(LOOP_METHOD)) {
return Collections.emptyList();
}
LiteralExpression aliasName = (LiteralExpression) fc.getArguments().get(0);
return Collections.singletonList(aliasName.getValue().toString());
}
use of org.apache.atlas.groovy.FunctionCallExpression in project incubator-atlas by apache.
the class Gremlin3ExpressionFactory method getRangeParameters.
@Override
public int[] getRangeParameters(AbstractFunctionExpression expr) {
if (isRangeExpression(expr)) {
FunctionCallExpression rangeExpression = (FunctionCallExpression) expr;
List<GroovyExpression> arguments = rangeExpression.getArguments();
int startIndex = (int) ((LiteralExpression) arguments.get(0)).getValue();
int endIndex = (int) ((LiteralExpression) arguments.get(1)).getValue();
return new int[] { startIndex, endIndex };
} else {
return null;
}
}
use of org.apache.atlas.groovy.FunctionCallExpression in project incubator-atlas by apache.
the class Gremlin3ExpressionFactory method generateSelectExpression.
@Override
public GroovyExpression generateSelectExpression(GroovyExpression parent, List<LiteralExpression> sourceNames, List<GroovyExpression> srcExprs) {
FunctionCallExpression result = new FunctionCallExpression(TraversalStepType.MAP_TO_VALUE, parent, SELECT_METHOD, sourceNames);
for (GroovyExpression expr : srcExprs) {
GroovyExpression closure = new ClosureExpression(expr);
GroovyExpression castClosure = new TypeCoersionExpression(closure, FUNCTION_CLASS);
result = new FunctionCallExpression(TraversalStepType.SIDE_EFFECT, result, BY_METHOD, castClosure);
}
return result;
}
use of org.apache.atlas.groovy.FunctionCallExpression in project incubator-atlas by apache.
the class Gremlin3ExpressionFactory method setRangeParameters.
@Override
public void setRangeParameters(GroovyExpression expr, int startIndex, int endIndex) {
if (isRangeExpression(expr)) {
FunctionCallExpression rangeExpression = (FunctionCallExpression) expr;
rangeExpression.setArgument(0, new LiteralExpression(Integer.valueOf(startIndex)));
rangeExpression.setArgument(1, new LiteralExpression(Integer.valueOf(endIndex)));
} else {
throw new IllegalArgumentException(expr + " is not a valid range expression");
}
}
use of org.apache.atlas.groovy.FunctionCallExpression in project incubator-atlas by apache.
the class Gremlin3ExpressionFactory method generateLoopExpression.
@Override
public GroovyExpression generateLoopExpression(GroovyExpression parent, GraphPersistenceStrategies s, IDataType dataType, GroovyExpression loopExpr, String alias, Integer times) {
GroovyExpression emitExpr = generateLoopEmitExpression(s, dataType);
GroovyExpression result = new FunctionCallExpression(TraversalStepType.BRANCH, parent, REPEAT_METHOD, loopExpr);
if (times != null) {
GroovyExpression timesExpr = new LiteralExpression(times);
result = new FunctionCallExpression(TraversalStepType.SIDE_EFFECT, result, TIMES_METHOD, timesExpr);
}
result = new FunctionCallExpression(TraversalStepType.SIDE_EFFECT, result, EMIT_METHOD, emitExpr);
return result;
}
Aggregations