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:edu.uci.ics.hyracks.algebricks.rewriter.util.JoinUtils.java

public static void setJoinAlgorithmAndExchangeAlgo(AbstractBinaryJoinOperator op, IOptimizationContext context)
        throws AlgebricksException {
    List<LogicalVariable> sideLeft = new LinkedList<LogicalVariable>();
    List<LogicalVariable> sideRight = new LinkedList<LogicalVariable>();
    List<LogicalVariable> varsLeft = op.getInputs().get(0).getValue().getSchema();
    List<LogicalVariable> varsRight = op.getInputs().get(1).getValue().getSchema();
    if (isHashJoinCondition(op.getCondition().getValue(), varsLeft, varsRight, sideLeft, sideRight)) {
        BroadcastSide side = getBroadcastJoinSide(op.getCondition().getValue(), varsLeft, varsRight);
        if (side == null) {
            setHashJoinOp(op, JoinPartitioningType.PAIRWISE, sideLeft, sideRight, context);
        } else {/*from  w  w  w  . jav  a 2 s . c om*/
            switch (side) {
            case RIGHT:
                setHashJoinOp(op, JoinPartitioningType.BROADCAST, sideLeft, sideRight, context);
                break;
            case LEFT:
                Mutable<ILogicalOperator> opRef0 = op.getInputs().get(0);
                Mutable<ILogicalOperator> opRef1 = op.getInputs().get(1);
                ILogicalOperator tmp = opRef0.getValue();
                opRef0.setValue(opRef1.getValue());
                opRef1.setValue(tmp);
                setHashJoinOp(op, JoinPartitioningType.BROADCAST, sideRight, sideLeft, context);
                break;
            default:
                setHashJoinOp(op, JoinPartitioningType.PAIRWISE, sideLeft, sideRight, context);
            }
        }
    } else {
        setNLJoinOp(op, context);
    }
}

From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.IsolateHyracksOperatorsRule.java

private final static void insertOneToOneExchange(Mutable<ILogicalOperator> i, IOptimizationContext context)
        throws AlgebricksException {
    ExchangeOperator e = new ExchangeOperator();
    e.setPhysicalOperator(new OneToOneExchangePOperator());
    ILogicalOperator inOp = i.getValue();

    e.getInputs().add(new MutableObject<ILogicalOperator>(inOp));
    i.setValue(e);
    // e.recomputeSchema();
    OperatorPropertiesUtil.computeSchemaAndPropertiesRecIfNull(e, context);
    ExecutionMode em = ((AbstractLogicalOperator) inOp).getExecutionMode();
    e.setExecutionMode(em);/*from ww w  .  j a  v  a  2s .c o  m*/
    e.computeDeliveredPhysicalProperties(context);
    context.computeAndSetTypeEnvironmentForOperator(e);
}

From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.ComplexJoinInferenceRule.java

/** clean up joins that have one input branch that is empty tuple source */
private static void cleanupJoins(Mutable<ILogicalOperator> opRef) {
    if (opRef.getValue() instanceof AbstractBinaryJoinOperator) {
        for (Mutable<ILogicalOperator> inputRef : opRef.getValue().getInputs()) {
            if (inputRef.getValue().getOperatorTag() == LogicalOperatorTag.EMPTYTUPLESOURCE) {
                opRef.getValue().getInputs().remove(inputRef);
                opRef.setValue(opRef.getValue().getInputs().get(0).getValue());
                break;
            }//  w w w.  ja  v  a 2  s .  com
        }
    }
    for (Mutable<ILogicalOperator> inputRef : opRef.getValue().getInputs()) {
        cleanupJoins(inputRef);
    }
}

From source file:edu.uci.ics.hyracks.algebricks.core.algebra.util.OperatorManipulationUtil.java

