use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class VariableCloneAndSubstitutionUtil method visitAndCloneExprList.
public static List<Expression> visitAndCloneExprList(List<Expression> oldExprList, VariableSubstitutionEnvironment arg, CloneAndSubstituteVariablesVisitor visitor) throws CompilationException {
List<Expression> exprs = new ArrayList<>(oldExprList.size());
for (Expression e : oldExprList) {
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = e.accept(visitor, arg);
exprs.add((Expression) p1.first);
}
return exprs;
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class AbstractInlineUdfsVisitor method visit.
@Override
public Boolean visit(RecordConstructor rc, List<FunctionDecl> arg) throws CompilationException {
boolean changed = false;
for (FieldBinding b : rc.getFbList()) {
Pair<Boolean, Expression> leftExprInlined = inlineUdfsInExpr(b.getLeftExpr(), arg);
b.setLeftExpr(leftExprInlined.second);
changed = changed || leftExprInlined.first;
Pair<Boolean, Expression> rightExprInlined = inlineUdfsInExpr(b.getRightExpr(), arg);
b.setRightExpr(rightExprInlined.second);
changed = changed || rightExprInlined.first;
}
return changed;
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class AbstractInlineUdfsVisitor method visit.
@Override
public Boolean visit(GroupbyClause gc, List<FunctionDecl> arg) throws CompilationException {
boolean changed = false;
for (GbyVariableExpressionPair p : gc.getGbyPairList()) {
Pair<Boolean, Expression> be = inlineUdfsInExpr(p.getExpr(), arg);
p.setExpr(be.second);
if (be.first) {
changed = true;
}
}
for (GbyVariableExpressionPair p : gc.getDecorPairList()) {
Pair<Boolean, Expression> be = inlineUdfsInExpr(p.getExpr(), arg);
p.setExpr(be.second);
if (be.first) {
changed = true;
}
}
return changed;
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class ClauseComparator method extractLetBindingVariables.
// Extracts the variables to be substituted.
private Map<VariableExpr, Expression> extractLetBindingVariables(List<Clause> clauses, GroupbyClause cuttingGbyClause) throws CompilationException {
Map<VariableExpr, Expression> varExprMap = new HashMap<VariableExpr, Expression>();
int gbyIndex = clauses.indexOf(cuttingGbyClause);
for (int i = gbyIndex + 1; i < clauses.size(); i++) {
Clause cl = clauses.get(i);
if (cl.getClauseType() == ClauseType.LET_CLAUSE) {
LetClause letClause = (LetClause) cl;
// inline let variables one by one iteratively.
letClause.setBindingExpr((Expression) AQLVariableSubstitutionUtil.substituteVariable(letClause.getBindingExpr(), varExprMap));
varExprMap.put(letClause.getVarExpr(), letClause.getBindingExpr());
}
}
return varExprMap;
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class ClauseComparator method visit.
@Override
public Void visit(LetClause lc, Integer step) throws CompilationException {
out.print(skip(step) + "with ");
lc.getVarExpr().accept(this, step + 2);
out.print(" as ");
Expression bindingExpr = lc.getBindingExpr();
bindingExpr.accept(this, step + 2);
out.println();
return null;
}
Aggregations