use of org.apache.asterix.lang.common.struct.QuantifiedPair in project asterixdb by apache.
the class AbstractSqlppExpressionScopingVisitor method visit.
@Override
public Expression visit(QuantifiedExpression qe, ILangExpression arg) throws CompilationException {
scopeChecker.createNewScope();
for (QuantifiedPair pair : qe.getQuantifiedList()) {
pair.setExpr(visit(pair.getExpr(), qe));
addNewVarSymbolToScope(scopeChecker.getCurrentScope(), pair.getVarExpr().getVar());
}
qe.setSatisfiesExpr(visit(qe.getSatisfiesExpr(), qe));
scopeChecker.removeCurrentScope();
return qe;
}
use of org.apache.asterix.lang.common.struct.QuantifiedPair 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.struct.QuantifiedPair 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);
}
Aggregations