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

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

Introduction

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

Prototype

void setValue(T value);

Source Link

Document

Sets the value of this mutable.

Usage

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

/**
 * Pushes one field-access assignment above toPushThroughChildRef
 *
 * @param toPush/*from  w  w  w.jav  a  2  s  .c o  m*/
 * @param toPushThroughChildRef
 */
private static void pushAccessAboveOpRef(AssignOperator toPush, Mutable<ILogicalOperator> toPushThroughChildRef,
        IOptimizationContext context) throws AlgebricksException {
    List<Mutable<ILogicalOperator>> tpInpList = toPush.getInputs();
    tpInpList.clear();
    tpInpList.add(new MutableObject<>(toPushThroughChildRef.getValue()));
    toPushThroughChildRef.setValue(toPush);
    findAndEliminateRedundantFieldAccess(toPush, context);
}

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

@Override
public boolean transform(Mutable<ILogicalExpression> exprRef) throws AlgebricksException {
    ILogicalExpression expr = exprRef.getValue();
    if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
        return false;
    }/*from  ww  w.  j  a  va2 s  . c om*/
    AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
    List<Mutable<ILogicalExpression>> argRefs = funcExpr.getArguments();

    // Recursively transform argument expressions.
    for (Mutable<ILogicalExpression> argRef : argRefs) {
        transform(argRef);
    }

    if (!funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.META)) {
        return false;
    }
    // The user query provides more than one parameter for the meta function.
    if (argRefs.size() > 1) {
        throw new AlgebricksException("The meta function can at most have one argument!");
    }

    // The user query provides exact one parameter for the meta function.
    if (argRefs.size() == 1) {
        ILogicalExpression argExpr = argRefs.get(0).getValue();
        if (argExpr.getExpressionTag() != LogicalExpressionTag.VARIABLE) {
            return false;
        }
        VariableReferenceExpression argVarExpr = (VariableReferenceExpression) argExpr;
        LogicalVariable argVar = argVarExpr.getVariableReference();
        if (!dataVar.equals(argVar)) {
            return false;
        }
        exprRef.setValue(new VariableReferenceExpression(metaVar));
        return true;
    }

    // The user query provides zero parameter for the meta function.
    if (variableRequired) {
        throw new AlgebricksException("Cannot resolve to ambiguity on the meta function call --"
                + " there are more than one dataset choices!");
    }
    exprRef.setValue(new VariableReferenceExpression(metaVar));
    return true;
}

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

@Override
public boolean transform(Mutable<ILogicalExpression> exprRef) throws AlgebricksException {
    ILogicalExpression expr = exprRef.getValue();
    if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
        return false;
    }/*from   w ww  . ja v a 2s.co  m*/
    AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
    if (!funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.META_KEY)) {
        return false;
    }
    // Get arguments
    // first argument : Resource key
    // second argument: field
    List<Mutable<ILogicalExpression>> args = funcExpr.getArguments();
    ConstantExpression fieldNameExpression = (ConstantExpression) args.get(1).getValue();
    AsterixConstantValue fieldNameValue = (AsterixConstantValue) fieldNameExpression.getValue();
    IAType fieldNameType = fieldNameValue.getObject().getType();
    FunctionIdentifier functionIdentifier;
    switch (fieldNameType.getTypeTag()) {
    case ORDEREDLIST:
        // Field access nested
        functionIdentifier = AsterixBuiltinFunctions.FIELD_ACCESS_NESTED;
        break;
    case STRING:
        // field access by name
        functionIdentifier = AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME;
        break;
    default:
        throw new AlgebricksException("Unsupported field name type " + fieldNameType.getTypeTag());
    }
    IFunctionInfo finfoAccess = FunctionUtil.getFunctionInfo(functionIdentifier);
    ArrayList<Mutable<ILogicalExpression>> argExprs = new ArrayList<>(2);
    argExprs.add(new MutableObject<>(new VariableReferenceExpression(metaVar)));
    argExprs.add(new MutableObject<>(fieldNameExpression));
    exprRef.setValue(new ScalarFunctionCallExpression(finfoAccess, argExprs));
    return true;
}

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

