Author: daijy
Date: Mon Aug 23 22:04:50 2010
New Revision: 988334

URL: http://svn.apache.org/viewvc?rev=988334&view=rev
Log:
PIG-1510: Add  for LogicalExpressions (swati.j via daijy)

Modified:
    hadoop/pig/trunk/CHANGES.txt
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/AddExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/AndExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/BinCondExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/CastExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ConstantExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/DereferenceExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/DivideExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/EqualExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/GreaterThanEqualExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/GreaterThanExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/IsNullExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LessThanEqualExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LessThanExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LogicalExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/MapLookupExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ModExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/MultiplyExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NegativeExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NotEqualExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NotExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/OrExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ProjectExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/RegexExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/SubtractExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/UnaryExpression.java
    
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/UserFuncExpression.java

Modified: hadoop/pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Mon Aug 23 22:04:50 2010
@@ -26,6 +26,8 @@ PIG-1249: Safe-guards against misconfigu
 
 IMPROVEMENTS
 
+PIG-1510: Add `deepCopy` for LogicalExpressions (swati.j via daijy)
+
 PIG-1447: Tune memory usage of InternalCachedBag (thejas)
 
 PIG-1505: support jars and scripts in dfs (anhi via rding)

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/AddExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/AddExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/AddExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/AddExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
 import org.apache.pig.newplan.OperatorPlan;
@@ -71,4 +73,13 @@ public class AddExpression extends Binar
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new AddExpression(
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan) );
+        return copy;
+    }
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/AndExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/AndExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/AndExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/AndExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
@@ -72,4 +74,13 @@ public class AndExpression extends Binar
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new AndExpression(
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan) );
+        return copy;
+    }
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/BinCondExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/BinCondExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/BinCondExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/BinCondExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
 import org.apache.pig.newplan.OperatorPlan;
@@ -101,4 +103,14 @@ public class BinCondExpression extends L
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+  
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new BinCondExpression(
+                lgExpPlan,
+                this.getCondition().deepCopy(lgExpPlan),
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan) );
+        return copy;
+    }
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/CastExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/CastExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/CastExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/CastExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.FuncSpec;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
@@ -62,7 +64,7 @@ public class CastExpression extends Unar
     public boolean isEqual(Operator other) throws FrontendException {
         if (other != null && other instanceof CastExpression) { 
             CastExpression of = (CastExpression)other;
-            return plan.isEqual(of.plan) && getExpression().isEqual( 
of.getExpression() );
+            return getExpression().isEqual( of.getExpression() );
         } else {
             return false;
         }
@@ -82,4 +84,22 @@ public class CastExpression extends Unar
         }
         return fieldSchema;
     }
+
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new CastExpression(
+                lgExpPlan,
+                this.getExpression().deepCopy(lgExpPlan),
+                this.getFieldSchema().deepCopy());
+        try {
+            FuncSpec origFuncSpec = this.getFuncSpec();
+            if (origFuncSpec != null ) {
+                ((CastExpression)copy).setFuncSpec(origFuncSpec.clone());
+            }
+        } catch(CloneNotSupportedException e) {
+            e.printStackTrace(); 
+        }
+        return copy;
+    }
+
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ConstantExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ConstantExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ConstantExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ConstantExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
 import org.apache.pig.newplan.OperatorPlan;
@@ -91,5 +93,14 @@ public class ConstantExpression extends 
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
-
+ 
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException{
+        LogicalExpression copy = new ConstantExpression( 
+                lgExpPlan,
+                this.getValue(),
+                this.getFieldSchema().deepCopy() );
+        return copy;
+    }
+ 
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/DereferenceExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/DereferenceExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/DereferenceExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/DereferenceExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,7 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -154,4 +155,14 @@ public class DereferenceExpression exten
         }
         return fieldSchema;
     }
+
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        List<Integer> columnsCopy = new 
ArrayList<Integer>(this.getBagColumns());
+        LogicalExpression copy = new DereferenceExpression(
+                lgExpPlan,
+                columnsCopy);
+        return copy;
+    }
+
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/DivideExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/DivideExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/DivideExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/DivideExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
 import org.apache.pig.newplan.OperatorPlan;
@@ -71,4 +73,14 @@ public class DivideExpression extends Bi
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+ 
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new DivideExpression( 
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan));
+        return copy;
+    }
+ 
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/EqualExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/EqualExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/EqualExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/EqualExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
@@ -74,4 +76,14 @@ public class EqualExpression extends Bin
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+ 
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new EqualExpression( 
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan));
+        return copy;
+    }
+ 
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/GreaterThanEqualExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/GreaterThanEqualExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/GreaterThanEqualExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/GreaterThanEqualExpression.java
 Mon Aug 23 22:04:50 2010
