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:edu.uci.ics.hyracks.algebricks.core.algebra.util.OperatorManipulationUtil.java

public static void substituteVarRec(AbstractLogicalOperator op, LogicalVariable v1, LogicalVariable v2,
        boolean goThroughNts, ITypingContext ctx) throws AlgebricksException {
    VariableUtilities.substituteVariables(op, v1, v2, goThroughNts, ctx);
    for (Mutable<ILogicalOperator> opRef2 : op.getInputs()) {
        substituteVarRec((AbstractLogicalOperator) opRef2.getValue(), v1, v2, goThroughNts, ctx);
    }//  w  w w.  j av a  2 s .  c  om
    if (op.getOperatorTag() == LogicalOperatorTag.NESTEDTUPLESOURCE && goThroughNts) {
        NestedTupleSourceOperator nts = (NestedTupleSourceOperator) op;
        if (nts.getDataSourceReference() != null) {
            AbstractLogicalOperator op2 = (AbstractLogicalOperator) nts.getDataSourceReference().getValue()
                    .getInputs().get(0).getValue();
            substituteVarRec(op2, v1, v2, goThroughNts, ctx);
        }
    }
    if (op.hasNestedPlans()) {
        AbstractOperatorWithNestedPlans aonp = (AbstractOperatorWithNestedPlans) op;
        for (ILogicalPlan p : aonp.getNestedPlans()) {
            for (Mutable<ILogicalOperator> ref : p.getRoots()) {
                AbstractLogicalOperator aop = (AbstractLogicalOperator) ref.getValue();
                substituteVarRec(aop, v1, v2, goThroughNts, ctx);
            }
        }
    }
}

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

private static List<Mutable<ILogicalOperator>> clonePipeline(List<Mutable<ILogicalOperator>> roots)
        throws AlgebricksException {
    List<Mutable<ILogicalOperator>> newRoots = new ArrayList<Mutable<ILogicalOperator>>();
    for (Mutable<ILogicalOperator> opRef : roots) {
        newRoots.add(new MutableObject<ILogicalOperator>(bottomUpCopyOperators(opRef.getValue())));
    }/* w w  w .  ja va  2s.  com*/
    return newRoots;
}

From source file:edu.uci.ics.hyracks.algebricks.rewriter.util.JoinUtils.java

private static boolean isHashJoinCondition(ILogicalExpression e, Collection<LogicalVariable> inLeftAll,
        Collection<LogicalVariable> inRightAll, Collection<LogicalVariable> outLeftFields,
        Collection<LogicalVariable> outRightFields) {
    switch (e.getExpressionTag()) {
    case FUNCTION_CALL: {
        AbstractFunctionCallExpression fexp = (AbstractFunctionCallExpression) e;
        FunctionIdentifier fi = fexp.getFunctionIdentifier();
        if (fi.equals(AlgebricksBuiltinFunctions.AND)) {
            for (Mutable<ILogicalExpression> a : fexp.getArguments()) {
                if (!isHashJoinCondition(a.getValue(), inLeftAll, inRightAll, outLeftFields, outRightFields)) {
                    return false;
                }/*w ww.j  a va 2  s  .  co m*/
            }
            return true;
        } else {
            ComparisonKind ck = AlgebricksBuiltinFunctions.getComparisonType(fi);
            if (ck != ComparisonKind.EQ) {
                return false;
            }
            ILogicalExpression opLeft = fexp.getArguments().get(0).getValue();
            ILogicalExpression opRight = fexp.getArguments().get(1).getValue();
            if (opLeft.getExpressionTag() != LogicalExpressionTag.VARIABLE
                    || opRight.getExpressionTag() != LogicalExpressionTag.VARIABLE) {
                return false;
            }
            LogicalVariable var1 = ((VariableReferenceExpression) opLeft).getVariableReference();
            if (inLeftAll.contains(var1) && !outLeftFields.contains(var1)) {
                outLeftFields.add(var1);
            } else if (inRightAll.contains(var1) && !outRightFields.contains(var1)) {
                outRightFields.add(var1);
            } else {
                return false;
            }
            LogicalVariable var2 = ((VariableReferenceExpression) opRight).getVariableReference();
            if (inLeftAll.contains(var2) && !outLeftFields.contains(var2)) {
                outLeftFields.add(var2);
            } else if (inRightAll.contains(var2) && !outRightFields.contains(var2)) {
                outRightFields.add(var2);
            } else {
                return false;
            }
            return true;
        }
    }
    default: {
        return false;
    }
    }
}

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

