Cloning utility functions for new logical plan ----------------------------------------------
Key: PIG-1587 URL: https://issues.apache.org/jira/browse/PIG-1587 Project: Pig Issue Type: Improvement Components: impl Affects Versions: 0.8.0 Reporter: Daniel Dai Fix For: 0.9.0 We sometimes need to copy a logical operator/plan when writing an optimization rule. Currently copy an operator/plan is awkward. We need to write some utilities to facilitate this process. Swati contribute PIG-1510 but we feel it still cannot address most use cases. I propose to add some more utilities into new logical plan: all LogicalExpressions: {code} copy(LogicalExpressionPlan newPlan, boolean keepUid); {code} * Do a shallow copy of the logical expression operator (except for fieldSchema, uidOnlySchema, ProjectExpression.attachedRelationalOp) * Set the plan to newPlan * If keepUid is true, further copy uidOnlyFieldSchema all LogicalRelationalOperators: {code} copy(LogicalPlan newPlan, boolean keepUid); {code} * Do a shallow copy of the logical relational operator (except for schema, uid related fields) * Set the plan to newPlan; * If the operator have inner plan/expression plan, copy the whole inner plan with the same keepUid flag (Especially, LOInnerLoad will copy its inner project, with the same keepUid flag) * If keepUid is true, further copy uid related fields (LOUnion.uidMapping, LOCogroup.groupKeyUidOnlySchema, LOCogroup.generatedInputUids) LogicalExpressionPlan.java {code} LogicalExpressionPlan copy(LogicalRelationalOperator attachedRelationalOp, boolean keepUid); {code} * Copy expression operator along with connection with the same keepUid flag * Set all ProjectExpression.attachedRelationalOp to attachedRelationalOp parameter {code} List<Operator> merge(LogicalExpressionPlan plan); {code} * Merge plan into the current logical expression plan as an independent tree * return the sources of this independent tree LogicalPlan.java {code} LogicalPlan copy(boolean keepUid); {code} * Main use case to copy inner plan of ForEach * Copy all relational operator along with connection * Copy all expression plans inside relational operator, set plan and attachedRelationalOp properly {code} List<Operator> merge(LogicalPlan plan); {code} * Merge plan into the current logical plan as an independent tree * return the sources of this independent tree -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.