@@ -17,6 +17,8 @@
  */
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
@@ -68,4 +70,14 @@ public class GreaterThanEqualExpression 
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new GreaterThanEqualExpression( 
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan));
+        return copy;
+    }
+ 
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/GreaterThanExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/GreaterThanExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/GreaterThanExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/GreaterThanExpression.java
 Mon Aug 23 22:04:50 2010
@@ -17,6 +17,8 @@
  */
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
@@ -68,4 +70,14 @@ public class GreaterThanExpression exten
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+ 
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException{
+        LogicalExpression copy = new GreaterThanExpression( 
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan));
+        return copy;
+    }
+ 
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/IsNullExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/IsNullExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/IsNullExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/IsNullExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
@@ -43,7 +45,7 @@ public class IsNullExpression extends Un
     public boolean isEqual(Operator other) throws FrontendException {
         if (other != null && other instanceof IsNullExpression) { 
             IsNullExpression of = (IsNullExpression)other;
-            return plan.isEqual(of.plan) && getExpression().isEqual( 
of.getExpression() );
+            return getExpression().isEqual( of.getExpression() );
         } else {
             return false;
         }
@@ -57,5 +59,13 @@ public class IsNullExpression extends Un
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
-
+ 
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException{
+        LogicalExpression copy = new IsNullExpression ( 
+                lgExpPlan,
+                this.getExpression().deepCopy(lgExpPlan));
+        return copy;
+    }
+ 
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LessThanEqualExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LessThanEqualExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LessThanEqualExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LessThanEqualExpression.java
 Mon Aug 23 22:04:50 2010
@@ -17,6 +17,8 @@
  */
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
@@ -68,4 +70,14 @@ public class LessThanEqualExpression ext
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+ 
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException{
+        LogicalExpression copy = new LessThanEqualExpression(
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan));
+        return copy;
+    }
+ 
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LessThanExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LessThanExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LessThanExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LessThanExpression.java
 Mon Aug 23 22:04:50 2010
@@ -17,6 +17,8 @@
  */
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
@@ -68,4 +70,14 @@ public class LessThanExpression extends 
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+ 
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException{
+        LogicalExpression copy = new LessThanExpression(
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan));
+        return copy;
+    }
+ 
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LogicalExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LogicalExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LogicalExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/LogicalExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
@@ -98,4 +100,15 @@ public abstract class LogicalExpression 
         fieldSchema = fs;
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
     }
+
+    /**
+     * Create the deep copy of this expression and add that into the passed
+     * LogicalExpressionPlan Return the copy of this expression with updated
+     * logical expression plan.
+     * @param lgExpPlan LogicalExpressionPlan in which this expression will be 
added.
+     * @return LogicalExpression with its own logical expression plan.
+     * @throws IOException.
+     */
+    abstract public LogicalExpression deepCopy(LogicalExpressionPlan 
lgExpPlan) throws IOException;
+
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/MapLookupExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/MapLookupExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/MapLookupExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/MapLookupExpression.java
 Mon Aug 23 22:04:50 2010
@@ -19,6 +19,7 @@
 package org.apache.pig.newplan.logical.expression;
 
 import java.util.List;
+import java.io.IOException;
 
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
@@ -106,4 +107,15 @@ public class MapLookupExpression extends
 
         return msg.toString();
     }
+
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = null;; 
+        copy = new MapLookupExpression(
+                lgExpPlan,
+                this.getLookupKey(),
+                this.getFieldSchema().deepCopy());
+        return copy;
+    }
+
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ModExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ModExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ModExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ModExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
 import org.apache.pig.newplan.OperatorPlan;
@@ -71,4 +73,14 @@ public class ModExpression extends Binar
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+ 
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new ModExpression(
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan));
+        return copy;
+    }
+ 
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/MultiplyExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/MultiplyExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/MultiplyExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/MultiplyExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
 import org.apache.pig.newplan.OperatorPlan;
@@ -72,4 +74,13 @@ public class MultiplyExpression extends 
         return fieldSchema;
     }
 
-}
\ No newline at end of file
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new MultiplyExpression(
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan) );
+        return copy;
+    }
+ 
+}

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NegativeExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NegativeExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NegativeExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NegativeExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
 import org.apache.pig.newplan.OperatorPlan;
