Package org.apache.pig.newplan.logical.expression

Examples of org.apache.pig.newplan.logical.expression.MultiplyExpression


    public void visit(LOMultiply binOp) throws VisitorException {
        ExpressionOperator left = binOp.getLhsOperand();
        ExpressionOperator right = binOp.getRhsOperand();
       
        MultiplyExpression ae = new MultiplyExpression(exprPlan,
                exprOpsMap.get(left), exprOpsMap.get(right));
        exprOpsMap.put(binOp, ae);
    }
View Full Code Here


       
        assertEquals( 1, genExp.getSources().size() );
       
        // Main Tests start here
        assertEquals( MultiplyExpression.class, genExp.getSources().get(0).getClass() );
        MultiplyExpression add = (MultiplyExpression) genExp.getSources().get(0);
        assertEquals( ls.getField(0).uid, add.getLhs().getFieldSchema().uid );
        assertEquals( ls.getField(1).uid, add.getRhs().getFieldSchema().uid );
        assertTrue( ls.getField(0).uid != add.getFieldSchema().uid );
        assertTrue( ls.getField(1).uid != add.getFieldSchema().uid );
       
        assertEquals( 1, inputPln.getLeaves().size() );
        assertEquals( Multiply.class, inputPln.getLeaves().get(0).getClass() );
        Multiply pMultiply = (Multiply) inputPln.getLeaves().get(0);
        assertEquals( 2, inputPln.getRoots().size() );
View Full Code Here

       
        assertEquals( 1, genExp.getSources().size() );
       
        // Main Tests start here
        assertEquals( MultiplyExpression.class, genExp.getSources().get(0).getClass() );
        MultiplyExpression add = (MultiplyExpression) genExp.getSources().get(0);
        assertEquals( ls.getField(0).uid, add.getLhs().getFieldSchema().uid );
        assertEquals( ls.getField(1).uid, add.getRhs().getFieldSchema().uid );
        assertTrue( ls.getField(0).uid != add.getFieldSchema().uid );
        assertTrue( ls.getField(1).uid != add.getFieldSchema().uid );
       
        assertEquals( 1, inputPln.getLeaves().size() );
        assertEquals( Multiply.class, inputPln.getLeaves().get(0).getClass() );
        Multiply pMultiply = (Multiply) inputPln.getLeaves().get(0);
        assertEquals( 2, inputPln.getRoots().size() );
View Full Code Here

        ConstantExpression constant2 =  new ConstantExpression(expPlan, 20D);
        ConstantExpression constant3 =  new ConstantExpression(expPlan, 123f);

        AddExpression add1 = new AddExpression(expPlan, constant1, constant2);
        CastExpression cast1 = new CastExpression(expPlan,constant3, createFS(DataType.DOUBLE));
        MultiplyExpression mul1 = new MultiplyExpression(expPlan, add1, cast1);

        CompilationMessageCollector collector = new CompilationMessageCollector();
        TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(expPlan, collector, null);
        expTypeChecker.visit();
        printMessageCollector(collector);
        //printTypeGraph(plan);

        if (collector.hasError()) {
            throw new Exception("Error during type checking");
        }

        // Induction check
        assertEquals(DataType.DOUBLE, add1.getType());
        assertEquals(DataType.DOUBLE, mul1.getType());

        // Cast insertion check
        assertEquals(DataType.DOUBLE, add1.getLhs().getType());
        assertEquals(DataType.DOUBLE, mul1.getRhs().getType());
    }