@Override
public boolean transform(Mutable<ILogicalExpression> exprRef) throws AlgebricksException {
    ILogicalExpression expr = exprRef.getValue();
    if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
        return false;
    }/*from   ww w  . j  a  va  2  s  .  c o m*/
    AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
    if (!funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.META_KEY)) {
        return false;
    }

    // Function is meta key access
    for (int i = 0; i < metaKeyAccessExpressions.size(); i++) {
        if (metaKeyAccessExpressions.get(i).equals(funcExpr)) {
            exprRef.setValue(new VariableReferenceExpression(keyVars.get(i)));
            return true;
        }
    }
    return false;
}

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

@Override
public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
        throws AlgebricksException {
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    if (op.getOperatorTag() != LogicalOperatorTag.UNNEST) {
        return false;
    }/*  www. j ava 2s  .c o m*/
    UnnestOperator unnest = (UnnestOperator) op;
    LogicalVariable p = unnest.getPositionalVariable();
    if (p == null) {
        return false;
    }
    ArrayList<LogicalVariable> rOpVars = new ArrayList<LogicalVariable>();
    rOpVars.add(p);
    ArrayList<Mutable<ILogicalExpression>> rOpExprList = new ArrayList<Mutable<ILogicalExpression>>();
    StatefulFunctionCallExpression fce = new StatefulFunctionCallExpression(
            FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.TID), UnpartitionedPropertyComputer.INSTANCE);
    rOpExprList.add(new MutableObject<ILogicalExpression>(fce));
    RunningAggregateOperator rOp = new RunningAggregateOperator(rOpVars, rOpExprList);
    rOp.setExecutionMode(unnest.getExecutionMode());
    RunningAggregatePOperator rPop = new RunningAggregatePOperator();
    rOp.setPhysicalOperator(rPop);
    rOp.getInputs().add(new MutableObject<ILogicalOperator>(unnest));
    opRef.setValue(rOp);
    unnest.setPositionalVariable(null);
    context.computeAndSetTypeEnvironmentForOperator(rOp);
    context.computeAndSetTypeEnvironmentForOperator(unnest);
    return true;
}

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

