@Override public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { if (hasRun) { return false; } hasRun = true; // Collect all used variables after each operator, including the used variables in itself in the plan. // This is necessary since introduceProjects() may generate a wrong project if it doesn't have the information // for all paths in the plan in case there are two or more branches since it can only deal one path at a time. // So, a variable used in one path might be removed while the method traverses another path. Set<LogicalVariable> parentUsedVars = new LinkedHashSet<>(); collectUsedVars(opRef, parentUsedVars); // Introduce projects return introduceProjects(null, -1, opRef, Collections.<LogicalVariable> emptySet(), context); }
if (introduceProjects(op, i, inputOpRef, parentsUsedVars, context)) { modified = true;