Fix for ASTERIXDB-1291: deals with the case that a NTS' data source operator has been deep copied.
Change-Id: Ie3efa74e38bbfa9eee4a20e4a9cf6fc2a5840973
Reviewed-on: https://asterix-gerrit.ics.uci.edu/622
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Wenhai Li <lwhaymail@yahoo.com>
Reviewed-by: Taewoo Kim <wangsaeu@gmail.com>
diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/visitors/LogicalOperatorDeepCopyWithNewVariablesVisitor.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/visitors/LogicalOperatorDeepCopyWithNewVariablesVisitor.java
index 2a92ead..b3f6639 100644
--- a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/visitors/LogicalOperatorDeepCopyWithNewVariablesVisitor.java
+++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/visitors/LogicalOperatorDeepCopyWithNewVariablesVisitor.java
@@ -117,7 +117,12 @@
dest.getAnnotations().putAll(src.getAnnotations());
}
- public ILogicalOperator deepCopy(ILogicalOperator op, ILogicalOperator arg) throws AlgebricksException {
+ public ILogicalOperator deepCopy(ILogicalOperator op) throws AlgebricksException {
+ // The deep copy call outside this visitor always has a null argument.
+ return deepCopy(op, null);
+ }
+
+ private ILogicalOperator deepCopy(ILogicalOperator op, ILogicalOperator arg) throws AlgebricksException {
ILogicalOperator opCopy = op.accept(this, arg);
OperatorManipulationUtil.computeTypeEnvironmentBottomUp(opCopy, context);
return opCopy;
@@ -308,8 +313,8 @@
List<ILogicalPlan> nestedPlansCopy = new ArrayList<ILogicalPlan>();
GroupByOperator opCopy = new GroupByOperator(groupByListCopy, decorListCopy, nestedPlansCopy);
- deepCopyPlanList(op.getNestedPlans(), nestedPlansCopy, opCopy);
deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy);
+ deepCopyPlanList(op.getNestedPlans(), nestedPlansCopy, opCopy);
return opCopy;
}
@@ -348,7 +353,9 @@
@Override
public ILogicalOperator visitNestedTupleSourceOperator(NestedTupleSourceOperator op, ILogicalOperator arg)
throws AlgebricksException {
- NestedTupleSourceOperator opCopy = new NestedTupleSourceOperator(op.getDataSourceReference());
+ Mutable<ILogicalOperator> dataSourceReference = arg == null ? op.getDataSourceReference()
+ : new MutableObject<ILogicalOperator>(arg);
+ NestedTupleSourceOperator opCopy = new NestedTupleSourceOperator(dataSourceReference);
deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy);
return opCopy;
}
@@ -423,8 +430,8 @@
public ILogicalOperator visitSubplanOperator(SubplanOperator op, ILogicalOperator arg) throws AlgebricksException {
List<ILogicalPlan> nestedPlansCopy = new ArrayList<ILogicalPlan>();
SubplanOperator opCopy = new SubplanOperator(nestedPlansCopy);
- deepCopyPlanList(op.getNestedPlans(), nestedPlansCopy, opCopy);
deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy);
+ deepCopyPlanList(op.getNestedPlans(), nestedPlansCopy, opCopy);
return opCopy;
}