Example usage for org.apache.commons.lang3.mutable Mutable getValue

List of usage examples for org.apache.commons.lang3.mutable Mutable getValue

Introduction

In this page you can find the example usage for org.apache.commons.lang3.mutable Mutable getValue.

Prototype

T getValue();

Source Link

Document

Gets the value of this mutable.

Usage

From source file:org.apache.asterix.optimizer.rules.temporal.TranslateIntervalExpressionRule.java

@Override
public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
        throws AlgebricksException {
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    if (op.getOperatorTag() != LogicalOperatorTag.SELECT) {
        return false;
    }/*from  w  w  w  .  j  a v  a  2s .c o m*/
    SelectOperator selectOp = (SelectOperator) op;

    Mutable<ILogicalExpression> exprRef = selectOp.getCondition();
    ILogicalExpression expr = exprRef.getValue();
    if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
        return false;
    }
    AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
    if (funcExpr.getArguments().size() != 2) {
        return false;
    }
    if (!hasTranslatableInterval(funcExpr)) {
        return false;
    }

    return translateIntervalExpression(exprRef, funcExpr);
}

From source file:org.apache.asterix.optimizer.rules.typecast.StaticTypeCastUtil.java

private static boolean injectCastToRelaxType(Mutable<ILogicalExpression> expRef, IAType inputFieldType,
        IVariableTypeEnvironment env) throws AlgebricksException {
    ILogicalExpression argExpr = expRef.getValue();
    List<LogicalVariable> parameterVars = new ArrayList<LogicalVariable>();
    argExpr.getUsedVariables(parameterVars);
    // we need to handle open fields recursively by their default
    // types//www .j  a v a  2s . com
    // for list, their item type is any
    // for record, their
    boolean castInjected = false;
    if (argExpr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL
            || argExpr.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
        IAType reqFieldType = inputFieldType;
        // do not enforce nested type in the case of no-used variables
        switch (inputFieldType.getTypeTag()) {
        case RECORD:
            reqFieldType = DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
            break;
        case ORDEREDLIST:
            reqFieldType = DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE;
            break;
        case UNORDEREDLIST:
            reqFieldType = DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_TYPE;
            break;
        default:
            break;
        }
        // do not enforce nested type in the case of no-used variables
        if (!inputFieldType.equals(reqFieldType) && !parameterVars.isEmpty()) {
            //inject dynamic type casting
            injectCastFunction(FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.CAST_TYPE), reqFieldType,
                    inputFieldType, expRef, argExpr);
            castInjected = true;
        }
        //recursively rewrite function arguments
        if (argExpr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL
                && TypeCastUtils.getRequiredType((AbstractFunctionCallExpression) argExpr) == null
                && reqFieldType != null) {
            if (castInjected) {
                //rewrite the arg expression inside the dynamic cast
                ScalarFunctionCallExpression argFunc = (ScalarFunctionCallExpression) argExpr;
                rewriteFuncExpr(argFunc, inputFieldType, inputFieldType, env);
            } else {
                //rewrite arg
                ScalarFunctionCallExpression argFunc = (ScalarFunctionCallExpression) argExpr;
                rewriteFuncExpr(argFunc, reqFieldType, inputFieldType, env);
            }
        }
    }
    return castInjected;
}

From source file:org.apache.asterix.optimizer.rules.UnnestToDataScanRule.java

@Override
public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
        throws AlgebricksException {
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    if (op.getOperatorTag() != LogicalOperatorTag.UNNEST) {
        return false;
    }// w w w . j  av  a 2 s  . c  o  m
    UnnestOperator unnest = (UnnestOperator) op;
    ILogicalExpression unnestExpr = unnest.getExpressionRef().getValue();
    if (unnestExpr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
        return false;
    }
    return handleFunction(opRef, context, unnest, (AbstractFunctionCallExpression) unnestExpr);
}

From source file:org.apache.asterix.optimizer.rules.util.InsertUpsertCheckUtil.java

