List of usage examples for org.apache.commons.lang3.mutable Mutable getValue
T getValue();
From source file:org.apache.hyracks.algebricks.core.algebra.prettyprint.PlanPrettyPrinter.java
public static void printPhysicalOps(ILogicalPlan plan, AlgebricksAppendable out, int indent) throws AlgebricksException { for (Mutable<ILogicalOperator> root : plan.getRoots()) { printPhysicalOperator((AbstractLogicalOperator) root.getValue(), indent, out); }// ww w. jav a 2 s. c o m }
From source file:org.apache.hyracks.algebricks.core.algebra.prettyprint.PlanPrettyPrinter.java
public static void printOperator(AbstractLogicalOperator op, LogicalOperatorPrettyPrintVisitor pvisitor, int indent) throws AlgebricksException { final AlgebricksAppendable out = pvisitor.get(); op.accept(pvisitor, indent);//from w ww . j av a2 s .co m IPhysicalOperator pOp = op.getPhysicalOperator(); if (pOp != null) { out.append("\n"); pad(out, indent); appendln(out, "-- " + pOp.toString() + " |" + op.getExecutionMode() + "|"); } else { appendln(out, " -- |" + op.getExecutionMode() + "|"); } for (Mutable<ILogicalOperator> i : op.getInputs()) { printOperator((AbstractLogicalOperator) i.getValue(), pvisitor, indent + 2); } }
From source file:org.apache.hyracks.algebricks.core.algebra.prettyprint.PlanPrettyPrinter.java
private static void printPhysicalOperator(AbstractLogicalOperator op, int indent, AlgebricksAppendable out) throws AlgebricksException { IPhysicalOperator pOp = op.getPhysicalOperator(); pad(out, indent);/*from w w w . j av a 2s .c om*/ appendln(out, "-- " + pOp.toString() + " |" + op.getExecutionMode() + "|"); if (op.hasNestedPlans()) { AbstractOperatorWithNestedPlans opNest = (AbstractOperatorWithNestedPlans) op; for (ILogicalPlan p : opNest.getNestedPlans()) { pad(out, indent + 8); appendln(out, "{"); printPhysicalOps(p, out, indent + 10); pad(out, indent + 8); appendln(out, "}"); } } for (Mutable<ILogicalOperator> i : op.getInputs()) { printPhysicalOperator((AbstractLogicalOperator) i.getValue(), indent + 2, out); } }
From source file:org.apache.hyracks.algebricks.core.algebra.util.OperatorManipulationUtil.java
public static boolean setOperatorMode(AbstractLogicalOperator op) { AbstractLogicalOperator.ExecutionMode oldMode = op.getExecutionMode(); switch (op.getOperatorTag()) { case DATASOURCESCAN: { op.setExecutionMode(AbstractLogicalOperator.ExecutionMode.PARTITIONED); AbstractLogicalOperator currentOp = op; while (currentOp.getInputs().size() == 1) { AbstractLogicalOperator child = (AbstractLogicalOperator) currentOp.getInputs().get(0).getValue(); // Empty tuple source is a special case that can be partitioned in the same way as the data scan. if (child.getOperatorTag() != LogicalOperatorTag.EMPTYTUPLESOURCE) { break; }/*from w w w . j a v a 2 s . c o m*/ child.setExecutionMode(AbstractLogicalOperator.ExecutionMode.PARTITIONED); currentOp = child; } break; } case NESTEDTUPLESOURCE: { NestedTupleSourceOperator nts = (NestedTupleSourceOperator) op; AbstractLogicalOperator prevOp = (AbstractLogicalOperator) nts.getDataSourceReference().getValue() .getInputs().get(0).getValue(); if (prevOp.getExecutionMode() != AbstractLogicalOperator.ExecutionMode.UNPARTITIONED) { nts.setExecutionMode(AbstractLogicalOperator.ExecutionMode.LOCAL); } break; } default: { boolean forceUnpartitioned = false; if (op.getOperatorTag() == LogicalOperatorTag.LIMIT) { LimitOperator opLim = (LimitOperator) op; if (opLim.isTopmostLimitOp()) { opLim.setExecutionMode(AbstractLogicalOperator.ExecutionMode.UNPARTITIONED); forceUnpartitioned = true; } } if (op.getOperatorTag() == LogicalOperatorTag.AGGREGATE) { AggregateOperator aggOp = (AggregateOperator) op; if (aggOp.isGlobal()) { op.setExecutionMode(AbstractLogicalOperator.ExecutionMode.UNPARTITIONED); forceUnpartitioned = true; } } if (op.getOperatorTag() == LogicalOperatorTag.GROUP) { GroupByOperator gbyOp = (GroupByOperator) op; if (gbyOp.isGroupAll() && gbyOp.isGlobal()) { op.setExecutionMode(AbstractLogicalOperator.ExecutionMode.UNPARTITIONED); forceUnpartitioned = true; } } for (Mutable<ILogicalOperator> i : op.getInputs()) { boolean exit = false; AbstractLogicalOperator inputOp = (AbstractLogicalOperator) i.getValue(); switch (inputOp.getExecutionMode()) { case PARTITIONED: { if (forceUnpartitioned) { break; } op.setExecutionMode(AbstractLogicalOperator.ExecutionMode.PARTITIONED); exit = true; break; } case LOCAL: { op.setExecutionMode(AbstractLogicalOperator.ExecutionMode.LOCAL); break; } } if (exit) { break; } } break; } } return oldMode != op.getExecutionMode(); }
From source file:org.apache.hyracks.algebricks.core.algebra.util.OperatorManipulationUtil.java
private static void setDataSource(Mutable<ILogicalOperator> opRef, ILogicalOperator dataSource) { ILogicalOperator op = opRef.getValue(); if (op.getOperatorTag() == LogicalOperatorTag.NESTEDTUPLESOURCE) { NestedTupleSourceOperator nts = (NestedTupleSourceOperator) op; nts.setDataSourceReference(new MutableObject<ILogicalOperator>(dataSource)); }/*from w w w . j a va2s .c om*/ for (Mutable<ILogicalOperator> childRef : op.getInputs()) { setDataSource(childRef, dataSource); } }
From source file:org.apache.hyracks.algebricks.core.algebra.util.OperatorManipulationUtil.java
public static ILogicalOperator bottomUpCopyOperators(ILogicalOperator op) throws AlgebricksException { ILogicalOperator newOp = deepCopy(op); newOp.getInputs().clear();/*www . j ava 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:org.apache.hyracks.algebricks.core.algebra.util.OperatorManipulationUtil.java
/** * Compute type environment of a newly generated operator {@code op} and its input. * * @param op,/* w ww.j a v a 2s .c o m*/ * the logical operator. * @param context,the * optimization context. * @throws AlgebricksException */ public static void computeTypeEnvironmentBottomUp(ILogicalOperator op, ITypingContext context) throws AlgebricksException { for (Mutable<ILogicalOperator> children : op.getInputs()) { computeTypeEnvironmentBottomUp(children.getValue(), context); } AbstractLogicalOperator abstractOp = (AbstractLogicalOperator) op; if (abstractOp.hasNestedPlans()) { for (ILogicalPlan p : ((AbstractOperatorWithNestedPlans) op).getNestedPlans()) { for (Mutable<ILogicalOperator> rootRef : p.getRoots()) { computeTypeEnvironmentBottomUp(rootRef.getValue(), context); } } } context.computeAndSetTypeEnvironmentForOperator(op); }
From source file:org.apache.hyracks.algebricks.core.algebra.util.OperatorManipulationUtil.java
/** * Computes the type environment for a logical query plan. * * @param plan,//from w ww.j a v a2 s . c o m * the logical plan to consider. * @param context * the typing context. * @throws AlgebricksException */ public static void computeTypeEnvironment(ILogicalPlan plan, ITypingContext context) throws AlgebricksException { for (Mutable<ILogicalOperator> rootRef : plan.getRoots()) { computeTypeEnvironmentBottomUp(rootRef.getValue(), context); } }
From source file:org.apache.hyracks.algebricks.core.algebra.util.OperatorManipulationUtil.java
/*** * Is the operator <code>>op</code> an ancestor of any operators with tags in the set <code>tags</code>? * * @param op/*from w w w. j av a 2 s.c o m*/ * @param tags * @return True if yes; false other wise. */ public static boolean ancestorOfOperators(ILogicalOperator op, Set<LogicalOperatorTag> tags) { LogicalOperatorTag opTag = op.getOperatorTag(); if (tags.contains(opTag)) { return true; } for (Mutable<ILogicalOperator> children : op.getInputs()) { if (ancestorOfOperators(children.getValue(), tags)) { return true; } } return false; }