private boolean pushAggregateFunction(AggregateOperator aggOp, AssignOperator assignOp,
        IOptimizationContext context) throws AlgebricksException {
    Mutable<ILogicalOperator> opRef3 = aggOp.getInputs().get(0);
    AbstractLogicalOperator op3 = (AbstractLogicalOperator) opRef3.getValue();
    // If there's a group by below the agg, then we want to have the agg pushed into the group by.
    if (op3.getOperatorTag() == LogicalOperatorTag.GROUP) {
        return false;
    }//  w  w w.  ja  v a  2 s . c  o  m
    if (aggOp.getVariables().size() != 1) {
        return false;
    }
    ILogicalExpression aggExpr = aggOp.getExpressions().get(0).getValue();
    if (aggExpr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
        return false;
    }
    AbstractFunctionCallExpression origAggFuncExpr = (AbstractFunctionCallExpression) aggExpr;
    if (origAggFuncExpr.getFunctionIdentifier() != AsterixBuiltinFunctions.LISTIFY) {
        return false;
    }

    LogicalVariable aggVar = aggOp.getVariables().get(0);
    List<LogicalVariable> used = new LinkedList<LogicalVariable>();
    VariableUtilities.getUsedVariables(assignOp, used);
    if (!used.contains(aggVar)) {
        return false;
    }

    List<Mutable<ILogicalExpression>> srcAssignExprRefs = new LinkedList<Mutable<ILogicalExpression>>();
    if (fingAggFuncExprRef(assignOp.getExpressions(), aggVar, srcAssignExprRefs) == false) {
        return false;
    }
    if (srcAssignExprRefs.isEmpty()) {
        return false;
    }

    AbstractFunctionCallExpression aggOpExpr = (AbstractFunctionCallExpression) aggOp.getExpressions().get(0)
            .getValue();
    aggOp.getExpressions().clear();
    aggOp.getVariables().clear();

    for (Mutable<ILogicalExpression> srcAssignExprRef : srcAssignExprRefs) {
        AbstractFunctionCallExpression assignFuncExpr = (AbstractFunctionCallExpression) srcAssignExprRef
                .getValue();
        FunctionIdentifier aggFuncIdent = AsterixBuiltinFunctions
                .getAggregateFunction(assignFuncExpr.getFunctionIdentifier());

        // Push the agg func into the agg op.

        List<Mutable<ILogicalExpression>> aggArgs = new ArrayList<Mutable<ILogicalExpression>>();
        aggArgs.add(aggOpExpr.getArguments().get(0));
        AggregateFunctionCallExpression aggFuncExpr = AsterixBuiltinFunctions
                .makeAggregateFunctionExpression(aggFuncIdent, aggArgs);
        LogicalVariable newVar = context.newVar();
        aggOp.getVariables().add(newVar);
        aggOp.getExpressions().add(new MutableObject<ILogicalExpression>(aggFuncExpr));

        // The assign now just "renames" the variable to make sure the upstream plan still works.
        srcAssignExprRef.setValue(new VariableReferenceExpression(newVar));
    }

    context.computeAndSetTypeEnvironmentForOperator(aggOp);
    context.computeAndSetTypeEnvironmentForOperator(assignOp);
    return true;
}

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

private boolean collectVarsBottomUp(Mutable<ILogicalOperator> opRef, IOptimizationContext context,
        Map<LogicalVariable, Integer> nspListifyVarsCount,
        Map<LogicalVariable, AbstractOperatorWithNestedPlans> nspWithAgg,
        Map<LogicalVariable, Integer> nspAggVarToPlanIndex,
        Map<ILogicalExpression, ILogicalExpression> aggregateExprToVarExpr) throws AlgebricksException {
    AbstractLogicalOperator op1 = (AbstractLogicalOperator) opRef.getValue();
    context.addToDontApplySet(this, op1);
    boolean change = false;
    for (Mutable<ILogicalOperator> child : op1.getInputs()) {
        if (collectVarsBottomUp(child, context, nspListifyVarsCount, nspWithAgg, nspAggVarToPlanIndex,
                aggregateExprToVarExpr)) {
            change = true;/*from  ww  w.j  a va2s. c o  m*/
        }
    }
    Set<LogicalVariable> used = new HashSet<>();
    VariableUtilities.getUsedVariables(op1, used);
    switch (op1.getOperatorTag()) {
    case ASSIGN:
    case SELECT:
        boolean found = false;
        // Do some prefiltering: check if the Assign uses any nsp vars.
        for (LogicalVariable v : used) {
            if (nspListifyVarsCount.get(v) != null) {
                found = true;
                break;
            }
        }
        if (!found) {
            break;
        }
        if (op1.getOperatorTag() == LogicalOperatorTag.ASSIGN) {
            AssignOperator assign = (AssignOperator) op1;
            for (Mutable<ILogicalExpression> exprRef : assign.getExpressions()) {
                Pair<Boolean, ILogicalExpression> p = extractAggFunctionsFromExpression(exprRef, nspWithAgg,
                        aggregateExprToVarExpr, context);
                if (p.first) {
                    change = true;
                    exprRef.setValue(p.second);
                }
            }
        }
        if (op1.getOperatorTag() == LogicalOperatorTag.SELECT) {
            SelectOperator select = (SelectOperator) op1;
            Mutable<ILogicalExpression> exprRef = select.getCondition();
            Pair<Boolean, ILogicalExpression> p = extractAggFunctionsFromExpression(exprRef, nspWithAgg,
                    aggregateExprToVarExpr, context);
            if (p.first) {
                change = true;
                exprRef.setValue(p.second);
            }
        }
        used.clear();
        VariableUtilities.getUsedVariables(op1, used);
        // increment the count for the ones which are still used
        for (LogicalVariable v : used) {
            Integer m = nspListifyVarsCount.get(v);
            if (m != null) {
                nspListifyVarsCount.put(v, m + 1);
            }
        }
        break;
    case SUBPLAN:
        // Try to push the subplan into a group-by operator if possible.
        for (LogicalVariable v : used) {
            Integer m = nspListifyVarsCount.get(v);
            if (m != null) {
                AbstractOperatorWithNestedPlans nspOp = nspWithAgg.get(v);
                if (pushSubplanAsAggIntoNestedSubplan(opRef, nspOp, v, nspListifyVarsCount, nspWithAgg,
                        nspAggVarToPlanIndex, context)) {
                    change = true;
                } else {
                    nspListifyVarsCount.put(v, m + 1);
                }
            }
        }
        if (!change) {
            // Collect aggregate variables for pushing aggregates into the subplan (if possible).
            collectAggregateVars(nspListifyVarsCount, nspWithAgg, nspAggVarToPlanIndex,
                    (AbstractOperatorWithNestedPlans) op1);
        }
        break;
    case GROUP:
        // Collect aggregate variables for pushing aggregates into the nested subplan
        // of the group by operator (if possible).
        collectAggregateVars(nspListifyVarsCount, nspWithAgg, nspAggVarToPlanIndex,
                (AbstractOperatorWithNestedPlans) op1);
        break;
    default:
        for (LogicalVariable v : used) {
            Integer m = nspListifyVarsCount.get(v);
            if (m != null) {
                nspListifyVarsCount.put(v, m + 1);
            }
        }
    }
    return change;
}

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