private static void cloneTypeEnvironments(IOptimizationContext ctx, List<Mutable<ILogicalOperator>> roots,
        List<Mutable<ILogicalOperator>> newRoots) {
    for (int i = 0; i < newRoots.size(); i++) {
        Mutable<ILogicalOperator> opRef = newRoots.get(i);
        Mutable<ILogicalOperator> oldOpRef = roots.get(i);
        while (opRef.getValue().getInputs().size() > 0) {
            ctx.setOutputTypeEnvironment(opRef.getValue(), ctx.getOutputTypeEnvironment(oldOpRef.getValue()));
            opRef = opRef.getValue().getInputs().get(0);
            oldOpRef = oldOpRef.getValue().getInputs().get(0);
        }/*w ww .j  a v  a  2 s. c o m*/
        ctx.setOutputTypeEnvironment(opRef.getValue(), ctx.getOutputTypeEnvironment(oldOpRef.getValue()));
    }
}

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

public static ILogicalOperator bottomUpCopyOperators(ILogicalOperator op) throws AlgebricksException {
    ILogicalOperator newOp = deepCopy(op);
    newOp.getInputs().clear();/*from   www  . jav a  2 s.  c  o m*/
    for (Mutable<ILogicalOperator> child : op.getInputs())
        newOp.getInputs().add(new MutableObject<ILogicalOperator>(bottomUpCopyOperators(child.getValue())));
    return newOp;
}

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);//from   www.ja  v  a  2s . com
    } else {
        for (Mutable<ILogicalOperator> i : opRef.getValue().getInputs()) {
            ntsToEts(i, 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);//w  w  w .j  av  a2s.  co m
    // e.recomputeSchema();
    OperatorPropertiesUtil.computeSchemaAndPropertiesRecIfNull(e, context);
    ExecutionMode em = ((AbstractLogicalOperator) inOp).getExecutionMode();
    e.setExecutionMode(em);
    e.computeDeliveredPhysicalProperties(context);
    context.computeAndSetTypeEnvironmentForOperator(e);
}

From source file:edu.uci.ics.hyracks.algebricks.core.algebra.prettyprint.PlanPlotter.java

public static void printVisualizationGraph(AbstractLogicalOperator op, int indent, StringBuilder out,
        String current_supernode_name, int randomInt) {
    if (!op.getInputs().isEmpty()) {
        //String stringToVisualize = op.toStringForVisualizationGraph();
        String stringToVisualize = op.getOperatorTag().name();
        int firstOccurenceOf_ = stringToVisualize.indexOf("_");
        String supernode_current = stringToVisualize.substring(firstOccurenceOf_ + 1,
                stringToVisualize.length());
        if (current_supernode_name.isEmpty()) {
            current_supernode_name = supernode_current;
            appendln(out, new String("subgraph cluster_" + supernode_current + " {"));
            pad(out, indent);/*  w ww  . j  av  a  2s. c o m*/
            appendln(out, new String("node [style=filled, color = lightgray];"));
            pad(out, indent);
            appendln(out, new String("color=blue;"));
            pad(out, indent);
            String op_id = op.toString().substring(op.toString().indexOf("@") + 1, op.toString().length());
            appendln(out, new String("label = \"" + supernode_current + "ID" + op_id + "\";"));
            pad(out, indent);
        }

        for (Mutable<ILogicalOperator> i : op.getInputs()) {
            String op_id = i.toString().substring(i.toString().indexOf("@") + 1, i.toString().length());
            String logOpStr = ((AbstractLogicalOperator) i.getValue()).getOperatorTag().name() + "ID" + op_id;
            firstOccurenceOf_ = logOpStr.indexOf("_");
            String supernode_child = logOpStr.substring(firstOccurenceOf_ + 1, logOpStr.length());
            if (!supernode_current.equals(supernode_child)) {
                appendln(out, new String("node [style=filled, color = lightgray];"));
                pad(out, indent);
                appendln(out, new String("color=blue"));
                pad(out, indent);
                appendln(out, new String("label = \"" + supernode_child + "\";"));
                pad(out, indent);
            }

            op_id = op.toString().substring(op.toString().indexOf("@") + 1, op.toString().length());
            appendln(out, stringToVisualize + "ID" + op_id + "[style = filled]");
            AbstractLogicalOperator child = (AbstractLogicalOperator) i.getValue();

            pad(out, indent);
            String op_id1 = op.toString().substring(op.toString().indexOf("@") + 1, op.toString().length());
            append(out, op.getOperatorTag().name() + "ID" + op_id1 + " -> ");
            String opc_id = child.toString().substring(child.toString().indexOf("@") + 1,
                    child.toString().length());
            appendln(out, child.getOperatorTag().name() + "ID" + opc_id);

            printVisualizationGraph(child, indent, out, supernode_current,
                    (randomGenerator.nextInt(100) + 10000));

        }
    }

}

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.  j  a va  2 s.co  m*/
            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.asterix.optimizer.rules.SetAsterixPhysicalOperatorsRule.java

private static void setPhysicalOperators(ILogicalPlan plan, IOptimizationContext context)
        throws AlgebricksException {
    for (Mutable<ILogicalOperator> root : plan.getRoots()) {
        computeDefaultPhysicalOp((AbstractLogicalOperator) root.getValue(), context);
    }//from   w  ww .  ja  v a2  s .  c o m
}