View Full Code Here

        ConstantExpression constant2 =  new ConstantExpression(plan, 20D);
        ConstantExpression constant3 =  new ConstantExpression(plan, "123");

        AddExpression add1 = new AddExpression(plan, constant1, constant2);
        CastExpression cast1 = new CastExpression(plan, constant3,  createFS(DataType.BYTEARRAY));
        MultiplyExpression mul1 = new MultiplyExpression(plan, add1, cast1);

        CompilationMessageCollector collector = new CompilationMessageCollector();
        TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(plan, collector, null);
        try {
            expTypeChecker.visit();
View Full Code Here

    public void testArithmeticOpCastInsert1() throws Throwable {
        LogicalExpressionPlan plan = new LogicalExpressionPlan();
        ConstantExpression constant1 = new ConstantExpression(plan, 10);
        ConstantExpression constant2 =  new ConstantExpression(plan, 20D);

        MultiplyExpression mul1 = new MultiplyExpression(plan,constant1, constant2);

        // Before type checking its set correctly - PIG-421
        // System.out.println(DataType.findTypeName(mul1.getType()));
        // assertEquals(DataType.DOUBLE, mul1.getType());

        CompilationMessageCollector collector = new CompilationMessageCollector();
        TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(plan, collector, null);
        expTypeChecker.visit();
        printMessageCollector(collector);

        //printTypeGraph(plan);

        // After type checking
        System.out.println(DataType.findTypeName(mul1.getType()));
        assertEquals(DataType.DOUBLE, mul1.getType());
    }
View Full Code Here

            // Create expression inner plan #1
            LogicalExpressionPlan innerPlan1 = new LogicalExpressionPlan();
            ProjectExpression project11 = new ProjectExpression(innerPlan1, 0, 0, sort1);
            ProjectExpression project12 = new ProjectExpression(innerPlan1, 0, 1, sort1);

            MultiplyExpression mul1 = new MultiplyExpression(innerPlan1, project11, project12);

            // Create expression inner plan #2
            LogicalExpressionPlan innerPlan2 = new LogicalExpressionPlan();
            ProjectExpression project21 = new ProjectExpression(innerPlan2, 0, 0, sort1);
View Full Code Here

            // Create expression inner plan #1
            LogicalExpressionPlan innerPlan1 = new LogicalExpressionPlan();
            ProjectExpression project11 = new ProjectExpression(innerPlan1, 0, 0, sort1);
            ProjectExpression project12 = new ProjectExpression(innerPlan1, 0, 1, sort1);
            MultiplyExpression mul1 = new MultiplyExpression(innerPlan1, project11, project12);


            // Create expression inner plan #2
            LogicalExpressionPlan innerPlan2 = new LogicalExpressionPlan();
            ProjectExpression project21 = new ProjectExpression(innerPlan2, 0, 0, sort1);
View Full Code Here

        ConstantExpression constant2 =  new ConstantExpression(expPlan, 20D) ;
        ConstantExpression constant3 =  new ConstantExpression(expPlan, 123f) ;

        AddExpression add1 = new AddExpression(expPlan, constant1, constant2) ;
        CastExpression cast1 = new CastExpression(expPlan,constant3, createFS(DataType.DOUBLE)) ;
        MultiplyExpression mul1 = new MultiplyExpression(expPlan, add1, cast1) ;

        CompilationMessageCollector collector = new CompilationMessageCollector() ;
        TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(expPlan, collector, null);
        expTypeChecker.visit();
        printMessageCollector(collector) ;
        //printTypeGraph(plan) ;

        if (collector.hasError()) {
            throw new Exception("Error during type checking") ;
        }      

        // Induction check
        assertEquals(DataType.DOUBLE, add1.getType()) ;
        assertEquals(DataType.DOUBLE, mul1.getType()) ;

        // Cast insertion check
        assertEquals(DataType.DOUBLE, add1.getLhs().getType()) ;
        assertEquals(DataType.DOUBLE, mul1.getRhs().getType()) ;

    }
View Full Code Here

        ConstantExpression constant2 =  new ConstantExpression(plan, 20D) ;
        ConstantExpression constant3 =  new ConstantExpression(plan, "123") ;

        AddExpression add1 = new AddExpression(plan, constant1, constant2) ;
        CastExpression cast1 = new CastExpression(plan, constant3,  createFS(DataType.BYTEARRAY)) ;
        MultiplyExpression mul1 = new MultiplyExpression(plan, add1, cast1) ;

        CompilationMessageCollector collector = new CompilationMessageCollector() ;
        TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(plan, collector, null);
        try {
            expTypeChecker.visit();
View Full Code Here

TOP

Related Classes of org.apache.pig.newplan.logical.expression.MultiplyExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.