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

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


        MultiMap<Integer, LogicalExpressionPlan> expressionPlans = cogroup.getExpressionPlans();
        assertEquals( 1, expressionPlans.size() );
        List<LogicalExpressionPlan> plans = (List<LogicalExpressionPlan>) expressionPlans.get(Integer.valueOf(0));
        assertEquals( 1, plans.size() );
       
        LogicalExpressionPlan exprPlan = plans.get(0);
        assertEquals( 1, exprPlan.getSinks().size() );
        assertEquals( ProjectExpression.class, exprPlan.getSinks().get(0).getClass() );
        ProjectExpression prj = (ProjectExpression) exprPlan.getSinks().get(0);
        assertEquals( loadSchema.getField(0).uid, prj.getFieldSchema().uid );
        assertEquals( 0, prj.getColNum() );
        assertEquals( 0, prj.getInputNum() );
    }
View Full Code Here


        MultiMap<Integer, LogicalExpressionPlan> expressionPlans = cogroup.getExpressionPlans();
        assertEquals( 1, expressionPlans.size() );
        List<LogicalExpressionPlan> plans = (List<LogicalExpressionPlan>) expressionPlans.get(Integer.valueOf(0));
        assertEquals( 2, plans.size() );
       
        LogicalExpressionPlan exprPlan = plans.get(0);
        assertEquals( 1, exprPlan.getSinks().size() );
        assertEquals( ProjectExpression.class, exprPlan.getSinks().get(0).getClass() );
        ProjectExpression prj = (ProjectExpression) exprPlan.getSinks().get(0);
        assertEquals( loadSchema.getField(0).uid, prj.getFieldSchema().uid );
        assertEquals( 0, prj.getColNum() );
        assertEquals( 0, prj.getInputNum() );
       
        LogicalExpressionPlan exprPlan2 = plans.get(1);
        assertEquals( 1, exprPlan2.getSinks().size() );
        assertEquals( ProjectExpression.class, exprPlan2.getSinks().get(0).getClass() );
        ProjectExpression prj2 = (ProjectExpression) exprPlan2.getSinks().get(0);
        assertEquals( loadSchema.getField(1).uid, prj2.getFieldSchema().uid );
        assertEquals( 1, prj2.getColNum() );
        assertEquals( 0, prj2.getInputNum() );
    }
View Full Code Here

        assertEquals( 1, plans.size() );
       
        List<LogicalExpressionPlan> plans2 = (List<LogicalExpressionPlan>) expressionPlans.get(Integer.valueOf(1));
        assertEquals( 1, plans2.size() );
       
        LogicalExpressionPlan exprPlan = plans.get(0);
        assertEquals( 1, exprPlan.getSinks().size() );
        assertEquals( ProjectExpression.class, exprPlan.getSinks().get(0).getClass() );
        ProjectExpression prj = (ProjectExpression) exprPlan.getSinks().get(0);
        assertEquals( loadSchema.getField(0).uid, prj.getFieldSchema().uid );
        assertEquals( 0, prj.getColNum() );
        assertEquals( 0, prj.getInputNum() );
       
        LogicalExpressionPlan exprPlan2 = plans2.get(0);
        assertEquals( 1, exprPlan2.getSinks().size() );
        assertEquals( ProjectExpression.class, exprPlan2.getSinks().get(0).getClass() );
        ProjectExpression prj2 = (ProjectExpression) exprPlan2.getSinks().get(0);
        assertEquals( load2Schema.getField(0).uid, prj2.getFieldSchema().uid );
        assertEquals( 0, prj2.getColNum() );
        assertEquals( 1, prj2.getInputNum() );
    }
