You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by pr...@apache.org on 2009/03/25 01:42:54 UTC

svn commit: r758107 [6/8] - in /hadoop/pig/branches/multiquery: ./ bin/ docs/ src/ src/docs/ src/docs/src/ src/docs/src/documentation/ src/docs/src/documentation/classes/ src/docs/src/documentation/content/ src/docs/src/documentation/content/xdocs/ src...

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/data/SortedDataBag.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/data/SortedDataBag.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/data/SortedDataBag.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/data/SortedDataBag.java Wed Mar 25 00:42:40 2009
@@ -35,6 +35,7 @@
   
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.pig.PigWarning;
 
 
 /**
@@ -108,8 +109,8 @@
             } catch (IOException ioe) {
                 // Do not remove last file from spilled array. It was not
                 // added as File.createTmpFile threw an IOException
-                log.error(
-                    "Unable to create tmp file to spill to disk", ioe);
+                warn(
+                    "Unable to create tmp file to spill to disk", PigWarning.UNABLE_TO_CREATE_FILE_TO_SPILL, ioe);
                 return 0;
             }
             try {
@@ -135,15 +136,15 @@
                 // Remove the last file from the spilled array, since we failed to
                 // write to it.
                 mSpillFiles.remove(mSpillFiles.size() - 1);
-                log.error(
-                    "Unable to spill contents to disk", ioe);
+                warn(
+                    "Unable to spill contents to disk", PigWarning.UNABLE_TO_SPILL, ioe);
                 return 0;
             } finally {
                 if (out != null) {
                     try {
                         out.close();
                     } catch (IOException e) {
-                        log.error("Error closing spill", e);
+                        warn("Error closing spill", PigWarning.UNABLE_TO_CLOSE_SPILL_FILE, e);
                     }
                 }
             }
@@ -254,9 +255,9 @@
                 } catch (FileNotFoundException fnfe) {
                     // We can't find our own spill file?  That should never
                     // happen.
-                    log.fatal(
-                        "Unable to find our spill file", fnfe);
-                    throw new RuntimeException(fnfe);
+                    String msg = "Unable to find our spill file.";
+                    log.fatal(msg, fnfe);
+                    throw new RuntimeException(msg, fnfe);
                 }
 
                 // Fast foward past the tuples we've already put in the
@@ -268,13 +269,13 @@
                     } catch (EOFException eof) {
                         // This should never happen, it means we
                         // didn't dump all of our tuples to disk.
-                        log.fatal(
-                            "Ran out of tuples too soon.", eof);
-                        throw new RuntimeException("Ran out of tuples to read prematurely.", eof);
+                        String msg = "Ran out of tuples to read prematurely.";
+                        log.fatal(msg, eof);
+                        throw new RuntimeException(msg, eof);
                     } catch (IOException ioe) {
-                        log.fatal(
-                            "Unable to read our spill file", ioe);
-                        throw new RuntimeException(ioe);
+                        String msg = "Unable to find our spill file.";
+                        log.fatal(msg, ioe);
+                        throw new RuntimeException(msg, ioe);
                     }
                 }
                 mMemoryPtr = 0;
@@ -319,9 +320,9 @@
                     } catch (FileNotFoundException fnfe) {
                         // We can't find our own spill file?  That should
                         // never happen.
-                        log.fatal(
-                            "Unable to find our spill file", fnfe);
-                        throw new RuntimeException(fnfe);
+                        String msg = "Unable to find our spill file."; 
+                        log.fatal(msg, fnfe);
+                        throw new RuntimeException(msg, fnfe);
                     }
                 }
 
@@ -378,9 +379,9 @@
                     // this file.
                     mStreams.set(fileNum, null);
                 } catch (IOException ioe) {
-                    log.fatal(
-                        "Unable to read our spill file", ioe);
-                    throw new RuntimeException(ioe);
+                    String msg = "Unable to find our spill file.";
+                    log.fatal(msg, ioe);
+                    throw new RuntimeException(msg, ioe);
                 }
 
             }
@@ -442,9 +443,9 @@
                         } catch (FileNotFoundException fnfe) {
                             // We can't find our own spill file?  That should
                             // neer happen.
-                            log.fatal(
-                                "Unable to find our spill file", fnfe);
-                            throw new RuntimeException(fnfe);
+                            String msg = "Unable to find our spill file.";
+                            log.fatal(msg, fnfe);
+                            throw new RuntimeException(msg, fnfe);
                         }
                     }
 
@@ -461,9 +462,9 @@
                         }
                         out.flush();
                     } catch (IOException ioe) {
-                        log.fatal(
-                            "Unable to read our spill file", ioe);
-                        throw new RuntimeException(ioe);
+                        String msg = "Unable to find our spill file.";
+                        log.fatal(msg, ioe);
+                        throw new RuntimeException(msg, ioe);
                     }
                 }
 

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/PigContext.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/PigContext.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/PigContext.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/PigContext.java Wed Mar 25 00:42:40 2009
@@ -116,6 +116,8 @@
 
     public boolean debug = true;
     
+    private String last_alias = null;
+
     // List of paths skipped for automatic shipping
     List<String> skippedShipPaths = new ArrayList<String>();
     
@@ -244,7 +246,7 @@
                     break;
             }
             String msg = "Unable to rename " + oldName + " to " + newName;            
-            throw new PigException(msg, errCode, errSrc, e);
+            throw new ExecException(msg, errCode, errSrc, e);
         }
 
         if (dst.exists()) {
@@ -284,7 +286,7 @@
                     break;
             }
             String msg = "Unable to copy " + src + " to " + dst;            
-            throw new PigException(msg, errCode, errSrc, e);
+            throw new ExecException(msg, errCode, errSrc, e);
         }
         
         srcElement.copy(dstElement, this.properties, false);
@@ -327,6 +329,14 @@
         return getProperties();
     }
 
+    public String getLastAlias() {
+      return this.last_alias;
+    }
+
+    public void setLastAlias(String value) {
+      this.last_alias = value;
+    }
+
     /**
      * Defines an alias for the given function spec. This
      * is useful for functions that require arguments to the 
@@ -412,7 +422,7 @@
             catch (UnsupportedClassVersionError e) {
                 int errCode = 1069;
                 String msg = "Problem resolving class version numbers for class " + name;
-                throw new PigException(msg, errCode, PigException.INPUT, e) ;
+                throw new ExecException(msg, errCode, PigException.INPUT, e) ;
             }
             
         }
@@ -421,7 +431,7 @@
         // so that we don't need to buble interface changes throughout the code
         int errCode = 1070;
         String msg = "Could not resolve " + name + " using imports: " + packageImportList;
-        throw new PigException(msg, errCode, PigException.INPUT);
+        throw new ExecException(msg, errCode, PigException.INPUT);
     }
     
     

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/builtin/GFCross.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/builtin/GFCross.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/builtin/GFCross.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/builtin/GFCross.java Wed Mar 25 00:42:40 2009
@@ -63,9 +63,7 @@
     
             return output;
         }catch(ExecException e){
-            IOException ioe = new IOException();
-            ioe.initCause(e);
-            throw ioe;
+            throw e;
         }
     }
     

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/builtin/RandomSampleLoader.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/builtin/RandomSampleLoader.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/builtin/RandomSampleLoader.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/builtin/RandomSampleLoader.java Wed Mar 25 00:42:40 2009
@@ -21,6 +21,8 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import org.apache.pig.PigException;
+import org.apache.pig.backend.executionengine.ExecException;
 import org.apache.pig.builtin.BinStorage;
 import org.apache.pig.data.Tuple;
 import org.apache.pig.impl.io.BufferedPositionedInputStream;
@@ -66,8 +68,10 @@
     }
     
     @Override
-    public void bindTo(OutputStream os) throws IOException {
-        throw new RuntimeException(this.getClass().getName() + " should not be used for writing");
+    public void bindTo(OutputStream os) throws IOException {
+        int errCode = 2101;
+        String msg = this.getClass().getName() + " should not be used for storing.";
+        throw new ExecException(msg, errCode, PigException.BUG);
     }
     
     

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/FileLocalizer.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/FileLocalizer.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/FileLocalizer.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/FileLocalizer.java Wed Mar 25 00:42:40 2009
@@ -451,7 +451,6 @@
     public static boolean fileExists(String filename, DataStorage store)
             throws IOException {
         ElementDescriptor elem = store.asElement(filename);
-
         return elem.exists() || globMatchesFiles(elem, store);
     }
 
@@ -496,7 +495,8 @@
             }
         }
         catch (DataStorageException e) {
-            throw WrappedIOException.wrap("Unable to get collect for pattern " + elem.toString(), e);
+            //throw WrappedIOException.wrap("Unable to get collect for pattern " + elem.toString(), e);
+            throw e;
         }
     }
 

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/NullableBag.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/NullableBag.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/NullableBag.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/NullableBag.java Wed Mar 25 00:42:40 2009
@@ -35,7 +35,7 @@
     }
 
     /**
-     * @param bytes
+     * @param b
      */
     public NullableBag(DataBag b) {
         mValue = b;

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/NullableTuple.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/NullableTuple.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/NullableTuple.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/NullableTuple.java Wed Mar 25 00:42:40 2009
@@ -35,7 +35,7 @@
     }
 
     /**
-     * @param bytes
+     * @param t
      */
     public NullableTuple(Tuple t) {
         mValue = t;

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/PigNullableWritable.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/PigNullableWritable.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/PigNullableWritable.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/io/PigNullableWritable.java Wed Mar 25 00:42:40 2009
@@ -129,6 +129,13 @@
         else return mValue.hashCode();
     }
 
