You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ga...@apache.org on 2008/03/28 22:44:46 UTC

svn commit: r642398 [1/2] - in /incubator/pig/branches/types: ./ src/org/apache/pig/ src/org/apache/pig/builtin/ src/org/apache/pig/impl/io/ src/org/apache/pig/impl/logicalLayer/ src/org/apache/pig/impl/logicalLayer/schema/ src/org/apache/pig/impl/plan/

Author: gates
Date: Fri Mar 28 14:44:40 2008
New Revision: 642398

URL: http://svn.apache.org/viewvc?rev=642398&view=rev
Log:
Committing Santosh's logical_operators_rev_3 patch.


Added:
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/BinaryExpressionOperator.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOAdd.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOAnd.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOBinCond.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOCast.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOConst.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LODistinct.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LODivide.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOEqual.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOFilter.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOForEach.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGreaterThan.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGreaterThanEqual.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLesserThan.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLesserThanEqual.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMapLookup.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMod.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMultiply.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LONegative.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LONot.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LONotEqual.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOOr.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOProject.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOSubtract.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/UnaryExpressionOperator.java
Removed:
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOEval.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOSplitOutput.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/schema/AtomSchema.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/schema/TupleSchema.java
Modified:
    incubator/pig/branches/types/build.xml
    incubator/pig/branches/types/src/org/apache/pig/LoadFunc.java
    incubator/pig/branches/types/src/org/apache/pig/PigServer.java
    incubator/pig/branches/types/src/org/apache/pig/builtin/BinStorage.java
    incubator/pig/branches/types/src/org/apache/pig/builtin/PigStorage.java
    incubator/pig/branches/types/src/org/apache/pig/builtin/TextLoader.java
    incubator/pig/branches/types/src/org/apache/pig/impl/io/FileSpec.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/ExpressionOperator.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOCogroup.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGenerate.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLoad.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOPrinter.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOSort.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOSplit.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOStore.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOUnion.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOUserFunc.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOVisitor.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LogicalOperator.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LogicalPlan.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LogicalPlanBuilder.java
    incubator/pig/branches/types/src/org/apache/pig/impl/plan/Operator.java
    incubator/pig/branches/types/src/org/apache/pig/impl/plan/PlanVisitor.java

Modified: incubator/pig/branches/types/build.xml
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/build.xml?rev=642398&r1=642397&r2=642398&view=diff
==============================================================================
--- incubator/pig/branches/types/build.xml (original)
+++ incubator/pig/branches/types/build.xml Fri Mar 28 14:44:40 2008
@@ -132,8 +132,7 @@
     </target>
 
     <target name="compile-sources">
-        <javac encoding="${build.encoding}" srcdir="${sources}"
-        includes="**/plan/*.java, **/data/*.java, **/pig/builtin/*.java, **/test/TestOperatorPlan.java, **/test/TestBuiltin.java, **/logicalLayer/LogicalPlan.java, **/logicalLayer/LOEval.java, **/logicalLayer/LOSort.java, **/logicalLayer/LOGenerate.java, **/logicalLayer/LOVisitor.java, **/logicalLayer/schema/Schema.java  " destdir="${dist}" debug="${javac.debug}" optimize="${javac.optimize}" target="${javac.version}" source="${javac.version}" deprecation="${javac.deprecation}">
+        <javac encoding="${build.encoding}" srcdir="${sources}" includes="**/plan/*.java, **/data/*.java, **/pig/builtin/*.java, **/test/TestOperatorPlan.java, **/test/TestBuiltin.java, **/logicalLayer/*.java, **/logicalLayer/schema/*.java  " destdir="${dist}" debug="${javac.debug}" optimize="${javac.optimize}" target="${javac.version}" source="${javac.version}" deprecation="${javac.deprecation}">
             <compilerarg line="${javac.args} ${javac.args.warnings}" />
             <classpath refid="${cp}" />
         </javac>

Modified: incubator/pig/branches/types/src/org/apache/pig/LoadFunc.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/LoadFunc.java?rev=642398&r1=642397&r2=642398&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/LoadFunc.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/LoadFunc.java Fri Mar 28 14:44:40 2008
@@ -18,6 +18,7 @@
 package org.apache.pig;
 
 import java.io.IOException;
+import java.net.URL;
 import java.util.Map;
 
 import org.apache.pig.data.DataBag;
@@ -157,13 +158,8 @@
      * loader may be able to do this if the data is self describing (e.g. JSON).  If
      * the loader cannot determine the schema, it can return a null.
      * @param fileName Name of the file to be read.
-     * @param in inpu stream, so that the function can read enough of the
-     * data to determine the schema.
-     * @param end Function should not read past this position in the stream.
      * @return a Schema describing the data if possible, or null otherwise.
      * @throws IOException.
      */
-    public Schema determineSchema(String fileName,
-                                  BufferedPositionedInputStream in,
-                                  long end) throws IOException;
+    public Schema determineSchema(URL fileName) throws IOException;
 }

Modified: incubator/pig/branches/types/src/org/apache/pig/PigServer.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/PigServer.java?rev=642398&r1=642397&r2=642398&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/PigServer.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/PigServer.java Fri Mar 28 14:44:40 2008
@@ -51,7 +51,6 @@
 import org.apache.pig.impl.logicalLayer.OperatorKey;
 import org.apache.pig.impl.logicalLayer.parser.ParseException;
 import org.apache.pig.impl.logicalLayer.parser.QueryParser;