public static void ntsToEts(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
        throws AlgebricksException {
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    if (op.getOperatorTag() == LogicalOperatorTag.NESTEDTUPLESOURCE) {
        EmptyTupleSourceOperator ets = new EmptyTupleSourceOperator();
        context.computeAndSetTypeEnvironmentForOperator(ets);
        opRef.setValue(ets);
    } else {//  w  w  w.  j a va2  s.co m
        for (Mutable<ILogicalOperator> i : opRef.getValue().getInputs()) {
            ntsToEts(i, context);
        }
    }
}

From source file:edu.uci.ics.asterix.optimizer.rules.LoadRecordFieldsRule.java

/**
 * Pushes one field-access assignment above toPushThroughChildRef
 * /*  w w  w. j av a 2  s .c o  m*/
 * @param toPush
 * @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<ILogicalOperator>(toPushThroughChildRef.getValue()));
    toPushThroughChildRef.setValue(toPush);
    findAndEliminateRedundantFieldAccess(toPush);
}

From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.PushSelectIntoJoinRule.java

private static void copySelectToBranch(SelectOperator select, Mutable<ILogicalOperator> branch,
        IOptimizationContext context) throws AlgebricksException {
    ILogicalOperator newSelect = new SelectOperator(select.getCondition(), select.getRetainNull(),
            select.getNullPlaceholderVariable());
    Mutable<ILogicalOperator> newRef = new MutableObject<ILogicalOperator>(branch.getValue());
    newSelect.getInputs().add(newRef);// w w w.j a  v a  2s. com
    branch.setValue(newSelect);
    context.computeAndSetTypeEnvironmentForOperator(newSelect);
}

From source file:edu.uci.ics.asterix.optimizer.rules.typecast.StaticTypeCastUtil.java

/**
 * Inject a dynamic cast function wrapping an existing expression
 * // w w w.j a va2s. c  om
 * @param funcInfo
 *            the cast function
 * @param reqType
 *            the required type
 * @param inputType
 *            the original type
 * @param exprRef
 *            the expression reference
 * @param argExpr
 *            the original expression
 */
private static void injectCastFunction(IFunctionInfo funcInfo, IAType reqType, IAType inputType,
        Mutable<ILogicalExpression> exprRef, ILogicalExpression argExpr) {
    ScalarFunctionCallExpression cast = new ScalarFunctionCallExpression(funcInfo);
    cast.getArguments().add(new MutableObject<ILogicalExpression>(argExpr));
    exprRef.setValue(cast);
    TypeComputerUtilities.setRequiredAndInputTypes(cast, reqType, inputType);
}

From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.PushSelectDownRule.java

private static boolean propagateSelectionRec(Mutable<ILogicalOperator> sigmaRef,
        Mutable<ILogicalOperator> opRef2) throws AlgebricksException {
    AbstractLogicalOperator op2 = (AbstractLogicalOperator) opRef2.getValue();
    if (op2.getInputs().size() != 1 || op2.getOperatorTag() == LogicalOperatorTag.DATASOURCESCAN) {
        return false;
    }//from w  ww.  ja  v  a 2s .co m

    SelectOperator sigma = (SelectOperator) sigmaRef.getValue();
    LinkedList<LogicalVariable> usedInSigma = new LinkedList<LogicalVariable>();
    sigma.getCondition().getValue().getUsedVariables(usedInSigma);

    LinkedList<LogicalVariable> produced2 = new LinkedList<LogicalVariable>();
    VariableUtilities.getProducedVariables(op2, produced2);
    if (OperatorPropertiesUtil.disjoint(produced2, usedInSigma)) {
        // just swap
        opRef2.setValue(sigma);
        sigmaRef.setValue(op2);
        List<Mutable<ILogicalOperator>> sigmaInpList = sigma.getInputs();
        sigmaInpList.clear();
        sigmaInpList.addAll(op2.getInputs());
        List<Mutable<ILogicalOperator>> op2InpList = op2.getInputs();
        op2InpList.clear();
        op2InpList.add(opRef2);
        propagateSelectionRec(opRef2, sigma.getInputs().get(0));
        return true;

    }
    return false;
}