private static boolean checkTopDown(ILogicalOperator op, boolean hasSubplanAboveWithDatasetAccess) {
    boolean metSubplanWithDataScan = hasSubplanAboveWithDatasetAccess;
    if (op.getOperatorTag() == LogicalOperatorTag.SUBPLAN) {
        SubplanOperator subplanOp = (SubplanOperator) op;
        metSubplanWithDataScan = containsDatasetAccess(subplanOp);
    }//from   w ww . j ava2 s.co  m
    if (op.getOperatorTag() == LogicalOperatorTag.INSERT_DELETE_UPSERT && metSubplanWithDataScan) {
        return true;
    }
    for (Mutable<ILogicalOperator> inputOpRef : op.getInputs()) {
        if (checkTopDown(inputOpRef.getValue(), metSubplanWithDataScan)) {
            return true;
        }
    }
    return false;
}

From source file:org.apache.asterix.optimizer.rules.util.InsertUpsertCheckUtil.java

private static boolean containsDatasetAccess(SubplanOperator subplanOp) {
    List<ILogicalPlan> nestedPlans = subplanOp.getNestedPlans();
    for (ILogicalPlan nestedPlan : nestedPlans) {
        for (Mutable<ILogicalOperator> opRef : nestedPlan.getRoots()) {
            if (containsDatasetAccessInternal(opRef.getValue())) {
                return true;
            }/*from  w w  w .ja va 2s  .  co  m*/
        }
    }
    return false;
}

From source file:org.apache.asterix.optimizer.rules.util.InsertUpsertCheckUtil.java

private static boolean containsDatasetAccessInternal(ILogicalOperator op) {
    if (op.getOperatorTag() == LogicalOperatorTag.UNNEST) {
        UnnestOperator unnestOp = (UnnestOperator) op;
        ILogicalExpression unnestExpr = unnestOp.getExpressionRef().getValue();
        UnnestingFunctionCallExpression unnestingFuncExpr = (UnnestingFunctionCallExpression) unnestExpr;
        return unnestingFuncExpr.getFunctionIdentifier().equals(BuiltinFunctions.DATASET);
    }//from  w  ww. j  a  va 2 s.  c o  m
    if (op.getOperatorTag() == LogicalOperatorTag.SUBPLAN && containsDatasetAccess((SubplanOperator) op)) {
        return true;
    }
    for (Mutable<ILogicalOperator> childRef : op.getInputs()) {
        if (containsDatasetAccessInternal(childRef.getValue())) {
            return true;
        }
    }
    return false;
}

From source file:org.apache.asterix.runtime.formats.NonTaggedDataFormat.java

