Modified: 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/POIsNull.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/POIsNull.java?rev=665739&r1=665738&r2=665739&view=diff
==============================================================================
--- 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/POIsNull.java
 (original)
+++ 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/POIsNull.java
 Mon Jun  9 09:18:42 2008
@@ -30,7 +30,7 @@
 import org.apache.pig.data.DataType;
 import org.apache.pig.data.Tuple;
 
-public class POIsNull extends ComparisonOperator {
+public class POIsNull extends UnaryComparisonOperator {
 
     public POIsNull(OperatorKey k, int rp) {
         super(k, rp);
@@ -44,8 +44,7 @@
     
     public POIsNull(OperatorKey k, int rp, ExpressionOperator in) {
         super(k, rp);
-        this.lhs = in;
-        this.rhs = null;
+        this.expr = in;
     }
 
     @Override
@@ -61,7 +60,7 @@
 
     @Override
     public Result getNext(Double d) throws ExecException {
-        Result res = lhs.getNext(d);
+        Result res = expr.getNext(d);
         if(res.returnStatus == POStatus.STATUS_OK) {
             if ((Double)res.result == null) {
                 res.result = true;
@@ -74,7 +73,7 @@
 
     @Override
     public Result getNext(Float f) throws ExecException {
-        Result res = lhs.getNext(f);
+        Result res = expr.getNext(f);
         if(res.returnStatus == POStatus.STATUS_OK) {
             if ((Float)res.result == null) {
                 res.result = true;
@@ -87,7 +86,7 @@
 
     @Override
     public Result getNext(Integer i) throws ExecException {
-        Result res = lhs.getNext(i);
+        Result res = expr.getNext(i);
         if(res.returnStatus == POStatus.STATUS_OK) {
             if ((Integer)res.result == null) {
                 res.result = true;
@@ -100,7 +99,7 @@
 
     @Override
     public Result getNext(Long l) throws ExecException {
-        Result res = lhs.getNext(l);
+        Result res = expr.getNext(l);
         if(res.returnStatus == POStatus.STATUS_OK) {
             if ((Long)res.result == null) {
                 res.result = true;
@@ -113,7 +112,7 @@
     
     @Override
     public Result getNext(DataByteArray dba) throws ExecException {
-        Result res = lhs.getNext(dba);
+        Result res = expr.getNext(dba);
         if(res.returnStatus == POStatus.STATUS_OK) {
             if ((DataByteArray)res.result == null) {
                 res.result = true;
@@ -126,7 +125,7 @@
     
     @Override
     public Result getNext(String s) throws ExecException {
-        Result res = lhs.getNext(s);
+        Result res = expr.getNext(s);
         if(res.returnStatus == POStatus.STATUS_OK) {
             if ((String)res.result == null) {
                 res.result = true;
@@ -139,7 +138,7 @@
     
     @Override
     public Result getNext(Boolean b) throws ExecException {
-        Result res = lhs.getNext(b);
+        Result res = expr.getNext(b);
         if(res.returnStatus == POStatus.STATUS_OK) {
             if ((Boolean)res.result == null) {
                 res.result = true;
@@ -152,7 +151,7 @@
     
     @Override
     public Result getNext(Tuple t) throws ExecException {
-        Result res = lhs.getNext(t);
+        Result res = expr.getNext(t);
         if(res.returnStatus == POStatus.STATUS_OK) {
             if ((Tuple)res.result == null) {
                 res.result = true;
@@ -165,7 +164,7 @@
     
     @Override
     public Result getNext(DataBag b) throws ExecException {
-        Result res = lhs.getNext(b);
+        Result res = expr.getNext(b);
         if(res.returnStatus == POStatus.STATUS_OK) {
             if ((DataBag)res.result == null) {
                 res.result = true;
@@ -178,7 +177,7 @@
     
     @Override
     public Result getNext(Map m) throws ExecException {
-        Result res = lhs.getNext(m);
+        Result res = expr.getNext(m);
         if(res.returnStatus == POStatus.STATUS_OK) {
             if ((Map)res.result == null) {
                 res.result = true;
@@ -190,8 +189,7 @@
     }
     
     public void setInput(ExpressionOperator in) {
-        this.lhs = in;
-        this.rhs = null;
+        this.expr = in;
     }
     
     

Modified: 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/PONegative.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/PONegative.java?rev=665739&r1=665738&r2=665739&view=diff
==============================================================================
--- 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/PONegative.java
 (original)
+++ 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/PONegative.java
 Mon Jun  9 09:18:42 2008
@@ -38,7 +38,7 @@
     
     public PONegative(OperatorKey k, int rp, ExpressionOperator input) {
         super(k, rp);
-        this.input = input;
+        this.expr = input;
     }
 
     @Override
@@ -54,7 +54,7 @@
 
     @Override
     public Result getNext(Double d) throws ExecException {
-        Result res = input.getNext(d);
+        Result res = expr.getNext(d);
         if(res.returnStatus == POStatus.STATUS_OK) {
             res.result = -1*((Double)res.result);
         }
@@ -63,7 +63,7 @@
 
     @Override
     public Result getNext(Float f) throws ExecException {
-        Result res = input.getNext(f);
+        Result res = expr.getNext(f);
         if(res.returnStatus == POStatus.STATUS_OK) {
             res.result = -1*((Float)res.result);
         }
@@ -72,7 +72,7 @@
 
     @Override
     public Result getNext(Integer i) throws ExecException {
-        Result res = input.getNext(i);
+        Result res = expr.getNext(i);
         if(res.returnStatus == POStatus.STATUS_OK) {
             res.result = -1*((Integer)res.result);
         }
@@ -81,7 +81,7 @@
 
     @Override
     public Result getNext(Long l) throws ExecException {
-        Result res = input.getNext(l);
+        Result res = expr.getNext(l);
         if(res.returnStatus == POStatus.STATUS_OK) {
             res.result = -1*((Long)res.result);
         }
@@ -89,7 +89,7 @@
     }
     
     public void setInput(ExpressionOperator in) {
-        this.input = in;
+        this.expr = in;
     }
     
     

Added: 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/PONot.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/PONot.java?rev=665739&view=auto
==============================================================================
--- 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/PONot.java
 (added)
+++ 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/PONot.java
 Mon Jun  9 09:18:42 2008
@@ -0,0 +1,69 @@
+/*
+ * 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.physicalLayer.expressionOperators;
+
+import org.apache.pig.backend.executionengine.ExecException;
+import org.apache.pig.impl.plan.OperatorKey;
+import org.apache.pig.impl.physicalLayer.POStatus;
+import org.apache.pig.impl.physicalLayer.Result;
+import org.apache.pig.impl.physicalLayer.plans.ExprPlanVisitor;
+import org.apache.pig.impl.plan.VisitorException;
+
+/**
+ * Boolean not operator.
+ */
+
+public class PONot extends UnaryComparisonOperator {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+
+    public PONot(OperatorKey k) {
+        super(k);
+    }
+
+    public PONot(OperatorKey k, int rp) {
+        super(k, rp);
+    }
+
+    @Override
+    public void visit(ExprPlanVisitor v) throws VisitorException {
+        v.visitNot(this);
+    }
+
+    @Override
+    public String name() {
+        return "Not - " + mKey.toString();
+    }
+
+    @Override
+    public Result getNext(Boolean b) throws ExecException {
+        byte status;
+        Result res;
+        Boolean dummy = null;
+        res = expr.getNext(dummy);
+        status = res.returnStatus;
+        if(status != POStatus.STATUS_OK) {
+            return res;
+        }
+        res.result = !(Boolean)res.result;
+        return res;
+    }
+}

Added: 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/POOr.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/POOr.java?rev=665739&view=auto
==============================================================================
--- 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/POOr.java
 (added)
+++ 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/POOr.java
 Mon Jun  9 09:18:42 2008
@@ -0,0 +1,80 @@
+/*
+ * 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.physicalLayer.expressionOperators;
+
+import org.apache.pig.backend.executionengine.ExecException;
+import org.apache.pig.impl.plan.OperatorKey;
+import org.apache.pig.impl.physicalLayer.POStatus;
+import org.apache.pig.impl.physicalLayer.Result;
+import org.apache.pig.impl.physicalLayer.plans.ExprPlanVisitor;
+import org.apache.pig.impl.plan.VisitorException;
+
+/**
+ * Boolean or operator.
+ */
+
+public class POOr extends BinaryComparisonOperator {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+
+    public POOr(OperatorKey k) {
+        super(k);
+    }
+
+    public POOr(OperatorKey k, int rp) {
+        super(k, rp);
+    }
+
+    @Override
+    public void visit(ExprPlanVisitor v) throws VisitorException {
+        v.visitOr(this);
+    }
+
+    @Override
+    public String name() {
+        return "Or - " + mKey.toString();
+    }
+
+    @Override
+    public Result getNext(Boolean b) throws ExecException {
+        byte status;
+        Result res;
+        Boolean left = null, right = null;
+        res = lhs.getNext(left);
+        status = res.returnStatus;
+        if(status != POStatus.STATUS_OK) {
+            return res;
+        }
+        left = (Boolean)res.result;
+        // Short circuit.
+        if (left) return res;
+        
+        res = rhs.getNext(right);
+        status = res.returnStatus;
+        if(status != POStatus.STATUS_OK) {
+            return res;
+        }
+        right = (Boolean)res.result;
+        
+        res.result = new Boolean(left || right);
+        return res;
+    }
+}

Added: 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/PORegexp.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/PORegexp.java?rev=665739&view=auto
==============================================================================
--- 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/PORegexp.java
 (added)
+++ 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/PORegexp.java
 Mon Jun  9 09:18:42 2008
@@ -0,0 +1,94 @@
+/*
+ * 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.physicalLayer.expressionOperators;
+
+import java.util.regex.PatternSyntaxException;
+
+import org.apache.pig.backend.executionengine.ExecException;
+import org.apache.pig.data.DataByteArray;
+import org.apache.pig.impl.plan.OperatorKey;
+import org.apache.pig.impl.physicalLayer.POStatus;
+import org.apache.pig.impl.physicalLayer.Result;
+import org.apache.pig.impl.physicalLayer.plans.ExprPlanVisitor;
+import org.apache.pig.impl.plan.VisitorException;
+
+public class PORegexp extends BinaryComparisonOperator {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+
+    public PORegexp(OperatorKey k) {
+        this(k, -1);
+    }
+
+    public PORegexp(OperatorKey k, int rp) {
+        super(k, rp);
+    }
+
+    @Override
+    public void visit(ExprPlanVisitor v) throws VisitorException {
+        v.visitRegexp(this);
+    }
+
+    @Override
+    public String name() {
+        return "Matches - " + mKey.toString();
+    }
+
+    @Override
+    public Result getNext(DataByteArray inp) throws ExecException {
+        // TODO, no idea how to take this on.
+        return new Result();
+    }
+
+    @Override
+    public Result getNext(String inp) throws ExecException {
+        byte status;
+        Result res;
+
+        String left = null, right = null;
+
+        res = lhs.getNext(left);
+        status = res.returnStatus;
+        if (status != POStatus.STATUS_OK) {
+
+            return res;
+        }
+        left = (String) res.result;
+
+        res = rhs.getNext(right);
+        status = res.returnStatus;
+        if (status != POStatus.STATUS_OK) {
+
+            return res;
+        }
+        right = (String) res.result;
+
+        // left is expression to match against, right is regular expression
+        try {
+            res.result = new Boolean(left.matches(right));
+            return res;
+        } catch (PatternSyntaxException pse) {
+            throw new ExecException("Unable to parse regular expression " +
+                right, pse);
+        }
+    }
+
+}

Added: 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/UnaryComparisonOperator.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/UnaryComparisonOperator.java?rev=665739&view=auto
==============================================================================
--- 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/UnaryComparisonOperator.java
 (added)
+++ 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/UnaryComparisonOperator.java
 Mon Jun  9 09:18:42 2008
@@ -0,0 +1,52 @@
+/*
+ * 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.physicalLayer.expressionOperators;
+
+import org.apache.pig.impl.plan.OperatorKey;
+
+/**
+ * This is a base class for all unary comparison operators. Supports the
+ * use of operand type instead of result type as the result type is
+ * always boolean.
+ * 
+ */
+public abstract class UnaryComparisonOperator extends UnaryExpressionOperator
+        implements ComparisonOperator {
+    //The result type for comparison operators is always
+    //Boolean. So the plans evaluating these should consider
+    //the type of the operands instead of the result.
+    //The result will be comunicated using the Status object.
+    //This is a slight abuse of the status object.
+    protected byte operandType;
+    
+    public UnaryComparisonOperator(OperatorKey k) {
+        this(k,-1);
+    }
+
+    public UnaryComparisonOperator(OperatorKey k, int rp) {
+        super(k, rp);
+    }
+
+    public byte getOperandType() {
+        return operandType;
+    }
+
+    public void setOperandType(byte operandType) {
+        this.operandType = operandType;
+    }
+}

Modified: 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/UnaryExpressionOperator.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/UnaryExpressionOperator.java?rev=665739&r1=665738&r2=665739&view=diff
==============================================================================
--- 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/UnaryExpressionOperator.java
 (original)
+++ 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/expressionOperators/UnaryExpressionOperator.java
 Mon Jun  9 09:18:42 2008
@@ -19,12 +19,13 @@
 
 import org.apache.pig.impl.plan.OperatorKey;
 import org.apache.pig.impl.physicalLayer.plans.ExprPlanVisitor;
+import org.apache.pig.impl.physicalLayer.plans.PhysicalPlan;
 import 
org.apache.pig.impl.physicalLayer.expressionOperators.ExpressionOperator;
 import org.apache.pig.impl.plan.VisitorException;
 
 public abstract class UnaryExpressionOperator extends ExpressionOperator {
 
-    ExpressionOperator input;
+    ExpressionOperator expr;
     
     public UnaryExpressionOperator(OperatorKey k, int rp) {
         super(k, rp);
@@ -41,7 +42,27 @@
         // TODO Auto-generated method stub
         return false;
     }
-    
-    
 
+    /**
+     * Set the contained expression to the be the input value.
+     */
+    public void setInputAsExpr(PhysicalPlan<ExpressionOperator> plan) {
+        expr = plan.getPredecessors(this).get(0);
+    }
+
+    /**
+     * Set the contained expression explicitly.  This is mostly for testing.
+     * @param e Expression to contain.
+     */
+    public void setExpr(ExpressionOperator e) {
+        expr = e;
+    }
+
+    /**
+     * Get the contained expression.
+     * @return contained expression.
+     */
+    public ExpressionOperator getExpr() { 
+        return expr;
+    }
 }

Modified: 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/plans/ExprPlanVisitor.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/plans/ExprPlanVisitor.java?rev=665739&r1=665738&r2=665739&view=diff
==============================================================================
--- 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/plans/ExprPlanVisitor.java
 (original)
+++ 
incubator/pig/branches/types/src/org/apache/pig/impl/physicalLayer/plans/ExprPlanVisitor.java
 Mon Jun  9 09:18:42 2008
@@ -71,6 +71,10 @@
         //do nothing
     }
     
+    public void visitRegexp(PORegexp re) throws VisitorException{
+        //do nothing
+    }
+    
     public void visitAdd(Add add) throws VisitorException{
         //do nothing
     }
@@ -91,6 +95,18 @@
         //do nothing
     }
     
+    public void visitAnd(POAnd and) throws VisitorException {
+        //do nothing
+    }
+
+    public void visitOr(POOr or) throws VisitorException {
+        //do nothing
+    }
+
+    public void visitNot(PONot not) throws VisitorException {
+        //do nothing
+    }
+
     public void visitBinCond(POBinCond binCond) {
         // do nothing
         

Added: incubator/pig/branches/types/test/org/apache/pig/test/TestBoolean.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/TestBoolean.java?rev=665739&view=auto
==============================================================================
--- incubator/pig/branches/types/test/org/apache/pig/test/TestBoolean.java 
(added)
+++ incubator/pig/branches/types/test/org/apache/pig/test/TestBoolean.java Mon 
Jun  9 09:18:42 2008
@@ -0,0 +1,174 @@
+/*
+ * 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.test;
+
+
+import java.util.Map;
+import java.util.Random;
+
+import junit.framework.TestCase;
+
+import org.apache.pig.backend.executionengine.ExecException;
+import org.apache.pig.data.DataType;
+import org.apache.pig.impl.plan.OperatorKey;
+import org.apache.pig.impl.physicalLayer.POStatus;
+import org.apache.pig.impl.physicalLayer.Result;
+import 
org.apache.pig.impl.physicalLayer.expressionOperators.ConstantExpression;
+import org.apache.pig.impl.physicalLayer.expressionOperators.*;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class TestBoolean extends TestCase{
+
+    Random r = new Random();
+    ConstantExpression lt, rt;
+    BinaryExpressionOperator bop;
+    UnaryExpressionOperator uop;
+    Boolean dummy = new Boolean(true);
+
+    @Before
+    public void setUp() throws Exception {
+        lt = new ConstantExpression(new OperatorKey("",r.nextLong()));
+        lt.setResultType(DataType.BOOLEAN);
+        rt = new ConstantExpression(new OperatorKey("",r.nextLong()));
+        rt.setResultType(DataType.BOOLEAN);
+    }
+
+    private void setupAnd() {
+        bop = new POAnd(new OperatorKey("", r.nextLong()));
+        bop.setLhs(lt);
+        bop.setRhs(rt);
+    }
+
+    private void setupOr() {
+        bop = new POOr(new OperatorKey("", r.nextLong()));
+        bop.setLhs(lt);
+        bop.setRhs(rt);
+    }
+
+    private void setupNot() {
+        uop = new PONot(new OperatorKey("", r.nextLong()));
+        uop.setExpr(lt);
+    }
+
+
+    @Test
+    public void testAndFirstFalse() throws ExecException{
+        setupAnd();
+        lt.setValue(new Boolean(false));
+        rt.setValue(new Boolean(true));
+        Result res = bop.getNext(dummy);
+        assertEquals(POStatus.STATUS_OK, res.returnStatus);
+        assertFalse((Boolean)res.result);
+    }
+
+    @Test
+    public void testAndSecondFalse() throws ExecException{
+        setupAnd();
+        lt.setValue(new Boolean(true));
+        rt.setValue(new Boolean(false));
+        Result res = bop.getNext(dummy);
+        assertEquals(POStatus.STATUS_OK, res.returnStatus);
+        assertFalse((Boolean)res.result);
+    }
+
+    @Test
+    public void testAndBothFalse() throws ExecException{
+        setupAnd();
+        lt.setValue(new Boolean(false));
+        rt.setValue(new Boolean(false));
+        Result res = bop.getNext(dummy);
+        assertEquals(POStatus.STATUS_OK, res.returnStatus);
+        assertFalse((Boolean)res.result);
+    }
+
+    @Test
+    public void testAndTrue() throws ExecException{
+        setupAnd();
+        lt.setValue(new Boolean(true));
+        rt.setValue(new Boolean(true));
+        Result res = bop.getNext(dummy);
+        assertEquals(POStatus.STATUS_OK, res.returnStatus);
+        assertTrue((Boolean)res.result);
+    }
+
+    @Test
+    public void testOrFirstFalse() throws ExecException{
+        setupOr();
+        lt.setValue(new Boolean(false));
+        rt.setValue(new Boolean(true));
+        Result res = bop.getNext(dummy);
+        assertEquals(POStatus.STATUS_OK, res.returnStatus);
+        assertTrue((Boolean)res.result);
+    }
+
+    @Test
+    public void testOrSecondFalse() throws ExecException{
+        setupOr();
+        lt.setValue(new Boolean(true));
+        rt.setValue(new Boolean(false));
+        Result res = bop.getNext(dummy);
+        assertEquals(POStatus.STATUS_OK, res.returnStatus);
+        assertTrue((Boolean)res.result);
+    }
+
+    @Test
+    public void testOrBothFalse() throws ExecException{
+        setupOr();
+        lt.setValue(new Boolean(false));
+        rt.setValue(new Boolean(false));
+        Result res = bop.getNext(dummy);
+        assertEquals(POStatus.STATUS_OK, res.returnStatus);
+        assertFalse((Boolean)res.result);
+    }
+
+    @Test
+    public void testOrTrue() throws ExecException{
+        setupOr();
+        lt.setValue(new Boolean(true));
+        rt.setValue(new Boolean(true));
+        Result res = bop.getNext(dummy);
+        assertEquals(POStatus.STATUS_OK, res.returnStatus);
+        assertTrue((Boolean)res.result);
+    }
+
+    @Test
+    public void testNotTrue() throws ExecException{
+        setupNot();
+        lt.setValue(new Boolean(true));
+        Result res = uop.getNext(dummy);
+        assertEquals(POStatus.STATUS_OK, res.returnStatus);
+        assertFalse((Boolean)res.result);
+    }
+
+    @Test
+    public void testNotFalse() throws ExecException{
+        setupNot();
+        lt.setValue(new Boolean(false));
+        Result res = uop.getNext(dummy);
+        assertEquals(POStatus.STATUS_OK, res.returnStatus);
+        assertTrue((Boolean)res.result);
+    }
+
+
+
+
+
+}
+

Added: incubator/pig/branches/types/test/org/apache/pig/test/TestRegexp.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/TestRegexp.java?rev=665739&view=auto
==============================================================================
--- incubator/pig/branches/types/test/org/apache/pig/test/TestRegexp.java 
(added)
+++ incubator/pig/branches/types/test/org/apache/pig/test/TestRegexp.java Mon 
Jun  9 09:18:42 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.test;
+
+
+import java.util.Map;
+import java.util.Random;
+
+import junit.framework.TestCase;
+
+import org.apache.pig.backend.executionengine.ExecException;
+import org.apache.pig.data.DataType;
+import org.apache.pig.impl.plan.OperatorKey;
+import org.apache.pig.impl.physicalLayer.POStatus;
+import org.apache.pig.impl.physicalLayer.Result;
+import 
org.apache.pig.impl.physicalLayer.expressionOperators.ConstantExpression;
+import org.apache.pig.impl.physicalLayer.expressionOperators.*;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class TestRegexp extends TestCase{
+
+    Random r = new Random();
+    ConstantExpression lt, rt;
+    BinaryExpressionOperator op;
+
+    @Before
+    public void setUp() throws Exception {
+        lt = new ConstantExpression(new OperatorKey("",r.nextLong()));
+        lt.setResultType(DataType.CHARARRAY);
+        rt = new ConstantExpression(new OperatorKey("",r.nextLong()));
+        rt.setResultType(DataType.CHARARRAY);
+        op = new PORegexp(new OperatorKey("", r.nextLong()));
+        op.setLhs(lt);
+        op.setRhs(rt);
+    }
+
+    @Test
+    public void testMatches() throws ExecException{
+        lt.setValue(new String(
+            "The quick sly fox jumped over the lazy brown dog"));
+        rt.setValue(".*s.y.*");
+        Result res = op.getNext(new String());
+        assertEquals(POStatus.STATUS_OK, res.returnStatus);
+        assertTrue((Boolean)res.result);
+    }
+
+    @Test
+    public void testDoesntMatch() throws ExecException{
+        lt.setValue(new String(
+            "The quick sly fox jumped over the lazy brown dog"));
+        rt.setValue(new String("zzz"));
+        Result res = op.getNext(new String());
+        assertEquals(POStatus.STATUS_OK, res.returnStatus);
+        assertFalse((Boolean)res.result);
+    }
+}
+

Modified: 
incubator/pig/branches/types/test/org/apache/pig/test/data/GoldenFiles/IsNull1.gld
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/data/GoldenFiles/IsNull1.gld?rev=665739&r1=665738&r2=665739&view=diff
==============================================================================
--- 
incubator/pig/branches/types/test/org/apache/pig/test/data/GoldenFiles/IsNull1.gld
 (original)
+++ 
incubator/pig/branches/types/test/org/apache/pig/test/data/GoldenFiles/IsNull1.gld
 Mon Jun  9 09:18:42 2008
@@ -10,9 +10,11 @@
 
 Filter - Test-Plan-Builder-221
 |   |
-|   POIsNull - Test-Plan-Builder-223
+|   Not - Test-Plan-Builder-224
 |   |
-|   |---Project(0) - Test-Plan-Builder-222
+|   |---POIsNull - Test-Plan-Builder-223
+|       |
+|       |---Project(0) - Test-Plan-Builder-222
 |
 |---Split - Test-Plan-Builder-217
     |

Modified: 
incubator/pig/branches/types/test/org/apache/pig/test/data/GoldenFiles/IsNull2.gld
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/data/GoldenFiles/IsNull2.gld?rev=665739&r1=665738&r2=665739&view=diff
==============================================================================
--- 
incubator/pig/branches/types/test/org/apache/pig/test/data/GoldenFiles/IsNull2.gld
 (original)
+++ 
incubator/pig/branches/types/test/org/apache/pig/test/data/GoldenFiles/IsNull2.gld
 Mon Jun  9 09:18:42 2008
@@ -1,8 +1,10 @@
 Filter - Test-Plan-Builder-221
 |   |
-|   POIsNull - Test-Plan-Builder-223
+|   Not - Test-Plan-Builder-224
 |   |
-|   |---Project(0) - Test-Plan-Builder-222
+|   |---POIsNull - Test-Plan-Builder-223
+|       |
+|       |---Project(0) - Test-Plan-Builder-222
 |
 |---Split - Test-Plan-Builder-217
     |

Modified: 
incubator/pig/branches/types/test/org/apache/pig/test/utils/GenPhyOp.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/utils/GenPhyOp.java?rev=665739&r1=665738&r2=665739&view=diff
==============================================================================
--- incubator/pig/branches/types/test/org/apache/pig/test/utils/GenPhyOp.java 
(original)
+++ incubator/pig/branches/types/test/org/apache/pig/test/utils/GenPhyOp.java 
Mon Jun  9 09:18:42 2008
@@ -607,7 +607,7 @@
         ConstantExpression ce2 = GenPhyOp.exprConst();
         ce2.setValue(rhsVal);
 
-        ComparisonOperator cop = null;
+        BinaryComparisonOperator cop = null;
         switch (CompType) {
         case GenPhyOp.GTE:
             cop = GenPhyOp.compGTOrEqualToExpr();
@@ -652,7 +652,7 @@
         ConstantExpression ce2 = GenPhyOp.exprConst();
         ce2.setValue(rhsVal);
         
-        ComparisonOperator cop = null;
+        BinaryComparisonOperator cop = null;
         switch(CompType){
         case GenPhyOp.GTE:
             cop = GenPhyOp.compGTOrEqualToExpr();


Reply via email to