@Override public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { // apply it only at the top of the plan ILogicalOperator op = opRef.getValue(); if (context.checkIfInDontApplySet(this, op)) { return false; } Set<LogicalVariable> varSet = new HashSet<LogicalVariable>(); return applyRuleDown(opRef, varSet, context); }
@Override public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { // apply it only at the top of the plan ILogicalOperator op = opRef.getValue(); if (context.checkIfInDontApplySet(this, op)) { return false; } Set<LogicalVariable> varSet = new HashSet<LogicalVariable>(); return applyRuleDown(opRef, varSet, context); }
@Override public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { if (context.checkIfInDontApplySet(this, opRef.getValue())) { return false; } typeOpRec(opRef, context); return true; }
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { ILogicalOperator op = opRef.getValue(); if (context.checkIfInDontApplySet(this, op)) { return false; } return op.acceptExpressionTransform(cfv); }
@Override public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { if (hasRun) { return false; } if (context.checkIfInDontApplySet(this, opRef.getValue())) { return false; } Pair<Boolean, LinkedHashMap<LogicalVariable, LogicalVariable>> result = rewriteSubplanOperator(opRef, context); hasRun = true; return result.first; }
@Override public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (context.checkIfInDontApplySet(this, op)) { return false; } computeDefaultPhysicalOp(op, true, context); context.addToDontApplySet(this, op); return true; }
@Override public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { if (context.checkIfInDontApplySet(this, opRef.getValue())) { return false; } if (checkParameter(opRef, context)) { OperatorPropertiesUtil.typeOpRec(opRef, context); return true; } return false; }
@Override public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { if (context.checkIfInDontApplySet(this, opRef.getValue())) { return false; } clear(); Set<LogicalVariable> accumulatedUsedVarFromRootSet = new HashSet<>(); collectUnusedAssignedVars(opRef, accumulatedUsedVarFromRootSet, true, context); // If there are ASSIGN, UNNEST, AGGREGATE, UNION, and GROUP operators in the plan, // we try to remove these operators if the produced variables from these // operators are not used. if (!assignedVarMap.isEmpty()) { removeUnusedAssigns(opRef, context); } return isTransformed; }
@Override public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); // Begin from the root operator to collect used variables after a possible group-by operator. if (op.getOperatorTag() != LogicalOperatorTag.DISTRIBUTE_RESULT && op.getOperatorTag() != LogicalOperatorTag.SINK) { return false; } if (context.checkIfInDontApplySet(this, op)) { return false; } usedVars.clear(); boolean planTransformed = checkAndApplyTheRule(opRef, context); return planTransformed; }
@Override public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { if (context.checkIfInDontApplySet(this, opRef.getValue())) { return false; } VXQueryOptimizationContext vxqueryContext = (VXQueryOptimizationContext) context; vxqueryContext.incrementTotalDataSources(); context.addToDontApplySet(this, opRef.getValue()); return false; } }
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { if (context.checkIfInDontApplySet(this, opRef.getValue())) { return false; } boolean modified = removeRedundantVariables(opRef, context); if (modified) { context.computeAndSetTypeEnvironmentForOperator(opRef.getValue()); } return modified; }
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { ILogicalOperator op = opRef.getValue(); if (context.checkIfInDontApplySet(this, op)) { return false; } op.accept(visitor, null); context.computeAndSetTypeEnvironmentForOperator(op); context.addToDontApplySet(this, op); return false; }
@Override public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { if (hasRun) { return false; } if (context.checkIfInDontApplySet(this, opRef.getValue())) { return false; } prepare(context); boolean modified = inlineVariables(opRef, context); if (performFinalAction()) { modified = true; } hasRun = true; return modified; }
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op1 = (AbstractLogicalOperator) opRef.getValue(); if (op1.getOperatorTag() != LogicalOperatorTag.ORDER) { return false; } if (context.checkIfInDontApplySet(this, op1)) { return false; } context.addToDontApplySet(this, op1); OrderOperator oo = (OrderOperator) op1; return extractComplexExpressions(oo, oo.getOrderExpressions(), context); }
private boolean checkIfRuleIsApplicable(Mutable<ILogicalOperator> opRef, IOptimizationContext context) { // First check that the operator is a select and its condition is a function call. AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (context.checkIfInDontApplySet(this, op)) { return false; } if (op.getOperatorTag() != LogicalOperatorTag.SELECT) { return false; } ILogicalExpression condExpr = ((SelectOperator) op).getCondition().getValue(); if (condExpr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) { return false; } return true; }
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext ctx) throws AlgebricksException { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (ctx.checkIfInDontApplySet(this, op)) { return false; } ctx.addToDontApplySet(this, op); this.recordVisitor.setOptimizationContext(ctx, op.computeInputTypeEnvironment(ctx)); boolean res = op.acceptExpressionTransform(recordVisitor); if (res) { ctx.computeAndSetTypeEnvironmentForOperator(op); } return res; }
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (op.getOperatorTag() != LogicalOperatorTag.WINDOW) { return false; } if (context.checkIfInDontApplySet(this, op)) { return false; } context.addToDontApplySet(this, op); WindowOperator winOp = (WindowOperator) op; boolean rewritten = ExtractGbyExpressionsRule.extractComplexExpressions(winOp, winOp.getPartitionExpressions(), Function.identity(), context); rewritten |= ExtractOrderExpressionsRule.extractComplexExpressions(winOp, winOp.getOrderExpressions(), context); if (rewritten) { context.computeAndSetTypeEnvironmentForOperator(op); } return rewritten; } }
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (context.checkIfInDontApplySet(this, op)) { return false; } if (op.getOperatorTag() != LogicalOperatorTag.ASSIGN) { return false; } AssignOperator access = (AssignOperator) op; ILogicalExpression expr = getFirstExpr(access); String finalAnnot; if (AnalysisUtil.isAccessToFieldRecord(expr)) { finalAnnot = OperatorAnnotation.PUSHED_FIELD_ACCESS; } else if (AnalysisUtil.isRunnableAccessToFieldRecord(expr)) { finalAnnot = OperatorAnnotation.PUSHED_RUNNABLE_FIELD_ACCESS; } else { return false; } return pushDownFieldAccessRec(opRef, context, finalAnnot); }
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op1 = (AbstractLogicalOperator) opRef.getValue(); if (op1.getOperatorTag() != LogicalOperatorTag.GROUP) { return false; } if (context.checkIfInDontApplySet(this, op1)) { return false; } context.addToDontApplySet(this, op1); GroupByOperator g = (GroupByOperator) op1; boolean r1 = extractComplexExpressions(g, g.getGroupByList(), context); boolean r2 = extractComplexExpressions(g, g.getDecorList(), context); boolean fired = r1 || r2; if (fired) { context.computeAndSetTypeEnvironmentForOperator(g); } return fired; }
@Override public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (context.checkIfInDontApplySet(this, op)) { return false; } // Disable aggregate combiners for nested plans inside window operators if (op.getOperatorTag() == LogicalOperatorTag.WINDOW) { WindowOperator winOp = (WindowOperator) op; if (winOp.hasNestedPlans()) { for (ILogicalPlan plan : winOp.getNestedPlans()) { for (Mutable<ILogicalOperator> root : plan.getRoots()) { ILogicalOperator rootOp = root.getValue(); if (rootOp.getOperatorTag() == LogicalOperatorTag.AGGREGATE) { context.addToDontApplySet(this, rootOp); } } } } } return false; }