void registerTypeInferers() {
    functionTypeInferers.put(AsterixBuiltinFunctions.LISTIFY, new FunctionTypeInferer() {
        @Override/*  w  w  w  .j av a  2s. c o m*/
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            ((ListifyAggregateDescriptor) fd).reset((AOrderedListType) context.getType(expr));
        }
    });
    functionTypeInferers.put(AsterixBuiltinFunctions.RECORD_MERGE, new FunctionTypeInferer() {
        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr;
            IAType outType = (IAType) context.getType(expr);
            IAType type0 = (IAType) context.getType(f.getArguments().get(0).getValue());
            IAType type1 = (IAType) context.getType(f.getArguments().get(1).getValue());
            PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.IAType, org.apache.asterix.om.types.IAType, "
                    + " org.apache.asterix.om.types.IAType)", outType, type0, type1);
        }
    });

    functionTypeInferers.put(AsterixBuiltinFunctions.DEEP_EQUAL, new FunctionTypeInferer() {

        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr;
            IAType type0 = (IAType) context.getType(f.getArguments().get(0).getValue());
            IAType type1 = (IAType) context.getType(f.getArguments().get(1).getValue());
            PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.IAType, org.apache.asterix.om.types.IAType)",
                    type0, type1);
        }
    });

    functionTypeInferers.put(AsterixBuiltinFunctions.ADD_FIELDS, new FunctionTypeInferer() {

        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr;
            IAType outType = (IAType) context.getType(expr);
            IAType type0 = (IAType) context.getType(f.getArguments().get(0).getValue());
            ILogicalExpression listExpr = f.getArguments().get(1).getValue();
            IAType type1 = (IAType) context.getType(listExpr);
            if (type0.getTypeTag().equals(ATypeTag.ANY)) {
                type0 = DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
            }
            if (type1.getTypeTag().equals(ATypeTag.ANY)) {
                type1 = DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE;
            }
            PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.IAType, org.apache.asterix.om.types.IAType,"
                    + " org.apache.asterix.om.types.IAType)", outType, type0, type1);
        }
    });

    functionTypeInferers.put(AsterixBuiltinFunctions.REMOVE_FIELDS, new FunctionTypeInferer() {

        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr;
            IAType outType = (IAType) context.getType(expr);
            IAType type0 = (IAType) context.getType(f.getArguments().get(0).getValue());
            ILogicalExpression le = f.getArguments().get(1).getValue();
            IAType type1 = (IAType) context.getType(le);
            if (type0.getTypeTag().equals(ATypeTag.ANY)) {
                type0 = DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
            }
            if (type1.getTypeTag().equals(ATypeTag.ANY)) {
                type1 = DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE;
            }
            PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.IAType, org.apache.asterix.om.types.IAType,"
                    + " org.apache.asterix.om.types.IAType)", outType, type0, type1);
        }
    });
    functionTypeInferers.put(AsterixBuiltinFunctions.CAST_TYPE, new FunctionTypeInferer() {
        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
            IAType rt = TypeCastUtils.getRequiredType(funcExpr);
            IAType it = (IAType) context.getType(funcExpr.getArguments().get(0).getValue());
            PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.IAType, org.apache.asterix.om.types.IAType)",
                    rt, it);
        }
    });
    functionTypeInferers.put(AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR, new FunctionTypeInferer() {
        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            ARecordType rt = (ARecordType) context.getType(expr);
            ((OpenRecordConstructorDescriptor) fd).reset(rt,
                    computeOpenFields((AbstractFunctionCallExpression) expr, rt));
        }

        private boolean[] computeOpenFields(AbstractFunctionCallExpression expr, ARecordType recType) {
            int n = expr.getArguments().size() / 2;
            boolean[] open = new boolean[n];
            for (int i = 0; i < n; i++) {
                Mutable<ILogicalExpression> argRef = expr.getArguments().get(2 * i);
                ILogicalExpression arg = argRef.getValue();
                open[i] = true;
                final String fn = ConstantExpressionUtil.getStringConstant(arg);
                if (fn != null) {
                    for (String s : recType.getFieldNames()) {
                        if (s.equals(fn)) {
                            open[i] = false;
                            break;
                        }
                    }
                }
            }
            return open;
        }
    });
    functionTypeInferers.put(AsterixBuiltinFunctions.CLOSED_RECORD_CONSTRUCTOR, new FunctionTypeInferer() {
        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            ((ClosedRecordConstructorDescriptor) fd).reset((ARecordType) context.getType(expr));
        }
    });
    functionTypeInferers.put(AsterixBuiltinFunctions.ORDERED_LIST_CONSTRUCTOR, new FunctionTypeInferer() {
        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            ((OrderedListConstructorDescriptor) fd).reset((AOrderedListType) context.getType(expr));
        }
    });
    functionTypeInferers.put(AsterixBuiltinFunctions.UNORDERED_LIST_CONSTRUCTOR, new FunctionTypeInferer() {
        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            ((UnorderedListConstructorDescriptor) fd).reset((AUnorderedListType) context.getType(expr));
        }
    });
    functionTypeInferers.put(AsterixBuiltinFunctions.FIELD_ACCESS_BY_INDEX, new FunctionTypeInferer() {
        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
            IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue());
            switch (t.getTypeTag()) {
            case RECORD: {
                ARecordType recType = (ARecordType) t;
                PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType)", recType);
                break;
            }
            case UNION: {
                AUnionType unionT = (AUnionType) t;
                if (unionT.isUnknownableType()) {
                    IAType t2 = unionT.getActualType();
                    if (t2.getTypeTag() == ATypeTag.RECORD) {
                        ARecordType recType = (ARecordType) t2;
                        PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType)", recType);
                        break;
                    }
                }
                throw new NotImplementedException("field-access-by-index for data of type " + t);
            }
            default: {
                throw new NotImplementedException("field-access-by-index for data of type " + t);
            }
            }
        }
    });
    functionTypeInferers.put(AsterixBuiltinFunctions.FIELD_ACCESS_NESTED, new FunctionTypeInferer() {
        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
            IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue());
            AOrderedList fieldPath = (AOrderedList) (((AsterixConstantValue) ((ConstantExpression) fce
                    .getArguments().get(1).getValue()).getValue()).getObject());
            List<String> listFieldPath = new ArrayList<String>();
            for (int i = 0; i < fieldPath.size(); i++) {
                listFieldPath.add(((AString) fieldPath.getItem(i)).getStringValue());
            }

            switch (t.getTypeTag()) {
            case RECORD: {
                ARecordType recType = (ARecordType) t;
                PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType, java.util.List)", recType,
                        listFieldPath);
                break;
            }
            case ANY:
                PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType, java.util.List)",
                        ARecordType.FULLY_OPEN_RECORD_TYPE, listFieldPath);
                break;
            default: {
                throw new NotImplementedException("field-access-nested for data of type " + t);
            }
            }
        }
    });
    functionTypeInferers.put(AsterixBuiltinFunctions.GET_RECORD_FIELDS, new FunctionTypeInferer() {
        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
            IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue());
            ATypeTag typeTag = t.getTypeTag();
            if (typeTag.equals(ATypeTag.RECORD)) {
                ARecordType recType = (ARecordType) t;
                PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType)", recType);
            } else if (typeTag.equals(ATypeTag.ANY)) {
                PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType)",
                        ARecordType.FULLY_OPEN_RECORD_TYPE);
            } else {
                throw new NotImplementedException("get-record-fields for data of type " + t);
            }
        }
    });
    functionTypeInferers.put(AsterixBuiltinFunctions.GET_RECORD_FIELD_VALUE, new FunctionTypeInferer() {
        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
            IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue());
            ATypeTag typeTag = t.getTypeTag();
            if (typeTag.equals(ATypeTag.RECORD)) {
                ARecordType recType = (ARecordType) t;
                PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType)", recType);
            } else if (typeTag.equals(ATypeTag.ANY)) {
                PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType)",
                        ARecordType.FULLY_OPEN_RECORD_TYPE);
            } else {
                throw new NotImplementedException("get-record-field-value for data of type " + t);
            }
        }
    });
    functionTypeInferers.put(AsterixBuiltinFunctions.RECORD_PAIRS, new FunctionTypeInferer() {
        @Override
        public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
                throws AlgebricksException {
            AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
            IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue());
            ATypeTag typeTag = t.getTypeTag();
            if (typeTag.equals(ATypeTag.RECORD)) {
                ARecordType recType = (ARecordType) t;
                PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType)", recType);
            } else if (typeTag.equals(ATypeTag.ANY)) {
                PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType)",
                        ARecordType.FULLY_OPEN_RECORD_TYPE);
            } else {
                throw new NotImplementedException("record-fields with data of type " + t);
            }
        }
    });
}

