Search in sources :

Example 6 with QuantifiedPair

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;
}
Also used : QuantifiedPair(org.apache.asterix.lang.common.struct.QuantifiedPair)

Example 7 with QuantifiedPair

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);
    }
}
Also used : OperatorExpr(org.apache.asterix.lang.common.expression.OperatorExpr) QuantifiedPair(org.apache.asterix.lang.common.struct.QuantifiedPair) QuantifiedExpression(org.apache.asterix.lang.common.expression.QuantifiedExpression) Expression(org.apache.asterix.lang.common.base.Expression) ILangExpression(org.apache.asterix.lang.common.base.ILangExpression) QuantifiedExpression(org.apache.asterix.lang.common.expression.QuantifiedExpression) VariableExpr(org.apache.asterix.lang.common.expression.VariableExpr)

Example 8 with QuantifiedPair

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);
}
Also used : QuantifiedPair(org.apache.asterix.lang.common.struct.QuantifiedPair) QuantifiedExpression(org.apache.asterix.lang.common.expression.QuantifiedExpression) ILangExpression(org.apache.asterix.lang.common.base.ILangExpression) Expression(org.apache.asterix.lang.common.base.Expression) SelectExpression(org.apache.asterix.lang.sqlpp.expression.SelectExpression) CaseExpression(org.apache.asterix.lang.sqlpp.expression.CaseExpression) QuantifiedExpression(org.apache.asterix.lang.common.expression.QuantifiedExpression) ArrayList(java.util.ArrayList) VariableExpr(org.apache.asterix.lang.common.expression.VariableExpr)

Aggregations

QuantifiedPair (org.apache.asterix.lang.common.struct.QuantifiedPair)8 ILangExpression (org.apache.asterix.lang.common.base.ILangExpression)4 QuantifiedExpression (org.apache.asterix.lang.common.expression.QuantifiedExpression)4 ArrayList (java.util.ArrayList)3 Expression (org.apache.asterix.lang.common.base.Expression)3 VariableExpr (org.apache.asterix.lang.common.expression.VariableExpr)3 GbyVariableExpressionPair (org.apache.asterix.lang.common.expression.GbyVariableExpressionPair)2 Pair (org.apache.hyracks.algebricks.common.utils.Pair)2 OperatorExpr (org.apache.asterix.lang.common.expression.OperatorExpr)1 VariableSubstitutionEnvironment (org.apache.asterix.lang.common.rewrites.VariableSubstitutionEnvironment)1 CaseExpression (org.apache.asterix.lang.sqlpp.expression.CaseExpression)1 SelectExpression (org.apache.asterix.lang.sqlpp.expression.SelectExpression)1 Mutable (org.apache.commons.lang3.mutable.Mutable)1 MutableObject (org.apache.commons.lang3.mutable.MutableObject)1 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)1 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)1 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)1 AggregateFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression)1 ScalarFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression)1 AggregateOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator)1