-import org.apache.pig.impl.logicalLayer.schema.TupleSchema;
 import org.apache.pig.impl.util.WrappedIOException;
 
 
@@ -231,6 +230,7 @@
             return;
         }
             
+        // TODO FIX Need to change so that only syntax parsing is done here, and so that logical plan is additive.
         // parse the query into a logical plan
         LogicalPlan lp = null;
         try {
@@ -239,19 +239,24 @@
             throw (IOException) new IOException(e.getMessage()).initCause(e);
         }
         
+        /*
         if (lp.getAlias() != null) {
             aliases.put(lp.getAlias(), lp);
         }
+        */
     }
       
     public void dumpSchema(String alias) throws IOException{
-    LogicalPlan lp = aliases.get(alias);
-    if (lp == null)
-        throw new IOException("Invalid alias - " + alias);
+        // TODO FIX Need to rework so we can get an appropriate output schema
+        /*
+        LogicalPlan lp = aliases.get(alias);
+        if (lp == null)
+            throw new IOException("Invalid alias - " + alias);
 
-    TupleSchema schema = lp.getOpTable().get(lp.getRoot()).outputSchema();
+        TupleSchema schema = lp.getOpTable().get(lp.getRoot()).outputSchema();
 
-    System.out.println(schema.toString());    
+        System.out.println(schema.toString());    
+        */
     }
 
     public void setJobName(String name){
@@ -272,6 +277,7 @@
         
         LogicalPlan readFrom = (LogicalPlan) aliases.get(id);
 
+        // TODO FIX Make this work
         try {
             ExecPhysicalPlan pp = 
                 pigContext.getExecutionEngine().compile(readFrom, null);
@@ -318,6 +324,8 @@
     }
         
     public void store(LogicalPlan readFrom, String filename, String func) throws IOException {
+        // TODO FIX
+        /*
         LogicalPlan storePlan = QueryParser.generateStorePlan(readFrom.getOpTable(),
                                                               scope,
                                                               readFrom,
@@ -334,6 +342,7 @@
         catch (ExecException e) {
             throw WrappedIOException.wrap("Unable to store alias " + readFrom.getAlias(), e);
         }
+        */
     }
 
     /**
@@ -356,6 +365,8 @@
 
         lp.explain(stream);
         
+        // TODO FIX
+        /*
         stream.println("-----------------------------------------------");
         stream.println("Physical Plan:");
         try {
@@ -369,6 +380,7 @@
             stream.println("Failed to compile the logical plan for " + alias + " into a physical plan");
             throw WrappedIOException.wrap("Failed to compile to phyiscal plan: " + alias, e);
         }
+        */
     }
 
     /**

Modified: incubator/pig/branches/types/src/org/apache/pig/builtin/BinStorage.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/builtin/BinStorage.java?rev=642398&r1=642397&r2=642398&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/builtin/BinStorage.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/builtin/BinStorage.java Fri Mar 28 14:44:40 2008
@@ -22,6 +22,7 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.net.URL;
 import java.util.Iterator;
 import java.util.Map;
 
@@ -147,7 +148,7 @@
 		return null;
 	}
 
-	public Schema determineSchema(String fileName, BufferedPositionedInputStream in, long end) throws IOException {
+	public Schema determineSchema(URL fileName) throws IOException {
 		// TODO Auto-generated method stub
 		return null;
 	}

Modified: incubator/pig/branches/types/src/org/apache/pig/builtin/PigStorage.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/builtin/PigStorage.java?rev=642398&r1=642397&r2=642398&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/builtin/PigStorage.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/builtin/PigStorage.java Fri Mar 28 14:44:40 2008
@@ -20,6 +20,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Map;
 
@@ -233,7 +234,7 @@
 		return null;
 	}
 
-	public Schema determineSchema(String fileName, BufferedPositionedInputStream in, long end) throws IOException {
+	public Schema determineSchema(URL fileName) throws IOException {
 		// TODO Auto-generated method stub
 		return null;
 	}

Modified: incubator/pig/branches/types/src/org/apache/pig/builtin/TextLoader.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/builtin/TextLoader.java?rev=642398&r1=642397&r2=642398&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/builtin/TextLoader.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/builtin/TextLoader.java Fri Mar 28 14:44:40 2008
@@ -20,6 +20,7 @@
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.io.IOException;
+import java.net.URL;
 import java.nio.charset.Charset;
 import java.util.Map;
 
@@ -135,9 +136,7 @@
     /**
      * TextLoader does not provide a schema.
      */