From source file:org.apache.asterix.translator.AqlExpressionToPlanTranslator.java

@Override
public Pair<ILogicalOperator, LogicalVariable> visit(FLWOGRExpression flwor,
        Mutable<ILogicalOperator> tupSource) throws AsterixException {
    Mutable<ILogicalOperator> flworPlan = tupSource;
    boolean isTop = context.isTopFlwor();
    if (!isTop) {
        context.enterSubplan();/*from w ww  . j  a  v a2s .  co  m*/
    }
    if (isTop) {
        context.setTopFlwor(false);
    }
    for (Clause c : flwor.getClauseList()) {
        Pair<ILogicalOperator, LogicalVariable> pC = c.accept(this, flworPlan);
        flworPlan = new MutableObject<>(pC.first);
    }

    Expression r = flwor.getReturnExpr();
    boolean noForClause = flwor.noForClause();

    Pair<ILogicalOperator, LogicalVariable> result;
    if (r.getKind() == Kind.VARIABLE_EXPRESSION) {
        VariableExpr v = (VariableExpr) r;
        LogicalVariable var = context.getVar(v.getVar().getId());
        result = produceFlworPlan(noForClause, isTop, flworPlan, var);
    } else {
        Mutable<ILogicalOperator> baseOp = new MutableObject<>(flworPlan.getValue());
        Pair<ILogicalOperator, LogicalVariable> rRes = r.accept(this, baseOp);
        ILogicalOperator rOp = rRes.first;
        ILogicalOperator resOp;
        if (expressionNeedsNoNesting(r)) {
            baseOp.setValue(flworPlan.getValue());
            resOp = rOp;
        } else {
            SubplanOperator s = new SubplanOperator(rOp);
            s.getInputs().add(flworPlan);
            resOp = s;
            baseOp.setValue(new NestedTupleSourceOperator(new MutableObject<ILogicalOperator>(s)));
        }
        Mutable<ILogicalOperator> resOpRef = new MutableObject<>(resOp);
        result = produceFlworPlan(noForClause, isTop, resOpRef, rRes.second);
    }
    if (!isTop) {
        context.exitSubplan();
    }

    return result;
}