+    
+    
+    @Override
+    public boolean equals(Object arg0) {
+        return compareTo(arg0)==0;
+    }
+
     @Override
     public String toString() {
         return new String("Null: " + mNull + " index: " + mIndex + " " +

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/BinaryExpressionOperator.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/BinaryExpressionOperator.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/BinaryExpressionOperator.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/BinaryExpressionOperator.java Wed Mar 25 00:42:40 2009
@@ -18,6 +18,8 @@
 
 package org.apache.pig.impl.logicalLayer;
 
+import java.util.List;
+
 import org.apache.pig.impl.plan.PlanVisitor;
 import org.apache.pig.impl.plan.OperatorKey;
 import org.apache.pig.impl.plan.VisitorException;
@@ -33,8 +35,6 @@
 
 public abstract class BinaryExpressionOperator extends ExpressionOperator {
     private static final long serialVersionUID = 2L;
-    private ExpressionOperator mLhsOperand; //left hand side operand
-    private ExpressionOperator mRhsOperand; //right hand side operand
     private static Log log = LogFactory.getLog(BinaryExpressionOperator.class);
 
     /**
@@ -45,16 +45,9 @@
      * @param rp
      *            degree of requested parallelism with which to execute this
      *            node.
-     * @param lhsOperand
-     *            ExpressionOperator the left hand side operand
-     * @param rhsOperand
-     *            ExpressionOperator the right hand side operand
      */
-    public BinaryExpressionOperator(LogicalPlan plan, OperatorKey k, int rp,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
+    public BinaryExpressionOperator(LogicalPlan plan, OperatorKey k, int rp) {
         super(plan, k, rp);
-        mLhsOperand = lhsOperand;
-        mRhsOperand = rhsOperand;
     }
 
     /**
@@ -62,34 +55,25 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            ExpressionOperator the left hand side operand
-     * @param rhsOperand
-     *            ExpressionOperator the right hand side operand
      */
-    public BinaryExpressionOperator(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
+    public BinaryExpressionOperator(LogicalPlan plan, OperatorKey k) {
         super(plan, k);
-        mLhsOperand = lhsOperand;
-        mRhsOperand = rhsOperand;
     }
     
     public ExpressionOperator getLhsOperand() {
-        return mLhsOperand;
+        List<LogicalOperator>preds = getPlan().getPredecessors(this);
+        if(preds == null)
+            return null;
+        return (ExpressionOperator)preds.get(0);
     }
 
     public ExpressionOperator getRhsOperand() {
-        return mRhsOperand;
-    }
-    
-    public void setLhsOperand(ExpressionOperator lhs) {
-        mLhsOperand = lhs ;
+        List<LogicalOperator>preds = getPlan().getPredecessors(this);
+        if(preds == null)
+            return null;
+        return (ExpressionOperator)preds.get(1);
     }
-
-    public void setRhsOperand(ExpressionOperator rhs) {
-        mRhsOperand = rhs ;
-    }
-    
+        
     @Override
     public void visit(LOVisitor v) throws VisitorException {
         v.visit(this);

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/ExpressionOperator.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/ExpressionOperator.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/ExpressionOperator.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/ExpressionOperator.java Wed Mar 25 00:42:40 2009
@@ -133,7 +133,7 @@
     }
 
     /**
-     * @see org.apache.pig.impl.plan.LogicalOperator#clone()
+     * @see org.apache.pig.impl.logicalLayer.LogicalOperator#clone()
      * Do not use the clone method directly. Operators are cloned when logical plans
      * are cloned using {@link LogicalPlanCloner}
      */

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOAdd.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOAdd.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOAdd.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOAdd.java Wed Mar 25 00:42:40 2009
@@ -37,14 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            the left hand side operand
-     * @param rhsOperand
-     *            the right hand side operand
      */
-    public LOAdd(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
-        super(plan, k, lhsOperand, rhsOperand);
+    public LOAdd(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOAnd.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOAnd.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOAnd.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOAnd.java Wed Mar 25 00:42:40 2009
@@ -37,14 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            the left hand side operand
-     * @param rhsOperand
-     *            the right hand side operand
      */
-    public LOAnd(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
-        super(plan, k, lhsOperand, rhsOperand);
+    public LOAnd(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOBinCond.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOBinCond.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOBinCond.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOBinCond.java Wed Mar 25 00:42:40 2009
@@ -19,6 +19,8 @@
 package org.apache.pig.impl.logicalLayer;
 
 
+import java.util.List;
+
 import org.apache.pig.impl.logicalLayer.schema.Schema;
 import org.apache.pig.impl.plan.OperatorKey;
 import org.apache.pig.impl.plan.PlanVisitor;
@@ -31,58 +33,40 @@
     // is executed else the second nested query is executed
 
     private static final long serialVersionUID = 2L;
-    private ExpressionOperator mCond;
-    private ExpressionOperator mLhsOp;
-    private ExpressionOperator mRhsOp;
-
+ 
     /**
      * 
      * @param plan
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param cond
-     *            ExpressionOperator the expression specifying condition
-     * @param lhsOp
-     *            ExpressionOperator query to be executed when condition is true
-     * @param rhsOp
-     *            ExpressionOperator query to be executed when condition is
-     *            false
      */
-    public LOBinCond(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator cond, ExpressionOperator lhsOp,
-            ExpressionOperator rhsOp) {
+    public LOBinCond(LogicalPlan plan, OperatorKey k) {
         super(plan, k);
-        mCond = cond;
-        mLhsOp = lhsOp;
-        mRhsOp = rhsOp;
-
     }// End Constructor LOBinCond
 
     public ExpressionOperator getCond() {
-        return mCond;
+        List<LogicalOperator>preds = getPlan().getPredecessors(this);
+        if(preds == null)
+            return null;
+        return (ExpressionOperator)preds.get(0);
     }
 
     public ExpressionOperator getLhsOp() {
-        return mLhsOp;
+        List<LogicalOperator>preds = getPlan().getPredecessors(this);
+        if(preds == null)
+            return null;
+        return (ExpressionOperator)preds.get(1);
     }
 
     public ExpressionOperator getRhsOp() {
-        return mRhsOp;
+        List<LogicalOperator>preds = getPlan().getPredecessors(this);
+        if(preds == null)
+            return null;
+        return (ExpressionOperator)preds.get(2);
     }
     
-    public void setCond(ExpressionOperator cond) {
-        mCond = cond;
-    }
-
-    public void setLhsOp(ExpressionOperator op) {
-        mLhsOp = op ;
-    }
-
-    public void setRhsOp(ExpressionOperator op) {
-        mRhsOp = op;
-    }
-
+    
     @Override
     public void visit(LOVisitor v) throws VisitorException {
         v.visit(this);
@@ -99,7 +83,7 @@
         //The type checker perform this task
         if (!mIsFieldSchemaComputed) {
             try {
-                mFieldSchema = mLhsOp.getFieldSchema();
+                mFieldSchema = getLhsOp().getFieldSchema();
                 mIsFieldSchemaComputed = true;
             } catch (FrontendException fee) {
                 mFieldSchema = null;

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOCast.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOCast.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOCast.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOCast.java Wed Mar 25 00:42:40 2009
@@ -18,6 +18,8 @@
 
 package org.apache.pig.impl.logicalLayer;
 
+import java.util.List;
+
 import org.apache.pig.FuncSpec;
 import org.apache.pig.LoadFunc;
 import org.apache.pig.impl.plan.OperatorKey;
@@ -31,7 +33,6 @@
     // Cast has an expression that has to be converted to a specified type
 
     private static final long serialVersionUID = 2L;
-    private ExpressionOperator mExpr;
     private FuncSpec mLoadFuncSpec = null;
 
     /**
@@ -40,24 +41,19 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param expr
-     *            the expression whose type has to be cast
      * @param type
      *            the type to which the expression is cast
      */
-    public LOCast(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator expr, byte type) {
+    public LOCast(LogicalPlan plan, OperatorKey k, byte type) {
         super(plan, k);
-        mExpr = expr;
         mType = type;
     }// End Constructor LOCast
 
     public ExpressionOperator getExpression() {
-        return mExpr;
-    }
-
-    public void setExpression(ExpressionOperator expr) {
-        mExpr = expr;
+        List<LogicalOperator>preds = getPlan().getPredecessors(this);
+        if(preds == null)
+            return null;
+        return (ExpressionOperator)preds.get(0);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOConst.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOConst.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOConst.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOConst.java Wed Mar 25 00:42:40 2009
@@ -79,7 +79,7 @@
 
     @Override
     public String name() {
-        return "Const " + mKey.scope + "-" + mKey.id;
+        return "Const " + mKey.scope + "-" + mKey.id + "( " + mValue + " )";
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LODivide.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LODivide.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LODivide.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LODivide.java Wed Mar 25 00:42:40 2009
@@ -37,14 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            the left hand side operand
-     * @param rhsOperand
-     *            the right hand side operand
      */
-    public LODivide(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
-        super(plan, k, lhsOperand, rhsOperand);
+    public LODivide(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOEqual.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOEqual.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOEqual.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOEqual.java Wed Mar 25 00:42:40 2009
@@ -37,14 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            the left hand side operand
-     * @param rhsOperand
-     *            the right hand side operand
      */
-    public LOEqual(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
-        super(plan, k, lhsOperand, rhsOperand);
+    public LOEqual(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOFRJoin.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOFRJoin.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOFRJoin.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOFRJoin.java Wed Mar 25 00:42:40 2009
@@ -25,6 +25,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.pig.PigException;
 import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.optimizer.SchemaRemover;
 import org.apache.pig.impl.logicalLayer.schema.Schema;
@@ -183,8 +184,10 @@
     }
     public byte getAtomicJoinColType() throws FrontendException {
         if (isTupleJoinCol()) {
-            throw new FrontendException("getAtomicjoinByType is used only when"
-                                     + " dealing with atomic join col") ;
+            int errCode = 1010;
+            String msg = "getAtomicGroupByType is used only when"
+                + " dealing with atomic join col";
+            throw new FrontendException(msg, errCode, PigException.INPUT, false, null) ;
         }
 
         byte joinColType = DataType.BYTEARRAY ;
@@ -195,8 +198,10 @@
             List<LogicalPlan> innerPlans
                         = new ArrayList<LogicalPlan>(getJoinColPlans().get(input)) ;
             if (innerPlans.size() != 1) {
-                throw new FrontendException("Each join input has to have "
-                                         + "the same number of inner plans") ;
+                int errCode = 1012;
+                String msg = "Each join input has to have "
+                + "the same number of inner plans";
+                throw new FrontendException(msg, errCode, PigException.INPUT, false, null) ;
             }
             byte innerType = innerPlans.get(0).getSingleLeafPlanOutputType() ;
             joinColType = DataType.mergeType(joinColType, innerType) ;
@@ -207,8 +212,10 @@
 
     public Schema getTupleJoinColSchema() throws FrontendException {
         if (!isTupleJoinCol()) {
-            throw new FrontendException("getTupleJoinColSchema is used only when"
-                                     + " dealing with tuple join col") ;
+            int errCode = 1011;
+            String msg = "getTupleGroupBySchema is used only when"
+                + " dealing with tuple join col";
+            throw new FrontendException(msg, errCode, PigException.INPUT, false, null) ;
         }
 
         // this fsList represents all the columns in join tuple
@@ -250,8 +257,10 @@
                 }
             }
 
-            if(seenProjectStar && innerPlans.size() > 1) {
-                throw new FrontendException("joining attributes can either be star (*) or a list of expressions, but not both.");
+            if(seenProjectStar && innerPlans.size() > 1) {                
+                int errCode = 1013;
+                String msg = "Join attributes can either be star (*) or a list of expressions, but not both.";
+                throw new FrontendException(msg, errCode, PigException.INPUT, false, null);
                 
             }
 

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOGreaterThan.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOGreaterThan.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOGreaterThan.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOGreaterThan.java Wed Mar 25 00:42:40 2009
@@ -37,14 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            the left hand side operand
-     * @param rhsOperand
-     *            the right hand side operand
      */
-    public LOGreaterThan(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
-        super(plan, k, lhsOperand, rhsOperand);
+    public LOGreaterThan(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOGreaterThanEqual.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOGreaterThanEqual.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOGreaterThanEqual.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOGreaterThanEqual.java Wed Mar 25 00:42:40 2009
@@ -37,14 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            the left hand side operand
-     * @param rhsOperand
-     *            the right hand side operand
      */
-    public LOGreaterThanEqual(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
-        super(plan, k, lhsOperand, rhsOperand);
+    public LOGreaterThanEqual(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOIsNull.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOIsNull.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOIsNull.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOIsNull.java Wed Mar 25 00:42:40 2009
@@ -37,12 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param operand
-     *            the only operand for a unary operator
      */
-    public LOIsNull(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator operand) {
-        super(plan, k, operand);
+    public LOIsNull(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
     
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOLesserThan.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOLesserThan.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOLesserThan.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOLesserThan.java Wed Mar 25 00:42:40 2009
@@ -37,14 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            the left hand side operand
-     * @param rhsOperand
-     *            the right hand side operand
      */
-    public LOLesserThan(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
-        super(plan, k, lhsOperand, rhsOperand);
+    public LOLesserThan(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOLesserThanEqual.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOLesserThanEqual.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOLesserThanEqual.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOLesserThanEqual.java Wed Mar 25 00:42:40 2009
@@ -37,14 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            the left hand side operand
-     * @param rhsOperand
-     *            the right hand side operand
      */
-    public LOLesserThanEqual(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
-        super(plan, k, lhsOperand, rhsOperand);
+    public LOLesserThanEqual(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOLoad.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOLoad.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOLoad.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOLoad.java Wed Mar 25 00:42:40 2009
@@ -56,8 +56,13 @@
      *            OperatorKey for this operator
      * @param inputFileSpec
      *            the file to be loaded *
-     * @param schemaFile
-     *            the file with the schema for the data to be loaded
+     * @param execType
+     *            the execution mode @see org.apache.pig.ExecType
+     * @param storage
+     *            the underlying storage
+     * @param splittable
+     *            if the input file is splittable (.gz is not)
+     *            
      * 
      */
     public LOLoad(LogicalPlan plan, OperatorKey key, FileSpec inputFileSpec,

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOMapLookup.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOMapLookup.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOMapLookup.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOMapLookup.java Wed Mar 25 00:42:40 2009
@@ -36,7 +36,6 @@
      * The key to lookup along with the type and schema corresponding to the
      * type and schema of the value linked to the key
      */
-    private ExpressionOperator mMap;
     private Object mMapKey;
     private byte mValueType;
     private Schema mValueSchema;
@@ -48,8 +47,6 @@
      *            Logical plan this operator is a part of.
      * @param key
      *            Operator key to assign to this node.
-     * @param map
-     *            the map expression
      * @param mapKey
      *            key to look up in the map. The key is of atomic type
      * @param valueType
@@ -57,7 +54,7 @@
      * @param valueSchema
      *            schema of the value if the type is tuple
      */
-    public LOMapLookup(LogicalPlan plan, OperatorKey key, ExpressionOperator map,
+    public LOMapLookup(LogicalPlan plan, OperatorKey key,
             Object mapKey, byte valueType, Schema valueSchema)
             throws ParseException {
         super(plan, key);
@@ -66,7 +63,6 @@
             throw new ParseException("Map key " + mapKey.toString()
                     + " is not atomic");
         }
-        mMap = map;
         mMapKey = mapKey;
         mValueType = valueType;
         mValueSchema = valueSchema;
@@ -74,11 +70,10 @@
     }
 
     public ExpressionOperator getMap() {
-        return mMap;
-    }
-
-    public void setMap(ExpressionOperator map) {
-        mMap = map;
+        List<LogicalOperator>preds = getPlan().getPredecessors(this);
+        if(preds == null)
+            return null;
+        return (ExpressionOperator)preds.get(0);
     }
 
     public Object getLookUpKey() {
@@ -112,7 +107,8 @@
             } else {
                 mFieldSchema = new Schema.FieldSchema(null, mValueType);
             }
-            mFieldSchema.setParent(mMap.getFieldSchema().canonicalName, mMap);
+            ExpressionOperator map = getMap();
+            mFieldSchema.setParent(map.getFieldSchema().canonicalName, map);
 
             mIsFieldSchemaComputed = true;
         }

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOMod.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOMod.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOMod.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOMod.java Wed Mar 25 00:42:40 2009
@@ -37,14 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            the left hand side operand
-     * @param rhsOperand
-     *            the right hand side operand
      */
-    public LOMod(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
-        super(plan, k, lhsOperand, rhsOperand);
+    public LOMod(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOMultiply.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOMultiply.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOMultiply.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOMultiply.java Wed Mar 25 00:42:40 2009
@@ -37,14 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            the left hand side operand
-     * @param rhsOperand
-     *            the right hand side operand
      */
-    public LOMultiply(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
-        super(plan, k, lhsOperand, rhsOperand);
+    public LOMultiply(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LONegative.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LONegative.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LONegative.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LONegative.java Wed Mar 25 00:42:40 2009
@@ -33,12 +33,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param operand
-     *            the only operand for a unary operator
      */
-    public LONegative(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator operand) {
-        super(plan, k, operand);
+    public LONegative(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LONot.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LONot.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LONot.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LONot.java Wed Mar 25 00:42:40 2009
@@ -37,12 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param operand
-     *            the only operand for a unary operator
      */
-    public LONot(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator operand) {
-        super(plan, k, operand);
+    public LONot(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
     
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LONotEqual.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LONotEqual.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LONotEqual.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LONotEqual.java Wed Mar 25 00:42:40 2009
@@ -37,14 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            the left hand side operand
-     * @param rhsOperand
-     *            the right hand side operand
      */
-    public LONotEqual(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
-        super(plan, k, lhsOperand, rhsOperand);
+    public LONotEqual(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOOr.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOOr.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOOr.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOOr.java Wed Mar 25 00:42:40 2009
@@ -37,14 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            the left hand side operand
-     * @param rhsOperand
-     *            the right hand side operand
      */
-    public LOOr(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
-        super(plan, k, lhsOperand, rhsOperand);
+    public LOOr(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
     
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LORegexp.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LORegexp.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LORegexp.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LORegexp.java Wed Mar 25 00:42:40 2009
@@ -43,24 +43,15 @@
      *            Logical plan this operator is a part of.
      * @param key
      *            Operator key to assign to this node.
-     * @param operand
-     *            input expression to be tested against
-     * @param regexp
-     *            regular expression to match
      */
-    public LORegexp(LogicalPlan plan, OperatorKey key,
-            ExpressionOperator operand, ExpressionOperator regexp) {
-        super(plan, key, operand, regexp);
+    public LORegexp(LogicalPlan plan, OperatorKey key) {
+        super(plan, key);
     }
 
     public ExpressionOperator getOperand() {
         return getLhsOperand();
     }
 
-    public void setOperand(ExpressionOperator op) {
-        setLhsOperand(op) ;
-    }
-
     public String getRegexp() {
         ExpressionOperator op = getRhsOperand();
         if (!(op instanceof LOConst)) {

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOSubtract.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOSubtract.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOSubtract.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOSubtract.java Wed Mar 25 00:42:40 2009
@@ -37,14 +37,9 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param lhsOperand
-     *            the left hand side operand
-     * @param rhsOperand
-     *            the right hand side operand
      */
-    public LOSubtract(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
-        super(plan, k, lhsOperand, rhsOperand);
+    public LOSubtract(LogicalPlan plan, OperatorKey k) {
+        super(plan, k);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOUserFunc.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOUserFunc.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOUserFunc.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LOUserFunc.java Wed Mar 25 00:42:40 2009
@@ -35,8 +35,7 @@
     private static final long serialVersionUID = 2L;
 
     private FuncSpec mFuncSpec;
-    private List<ExpressionOperator> mArgs;
-
+    
     /**
      * @param plan
      *            LogicalPlan this operator is a part of.
@@ -44,16 +43,13 @@
      *            OperatorKey for this operator.
      * @param funcSpec
      *            name of the user defined function.
-     * @param args
-     *            List of expressions that form the arguments for this function.
      * @param returnType
      *            return type of this function.
      */
     public LOUserFunc(LogicalPlan plan, OperatorKey k, FuncSpec funcSpec,
-            List<ExpressionOperator> args, byte returnType) {
+            byte returnType) {
         super(plan, k, -1);
         mFuncSpec = funcSpec;
-        mArgs = args;
         mType = returnType;
     }
 
@@ -62,11 +58,15 @@
     }
 
     public List<ExpressionOperator> getArguments() {
-        return mArgs;
-    }
-
-    public void setArguments(List<ExpressionOperator> args) {
-        mArgs = args;
+        List<LogicalOperator> preds = getPlan().getPredecessors(this);
+        List<ExpressionOperator> args = new ArrayList<ExpressionOperator>();
+        if(preds == null)
+                return args;
+            
+        for(LogicalOperator lo : preds){
+            args.add((ExpressionOperator)lo);
+        }
+        return args;
     }
 
     @Override
@@ -88,7 +88,8 @@
     public Schema.FieldSchema getFieldSchema() throws FrontendException {
         if(!mIsFieldSchemaComputed) {
             Schema inputSchema = new Schema();
-            for(ExpressionOperator op: mArgs) {
+            List<ExpressionOperator> args = getArguments();
+            for(ExpressionOperator op: args) {
                 if (!DataType.isUsableType(op.getType())) {
                     mFieldSchema = null;
                     mIsFieldSchemaComputed = false;
@@ -141,10 +142,6 @@
         mFuncSpec = funcSpec;
     }
 
-    public void setMArgs(List<ExpressionOperator> args) {
-        mArgs = args;
-    }
-
     /**
      * @see org.apache.pig.impl.logicalLayer.ExpressionOperator#clone()
      * Do not use the clone method directly. Operators are cloned when logical plans

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LogicalPlanCloneHelper.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LogicalPlanCloneHelper.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LogicalPlanCloneHelper.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/LogicalPlanCloneHelper.java Wed Mar 25 00:42:40 2009
@@ -40,7 +40,6 @@
 
     /**
      * @param plan logical plan to be cloned
-     * @param walker walker used for traversing the logical plan
      */
     public LogicalPlanCloneHelper(LogicalPlan plan) throws CloneNotSupportedException {
         super(plan, new DependencyOrderWalker<LogicalOperator, LogicalPlan>(plan));
@@ -54,7 +53,6 @@
     
     /**
      * @param plan
-     * @param walker
      * @param origCloneMap the lookup table used for tracking operators cloned in the plan
      */
     public LogicalPlanCloneHelper(LogicalPlan plan,
@@ -94,14 +92,6 @@
     
     @Override
     public void visit(BinaryExpressionOperator binOp) {
-        ExpressionOperator lhsOperandClone = (ExpressionOperator)mOpToCloneMap.get(binOp.getLhsOperand());
-        if(lhsOperandClone != null) {
-            binOp.setLhsOperand(lhsOperandClone);
-        }
-        ExpressionOperator rhsOperandClone = (ExpressionOperator)mOpToCloneMap.get(binOp.getRhsOperand());
-        if(rhsOperandClone != null) {
-            binOp.setRhsOperand(rhsOperandClone);
-        }
     }
 
     /**
@@ -125,20 +115,6 @@
      */
     @Override
     protected void visit(LOBinCond binCond) throws VisitorException {
-        ExpressionOperator condClone = (ExpressionOperator)mOpToCloneMap.get(binCond.getCond());
-        if(condClone != null) {
-            binCond.setCond(condClone);
-        }
-
-        ExpressionOperator lhsOpClone = (ExpressionOperator)mOpToCloneMap.get(binCond.getLhsOp());
-        if(lhsOpClone != null) {
-            binCond.setLhsOp(lhsOpClone);
-        }
-
-        ExpressionOperator rhsOpClone = (ExpressionOperator)mOpToCloneMap.get(binCond.getRhsOp());
-        if(rhsOpClone != null) {
-            binCond.setRhsOp(rhsOpClone);
-        }
     }
 
     /**
@@ -146,10 +122,6 @@
      */
     @Override
     protected void visit(LOCast cast) throws VisitorException {
-        ExpressionOperator exprClone = (ExpressionOperator)mOpToCloneMap.get(cast.getExpression());
-        if(exprClone != null) {
-            cast.setExpression(exprClone);
-        }
     }
 
     /**
@@ -304,10 +276,6 @@
      */
     @Override
     public void visit(LOMapLookup op) throws VisitorException {
-        ExpressionOperator mapClone = (ExpressionOperator)mOpToCloneMap.get(op.getMap());
-        if(mapClone != null) {
-            op.setMap(mapClone);
-        }
     }
 
     /**
@@ -450,17 +418,6 @@
      */
     @Override
     protected void visit(LOUserFunc func) throws VisitorException {
-        List<ExpressionOperator> args = func.getArguments();
-        List<ExpressionOperator> argsClone = new ArrayList<ExpressionOperator>(args.size());
-        for(ExpressionOperator arg: args) {
-            ExpressionOperator argClone = (ExpressionOperator)mOpToCloneMap.get(arg);
-            if(argClone != null) {
-                argsClone.add(argClone);
-            } else {
-                argsClone.add(arg);
-            }
-        }
-        func.setArguments(argsClone);
     }
 
     /**
@@ -468,10 +425,6 @@
      */
     @Override
     protected void visit(UnaryExpressionOperator uniOp) throws VisitorException {
-        ExpressionOperator operandClone = (ExpressionOperator)mOpToCloneMap.get(uniOp.getOperand());
-        if(operandClone != null) {
-            uniOp.setOperand(operandClone);
-        }
     }
     
 }

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/RemoveRedundantOperators.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/RemoveRedundantOperators.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/RemoveRedundantOperators.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/RemoveRedundantOperators.java Wed Mar 25 00:42:40 2009
@@ -17,12 +17,14 @@
  */
 package org.apache.pig.impl.logicalLayer;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.Iterator;
 import java.util.Set;
 import java.util.Map;
 import java.util.ArrayList;
 
+import org.apache.commons.el.RelationalOperator;
 import org.apache.pig.impl.plan.PlanVisitor;
 import org.apache.pig.impl.plan.PlanWalker;
 import org.apache.pig.impl.plan.DepthFirstWalker;
@@ -54,102 +56,74 @@
     protected void visit(LOProject project) throws VisitorException {
         LogicalPlan currentPlan = (LogicalPlan)mCurrentWalker.getPlan();
         
-        //if the project is a project(*) and if there are predecessors and successors that are
+        //if the project is a project(*) and if there are predecessors 
+        // and successors that are
         //1. both relational operators OR
         //2. both expression operators
-        //then the project(*) can be removed and the input and outputs short circuited, i.e. directly connected
+        //then the project(*) can be removed and the input and outputs
+        // short circuited, i.e. directly connected
         if(project.isStar()) {
 
-            List<LogicalOperator> projectSuccessors = currentPlan.getSuccessors(project);
-            List<LogicalOperator> projectPredecessors = currentPlan.getPredecessors(project);
-
-            if(((projectSuccessors != null) && (projectSuccessors.size() > 0)) 
-                && ((projectPredecessors != null) && (projectPredecessors.size() > 0))) {
-
-                //Making copies to avoid concurrent modification exceptions
-                List<LogicalOperator> successors = new ArrayList(currentPlan.getSuccessors(project));
-                List<LogicalOperator> predecessors = new ArrayList(currentPlan.getPredecessors(project));
-
-                //if the project(*) cannot be removed
-                boolean removeProject = true;
-
-                for(LogicalOperator projectPred: predecessors) {
-                    for(LogicalOperator projectSucc: successors) {
-                        if (((projectPred instanceof ExpressionOperator) && (projectSucc instanceof ExpressionOperator))
-                            || (!(projectPred instanceof ExpressionOperator) && !(projectSucc instanceof ExpressionOperator))) {
-                            try {
-                                currentPlan.disconnect(projectPred, project);
-                                currentPlan.disconnect(project, projectSucc);
-                                currentPlan.connect(projectPred, projectSucc);
-                                patchInputReference(projectSucc, project, projectPred);
-                            } catch (PlanException pe) {
-                                throw new VisitorException(pe.getMessage(), pe);
-                            }
-                        } else {
-                            removeProject = false;
-                        }
-                    }
+            List<LogicalOperator> prSuccessors = 
+                    currentPlan.getSuccessors(project);
+            
+            List<LogicalOperator> prPredecessors = 
+                    currentPlan.getPredecessors(project);
+            
+            if( ((prSuccessors != null) && (prSuccessors.size() > 0)) 
+                    /* prPredecessors.size() == 1 for project(*) */
+                    && ((prPredecessors != null) && (prPredecessors.size() == 1)) ){
+                
+                LogicalOperator pred =  prPredecessors.get(0);
+                
+                
+                //check if either all pred and succ oper are ExpressionOperator
+                // or if all of them are relationalOperators (ie != ExpressionOperator)
+                boolean allExpressionOp = true;
+                boolean allRelationalOp = true;
+                if(pred instanceof ExpressionOperator)
+                    allRelationalOp = false;
+                else 
+                    allExpressionOp = false;
+                
+                for(LogicalOperator op: prSuccessors){
+                    if (op instanceof ExpressionOperator) 
+                        allRelationalOp = false;
+                    else 
+                        allExpressionOp = false;
+                    
+                    if(allExpressionOp == false && allRelationalOp == false)
+                        break;
                 }
-                if(removeProject) {
-                    currentPlan.remove(project);
+                
+                // remove project if either condition is met
+                if(allExpressionOp == true || allRelationalOp == true){
+                    try{
+                        currentPlan.removeAndReconnectMultiSucc(project);
+                        patchInputReference(pred, project, prSuccessors);
+                    }catch (PlanException pe){
+                        String msg = new String("Error while removing redundant project in plan");
+                        throw new VisitorException(msg,pe);
+                    }
                 }
+                
             }
-        }
+        }       
     }
-
-    private void patchInputReference(LogicalOperator op, LogicalOperator prevInput, LogicalOperator newInput) {
-        //TODO
-        //Using reference comparison here as operators do not have equals() method yet
-        //Depending on the successor of prevInput, fix the referenes to point to newInput
-        if(op instanceof BinaryExpressionOperator) {
-            BinaryExpressionOperator binOp = (BinaryExpressionOperator)op;
-            if(prevInput == binOp.getLhsOperand()) {
-                binOp.setLhsOperand((ExpressionOperator)newInput);
-            } else if(prevInput == binOp.getRhsOperand()) {
-                binOp.setRhsOperand((ExpressionOperator)newInput);
-            }
-        } else if (op instanceof UnaryExpressionOperator) {
-            UnaryExpressionOperator uniOp = (UnaryExpressionOperator)op;
-            if(prevInput == uniOp.getOperand()) {
-                uniOp.setOperand((ExpressionOperator)newInput);
-            }
-        } else if (op instanceof LOBinCond) {
-            LOBinCond binCond = (LOBinCond)op;
-            if(prevInput == binCond.getLhsOp()) {
-                binCond.setLhsOp((ExpressionOperator)newInput);
-            } else if(prevInput == binCond.getRhsOp()) {
-                binCond.setRhsOp((ExpressionOperator)newInput);
-            } else if(prevInput == binCond.getCond()) {
-                binCond.setCond((ExpressionOperator)newInput);
-            }
-        } else if (op instanceof LOCast) {
-            LOCast cast = (LOCast)op;
-            if(prevInput == cast.getExpression()) {
-                cast.setExpression((ExpressionOperator)newInput);
-            }
-        } else if (op instanceof LOMapLookup) {
-            LOMapLookup map = (LOMapLookup)op;
-            if(prevInput == map.getMap()) {
-                map.setMap((ExpressionOperator)newInput);
-            }
-        } else if (op instanceof LOUserFunc) {
-            LOUserFunc userFunc = (LOUserFunc)op;
-            List<ExpressionOperator> args = userFunc.getArguments();
-            ArrayList<ExpressionOperator> newArgs = new ArrayList<ExpressionOperator>(args.size());
-            for(ExpressionOperator expOp: args) {
-                if(prevInput == expOp) {
-                    newArgs.add((ExpressionOperator)newInput);
-                } else {
-                    newArgs.add(expOp);
+    
+    
+    private void patchInputReference(LogicalOperator pred, LogicalOperator current, List<LogicalOperator> succs) {
+        for(LogicalOperator n : succs){
+            // special handling of LOProject because its getExpression() does
+            // need not be same as getPredecessors(LOProject)
+            if(n instanceof LOProject){
+                LOProject lop = (LOProject)n;
+                if(current == lop.getExpression()){
+                    lop.setExpression((LogicalOperator)pred);
                 }
             }
-            userFunc.setArguments(newArgs);
-        } else if (op instanceof LOProject) {
-            LOProject proj = (LOProject)op;
-            if(prevInput == proj.getExpression()) {
-                proj.setExpression(newInput);
-            }
         }
     }
-
+    
+    
 }

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/UnaryExpressionOperator.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/UnaryExpressionOperator.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/UnaryExpressionOperator.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/UnaryExpressionOperator.java Wed Mar 25 00:42:40 2009
@@ -18,6 +18,8 @@
 
 package org.apache.pig.impl.logicalLayer;
 
+import java.util.List;
+
 import org.apache.pig.impl.plan.OperatorKey;
 import org.apache.pig.impl.plan.PlanVisitor;
 import org.apache.pig.impl.plan.VisitorException;
@@ -32,7 +34,6 @@
  */
 public abstract class UnaryExpressionOperator extends ExpressionOperator {
     private static final long serialVersionUID = 2L;
-    protected ExpressionOperator mOperand; // operand
     private static Log log = LogFactory.getLog(UnaryExpressionOperator.class);
 
     /**
@@ -43,13 +44,9 @@
      * @param rp
      *            degree of requested parallelism with which to execute this
      *            node.
-     * @param operand
-     *            ExpressionOperator the left hand side operand
      */
-    public UnaryExpressionOperator(LogicalPlan plan, OperatorKey k, int rp,
-            ExpressionOperator operand) {
+    public UnaryExpressionOperator(LogicalPlan plan, OperatorKey k, int rp) {
         super(plan, k, rp);
-        mOperand = operand;
     }
 
     /**
@@ -57,21 +54,17 @@
      *            Logical plan this operator is a part of.
      * @param k
      *            Operator key to assign to this node.
-     * @param operand
-     *            ExpressionOperator the left hand side operand
      */
-    public UnaryExpressionOperator(LogicalPlan plan, OperatorKey k,
-            ExpressionOperator operand) {
+    public UnaryExpressionOperator(LogicalPlan plan, OperatorKey k) {
         super(plan, k);
-        mOperand = operand;
+
     }
     
     public ExpressionOperator getOperand() {
-        return mOperand;
-    }
-
-    public void setOperand(ExpressionOperator eOp) {
-        mOperand = eOp;
+        List<LogicalOperator>preds = getPlan().getPredecessors(this);
+        if(preds == null)
+            return null;
+        return (ExpressionOperator)preds.get(0);
     }
 
     @Override

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/optimizer/LogicalOptimizer.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/optimizer/LogicalOptimizer.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/optimizer/LogicalOptimizer.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/optimizer/LogicalOptimizer.java Wed Mar 25 00:42:40 2009
@@ -22,6 +22,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.pig.ExecType;
 import org.apache.pig.impl.logicalLayer.LogicalOperator;
 import org.apache.pig.impl.logicalLayer.LogicalPlan;
 import org.apache.pig.impl.plan.optimizer.*;
@@ -29,21 +30,29 @@
 /**
  * An optimizer for logical plans.
  */
-public class LogicalOptimizer extends PlanOptimizer<LogicalOperator, LogicalPlan> {
-    
+public class LogicalOptimizer extends
+        PlanOptimizer<LogicalOperator, LogicalPlan> {
+
     public static final String LOLOAD_CLASSNAME = "org.apache.pig.impl.logicalLayer.LOLoad";
     public static final String LOSTREAM_CLASSNAME = "org.apache.pig.impl.logicalLayer.LOStream";
 
     public LogicalOptimizer(LogicalPlan plan) {
+        this(plan, ExecType.MAPREDUCE);
+    }
+
+    public LogicalOptimizer(LogicalPlan plan, ExecType mode) {
         super(plan);
+        runOptimizations(plan, mode);
+    }
 
+    private void runOptimizations(LogicalPlan plan, ExecType mode) {
         // List of rules for the logical optimizer
-        
+
         // This one has to be first, as the type cast inserter expects the
         // load to only have one output.
         // Find any places in the plan that have an implicit split and make
-        // it explicit.  Since the RuleMatcher doesn't handle trees properly,
-        // we cheat and say that we match any node.  Then we'll do the actual
+        // it explicit. Since the RuleMatcher doesn't handle trees properly,
+        // we cheat and say that we match any node. Then we'll do the actual
         // test in the transformers check method.
         List<String> nodes = new ArrayList<String>(1);
         Map<Integer, Integer> edges = new HashMap<Integer, Integer>();
@@ -51,8 +60,8 @@
         nodes.add("any");
         required.add(true);
         mRules.add(new Rule<LogicalOperator, LogicalPlan>(nodes, edges,
-            required, new ImplicitSplitInserter(plan)));
-        
+                required, new ImplicitSplitInserter(plan)));
+
         // Add type casting to plans where the schema has been declared (by
         // user, data, or data catalog).
         nodes = new ArrayList<String>(1);
@@ -60,9 +69,9 @@
         edges = new HashMap<Integer, Integer>();
         required = new ArrayList<Boolean>(1);
         required.add(true);
-        mRules.add(new Rule<LogicalOperator, LogicalPlan>(nodes, edges, required,
-            new TypeCastInserter(plan, LOLOAD_CLASSNAME)));
-        
+        mRules.add(new Rule<LogicalOperator, LogicalPlan>(nodes, edges,
+                required, new TypeCastInserter(plan, LOLOAD_CLASSNAME)));
+
         // Add type casting to plans where the schema has been declared by
         // user in a statement with stream operator.
         nodes = new ArrayList<String>(1);
@@ -70,28 +79,24 @@
         edges = new HashMap<Integer, Integer>();
         required = new ArrayList<Boolean>(1);
         required.add(true);
-        mRules.add(new Rule(nodes, edges, required,
-            new TypeCastInserter(plan, LOSTREAM_CLASSNAME)));
-        
+        mRules.add(new Rule(nodes, edges, required, new TypeCastInserter(plan,
+                LOSTREAM_CLASSNAME)));
+
         // Optimize when LOAD precedes STREAM and the loader class
         // is the same as the serializer for the STREAM.
         // Similarly optimize when STREAM is followed by store and the
         // deserializer class is same as the Storage class.
-        mRules.add(new Rule(nodes, edges, required,
-            new StreamOptimizer(plan, LOSTREAM_CLASSNAME)));
-        
+        mRules.add(new Rule(nodes, edges, required, new StreamOptimizer(plan,
+                LOSTREAM_CLASSNAME)));
+
         // Push up limit where ever possible.
         nodes = new ArrayList<String>(1);
         edges = new HashMap<Integer, Integer>();
         required = new ArrayList<Boolean>(1);
         nodes.add("org.apache.pig.impl.logicalLayer.LOLimit");
         required.add(true);
-        mRules.add(new Rule<LogicalOperator, LogicalPlan>(nodes, edges, required,
-            new OpLimitOptimizer(plan)));
-        
-        
+        mRules.add(new Rule<LogicalOperator, LogicalPlan>(nodes, edges,
+                required, new OpLimitOptimizer(plan, mode)));
     }
 
 }
-
-

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/optimizer/OpLimitOptimizer.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/optimizer/OpLimitOptimizer.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/optimizer/OpLimitOptimizer.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/optimizer/OpLimitOptimizer.java Wed Mar 25 00:42:40 2009
@@ -23,6 +23,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.pig.ExecType;
 import org.apache.pig.PigException;
 import org.apache.pig.impl.logicalLayer.LOCogroup;
 import org.apache.pig.impl.logicalLayer.LOCross;
@@ -53,11 +54,17 @@
 public class OpLimitOptimizer extends LogicalTransformer {
 
     private static final Log log = LogFactory.getLog(OpLimitOptimizer.class);
+    private ExecType mode = ExecType.MAPREDUCE;
 
     public OpLimitOptimizer(LogicalPlan plan) {
         super(plan, new DepthFirstWalker<LogicalOperator, LogicalPlan>(plan));
     }
 
+    public OpLimitOptimizer(LogicalPlan plan, ExecType mode) {
+        super(plan, new DepthFirstWalker<LogicalOperator, LogicalPlan>(plan));
+        this.mode = mode;
+    }
+
     @Override
     public boolean check(List<LogicalOperator> nodes) throws OptimizerException {
         if((nodes == null) || (nodes.size() <= 0)) {
@@ -193,18 +200,23 @@
             // Limit can be merged into LOSort, result a "limited sort"
             else if (predecessor instanceof LOSort)
             {
-            	LOSort sort = (LOSort)predecessor;
-            	if (sort.getLimit()==-1)
-            		sort.setLimit(limit.getLimit());
-            	else
-            	    sort.setLimit(sort.getLimit()<limit.getLimit()?sort.getLimit():limit.getLimit());
-            	try {
-            		removeFromChain(limit, null);
-            	} catch (Exception e) {
-            	    int errCode = 2012;
-            	    String msg = "Can not remove LOLimit after LOSort";
-            		throw new OptimizerException(msg, errCode, PigException.BUG, e);
-            	}
+                if(mode == ExecType.LOCAL) {
+                    //We don't need this optimisation to happen in the local mode.
+                    //so we do nothing here.
+                } else {
+                    LOSort sort = (LOSort)predecessor;
+                    if (sort.getLimit()==-1)
+                        sort.setLimit(limit.getLimit());
+                    else
+                        sort.setLimit(sort.getLimit()<limit.getLimit()?sort.getLimit():limit.getLimit());
+                    try {
+                        removeFromChain(limit, null);
+                    } catch (Exception e) {
+                        int errCode = 2012;
+                        String msg = "Can not remove LOLimit after LOSort";
+                        throw new OptimizerException(msg, errCode, PigException.BUG, e);
+                    }
+                }
             }
             // Limit is merged into another LOLimit
             else if (predecessor instanceof LOLimit)

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/optimizer/TypeCastInserter.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/optimizer/TypeCastInserter.java?rev=758107&r1=758106&r2=758107&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/optimizer/TypeCastInserter.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/impl/logicalLayer/optimizer/TypeCastInserter.java Wed Mar 25 00:42:40 2009
@@ -165,8 +165,8 @@
                             // Either no schema was determined by loader OR the type 
                             // from the "determinedSchema" is different
                             // from the type specified - so we need to cast
-                            LOCast cast = new LOCast(p, OperatorKey.genOpKey(scope),
-                                proj, fs.type);
+                            LOCast cast = new LOCast(p, 
+                                        OperatorKey.genOpKey(scope), fs.type);
                             p.add(cast);
                             p.connect(proj, cast);