hadoop-pig-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shubham Chopra (JIRA)" <j...@apache.org>
Subject [jira] Commented: (PIG-161) Rework physical plan
Date Wed, 21 May 2008 09:23:55 GMT

    [ https://issues.apache.org/jira/browse/PIG-161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12598598#action_12598598
] 

Shubham Chopra commented on PIG-161:
------------------------------------

I had to modify Pi's TypeCheckingVisitor. Instead of the visit(BinaryExpressionOperator) function,
I had to put in individual functions that override corresponding methods in LOVisitor. So,
instead of;

{{{
protected void visit(BinaryExpressionOperator binOp)
            throws VisitorException {       
        
        ExpressionOperator lhs = binOp.getLhsOperand() ;
        ExpressionOperator rhs = binOp.getRhsOperand() ;
        
        byte lhsType = lhs.getType() ;
        byte rhsType = rhs.getType() ;
        
        
        /**
         * For AND/OR, all operands must be boolean
         * Output is always boolean
         */
        if ( (binOp instanceof LOAnd) ||
             (binOp instanceof LOOr)  ) {
            
            if (  (lhsType != DataType.BOOLEAN)  ||
                  (rhsType != DataType.BOOLEAN)  ) {
                String msg = "Operands of AND/OR can be boolean only" ;
                msgCollector.collect(msg, MessageType.Error);
                throw new VisitorException(msg) ;
            }
            
            binOp.setType(DataType.BOOLEAN) ;
        } 
}}}

I had to convert it to the following : 
{{{
@Override
    public void visit(LOAnd binOp) throws VisitorException {
    	ExpressionOperator lhs = binOp.getLhsOperand() ;
    	ExpressionOperator rhs = binOp.getRhsOperand() ;

    	byte lhsType = lhs.getType() ;
    	byte rhsType = rhs.getType() ;

    	if (  (lhsType != DataType.BOOLEAN)  ||
    			(rhsType != DataType.BOOLEAN)  ) {
    		String msg = "Operands of AND/OR can be boolean only" ;
    		msgCollector.collect(msg, MessageType.Error);
    		throw new VisitorException(msg) ;
    	}

    	binOp.setType(DataType.BOOLEAN) ;

    }
    
    @Override
    public void visit(LOOr binOp) throws VisitorException {
    	ExpressionOperator lhs = binOp.getLhsOperand() ;
    	ExpressionOperator rhs = binOp.getRhsOperand() ;

    	byte lhsType = lhs.getType() ;
    	byte rhsType = rhs.getType() ;

    	if (  (lhsType != DataType.BOOLEAN)  ||
    			(rhsType != DataType.BOOLEAN)  ) {
    		String msg = "Operands of AND/OR can be boolean only" ;
    		msgCollector.collect(msg, MessageType.Error);
    		throw new VisitorException(msg) ;
    	}

    	binOp.setType(DataType.BOOLEAN) ;
    }
}}}

> Rework physical plan
> --------------------
>
>                 Key: PIG-161
>                 URL: https://issues.apache.org/jira/browse/PIG-161
>             Project: Pig
>          Issue Type: Sub-task
>            Reporter: Alan Gates
>            Assignee: Alan Gates
>         Attachments: arithmeticOperators.patch, BinCondAndNegative.patch, CastAndMapLookUp.patch,
incr2.patch, incr3.patch, incr4.patch, incr5.patch, logToPhyTranslator.patch, MRCompilerTests_PlansAndOutputs.txt,
Phy_AbsClass.patch, physicalOps.patch, physicalOps.patch, physicalOps.patch, physicalOps.patch,
physicalOps_latest.patch, POCast.patch, POCast.patch, podistinct.patch, pogenerate.patch,
pogenerate.patch, pogenerate.patch, posort.patch, TEST-org.apache.pig.test.TestLocalJobSubmission.txt,
TEST-org.apache.pig.test.TestLogToPhyCompiler.txt, TEST-org.apache.pig.test.TestTypeCheckingValidator.txt,
TEST-org.apache.pig.test.TestUnion.txt, translator.patch, translator.patch, translator.patch
>
>
> This bug tracks work to rework all of the physical operators as described in http://wiki.apache.org/pig/PigTypesFunctionalSpec

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message