View Full Code Here

        assertEquals( 2, plans.size() );
       
        List<LogicalExpressionPlan> plans2 = (List<LogicalExpressionPlan>) expressionPlans.get(Integer.valueOf(1));
        assertEquals( 2, plans2.size() );
       
        LogicalExpressionPlan exprPlan = plans.get(0);
        assertEquals( 1, exprPlan.getSinks().size() );
        assertEquals( ProjectExpression.class, exprPlan.getSinks().get(0).getClass() );
        ProjectExpression prj = (ProjectExpression) exprPlan.getSinks().get(0);
        assertEquals( loadSchema.getField(0).uid, prj.getFieldSchema().uid );
        assertEquals( 0, prj.getColNum() );
        assertEquals( 0, prj.getInputNum() );
       
        LogicalExpressionPlan exprPlan2 = plans.get(1);
        assertEquals( 1, exprPlan2.getSinks().size() );
        assertEquals( ProjectExpression.class, exprPlan2.getSinks().get(0).getClass() );
        ProjectExpression prj2 = (ProjectExpression) exprPlan2.getSinks().get(0);
        assertEquals( loadSchema.getField(1).uid, prj2.getFieldSchema().uid );
        assertEquals( 1, prj2.getColNum() );
        assertEquals( 0, prj2.getInputNum() );       
       
        LogicalExpressionPlan exprPlan3 = plans2.get(0);
        assertEquals( 1, exprPlan3.getSinks().size() );
        assertEquals( ProjectExpression.class, exprPlan3.getSinks().get(0).getClass() );
        ProjectExpression prj3 = (ProjectExpression) exprPlan3.getSinks().get(0);
        assertEquals( load2Schema.getField(0).uid, prj3.getFieldSchema().uid );
        assertEquals( 0, prj3.getColNum() );
        assertEquals( 1, prj3.getInputNum() );
       
        LogicalExpressionPlan exprPlan4 = plans2.get(1);
        assertEquals( 1, exprPlan4.getSinks().size() );
        assertEquals( ProjectExpression.class, exprPlan4.getSinks().get(0).getClass() );
        ProjectExpression prj4 = (ProjectExpression) exprPlan4.getSinks().get(0);
        assertEquals( load2Schema.getField(1).uid, prj4.getFieldSchema().uid );
        assertEquals( 1, prj4.getColNum() );
        assertEquals( 1, prj4.getInputNum() );
    }
View Full Code Here

       
        // check filter
        op = (LogicalRelationalOperator)newPlan.getSuccessors(op).get(0);
        assertEquals(op.getClass(), org.apache.pig.newplan.logical.relational.LOFilter.class);
       
        LogicalExpressionPlan exp = ((org.apache.pig.newplan.logical.relational.LOFilter)op).getFilterPlan();
       
        EqualExpression eq = (EqualExpression)exp.getSources().get(0);
        assertEquals(eq.getLhs().getClass(), ProjectExpression.class);
        assertEquals(((ProjectExpression)eq.getLhs()).getColNum(), 0);
        assertEquals(((ProjectExpression)eq.getLhs()).getInputNum(), 0);
       
        assertEquals(eq.getRhs().getClass(), ConstantExpression.class);
View Full Code Here

       
        // check filter
        op = (LogicalRelationalOperator)newPlan.getSuccessors(op).get(0);
        assertEquals(op.getClass(), org.apache.pig.newplan.logical.relational.LOFilter.class);
       
        LogicalExpressionPlan exp = ((org.apache.pig.newplan.logical.relational.LOFilter)op).getFilterPlan();
       
        EqualExpression eq = (EqualExpression)exp.getSources().get(0);
        assertEquals(eq.getLhs().getClass(), CastExpression.class);
               
        assertEquals(eq.getLhs().getClass(), CastExpression.class);
        LogicalExpression ep = (LogicalExpression)exp.getSuccessors(eq.getLhs()).get(0);
        assertEquals(ep.getClass(), ProjectExpression.class);
        assertEquals(((ProjectExpression)ep).getColNum(), 0);
        assertEquals(((ProjectExpression)ep).getInputNum(), 0);
       
        assertEquals(eq.getRhs().getClass(), ConstantExpression.class);
View Full Code Here

        LogicalRelationalOperator l2 = (LogicalRelationalOperator)newPlan.getPredecessors(op).get(1);
        assertEquals(l2.getClass(), org.apache.pig.newplan.logical.relational.LOLoad.class);
        assertEquals(l2.getAlias(), "b");

        // check join input plans
        LogicalExpressionPlan p1 = ((LOJoin)op).getJoinPlan(0).iterator().next();
        assertEquals(p1.size(), 1);
       
        ProjectExpression prj = (ProjectExpression)p1.getSources().get(0);
      
        assertEquals(prj.getInputNum(), 0);
        assertEquals(prj.getColNum(), 0);
       
        LogicalExpressionPlan p2 = ((LOJoin)op).getJoinPlan(1).iterator().next();
        assertEquals(p2.size(), 1);
       
        prj = (ProjectExpression)p2.getSources().get(0);
    
        assertEquals(prj.getInputNum(), 1);
        assertEquals(prj.getColNum(), 1);
       
        // check filter
        op = (LogicalRelationalOperator)newPlan.getSuccessors(op).get(0);
        assertEquals(op.getClass(), org.apache.pig.newplan.logical.relational.LOFilter.class);       
        LogicalExpressionPlan exp = ((org.apache.pig.newplan.logical.relational.LOFilter)op).getFilterPlan();
       
        AndExpression ae = (AndExpression)exp.getSources().get(0);
       
        EqualExpression eq = (EqualExpression)exp.getSuccessors(ae).get(0);
        assertEquals(eq.getLhs().getClass(), ProjectExpression.class);
        assertEquals(((ProjectExpression)eq.getLhs()).getColNum(), 0);
        assertEquals(((ProjectExpression)eq.getLhs()).getInputNum(), 0);
       
        assertEquals(eq.getRhs().getClass(), ConstantExpression.class);
       
        eq = (EqualExpression)exp.getSuccessors(ae).get(1);
        assertEquals(eq.getLhs().getClass(), ProjectExpression.class);
        assertEquals(((ProjectExpression)eq.getLhs()).getColNum(), 3);
        assertEquals(((ProjectExpression)eq.getLhs()).getInputNum(), 0);
       
        assertEquals(eq.getRhs().getClass(), ConstantExpression.class);