/**
 * @param exprRef//from  w  w w.j a  v  a 2s .co  m
 * @param nspWithAgg
 * @param context
 * @return a pair whose first member is a boolean which is true iff
 *         something was changed in the expression tree rooted at expr. The
 *         second member is the result of transforming expr.
 * @throws AlgebricksException
 */
private Pair<Boolean, ILogicalExpression> extractAggFunctionsFromExpression(Mutable<ILogicalExpression> exprRef,
        Map<LogicalVariable, AbstractOperatorWithNestedPlans> nspWithAgg,
        Map<ILogicalExpression, ILogicalExpression> aggregateExprToVarExpr, IOptimizationContext context)
        throws AlgebricksException {
    ILogicalExpression expr = exprRef.getValue();
    switch (expr.getExpressionTag()) {
    case FUNCTION_CALL:
        AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
        FunctionIdentifier fi = AsterixBuiltinFunctions.getAggregateFunction(fce.getFunctionIdentifier());
        if (fi != null) {
            ILogicalExpression a1 = fce.getArguments().get(0).getValue();
            if (a1.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
                LogicalVariable argVar = ((VariableReferenceExpression) a1).getVariableReference();
                AbstractOperatorWithNestedPlans nspOp = nspWithAgg.get(argVar);

                if (nspOp != null) {
                    if (!aggregateExprToVarExpr.containsKey(expr)) {
                        LogicalVariable newVar = context.newVar();
                        AggregateFunctionCallExpression aggFun = AsterixBuiltinFunctions
                                .makeAggregateFunctionExpression(fi, fce.getArguments());
                        rewriteAggregateInNestedSubplan(argVar, nspOp, aggFun, newVar, context);
                        ILogicalExpression newVarExpr = new VariableReferenceExpression(newVar);
                        aggregateExprToVarExpr.put(expr, newVarExpr);
                        return new Pair<>(Boolean.TRUE, newVarExpr);
                    } else {
                        ILogicalExpression varExpr = aggregateExprToVarExpr.get(expr);
                        return new Pair<>(Boolean.TRUE, varExpr);
                    }
                }
            }
        }

        boolean change = false;
        for (Mutable<ILogicalExpression> a : fce.getArguments()) {
            Pair<Boolean, ILogicalExpression> aggArg = extractAggFunctionsFromExpression(a, nspWithAgg,
                    aggregateExprToVarExpr, context);
            if (aggArg.first.booleanValue()) {
                a.setValue(aggArg.second);
                change = true;
            }
        }
        return new Pair<>(change, fce);
    case VARIABLE:
    case CONSTANT:
        return new Pair<>(Boolean.FALSE, expr);
    default:
        throw new IllegalArgumentException();
    }
}

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