-    public Schema determineSchema(String fileName,
-                                  BufferedPositionedInputStream in,
-                                  long end) throws IOException {
+    public Schema determineSchema(URL fileName) throws IOException {
         return null;
     }
 

Modified: incubator/pig/branches/types/src/org/apache/pig/impl/io/FileSpec.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/io/FileSpec.java?rev=642398&r1=642397&r2=642398&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/io/FileSpec.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/io/FileSpec.java Fri Mar 28 14:44:40 2008
@@ -15,47 +15,55 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.pig.impl.io;
-
-import java.io.Serializable;
-
-import org.apache.pig.impl.PigContext;
-
-
-/**
- * A simple class that specifies a file name and storage function which is used to read/write it
- * @author utkarsh
- *
- */
-public class FileSpec implements Serializable {
-    
-    private static final long serialVersionUID = 1L;
-    String fileName;
-
-    String funcSpec;
-    
-    public FileSpec(String fileName, String funcSpec){
-        this.fileName = fileName;
-        this.funcSpec = funcSpec;
-    }
-    
-    public String getFileName(){
-        return fileName;
-    }
-    
-    public String getFuncSpec(){
-        return funcSpec;
-    }
-    
-    @Override
-    public String toString(){
-        return fileName + ":" + funcSpec;
-    }
-    
-    public String getFuncName(){
-            return PigContext.getClassNameFromSpec(funcSpec);
-    }
-    public int getSize() {
-        throw new UnsupportedOperationException("File Size not implemented yet");
-    }
-}
+package org.apache.pig.impl.io;
+
+import java.io.Serializable;
+
+//import org.apache.pig.impl.PigContext;
+
+
+/**
+ * A simple class that specifies a file name and storage function which is used to read/write it
+ * @author utkarsh
+ *
+ */
+public class FileSpec implements Serializable {
+    
+    private static final long serialVersionUID = 1L;
+    String fileName;
+
+    String funcSpec;
+    
+    public FileSpec(String fileName, String funcSpec){
+        this.fileName = fileName;
+        this.funcSpec = funcSpec;
+    }
+    
+    public String getFileName(){
+        return fileName;
+    }
+    
+    public String getFuncSpec(){
+        return funcSpec;
+    }
+    
+    @Override
+    public String toString(){
+        return fileName + ":" + funcSpec;
+    }
+
+    //TODO FIX
+    //Commenting out the method getFuncName as it calls getClassNameFromSpec
+    //which is part of PigContext. PigContext pulls in HExecutionEngine which
+    //is completely commented out. The import org.apache.pig.impl.PigContext
+    //is also commented out
+    /*    
+    public String getFuncName(){
+            return PigContext.getClassNameFromSpec(funcSpec);
+    }
+    */
+
+    public int getSize() {
+        throw new UnsupportedOperationException("File Size not implemented yet");
+    }
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/BinaryExpressionOperator.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/BinaryExpressionOperator.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/BinaryExpressionOperator.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/BinaryExpressionOperator.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+
+/**
+ * This abstract class represents the logical Binary Expression Operator
+ * The binary operator has two operands and an operator. The format of
+ * the expression is lhs_operand operator rhs_operand. The operator name
+ * is assumed and can be inferred by the class name 
+ */
+
+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
+
+    /**
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @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) {
+        super(plan, k, rp);
+        mLhsOperand = lhsOperand;
+        mRhsOperand = rhsOperand;
+    }
+
+    public ExpressionOperator getLhsOperand() {
+        return mLhsOperand;
+    }
+
+    public ExpressionOperator getRhsOperand() {
+        return mRhsOperand;
+    }
+    
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+    
+    @Override
+    public boolean supportsMultipleInputs() {
+        return true;
+    }
+
+}
\ No newline at end of file

Modified: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/ExpressionOperator.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/ExpressionOperator.java?rev=642398&r1=642397&r2=642398&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/ExpressionOperator.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/ExpressionOperator.java Fri Mar 28 14:44:40 2008
@@ -17,17 +17,29 @@
  */
 package org.apache.pig.impl.logicalLayer;
 
+import java.util.List;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
 
 public abstract class ExpressionOperator extends LogicalOperator {
 
+    private static final long serialVersionUID = 2L;
+
     /**
-     * @param plan LogicalPlan this operator will be a part of.
-     * @param k OperatorKey of this operator
-     * @param rp requested level of parallelism, -1 for default.
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
      */
     public ExpressionOperator(LogicalPlan plan, OperatorKey k, int rp) {
         super(plan, k, rp);
     }
 
+    @Override
+    public boolean supportsMultipleOutputs() {
+        return false;
+    }
 }
 

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOAdd.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOAdd.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOAdd.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOAdd.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,66 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LOAdd extends BinaryExpressionOperator {
+
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param lhsOperand
+     *            the left hand side operand
+     * @param rhsOperand
+     *            the right hand side operand
+     */
+    public LOAdd(LogicalPlan plan, OperatorKey k, int rp,
+            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
+        super(plan, k, rp, lhsOperand, rhsOperand);
+    }
+
+    @Override
+    public Schema getSchema() {
+        // TODO When tuple addition is implemented, getSchema should
+        // compute the schema, store the computed schema and return
+        // the computed schema
+
+        return mSchema;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public String name() {
+        return "Add " + mKey.scope + "-" + mKey.id;
+    }
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOAnd.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOAnd.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOAnd.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOAnd.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,62 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LOAnd extends BinaryExpressionOperator {
+
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param lhsOperand
+     *            the left hand side operand
+     * @param rhsOperand
+     *            the right hand side operand
+     */
+    public LOAnd(LogicalPlan plan, OperatorKey k, int rp,
+            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
+        super(plan, k, rp, lhsOperand, rhsOperand);
+    }
+
+    @Override
+    public Schema getSchema() {
+        return mSchema;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public String name() {
+        return "And " + mKey.scope + "-" + mKey.id;
+    }
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOBinCond.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOBinCond.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOBinCond.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOBinCond.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import java.io.IOException;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LOBinCond extends ExpressionOperator {
+
+    // BinCond has a conditional expression and two nested queries.
+    // If the conditional expression evaluates to true the first nested query
+    // 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 rp
+     *            degree of requested parallelism with which to execute 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, int rp,
+            ExpressionOperator cond, ExpressionOperator lhsOp,
+            ExpressionOperator rhsOp) {
+        super(plan, k, rp);
+        mCond = cond;
+        mLhsOp = lhsOp;
+        mRhsOp = rhsOp;
+
+    }// End Constructor LOBinCond
+
+    public ExpressionOperator getCond() {
+        return mCond;
+    }
+
+    public ExpressionOperator getLhsOp() {
+        return mLhsOp;
+    }
+
+    public ExpressionOperator getRhsOp() {
+        return mRhsOp;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public Schema getSchema() throws IOException {
+        if (!mIsSchemaComputed && (null == mSchema)) {
+            try {
+                mSchema = mLhsOp.getSchema();
+                mIsSchemaComputed = true;
+            } catch (IOException ioe) {
+                mSchema = null;
+                mIsSchemaComputed = false;
+                throw ioe;
+            }
+        }
+        return mSchema;
+    }
+
+    @Override
+    public String name() {
+        return "BinCond " + mKey.scope + "-" + mKey.id;
+    }
+
+    @Override
+    public boolean supportsMultipleInputs() {
+        return true;
+    }
+
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOCast.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOCast.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOCast.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOCast.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LOCast extends ExpressionOperator {
+
+    // Cast has an expression that has to be converted to a specified type
+
+    private static final long serialVersionUID = 2L;
+    private ExpressionOperator mExpr;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute 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, int rp,
+            ExpressionOperator expr, byte type) {
+        super(plan, k, rp);
+        mExpr = expr;
+        mType = type;
+    }// End Constructor LOCast
+
+    public ExpressionOperator getExpression() {
+        return mExpr;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public Schema getSchema() {
+        return mSchema;
+    }
+
+    @Override
+    public String name() {
+        return "Cast " + mKey.scope + "-" + mKey.id;
+    }
+
+    @Override
+    public boolean supportsMultipleInputs() {
+        return false;
+    }
+
+}

Modified: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOCogroup.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOCogroup.java?rev=642398&r1=642397&r2=642398&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOCogroup.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOCogroup.java Fri Mar 28 14:44:40 2008
@@ -22,26 +22,46 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.pig.data.DataType;
 import org.apache.pig.impl.logicalLayer.parser.ParseException;
 import org.apache.pig.impl.logicalLayer.schema.Schema;
 import org.apache.pig.impl.plan.PlanVisitor;
 
-
 public class LOCogroup extends LogicalOperator {
     private static final long serialVersionUID = 2L;
 
-    public LOCogroup(LogicalPlan plan, OperatorKey k) { 
-        super(plan, k, -1);
+    private ArrayList<String> mInputs;
+    private ArrayList<ExpressionOperator> mGroupByCols;
+
+    /**
+     * 
+     * @param plan
+     *            LogicalPlan this operator is a part of.
+     * @param key
+     *            OperatorKey for this operator
+     * @param rp
+     *            Requested level of parallelism to be used
+     * @param groupByCols
+     *            the group by columns
+     */
+    public LOCogroup(LogicalPlan plan, OperatorKey k, int rp,
+            ArrayList<String> inputs, ArrayList<ExpressionOperator> groupByCols) {
+        super(plan, k, rp);
+        mInputs = inputs;
+        mGroupByCols = groupByCols;
     }
 
-    @Override
-    public String name() {
-        return "CoGroup " + mKey.scope + "-" + mKey.id;
+    public List<String> getInputs() {
+        return mInputs;
+    }
+
+    public List<ExpressionOperator> getGroupByCols() {
+        return mGroupByCols;
     }
 
     @Override
-    public String typeName() {
-        return "LOCogroup";
+    public String name() {
+        return "CoGroup " + mKey.scope + "-" + mKey.id;
     }
 
     @Override
@@ -55,18 +75,36 @@
     }
 
     @Override
-    public Schema getSchema() {
+    public Schema getSchema() throws IOException {
         // TODO create schema
-        return null;
+        /**
+         * Dumping my understanding of how the schema of a Group/CoGroup will
+         * look. The first field of the resulting tuple will have the alias
+         * 'group'. The schema for this field is a union of the group by columns
+         * for each input. The subsequent fields in the output tuple will have
+         * the alias of the input as the alias for a bag that contains the
+         * tuples from the input that match the grouping criterion
+         */
+        if (null == mSchema) {
+            List<Schema.FieldSchema> fss = new ArrayList<Schema.FieldSchema>(
+                    mGroupByCols.size() + 1);
+            // one more to account for the "group"
+            // the alias of the first field is group and hence the
+            // string "group"
+            // TODO The type of the field named "group" requires
+            // type promotion and the like
+            fss.add(new Schema.FieldSchema("group", null));
+            for (String input : mInputs) {
+                fss.add(new Schema.FieldSchema(input, DataType.BAG));
+            }
+            mIsSchemaComputed = true;
+        }
+        return mSchema;
     }
 
     @Override
-    public void visit(PlanVisitor v) throws ParseException {
-        if (!(v instanceof LOVisitor)) {
-            throw new RuntimeException("You can only visit LogicalOperators "
-                + "with an LOVisitor!");
-        }
-        ((LOVisitor)v).visitCogroup(this);
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
     }
 
 }

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOConst.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOConst.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOConst.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOConst.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LOConst extends ExpressionOperator {
+
+    // Cast has an expression that has to be converted to a specified type
+
+    private static final long serialVersionUID = 2L;
+    private Object mValue;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param value
+     *            the value of the constant
+     */
+    public LOConst(LogicalPlan plan, OperatorKey k, int rp, Object value) {
+        super(plan, k, rp);
+        mValue = value;
+    }// End Constructor LOConst
+
+    public Object getValue() {
+        return mValue;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public Schema getSchema() {
+        return mSchema;
+    }
+
+    @Override
+    public String name() {
+        return "Const " + mKey.scope + "-" + mKey.id;
+    }
+
+    @Override
+    public boolean supportsMultipleInputs() {
+        return false;
+    }
+
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LODistinct.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LODistinct.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LODistinct.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LODistinct.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pig.impl.logicalLayer;
+
+import java.util.Collection;
+import java.util.List;
+import java.io.IOException;
+
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+
+public class LODistinct extends LogicalOperator {
+
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     */
+    public LODistinct(LogicalPlan plan, OperatorKey k, int rp) {
+
+        super(plan, k, rp);
+    }
+
+    @Override
+    public Schema getSchema() throws IOException {
+        if (!mIsSchemaComputed && (null == mSchema)) {
+            // Get the schema of the parent
+            Collection<LogicalOperator> s = mPlan.getSuccessors(this);
+            try {
+                LogicalOperator op = s.iterator().next();
+                if(null == op) {
+                    throw new IOException("Could not find operator in plan");
+                }
+                mSchema = s.iterator().next().getSchema();
+                mIsSchemaComputed = true;
+            } catch (IOException ioe) {
+                mSchema = null;
+                mIsSchemaComputed = false;
+                throw ioe;
+            }
+        }
+        return mSchema;
+    }
+
+    @Override
+    public String name() {
+        return "Distinct " + mKey.scope + "-" + mKey.id;
+    }
+
+    @Override
+    public boolean supportsMultipleInputs() {
+        return false;
+    }
+
+    @Override
+    public boolean supportsMultipleOutputs() {
+        return false;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LODivide.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LODivide.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LODivide.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LODivide.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,66 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LODivide extends BinaryExpressionOperator {
+
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param lhsOperand
+     *            the left hand side operand
+     * @param rhsOperand
+     *            the right hand side operand
+     */
+    public LODivide(LogicalPlan plan, OperatorKey k, int rp,
+            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
+        super(plan, k, rp, lhsOperand, rhsOperand);
+    }
+
+    @Override
+    public Schema getSchema() {
+        // TODO When tuple division is implemented, getSchema should
+        // compute the schema, store the computed schema and return
+        // the computed schema
+
+        return mSchema;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public String name() {
+        return "Divide " + mKey.scope + "-" + mKey.id;
+    }
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOEqual.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOEqual.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOEqual.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOEqual.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,62 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LOEqual extends BinaryExpressionOperator {
+
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param lhsOperand
+     *            the left hand side operand
+     * @param rhsOperand
+     *            the right hand side operand
+     */
+    public LOEqual(LogicalPlan plan, OperatorKey k, int rp,
+            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
+        super(plan, k, rp, lhsOperand, rhsOperand);
+    }
+
+    @Override
+    public Schema getSchema() {
+        return mSchema;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public String name() {
+        return "Equal " + mKey.scope + "-" + mKey.id;
+    }
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOFilter.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOFilter.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOFilter.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOFilter.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pig.impl.logicalLayer;
+
+import java.io.IOException;
+import java.util.List;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+
+public class LOFilter extends LogicalOperator {
+
+    private static final long serialVersionUID = 2L;
+    private ExpressionOperator mCond;
+    private LogicalOperator mInput;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param cond
+     *            the filter condition
+     * @param input
+     *            the input that needs filtering
+     */
+    public LOFilter(LogicalPlan plan, OperatorKey k, int rp,
+            ExpressionOperator cond, LogicalOperator input) {
+
+        super(plan, k, rp);
+        mCond = cond;
+        mInput = input;
+    }
+
+    public LogicalOperator getInput() {
+        return mInput;
+    }
+
+    public ExpressionOperator getCondition() {
+        return mCond;
+    }
+
+    @Override
+    public Schema getSchema() throws IOException {
+        if (!mIsSchemaComputed && (null == mSchema)) {
+            try {
+                mSchema = mInput.getSchema();
+                mIsSchemaComputed = true;
+            } catch (IOException ioe) {
+                mSchema = null;
+                mIsSchemaComputed = false;
+                throw ioe;
+            }
+        }
+        return mSchema;
+    }
+
+    @Override
+    public String name() {
+        return "Filter " + mKey.scope + "-" + mKey.id;
+    }
+
+    @Override
+    public boolean supportsMultipleInputs() {
+        return false;
+    }
+
+    @Override
+    public boolean supportsMultipleOutputs() {
+        return false;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOForEach.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOForEach.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOForEach.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOForEach.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pig.impl.logicalLayer;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+
+public class LOForEach extends LogicalOperator {
+
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * The foreach operator supports nested query plans. At this point its one
+     * level of nesting. Foreach can have a list of operators that need to be
+     * applied over the input.
+     */
+
+    private ArrayList<LogicalOperator> mOperators;
+
+    /**
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param operators
+     *            the list of operators that are applied for each input
+     */
+    public LOForEach(LogicalPlan plan, OperatorKey k, int rp,
+            ArrayList<LogicalOperator> operators) {
+
+        super(plan, k, rp);
+        mOperators = operators;
+    }
+
+    public List<LogicalOperator> getOperators() {
+        return mOperators;
+    }
+
+    @Override
+    public Schema getSchema() throws IOException {
+        if (mSchema == null) {
+            // Assuming that the last operator is the GENERATE
+            // foreach has to terminate with a GENERATE
+            LogicalOperator last = mOperators.get(mOperators.size() - 1);
+            try {
+                mSchema = last.getSchema();
+                mIsSchemaComputed = true;
+            } catch (IOException ioe) {
+                mSchema = null;
+                mIsSchemaComputed = false;
+                throw ioe;
+            }
+        }
+        return mSchema;
+    }
+
+    @Override
+    public String name() {
+        return "Filter " + mKey.scope + "-" + mKey.id;
+    }
+
+    @Override
+    public boolean supportsMultipleInputs() {
+        return false;
+    }
+
+    @Override
+    public boolean supportsMultipleOutputs() {
+        return false;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+}

Modified: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGenerate.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGenerate.java?rev=642398&r1=642397&r2=642398&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGenerate.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGenerate.java Fri Mar 28 14:44:40 2008
@@ -17,6 +17,7 @@
  */
 package org.apache.pig.impl.logicalLayer;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -31,20 +32,33 @@
     /**
      * The projection list of this generate.
      */
-    private ArrayList<LogicalOperator> mProjections;
+    private ArrayList<ExpressionOperator> mProjections;
 
-    public LOGenerate(LogicalPlan plan, OperatorKey key) {
-        super(plan, key);
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param projections
+     *            the projection list of the generate
+     */
+    public LOGenerate(LogicalPlan plan, OperatorKey key, int rp,
+            ArrayList<ExpressionOperator> projections) {
+        super(plan, key, rp);
+        mProjections = projections;
     }
 
-    @Override
-    public String name() {
-        return "Generate " + mKey.scope + "-" + mKey.id;
+    public List<ExpressionOperator> getProjections() {
+        return mProjections;
     }
 
     @Override
-    public String typeName() {
-        return "LOGenerate";
+    public String name() {
+        return "Generate " + mKey.scope + "-" + mKey.id;
     }
 
     @Override
@@ -58,33 +72,33 @@
     }
 
     @Override
-    public Schema getSchema() {
+    public Schema getSchema() throws IOException {
         if (mSchema == null) {
-            List<Schema.FieldSchema> fss =
-                new ArrayList<Schema.FieldSchema>(mProjections.size());
-            for (LogicalOperator op : mProjections) {
+            List<Schema.FieldSchema> fss = new ArrayList<Schema.FieldSchema>(
+                    mProjections.size());
+            for (ExpressionOperator op : mProjections) {
+                String opAlias = op.getAlias();
                 if (op.getType() == DataType.TUPLE) {
-                    fss.add(new Schema.FieldSchema(null, op.getSchema()));
+                    try {
+                        fss.add(new Schema.FieldSchema(opAlias, op.getSchema()));
+                    } catch (IOException ioe) {
+                        mSchema = null;
+                        mIsSchemaComputed = false;
+                        throw ioe;
+                    }
                 } else {
-                    fss.add(new Schema.FieldSchema(null, op.getType()));
+                    fss.add(new Schema.FieldSchema(opAlias, op.getType()));
                 }
             }
             mSchema = new Schema(fss);
+            mIsSchemaComputed = true;
         }
         return mSchema;
     }
 
     @Override
-    public void visit(PlanVisitor v) throws ParseException {
-        if (!(v instanceof LOVisitor)) {
-            throw new RuntimeException("You can only visit LogicalOperators "
-                + "with an LOVisitor!");
-        }
-        ((LOVisitor)v).visitGenerate(this);
-    }
-
-    public List<LogicalOperator> getProjections() {
-        return mProjections;
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
     }
 
 }

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGreaterThan.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGreaterThan.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGreaterThan.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGreaterThan.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,62 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LOGreaterThan extends BinaryExpressionOperator {
+
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param lhsOperand
+     *            the left hand side operand
+     * @param rhsOperand
+     *            the right hand side operand
+     */
+    public LOGreaterThan(LogicalPlan plan, OperatorKey k, int rp,
+            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
+        super(plan, k, rp, lhsOperand, rhsOperand);
+    }
+
+    @Override
+    public Schema getSchema() {
+        return mSchema;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public String name() {
+        return "GreaterThan " + mKey.scope + "-" + mKey.id;
+    }
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGreaterThanEqual.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGreaterThanEqual.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGreaterThanEqual.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOGreaterThanEqual.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,62 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LOGreaterThanEqual extends BinaryExpressionOperator {
+
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param lhsOperand
+     *            the left hand side operand
+     * @param rhsOperand
+     *            the right hand side operand
+     */
+    public LOGreaterThanEqual(LogicalPlan plan, OperatorKey k, int rp,
+            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
+        super(plan, k, rp, lhsOperand, rhsOperand);
+    }
+
+    @Override
+    public Schema getSchema() {
+        return mSchema;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public String name() {
+        return "GreaterThanEqual " + mKey.scope + "-" + mKey.id;
+    }
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLesserThan.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLesserThan.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLesserThan.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLesserThan.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,62 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LOLesserThan extends BinaryExpressionOperator {
+
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param lhsOperand
+     *            the left hand side operand
+     * @param rhsOperand
+     *            the right hand side operand
+     */
+    public LOLesserThan(LogicalPlan plan, OperatorKey k, int rp,
+            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
+        super(plan, k, rp, lhsOperand, rhsOperand);
+    }
+
+    @Override
+    public Schema getSchema() {
+        return mSchema;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public String name() {
+        return "LesserThan " + mKey.scope + "-" + mKey.id;
+    }
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLesserThanEqual.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLesserThanEqual.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLesserThanEqual.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLesserThanEqual.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,62 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LOLesserThanEqual extends BinaryExpressionOperator {
+
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param lhsOperand
+     *            the left hand side operand
+     * @param rhsOperand
+     *            the right hand side operand
+     */
+    public LOLesserThanEqual(LogicalPlan plan, OperatorKey k, int rp,
+            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
+        super(plan, k, rp, lhsOperand, rhsOperand);
+    }
+
+    @Override
+    public Schema getSchema() {
+        return mSchema;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public String name() {
+        return "LesserThanEqual " + mKey.scope + "-" + mKey.id;
+    }
+}

Modified: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLoad.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLoad.java?rev=642398&r1=642397&r2=642398&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLoad.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOLoad.java Fri Mar 28 14:44:40 2008
@@ -18,68 +18,100 @@
 package org.apache.pig.impl.logicalLayer;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.net.URL;
 
-import org.apache.pig.LoadFunc;
-import org.apache.pig.impl.PigContext;
+import org.apache.pig.LoadFunc; // import org.apache.pig.impl.PigContext;
 import org.apache.pig.impl.io.FileSpec;
 import org.apache.pig.impl.logicalLayer.parser.ParseException;
-import org.apache.pig.impl.logicalLayer.schema.TupleSchema;
-
-
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.impl.plan.PlanVisitor;
 
 public class LOLoad extends LogicalOperator {
     private static final long serialVersionUID = 2L;
-    
-    private FileSpec mInput;
+
+    private FileSpec mInputFileSpec;
     private LoadFunc mLoadFunc;
+    private URL mSchemaFile;
+
+    /**
+     * @param plan
+     *            LogicalPlan this operator is a part of.
+     * @param key
+     *            OperatorKey for this operator
+     * @param rp
+     *            Requested level of parallelism to be used in the sort.
+     * @param inputFileSpec
+     *            the file to be loaded
+     */
+    public LOLoad(LogicalPlan plan, OperatorKey key, int rp,
+            FileSpec inputFileSpec, URL schemaFile) throws IOException {
+        super(plan, key, rp);
+
+        mInputFileSpec = inputFileSpec;
+        mSchemaFile = schemaFile;
+
+        // TODO FIX
+        // The code below is commented out as PigContext pulls in
+        // HExecutionEngine which in turn is completely commented out
+        // Also remove the commented out import org.apache.pig.impl.PigContext
+
+        /*
+         * try { mLoadFunc = (LoadFunc)
+         * PigContext.instantiateFuncFromSpec(inputFileSpec.getFuncSpec()); }
+         * catch (Exception e){ IOException ioe = new
+         * IOException(e.getMessage()); ioe.setStackTrace(e.getStackTrace());
+         * throw ioe; }
+         */
+    }
+
+    public FileSpec getInputFile() {
+        return mInputFileSpec;
+    }
 
-    public LOLoad(OperatorKey k,
-                  FileSpec inputFileSpec,
-                  String loader) throws IOException, ParseException {
-        super(k);
-        this.mInput = inputFileSpec;
-        
-        // check if we can instantiate load func
-        LoadFunc storageFunc =
-            (LoadFunc)PigContext.instantiateFuncFromSpec(loader);
+    public URL getSchemaFile() {
+        return mSchemaFile;
+    }
 
-        // TODO: Handle Schemas defined by Load Functions
-        //schema = new TupleSchema();
+    public LoadFunc getLoadFunc() {
+        return mLoadFunc;
     }
 
     @Override
     public String name() {
-        return "Load " + scope + "-" + id;
-    }
-
-    public FileSpec getInputFileSpec() {
-        return mInput;
+        return "Load " + mKey.scope + "-" + mKey.id;
     }
 
     @Override
-    public String arguments() {
-        return mInput.toString();
+    public Schema getSchema() throws IOException {
+        if (!mIsSchemaComputed && (null == mSchema)) {
+            // get the schema of the load function
+            try {
+                mSchema = mLoadFunc.determineSchema(mSchemaFile);
+                mIsSchemaComputed = true;
+            } catch (Exception e) {
+                IOException ioe = new IOException(e.getMessage());
+                ioe.setStackTrace(e.getStackTrace());
+                throw ioe;
+            }
+        }
+        return mSchema;
     }
 
     @Override
-    public String toString() {
-        StringBuffer result = new StringBuffer(super.toString());
-        result.append(" (outputType: ");
-        result.append(outputType);
-        result.append(')');
-        return result.toString();
+    public boolean supportsMultipleInputs() {
+        return false;
     }
 
     @Override
-    public List<String> getFuncs() {
-        List<String> funcs = super.getFuncs();
-        funcs.add(mInput.getFuncName());
-        return funcs;
+    public boolean supportsMultipleOutputs() {
+        return false;
     }
 
-    public void visit(LOVisitor v) {
-        v.visitLoad(this);
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
     }
 }

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMapLookup.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMapLookup.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMapLookup.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMapLookup.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pig.impl.logicalLayer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.pig.data.DataType;
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.impl.plan.PlanVisitor;
+
+public class LOMapLookup extends ExpressionOperator {
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * 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 DataType mValueType;
+    private Schema mValueSchema;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param map
+     *            the map expression
+     * @param mapKey
+     *            key to look up in the map. The key is of atomic type
+     * @param valueType
+     *            type of the value corresponding to the key
+     * @param valueSchema
+     *            schema of the value if the type is tuple
+     */
+    public LOMapLookup(LogicalPlan plan, OperatorKey key, int rp, ExpressionOperator map,
+            Object mapKey, DataType valueType, Schema valueSchema)
+            throws ParseException {
+        super(plan, key, rp);
+
+        if (!DataType.isAtomic(mapKey)) {
+            throw new ParseException("Map key" + mapKey.toString()
+                    + "is not atomic");
+        }
+        mMap = map;
+        mMapKey = mapKey;
+        mValueType = valueType;
+        mValueSchema = valueSchema;
+    }
+
+    public ExpressionOperator getMap() {
+        return mMap;
+    }
+
+    public Object getKey() {
+        return mMapKey;
+    }
+
+    public DataType getValueType() {
+        return mValueType;
+    }
+
+    @Override
+    public String name() {
+        return "MapLookup " + mKey.scope + "-" + mKey.id;
+    }
+
+    @Override
+    public boolean supportsMultipleInputs() {
+        return false;
+    }
+
+    @Override
+    public Schema getSchema() {
+        if (!mIsSchemaComputed && (null == mSchema)) {
+            Schema.FieldSchema fss;
+            if (DataType.findType(mValueType) == DataType.TUPLE) {
+                fss = new Schema.FieldSchema(null, mValueSchema);
+            } else {
+                fss = new Schema.FieldSchema(null, DataType
+                        .findType(mValueType));
+            }
+
+            mSchema = new Schema(fss);
+            mIsSchemaComputed = true;
+        }
+        return mSchema;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMod.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMod.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMod.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMod.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,62 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LOMod extends BinaryExpressionOperator {
+
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param lhsOperand
+     *            the left hand side operand
+     * @param rhsOperand
+     *            the right hand side operand
+     */
+    public LOMod(LogicalPlan plan, OperatorKey k, int rp,
+            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
+        super(plan, k, rp, lhsOperand, rhsOperand);
+    }
+
+    @Override
+    public Schema getSchema() {
+        return mSchema;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public String name() {
+        return "Mod " + mKey.scope + "-" + mKey.id;
+    }
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMultiply.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMultiply.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMultiply.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOMultiply.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,66 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LOMultiply extends BinaryExpressionOperator {
+
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param lhsOperand
+     *            the left hand side operand
+     * @param rhsOperand
+     *            the right hand side operand
+     */
+    public LOMultiply(LogicalPlan plan, OperatorKey k, int rp,
+            ExpressionOperator lhsOperand, ExpressionOperator rhsOperand) {
+        super(plan, k, rp, lhsOperand, rhsOperand);
+    }
+
+    @Override
+    public Schema getSchema() {
+        // TODO When tuple multiplication is implemented, getSchema should
+        // compute the schema, store the computed schema and return
+        // the computed schema
+
+        return mSchema;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public String name() {
+        return "Multiply " + mKey.scope + "-" + mKey.id;
+    }
+}

Added: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LONegative.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LONegative.java?rev=642398&view=auto
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LONegative.java (added)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LONegative.java Fri Mar 28 14:44:40 2008
@@ -0,0 +1,60 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pig.impl.logicalLayer;
+
+import org.apache.pig.impl.logicalLayer.parser.ParseException;
+import org.apache.pig.impl.plan.PlanVisitor;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+
+public class LONegative extends UnaryExpressionOperator {
+
+    private static final long serialVersionUID = 2L;
+
+    /**
+     * 
+     * @param plan
+     *            Logical plan this operator is a part of.
+     * @param k
+     *            Operator key to assign to this node.
+     * @param rp
+     *            degree of requested parallelism with which to execute this
+     *            node.
+     * @param operand
+     *            the only operand for a unary operator
+     */
+    public LONegative(LogicalPlan plan, OperatorKey k, int rp,
+            ExpressionOperator operand) {
+        super(plan, k, rp, operand);
+    }
+
+    @Override
+    public Schema getSchema() {
+        return mSchema;
+    }
+
+    @Override
+    public void visit(LOVisitor v) throws ParseException {
+        v.visit(this);
+    }
+
+    @Override
+    public String name() {
+        return "Negative " + mKey.scope + "-" + mKey.id;
+    }
+}