private static boolean extractComplexExpressions(ILogicalOperator op, List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> exprList, IOptimizationContext context) throws AlgebricksException { return extractComplexExpressions(op, exprList, Pair::getSecond, context); }
public static <T> boolean extractComplexExpressions(ILogicalOperator op, List<T> exprList, Function<T, Mutable<ILogicalExpression>> exprGetter, IOptimizationContext context) throws AlgebricksException { return extractComplexExpressions(op, exprList, exprGetter, t -> false, context); } }
@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 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; } }