private boolean pushSubplanAsAggIntoNestedSubplan(Mutable<ILogicalOperator> subplanOpRef,
        AbstractOperatorWithNestedPlans nspOp, LogicalVariable varFromNestedAgg,
        Map<LogicalVariable, Integer> nspAggVars,
        Map<LogicalVariable, AbstractOperatorWithNestedPlans> nspWithAgg,
        Map<LogicalVariable, Integer> nspAggVarToPlanIndex, IOptimizationContext context)
        throws AlgebricksException {
    SubplanOperator subplan = (SubplanOperator) subplanOpRef.getValue();
    // only free var can be varFromNestedAgg
    HashSet<LogicalVariable> freeVars = new HashSet<>();
    OperatorPropertiesUtil.getFreeVariablesInSubplans(subplan, freeVars);
    for (LogicalVariable vFree : freeVars) {
        if (!vFree.equals(varFromNestedAgg)) {
            return false;
        }/*from   w w  w .  j a va 2  s .  co m*/
    }

    List<ILogicalPlan> plans = subplan.getNestedPlans();
    if (plans.size() > 1) {
        return false;
    }
    ILogicalPlan p = plans.get(0);
    if (p.getRoots().size() > 1) {
        return false;
    }
    Mutable<ILogicalOperator> opRef = p.getRoots().get(0);
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    if (op.getOperatorTag() != LogicalOperatorTag.AGGREGATE) {
        return false;
    }
    AggregateOperator aggInSubplanOp = (AggregateOperator) op;
    LogicalVariable unnestVar = null;
    boolean pushableNestedSubplan = false;
    while (op.getInputs().size() == 1) {
        opRef = op.getInputs().get(0);
        op = (AbstractLogicalOperator) opRef.getValue();
        switch (op.getOperatorTag()) {
        case ASSIGN:
            break;
        case UNNEST:
            UnnestOperator unnest = (UnnestOperator) op;
            if (unnest.getPositionalVariable() != null) {
                // TODO currently subplan with both accumulating and running aggregate is not supported.
                return false;
            }
            ILogicalExpression expr = unnest.getExpressionRef().getValue();
            if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
                return false;
            }
            AbstractFunctionCallExpression fun = (AbstractFunctionCallExpression) expr;
            if (fun.getFunctionIdentifier() != AsterixBuiltinFunctions.SCAN_COLLECTION) {
                return false;
            }
            ILogicalExpression arg0 = fun.getArguments().get(0).getValue();
            if (arg0.getExpressionTag() != LogicalExpressionTag.VARIABLE) {
                return false;
            }
            VariableReferenceExpression varExpr = (VariableReferenceExpression) arg0;
            if (!varExpr.getVariableReference().equals(varFromNestedAgg)) {
                return false;
            }
            opRef = op.getInputs().get(0);
            op = (AbstractLogicalOperator) opRef.getValue();
            if (op.getOperatorTag() != LogicalOperatorTag.NESTEDTUPLESOURCE) {
                return false;
            }
            pushableNestedSubplan = true;
            unnestVar = unnest.getVariable();
            break;
        default:
            return false;
        }
    }
    if (!pushableNestedSubplan) {
        return false;
    }

    for (int i = 0; i < nspOp.getNestedPlans().size(); i++) {
        Mutable<ILogicalOperator> nspAggRef = nspOp.getNestedPlans().get(i).getRoots().get(0);
        AggregateOperator nspAgg = (AggregateOperator) nspAggRef.getValue();
        Mutable<ILogicalOperator> nspAggChildRef = nspAgg.getInputs().get(0);
        LogicalVariable listifyVar = findListifiedVariable(nspAgg, varFromNestedAgg);
        if (listifyVar == null) {
            continue;
        }
        OperatorManipulationUtil.substituteVarRec(aggInSubplanOp, unnestVar, listifyVar, true, context);
        nspAgg.getVariables().addAll(aggInSubplanOp.getVariables());
        nspAgg.getExpressions().addAll(aggInSubplanOp.getExpressions());
        for (LogicalVariable v : aggInSubplanOp.getVariables()) {
            nspWithAgg.put(v, nspOp);
            nspAggVars.put(v, 0);
            nspAggVarToPlanIndex.put(v, i);
        }

        Mutable<ILogicalOperator> opRef1InSubplan = aggInSubplanOp.getInputs().get(0);
        if (!opRef1InSubplan.getValue().getInputs().isEmpty()) {
            Mutable<ILogicalOperator> opRef2InSubplan = opRef1InSubplan.getValue().getInputs().get(0);
            AbstractLogicalOperator op2InSubplan = (AbstractLogicalOperator) opRef2InSubplan.getValue();
            if (op2InSubplan.getOperatorTag() != LogicalOperatorTag.NESTEDTUPLESOURCE) {
                List<Mutable<ILogicalOperator>> nspInpList = nspAgg.getInputs();
                nspInpList.clear();
                nspInpList.add(opRef1InSubplan);
                while (true) {
                    opRef2InSubplan = opRef1InSubplan.getValue().getInputs().get(0);
                    op2InSubplan = (AbstractLogicalOperator) opRef2InSubplan.getValue();
                    if (op2InSubplan.getOperatorTag() == LogicalOperatorTag.UNNEST) {
                        List<Mutable<ILogicalOperator>> opInpList = opRef1InSubplan.getValue().getInputs();
                        opInpList.clear();
                        opInpList.add(nspAggChildRef);
                        break;
                    }
                    opRef1InSubplan = opRef2InSubplan;
                    if (opRef1InSubplan.getValue().getInputs().isEmpty()) {
                        throw new IllegalStateException(
                                "PushAggregateIntoNestedSubplanRule: could not find UNNEST.");
                    }
                }
            }
        }
        subplanOpRef.setValue(subplan.getInputs().get(0).getValue());
        OperatorPropertiesUtil.typeOpRec(nspAggRef, context);
    }
    return true;
}

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

private void push(Mutable<ILogicalOperator> opRefGby, Mutable<ILogicalOperator> opRefJoin, int branch,
        List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> decorToPush,
        List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> decorNotToPush, IOptimizationContext context)
        throws AlgebricksException {
    GroupByOperator gby = (GroupByOperator) opRefGby.getValue();
    AbstractBinaryJoinOperator join = (AbstractBinaryJoinOperator) opRefJoin.getValue();
    gby.getDecorList().clear();/*from w  w w .j  a v a  2s  . c om*/
    gby.getDecorList().addAll(decorToPush);
    for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : decorNotToPush) {
        LogicalVariable v1 = p.first;
        if (v1 != null) {
            VariableReferenceExpression varRef = (VariableReferenceExpression) p.second.getValue();
            LogicalVariable v2 = varRef.getVariableReference();
            OperatorManipulationUtil.substituteVarRec(join, v2, v1, true, context);
        }
    }
    Mutable<ILogicalOperator> branchRef = join.getInputs().get(branch);
    ILogicalOperator opBranch = branchRef.getValue();
    opRefJoin.setValue(opBranch);
    branchRef.setValue(gby);
    opRefGby.setValue(join);
}