From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.PushProjectDownRule.java

private static boolean pushAllProjectionsOnTopOf(Collection<LogicalVariable> toPush,
        Mutable<ILogicalOperator> opRef, IOptimizationContext context, ILogicalOperator initialOp)
        throws AlgebricksException {
    if (toPush.isEmpty()) {
        return false;
    }//from  w  w w . j  av  a2s.  c o  m
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();

    if (context.checkAndAddToAlreadyCompared(initialOp, op)) {
        return false;
    }

    switch (op.getOperatorTag()) {
    case EXCHANGE: {
        opRef = opRef.getValue().getInputs().get(0);
        op = (AbstractLogicalOperator) opRef.getValue();
        break;
    }
    case PROJECT: {
        return false;
    }
    }

    ProjectOperator pi2 = new ProjectOperator(new ArrayList<LogicalVariable>(toPush));
    pi2.getInputs().add(new MutableObject<ILogicalOperator>(op));
    opRef.setValue(pi2);
    pi2.setExecutionMode(op.getExecutionMode());
    context.computeAndSetTypeEnvironmentForOperator(pi2);
    return true;
}

From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.EliminateSubplanWithInputCardinalityOneRule.java

@Override
public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
        throws AlgebricksException {
    if (!invoked) {
        rootRef = opRef;/*from   w  w w .  jav a 2s  . c o  m*/
        invoked = true;
    }
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    if (op.getInputs().size() <= 0) {
        return false;
    }
    boolean changed = false;
    for (Mutable<ILogicalOperator> subplanRef : op.getInputs()) {
        AbstractLogicalOperator op1 = (AbstractLogicalOperator) subplanRef.getValue();
        if (op1.getOperatorTag() != LogicalOperatorTag.SUBPLAN) {
            continue;
        }

        SubplanOperator subplan = (SubplanOperator) op1;
        Set<LogicalVariable> usedVarsUp = new ListSet<LogicalVariable>();
        OperatorPropertiesUtil.getFreeVariablesInPath(rootRef.getValue(), subplan, usedVarsUp);
        // TODO(buyingyi): figure out the rewriting for subplan operators with multiple subplans.
        if (subplan.getNestedPlans().size() != 1) {
            continue;
        }

        ILogicalOperator subplanInputOperator = subplan.getInputs().get(0).getValue();
        Set<LogicalVariable> subplanInputVars = new ListSet<LogicalVariable>();
        VariableUtilities.getLiveVariables(subplanInputOperator, subplanInputVars);
        int subplanInputVarSize = subplanInputVars.size();
        subplanInputVars.removeAll(usedVarsUp);
        // Makes sure the free variables are only used in the subplan.
        if (subplanInputVars.size() < subplanInputVarSize) {
            continue;
        }
        Set<LogicalVariable> freeVars = new ListSet<LogicalVariable>();
        OperatorPropertiesUtil.getFreeVariablesInSubplans(subplan, freeVars);
        boolean cardinalityOne = isCardinalityOne(subplan.getInputs().get(0), freeVars);
        if (cardinalityOne) {
            /** If the cardinality of freeVars in the subplan is one, the subplan can be removed. */
            ILogicalPlan plan = subplan.getNestedPlans().get(0);

            List<Mutable<ILogicalOperator>> rootRefs = plan.getRoots();
            // TODO(buyingyi): investigate the case of multi-root plans.
            if (rootRefs.size() != 1) {
                continue;
            }
            Set<Mutable<ILogicalOperator>> ntsSet = new ListSet<Mutable<ILogicalOperator>>();
            findNts(rootRefs.get(0), ntsSet);

            /** Replaces nts with the input operator of the subplan. */
            for (Mutable<ILogicalOperator> nts : ntsSet) {
                nts.setValue(subplanInputOperator);
            }
            subplanRef.setValue(rootRefs.get(0).getValue());
            changed = true;
        } else {
            continue;
        }
    }
    return changed;
}