/** * Clones the given assign operator changing the returned variables to be new ones. * Also, leaves the inputs of the clone clear. */ private AssignOperator cloneAssignOperator(AssignOperator assignOp, IOptimizationContext context) { List<LogicalVariable> vars = new ArrayList<LogicalVariable>(); List<Mutable<ILogicalExpression>> exprs = new ArrayList<Mutable<ILogicalExpression>>(); int numVars = assignOp.getVariables().size(); for (int i = 0; i < numVars; i++) { vars.add(context.newVar()); exprs.add(new MutableObject<ILogicalExpression>( assignOp.getExpressions().get(i).getValue().cloneExpression())); } AssignOperator assignCloneOp = new AssignOperator(vars, exprs); assignCloneOp.setSourceLocation(assignOp.getSourceLocation()); assignCloneOp.setExecutionMode(assignOp.getExecutionMode()); return assignCloneOp; } }
AssignOperator newAssign = new AssignOperator(assignVars, assignExprs); newAssign.getInputs().add(new MutableObject<ILogicalOperator>(joinInputOp)); newAssign.setExecutionMode(joinOp.getExecutionMode()); joinOp.getInputs().get(inputIndex).setValue(newAssign); context.computeAndSetTypeEnvironmentForOperator(newAssign);
assignOp.setExecutionMode(branchOp.getExecutionMode()); assignOp.getInputs().add(new MutableObject<>(branchOp)); branchOpRef.setValue(assignOp);
constAssignOp.setExecutionMode(ExecutionMode.PARTITIONED); context.computeAndSetTypeEnvironmentForOperator(constAssignOp); currentOp = constAssignOp; origVarsToLeftPathVarsAssignOp.getInputs().add(new MutableObject<ILogicalOperator>(splitOp)); context.computeAndSetTypeEnvironmentForOperator(origVarsToLeftPathVarsAssignOp); origVarsToLeftPathVarsAssignOp.setExecutionMode(ExecutionMode.PARTITIONED); skVarAssignOpInRightPath.setExecutionMode(ExecutionMode.PARTITIONED); context.computeAndSetTypeEnvironmentForOperator(skVarAssignOpInRightPath); currentTopOpInRightPath = skVarAssignOpInRightPath; constAssignOp.getInputs().clear(); constAssignOp.getInputs().add(new MutableObject<ILogicalOperator>(unionAllOp)); constAssignOp.setExecutionMode(ExecutionMode.PARTITIONED); context.computeAndSetTypeEnvironmentForOperator(constAssignOp);
private boolean assignCommonExpression(ExprEquivalenceClass exprEqClass, ILogicalExpression expr) throws AlgebricksException { SourceLocation sourceLoc = expr.getSourceLocation(); AbstractLogicalOperator firstOp = (AbstractLogicalOperator) exprEqClass.getFirstOperator(); Mutable<ILogicalExpression> firstExprRef = exprEqClass.getFirstExpression(); // We don't consider to eliminate common exprs in join operators by doing a cartesian production // and pulling the condition in to a select. This will negatively impact the performance. if (firstOp.getInputs().size() > 1) { // Bail for any non-join operator with multiple inputs. return false; } LogicalVariable newVar = context.newVar(); AssignOperator newAssign = new AssignOperator(newVar, new MutableObject<ILogicalExpression>(firstExprRef.getValue().cloneExpression())); newAssign.setSourceLocation(sourceLoc); // Place assign below firstOp. newAssign.getInputs().add(new MutableObject<ILogicalOperator>(firstOp.getInputs().get(0).getValue())); newAssign.setExecutionMode(firstOp.getExecutionMode()); firstOp.getInputs().get(0).setValue(newAssign); // Replace original expr with variable reference, and set var in expression equivalence class. VariableReferenceExpression newVarRef = new VariableReferenceExpression(newVar); newVarRef.setSourceLocation(sourceLoc); firstExprRef.setValue(newVarRef); exprEqClass.setVariable(newVar); context.computeAndSetTypeEnvironmentForOperator(newAssign); context.computeAndSetTypeEnvironmentForOperator(firstOp); return true; }
AssignOperator newAssign = new AssignOperator(newVar, new MutableObject<ILogicalExpression>(exprRef .getValue().cloneExpression())); newAssign.setExecutionMode(joinOp.getExecutionMode());
new AssignOperator(newAssignVar, new MutableObject<ILogicalExpression>(cast)); newAssignOperator.setSourceLocation(sourceLoc); newAssignOperator.setExecutionMode(op.getExecutionMode()); newAssignOperator.getInputs().add(new MutableObject<ILogicalOperator>(op)); opRef.setValue(newAssignOperator);
new MutableObject<ILogicalExpression>(exprRef.getValue().cloneExpression())); newAssign.setSourceLocation(exprRefSourceLoc); newAssign.setExecutionMode(joinOp.getExecutionMode());
@Test public void noBlockingPlan() throws AlgebricksException { EmptyTupleSourceOperator ets = new EmptyTupleSourceOperator(); ets.setExecutionMode(UNPARTITIONED); AssignOperator assignOperator = new AssignOperator(Collections.emptyList(), null); assignOperator.setExecutionMode(UNPARTITIONED); assignOperator.getInputs().add(new MutableObject<>(ets)); ExchangeOperator exchange = new ExchangeOperator(); exchange.setExecutionMode(UNPARTITIONED); exchange.setPhysicalOperator(new OneToOneExchangePOperator()); exchange.getInputs().add(new MutableObject<>(assignOperator)); DistributeResultOperator resultOperator = new DistributeResultOperator(null, null); resultOperator.setExecutionMode(UNPARTITIONED); resultOperator.getInputs().add(new MutableObject<>(exchange)); ALogicalPlanImpl plan = new ALogicalPlanImpl(Collections.singletonList(new MutableObject(resultOperator))); List<PlanStage> stages = ResourceUtils.getStages(plan); // ensure a single stage plan final int expectedStages = 1; Assert.assertEquals(expectedStages, stages.size()); validateStages(stages, resultOperator, exchange, ets, assignOperator); // frame size for every operator final long expectedMemory = stages.get(0).getOperators().size() * FRAME_SIZE; assertRequiredMemory(stages, expectedMemory); }
assignSearchKeys.setExecutionMode(dataSourceOp.getExecutionMode()); } else { assignSearchKeys.setExecutionMode(probeSubTree.getRootRef().getValue().getExecutionMode());
assignSearchKeys.getInputs().add( new MutableObject<>(OperatorManipulationUtil.deepCopy(dataSourceOp.getInputs().get(0).getValue()))); assignSearchKeys.setExecutionMode(dataSourceOp.getExecutionMode()); } else { assignSearchKeys.setExecutionMode(dataSourceOp.getExecutionMode()); OperatorPropertiesUtil.typeOpRec(probeSubTree.getRootRef(), context);