use of org.apache.asterix.lang.common.expression.QuantifiedExpression in project asterixdb by apache.
the class AbstractInlineUdfsVisitor method visit.
@Override
public Boolean visit(QuantifiedExpression qe, List<FunctionDecl> arg) throws CompilationException {
boolean changed = false;
for (QuantifiedPair t : qe.getQuantifiedList()) {
Pair<Boolean, Expression> p = inlineUdfsInExpr(t.getExpr(), arg);
t.setExpr(p.second);
if (p.first) {
changed = true;
}
}
Pair<Boolean, Expression> p2 = inlineUdfsInExpr(qe.getSatisfiesExpr(), arg);
qe.setSatisfiesExpr(p2.second);
return changed || p2.first;
}
use of org.apache.asterix.lang.common.expression.QuantifiedExpression in project asterixdb by apache.
the class OperatorExpressionVisitor method processInOperator.
private Expression processInOperator(OperatorExpr operatorExpr, OperatorType opType) throws CompilationException {
VariableExpr bindingVar = new VariableExpr(context.newVariable());
Expression itemExpr = operatorExpr.getExprList().get(0);
Expression collectionExpr = operatorExpr.getExprList().get(1);
OperatorExpr comparison = new OperatorExpr();
comparison.addOperand(itemExpr);
comparison.addOperand(bindingVar);
comparison.setCurrentop(true);
if (opType == OperatorType.IN) {
comparison.addOperator("=");
return new QuantifiedExpression(Quantifier.SOME, new ArrayList<>(Collections.singletonList(new QuantifiedPair(bindingVar, collectionExpr))), comparison);
} else {
comparison.addOperator("!=");
return new QuantifiedExpression(Quantifier.EVERY, new ArrayList<>(Collections.singletonList(new QuantifiedPair(bindingVar, collectionExpr))), comparison);
}
}
use of org.apache.asterix.lang.common.expression.QuantifiedExpression in project asterixdb by apache.
the class DeepCopyVisitor method visit.
@Override
public QuantifiedExpression visit(QuantifiedExpression qe, Void arg) throws CompilationException {
List<QuantifiedPair> quantifiedPairs = new ArrayList<>();
for (QuantifiedPair pair : qe.getQuantifiedList()) {
Expression expr = (Expression) pair.getExpr().accept(this, arg);
VariableExpr var = (VariableExpr) pair.getVarExpr().accept(this, arg);
quantifiedPairs.add(new QuantifiedPair(var, expr));
}
Expression condition = (Expression) qe.getSatisfiesExpr().accept(this, arg);
return new QuantifiedExpression(qe.getQuantifier(), quantifiedPairs, condition);
}
use of org.apache.asterix.lang.common.expression.QuantifiedExpression in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(QuantifiedExpression qe, VariableSubstitutionEnvironment env) throws CompilationException {
List<QuantifiedPair> oldPairs = qe.getQuantifiedList();
List<QuantifiedPair> newPairs = new ArrayList<>(oldPairs.size());
VariableSubstitutionEnvironment newSubs = env;
for (QuantifiedPair t : oldPairs) {
VariableExpr newVar = generateNewVariable(context, t.getVarExpr());
newSubs = VariableCloneAndSubstitutionUtil.eliminateSubstFromList(newVar, newSubs);
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = visitUnnesBindingExpression(t.getExpr(), newSubs);
QuantifiedPair t2 = new QuantifiedPair(newVar, (Expression) p1.first);
newPairs.add(t2);
}
Pair<ILangExpression, VariableSubstitutionEnvironment> p2 = qe.getSatisfiesExpr().accept(this, newSubs);
QuantifiedExpression qe2 = new QuantifiedExpression(qe.getQuantifier(), newPairs, (Expression) p2.first);
return new Pair<>(qe2, newSubs);
}
Aggregations