@@ -42,7 +44,7 @@ public class NegativeExpression extends 
     public boolean isEqual(Operator other) throws FrontendException {
         if (other != null && other instanceof NegativeExpression) { 
             NegativeExpression of = (NegativeExpression)other;
-            return plan.isEqual(of.plan) && getExpression().isEqual( 
of.getExpression() );
+            return getExpression().isEqual( of.getExpression() );
         } else {
             return false;
         }
@@ -57,4 +59,13 @@ public class NegativeExpression extends 
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new NegativeExpression(
+                lgExpPlan,
+                this.getExpression().deepCopy(lgExpPlan) );
+        return copy;
+    }
+
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NotEqualExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NotEqualExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NotEqualExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NotEqualExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
@@ -72,4 +74,14 @@ public class NotEqualExpression extends 
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+ 
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new NotEqualExpression(
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan) );
+        return copy;
+    }
+
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NotExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NotExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NotExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/NotExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
@@ -43,7 +45,7 @@ public class NotExpression extends Unary
     public boolean isEqual(Operator other) throws FrontendException {
         if (other != null && other instanceof NotExpression) { 
             NotExpression of = (NotExpression)other;
-            return plan.isEqual(of.plan) && getExpression().isEqual( 
of.getExpression() );
+            return getExpression().isEqual( of.getExpression() );
         } else {
             return false;
         }
@@ -57,4 +59,13 @@ public class NotExpression extends Unary
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new NotExpression(
+                lgExpPlan,
+                this.getExpression().deepCopy(lgExpPlan) );
+        return copy;
+    }
+
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/OrExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/OrExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/OrExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/OrExpression.java
 Mon Aug 23 22:04:50 2010
@@ -17,6 +17,8 @@
  */
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
@@ -72,4 +74,14 @@ public class OrExpression extends Binary
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
+
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new OrExpression(
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan) );
+        return copy;
+    }
+ 
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ProjectExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ProjectExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ProjectExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/ProjectExpression.java
 Mon Aug 23 22:04:50 2010
@@ -19,6 +19,7 @@
 package org.apache.pig.newplan.logical.expression;
 
 import java.util.List;
+import java.io.IOException;
 
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
@@ -267,4 +268,15 @@ public class ProjectExpression extends C
         }
         return super.getType();
     }
+
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new ProjectExpression(
+                lgExpPlan,
+                this.getInputNum(),
+                this.getColNum(),
+                this.getAttachedRelationalOp());
+        return copy;
+    }
+
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/RegexExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/RegexExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/RegexExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/RegexExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
@@ -72,4 +74,14 @@ public class RegexExpression extends Bin
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
-}
\ No newline at end of file
+
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new RegexExpression(
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan) );
+        return copy;
+    }
+
+}

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/SubtractExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/SubtractExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/SubtractExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/SubtractExpression.java
 Mon Aug 23 22:04:50 2010
@@ -18,6 +18,8 @@
 
 package org.apache.pig.newplan.logical.expression;
 
+import java.io.IOException;
+
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;
 import org.apache.pig.newplan.OperatorPlan;
@@ -71,4 +73,14 @@ public class SubtractExpression extends 
         uidOnlyFieldSchema = fieldSchema.mergeUid(uidOnlyFieldSchema);
         return fieldSchema;
     }
-}
\ No newline at end of file
+
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy = new SubtractExpression(
+                lgExpPlan,
+                this.getLhs().deepCopy(lgExpPlan),
+                this.getRhs().deepCopy(lgExpPlan) );
+        return copy;
+    }
+ 
+}

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/UnaryExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/UnaryExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/UnaryExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/UnaryExpression.java
 Mon Aug 23 22:04:50 2010
@@ -19,6 +19,7 @@
 package org.apache.pig.newplan.logical.expression;
 
 import java.util.List;
+import java.io.IOException;
 
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.newplan.Operator;

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/UserFuncExpression.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/UserFuncExpression.java?rev=988334&r1=988333&r2=988334&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/UserFuncExpression.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/expression/UserFuncExpression.java
 Mon Aug 23 22:04:50 2010
@@ -20,6 +20,7 @@ package org.apache.pig.newplan.logical.e
 
 import java.util.ArrayList;
 import java.util.List;
+import java.io.IOException;
 
 import org.apache.pig.EvalFunc;
 import org.apache.pig.FuncSpec;
@@ -135,4 +136,17 @@ public class UserFuncExpression extends 
     public void setImplicitReferencedOperator(Operator 
implicitReferencedOperator) {
         this.implicitReferencedOperator = implicitReferencedOperator;
     }
+
+    @Override
+    public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws 
IOException {
+        LogicalExpression copy =  null; 
+        try {
+        copy = new UserFuncExpression(
+                lgExpPlan,
+                this.getFuncSpec().clone() );
+        } catch(CloneNotSupportedException e) {
+             e.printStackTrace();
+        }
+        return copy;
+    }
 }


Reply via email to