View Full Code Here

        assertEquals("load ", v.getVisitPlan());
    }
   
    @Test
    public void testBinaryOperatorOrder() throws FrontendException {
        LogicalExpressionPlan ep = new LogicalExpressionPlan();
        ConstantExpression c = new ConstantExpression(ep, new Integer(5), new LogicalFieldSchema(null, null, DataType.INTEGER));
        ProjectExpression p = new ProjectExpression(ep, 0, 0, null);
        EqualExpression e = new EqualExpression(ep, p, c);
        assertEquals(p, e.getLhs());
        assertEquals(c, e.getRhs());
View Full Code Here

       
    }
   
    @Test
    public void testExpressionPlanVisitor() throws FrontendException {
        LogicalExpressionPlan ep = new LogicalExpressionPlan();
        ConstantExpression c = new ConstantExpression(ep, new Integer(5), new LogicalFieldSchema(null, null, DataType.INTEGER));
        ProjectExpression p = new ProjectExpression(ep, 0, 0, null);
        EqualExpression e = new EqualExpression(ep, p, c);
        ConstantExpression c2 = new ConstantExpression(ep, new Boolean("true"), new LogicalFieldSchema(null, null, DataType.BOOLEAN));
        new AndExpression(ep, e, c2);
View Full Code Here

        assertEquals("and equal project constant constant ", v.getVisitPlan());
    }
   
    @Test
    public void testExpressionEquality() throws FrontendException {
        LogicalExpressionPlan ep1 = new LogicalExpressionPlan();
        ConstantExpression c1 = new ConstantExpression(ep1, new Integer(5), new LogicalFieldSchema(null, null, DataType.INTEGER));
        ProjectExpression p1 = new ProjectExpression(ep1, 0, 0, null);
        EqualExpression e1 = new EqualExpression(ep1, p1, c1);
        ConstantExpression ca1 = new ConstantExpression(ep1, new Boolean("true"), new LogicalFieldSchema(null, null, DataType.BOOLEAN));
        AndExpression a1 = new AndExpression(ep1, e1, ca1);
       
        LogicalExpressionPlan ep2 = new LogicalExpressionPlan();
        ConstantExpression c2 = new ConstantExpression(ep2, new Integer(5), new LogicalFieldSchema(null, null, DataType.INTEGER));
        ProjectExpression p2 = new ProjectExpression(ep2, 0, 0, null);
        EqualExpression e2 = new EqualExpression(ep2, p2, c2);
        ConstantExpression ca2 = new ConstantExpression(ep2, new Boolean("true"), new LogicalFieldSchema(null, null, DataType.BOOLEAN));
        AndExpression a2 = new AndExpression(ep2, e2, ca2);
       
        assertTrue(ep1.isEqual(ep2));
        assertTrue(c1.isEqual(c2));
        assertTrue(p1.isEqual(p2));
        assertTrue(e1.isEqual(e2));
        assertTrue(ca1.isEqual(ca2));
        assertTrue(a1.isEqual(a2));
       
        LogicalExpressionPlan ep3 = new LogicalExpressionPlan();
        ConstantExpression c3 = new ConstantExpression(ep3, new Integer(3), new LogicalFieldSchema(null, null, DataType.INTEGER));
        ProjectExpression p3 = new ProjectExpression(ep3, 0, 1, null);
        EqualExpression e3 = new EqualExpression(ep3, p3, c3);
        ConstantExpression ca3 = new ConstantExpression(ep3, "true", new LogicalFieldSchema(null, null, DataType.CHARARRAY));
        AndExpression a3 = new AndExpression(ep3, e3, ca3);
       
        assertFalse(ep1.isEqual(ep3));
        assertFalse(c1.isEqual(c3));
        assertFalse(p1.isEqual(p3));
        assertFalse(e1.isEqual(e3));
        assertFalse(ca1.isEqual(ca3));
        assertFalse(a1.isEqual(a3));
       
        LogicalExpressionPlan ep4 = new LogicalExpressionPlan();
        ProjectExpression p4 = new ProjectExpression(ep4, 1, 0, null);
       
        assertFalse(ep1.isEqual(ep4));
        assertFalse(p1.isEqual(p4));
    }
View Full Code Here

TOP

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

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.