From source file:org.apache.asterix.translator.AqlExpressionToPlanTranslator.java

private Pair<ILogicalOperator, LogicalVariable> produceFlworPlan(boolean noForClause, boolean isTop,
        Mutable<ILogicalOperator> resOpRef, LogicalVariable resVar) {
    if (isTop) {/*www. j a v a2s.c o m*/
        ProjectOperator pr = new ProjectOperator(resVar);
        pr.getInputs().add(resOpRef);
        return new Pair<>(pr, resVar);
    } else if (noForClause) {
        ILogicalOperator resOp = resOpRef.getValue();
        if (resOp.getOperatorTag() == LogicalOperatorTag.ASSIGN) {
            return new Pair<>(resOp, resVar);
        }
        LogicalVariable newResVar = context.newVar();
        ILogicalOperator assign = new AssignOperator(newResVar,
                new MutableObject<>(new VariableReferenceExpression(resVar)));
        assign.getInputs().add(resOpRef);
        return new Pair<>(assign, newResVar);
    } else {
        return aggListifyForSubquery(resVar, resOpRef, false);
    }
}

From source file:org.apache.asterix.translator.AqlPlusExpressionToPlanTranslator.java

@Override
public Pair<ILogicalOperator, LogicalVariable> visit(FLWOGRExpression flwor,
        Mutable<ILogicalOperator> tupSource) throws AsterixException {
    Mutable<ILogicalOperator> flworPlan = tupSource;
    boolean isTop = context.isTopFlwor();
    if (isTop) {/*from   ww w  .  ja  v  a  2s  .co m*/
        context.setTopFlwor(false);
    }
    for (Clause c : flwor.getClauseList()) {
        Pair<ILogicalOperator, LogicalVariable> pC = c.accept(this, flworPlan);
        flworPlan = new MutableObject<ILogicalOperator>(pC.first);
    }

    Expression r = flwor.getReturnExpr();
    boolean noFlworClause = flwor.noForClause();

    if (r.getKind() == Kind.VARIABLE_EXPRESSION) {
        VariableExpr v = (VariableExpr) r;
        LogicalVariable var = context.getVar(v.getVar().getId());

        return produceFlwrResult(noFlworClause, isTop, flworPlan, var);

    } else {
        Mutable<ILogicalOperator> baseOp = new MutableObject<ILogicalOperator>(flworPlan.getValue());
        Pair<ILogicalOperator, LogicalVariable> rRes = r.accept(this, baseOp);
        ILogicalOperator rOp = rRes.first;
        ILogicalOperator resOp;
        if (expressionNeedsNoNesting(r)) {
            baseOp.setValue(flworPlan.getValue());
            resOp = rOp;
        } else {
            SubplanOperator s = new SubplanOperator(rOp);
            s.getInputs().add(flworPlan);
            resOp = s;
            baseOp.setValue(new NestedTupleSourceOperator(new MutableObject<ILogicalOperator>(s)));
        }
        Mutable<ILogicalOperator> resOpRef = new MutableObject<ILogicalOperator>(resOp);
        return produceFlwrResult(noFlworClause, isTop, resOpRef, rRes.second);
    }
}