Package org.apache.pig.experimental.logical.relational

Examples of org.apache.pig.experimental.logical.relational.LogicalSchema


    LogicalRelationalOperator join = null;
    LogicalRelationalOperator store = null;   
   
    private void prep() {
        plan = new LogicalPlan();
        LogicalSchema schema = new LogicalSchema();
        schema.addField(new LogicalSchema.LogicalFieldSchema("id", null, DataType.INTEGER));
        schema.addField(new LogicalSchema.LogicalFieldSchema("name", null, DataType.CHARARRAY));
        schema.addField(new LogicalSchema.LogicalFieldSchema("age", null, DataType.INTEGER));   
        schema.getField(0).uid = 1;
        schema.getField(1).uid = 2;
        schema.getField(2).uid = 3;
        LogicalRelationalOperator l1 = new LOLoad(null, schema, plan);
        l1.setAlias("A");
        plan.add(l1);

        schema = new LogicalSchema();
        schema.addField(new LogicalSchema.LogicalFieldSchema("id", null, DataType.INTEGER));
        schema.addField(new LogicalSchema.LogicalFieldSchema("dept", null, DataType.INTEGER));
        schema.addField(new LogicalSchema.LogicalFieldSchema("salary", null, DataType.FLOAT));   
        schema.getField(0).uid = 4;
        schema.getField(1).uid = 5;
        schema.getField(2).uid = 6;
        LogicalRelationalOperator l2 = new LOLoad(null, schema, plan);
        l2.setAlias("B");
        plan.add(l2);
       
        MultiMap<Integer, LogicalExpressionPlan> joinPlans = new MultiMap<Integer, LogicalExpressionPlan>();
View Full Code Here


        LogicalPlan plan = lpt.buildPlan("store b into 'empty';")
       
        org.apache.pig.experimental.logical.relational.LogicalPlan newLogicalPlan = migratePlan(plan);
        LogicalRelationalOperator ld =  (LogicalRelationalOperator)newLogicalPlan.getSources().get(0);
        LogicalRelationalOperator fe = (LogicalRelationalOperator)newLogicalPlan.getSuccessors(ld).get(0);
        LogicalSchema ls = fe.getSchema();
        assertEquals(1, ls.getField(0).uid);
        assertEquals(4, ls.getField(1).uid);
        assertEquals(5, ls.getField(2).uid);
       
        LogicalSchema expected = new LogicalSchema();
        expected.addField(new LogicalFieldSchema("id", null, DataType.BYTEARRAY));
        expected.addField(new LogicalFieldSchema("s", null, DataType.BYTEARRAY));
        expected.addField(new LogicalFieldSchema("v", null, DataType.BYTEARRAY));
        assertTrue(expected.isEqual(ls));
       
       
        PhysicalPlan phyPlan = translatePlan(newLogicalPlan);
       
        assertEquals(phyPlan.size(), 3);
View Full Code Here

       
        org.apache.pig.experimental.logical.relational.LogicalPlan newLogicalPlan = migratePlan(plan);
        LogicalRelationalOperator ld =  (LogicalRelationalOperator)newLogicalPlan.getSources().get(0);
        assertEquals( LOLoad.class, ld.getClass() );
        LOLoad load = (LOLoad)ld;
        LogicalSchema ls = load.getSchema();
       
        PhysicalPlan phyPlan = translatePlan(newLogicalPlan);
       
        PhysicalOperator pFE = phyPlan.getSuccessors( phyPlan.getRoots().get(0) ).get(0);
        assertEquals( POForEach.class, pFE.getClass() );
        POForEach pForEach = (POForEach)pFE;
        PhysicalPlan inputPln = pForEach.getInputPlans().get(0);
       
        assertEquals(1, ls.getField(0).uid);
        assertEquals(2, ls.getField(1).uid);
       
        LogicalRelationalOperator fe =
            (LogicalRelationalOperator) newLogicalPlan.getSuccessors(load).get(0);
        assertEquals( LOForEach.class, fe.getClass() );
        LOForEach forEach = (LOForEach)fe;
       
        org.apache.pig.experimental.logical.relational.LogicalPlan innerPlan =
            forEach.getInnerPlan();
       
        assertEquals( 1, innerPlan.getSinks().size() );       
        assertEquals( LOGenerate.class, innerPlan.getSinks().get(0).getClass() );
        LOGenerate gen = (LOGenerate)innerPlan.getSinks().get(0);
        assertEquals( 1, gen.getOutputPlans().size() );
        LogicalExpressionPlan genExp = gen.getOutputPlans().get(0);
       
        assertEquals( 1, genExp.getSources().size() );
       
       
        // Main Tests start here
        assertEquals( AddExpression.class, genExp.getSources().get(0).getClass() );
        AddExpression add = (AddExpression) genExp.getSources().get(0);
        assertEquals( ls.getField(0).uid, add.getLhs().getUid() );
        assertEquals( ls.getField(1).uid, add.getRhs().getUid() );
        assertTrue( ls.getField(0).uid != add.getUid() );
        assertTrue( ls.getField(1).uid != add.getUid() );
       
        assertEquals( 1, inputPln.getLeaves().size() );
        assertEquals( Add.class, inputPln.getLeaves().get(0).getClass() );
        Add pAdd = (Add) inputPln.getLeaves().get(0);
        assertEquals( 2, inputPln.getRoots().size() );
View Full Code Here

       
        org.apache.pig.experimental.logical.relational.LogicalPlan newLogicalPlan = migratePlan(plan);
        LogicalRelationalOperator ld =  (LogicalRelationalOperator)newLogicalPlan.getSources().get(0);
        assertEquals( LOLoad.class, ld.getClass() );
        LOLoad load = (LOLoad)ld;
        LogicalSchema ls = load.getSchema();
       
        PhysicalPlan phyPlan = translatePlan(newLogicalPlan);
       
        PhysicalOperator pFE = phyPlan.getSuccessors( phyPlan.getRoots().get(0) ).get(0);
        assertEquals( POForEach.class, pFE.getClass() );
        POForEach pForEach = (POForEach)pFE;
        PhysicalPlan inputPln = pForEach.getInputPlans().get(0);
       
        assertEquals(1, ls.getField(0).uid);
        assertEquals(2, ls.getField(1).uid);
       
        LogicalRelationalOperator fe =
            (LogicalRelationalOperator) newLogicalPlan.getSuccessors(load).get(0);
        assertEquals( LOForEach.class, fe.getClass() );
        LOForEach forEach = (LOForEach)fe;
       
        org.apache.pig.experimental.logical.relational.LogicalPlan innerPlan =
            forEach.getInnerPlan();
       
        assertEquals( 1, innerPlan.getSinks().size() );       
        assertEquals( LOGenerate.class, innerPlan.getSinks().get(0).getClass() );
        LOGenerate gen = (LOGenerate)innerPlan.getSinks().get(0);
        assertEquals( 1, gen.getOutputPlans().size() );
        LogicalExpressionPlan genExp = gen.getOutputPlans().get(0);
       
        assertEquals( 1, genExp.getSources().size() );
       
        // Main Tests start here
        assertEquals( SubtractExpression.class, genExp.getSources().get(0).getClass() );
        SubtractExpression add = (SubtractExpression) genExp.getSources().get(0);
        assertEquals( ls.getField(0).uid, add.getLhs().getUid() );
        assertEquals( ls.getField(1).uid, add.getRhs().getUid() );
        assertTrue( ls.getField(0).uid != add.getUid() );
        assertTrue( ls.getField(1).uid != add.getUid() );
       
        assertEquals( 1, inputPln.getLeaves().size() );
        assertEquals( Subtract.class, inputPln.getLeaves().get(0).getClass() );
        Subtract pSubtract = (Subtract) inputPln.getLeaves().get(0);
        assertEquals( 2, inputPln.getRoots().size() );
View Full Code Here

       
        org.apache.pig.experimental.logical.relational.LogicalPlan newLogicalPlan = migratePlan(plan);
        LogicalRelationalOperator ld =  (LogicalRelationalOperator)newLogicalPlan.getSources().get(0);
        assertEquals( LOLoad.class, ld.getClass() );
        LOLoad load = (LOLoad)ld;
        LogicalSchema ls = load.getSchema();
       
        PhysicalPlan phyPlan = translatePlan(newLogicalPlan);
       
        PhysicalOperator pFE = phyPlan.getSuccessors( phyPlan.getRoots().get(0) ).get(0);
        assertEquals( POForEach.class, pFE.getClass() );
        POForEach pForEach = (POForEach)pFE;
        PhysicalPlan inputPln = pForEach.getInputPlans().get(0);
       
        assertEquals(1, ls.getField(0).uid);
        assertEquals(2, ls.getField(1).uid);
       
        LogicalRelationalOperator fe =
            (LogicalRelationalOperator) newLogicalPlan.getSuccessors(load).get(0);
        assertEquals( LOForEach.class, fe.getClass() );
        LOForEach forEach = (LOForEach)fe;
       
        org.apache.pig.experimental.logical.relational.LogicalPlan innerPlan =
            forEach.getInnerPlan();
       
        assertEquals( 1, innerPlan.getSinks().size() );       
        assertEquals( LOGenerate.class, innerPlan.getSinks().get(0).getClass() );
        LOGenerate gen = (LOGenerate)innerPlan.getSinks().get(0);
        assertEquals( 1, gen.getOutputPlans().size() );
        LogicalExpressionPlan genExp = gen.getOutputPlans().get(0);
       
        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().getUid() );
        assertEquals( ls.getField(1).uid, add.getRhs().getUid() );
        assertTrue( ls.getField(0).uid != add.getUid() );
        assertTrue( ls.getField(1).uid != add.getUid() );
       
        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

       
        org.apache.pig.experimental.logical.relational.LogicalPlan newLogicalPlan = migratePlan(plan);
        LogicalRelationalOperator ld =  (LogicalRelationalOperator)newLogicalPlan.getSources().get(0);
        assertEquals( LOLoad.class, ld.getClass() );
        LOLoad load = (LOLoad)ld;
        LogicalSchema ls = load.getSchema();
       
        PhysicalPlan phyPlan = translatePlan(newLogicalPlan);
       
        PhysicalOperator pFE = phyPlan.getSuccessors( phyPlan.getRoots().get(0) ).get(0);
        assertEquals( POForEach.class, pFE.getClass() );
        POForEach pForEach = (POForEach)pFE;
        PhysicalPlan inputPln = pForEach.getInputPlans().get(0);
       
        assertEquals(1, ls.getField(0).uid);
        assertEquals(2, ls.getField(1).uid);
       
        LogicalRelationalOperator fe =
            (LogicalRelationalOperator) newLogicalPlan.getSuccessors(load).get(0);
        assertEquals( LOForEach.class, fe.getClass() );
        LOForEach forEach = (LOForEach)fe;
       
        org.apache.pig.experimental.logical.relational.LogicalPlan innerPlan =
            forEach.getInnerPlan();
       
        assertEquals( 1, innerPlan.getSinks().size() );       
        assertEquals( LOGenerate.class, innerPlan.getSinks().get(0).getClass() );
        LOGenerate gen = (LOGenerate)innerPlan.getSinks().get(0);
        assertEquals( 1, gen.getOutputPlans().size() );
        LogicalExpressionPlan genExp = gen.getOutputPlans().get(0);
       
        assertEquals( 1, genExp.getSources().size() );
       
        // Main Tests start here
        assertEquals( DivideExpression.class, genExp.getSources().get(0).getClass() );
        DivideExpression add = (DivideExpression) genExp.getSources().get(0);
        assertEquals( ls.getField(0).uid, add.getLhs().getUid() );
        assertEquals( ls.getField(1).uid, add.getRhs().getUid() );
        assertTrue( ls.getField(0).uid != add.getUid() );
        assertTrue( ls.getField(1).uid != add.getUid() );
       
        assertEquals( 1, inputPln.getLeaves().size() );
        assertEquals( Divide.class, inputPln.getLeaves().get(0).getClass() );
        Divide pDivide = (Divide) inputPln.getLeaves().get(0);
        assertEquals( 2, inputPln.getRoots().size() );
View Full Code Here

       
        org.apache.pig.experimental.logical.relational.LogicalPlan newLogicalPlan = migratePlan(plan);
        LogicalRelationalOperator ld =  (LogicalRelationalOperator)newLogicalPlan.getSources().get(0);
        assertEquals( LOLoad.class, ld.getClass() );
        LOLoad load = (LOLoad)ld;
        LogicalSchema ls = load.getSchema();
       
        PhysicalPlan phyPlan = translatePlan(newLogicalPlan);
       
        PhysicalOperator pFE = phyPlan.getSuccessors( phyPlan.getRoots().get(0) ).get(0);
        assertEquals( POForEach.class, pFE.getClass() );
        POForEach pForEach = (POForEach)pFE;
        PhysicalPlan inputPln = pForEach.getInputPlans().get(0);
       
        assertEquals(1, ls.getField(0).uid);
        assertEquals(2, ls.getField(1).uid);
       
        LogicalRelationalOperator fe =
            (LogicalRelationalOperator) newLogicalPlan.getSuccessors(load).get(0);
        assertEquals( LOForEach.class, fe.getClass() );
        LOForEach forEach = (LOForEach)fe;
       
        org.apache.pig.experimental.logical.relational.LogicalPlan innerPlan =
            forEach.getInnerPlan();
       
        assertEquals( 1, innerPlan.getSinks().size() );       
        assertEquals( LOGenerate.class, innerPlan.getSinks().get(0).getClass() );
        LOGenerate gen = (LOGenerate)innerPlan.getSinks().get(0);
        assertEquals( 1, gen.getOutputPlans().size() );
        LogicalExpressionPlan genExp = gen.getOutputPlans().get(0);
       
        assertEquals( 1, genExp.getSources().size() );
       
        // Main Tests start here
        assertEquals( ModExpression.class, genExp.getSources().get(0).getClass() );
        ModExpression add = (ModExpression) genExp.getSources().get(0);
        assertEquals( ls.getField(0).uid, add.getLhs().getUid() );
        assertEquals( ls.getField(1).uid, add.getRhs().getUid() );
        assertTrue( ls.getField(0).uid != add.getUid() );
        assertTrue( ls.getField(1).uid != add.getUid() );
       
        assertEquals( 1, inputPln.getLeaves().size() );
        assertEquals( Mod.class, inputPln.getLeaves().get(0).getClass() );
        Mod pMod = (Mod) inputPln.getLeaves().get(0);
        assertEquals( 2, inputPln.getRoots().size() );
View Full Code Here

       
        org.apache.pig.experimental.logical.relational.LogicalPlan newLogicalPlan = migratePlan(plan);
        LogicalRelationalOperator ld =  (LogicalRelationalOperator)newLogicalPlan.getSources().get(0);
        assertEquals( LOLoad.class, ld.getClass() );
        LOLoad load = (LOLoad)ld;
        LogicalSchema ls = load.getSchema();
       
        PhysicalPlan phyPlan = translatePlan(newLogicalPlan);
       
        PhysicalOperator pFE = phyPlan.getSuccessors( phyPlan.getRoots().get(0) ).get(0);
        assertEquals( POForEach.class, pFE.getClass() );
        POForEach pForEach = (POForEach)pFE;
        PhysicalPlan inputPln = pForEach.getInputPlans().get(0);
       
        assertEquals(1, ls.getField(0).uid);
        assertEquals(2, ls.getField(1).uid);
       
        LogicalRelationalOperator fe =
            (LogicalRelationalOperator) newLogicalPlan.getSuccessors(load).get(0);
        assertEquals( LOForEach.class, fe.getClass() );
        LOForEach forEach = (LOForEach)fe;
       
        org.apache.pig.experimental.logical.relational.LogicalPlan innerPlan =
            forEach.getInnerPlan();
       
        assertEquals( 1, innerPlan.getSinks().size() );       
        assertEquals( LOGenerate.class, innerPlan.getSinks().get(0).getClass() );
        LOGenerate gen = (LOGenerate)innerPlan.getSinks().get(0);
        assertEquals( 1, gen.getOutputPlans().size() );
        LogicalExpressionPlan genExp = gen.getOutputPlans().get(0);
       
        assertEquals( 1, genExp.getSources().size() );
       
        // Main Tests start here
        assertEquals( NegativeExpression.class, genExp.getSources().get(0).getClass() );
        NegativeExpression add = (NegativeExpression) genExp.getSources().get(0);
        assertEquals( ls.getField(0).uid, add.getExpression().getUid() );
        assertTrue( ls.getField(0).uid != add.getUid() );
        assertTrue( ls.getField(1).uid != add.getUid() );
       
        assertEquals( 1, inputPln.getLeaves().size() );
        assertEquals( PONegative.class, inputPln.getLeaves().get(0).getClass() );
        PONegative pNegative = (PONegative) inputPln.getLeaves().get(0);
        assertEquals( 1, inputPln.getRoots().size() );
View Full Code Here

       
        org.apache.pig.experimental.logical.relational.LogicalPlan newLogicalPlan = migratePlan(plan);
        LogicalRelationalOperator ld =  (LogicalRelationalOperator)newLogicalPlan.getSources().get(0);
        assertEquals( LOLoad.class, ld.getClass() );
        LOLoad load = (LOLoad)ld;
        LogicalSchema ls = load.getSchema();
       
        PhysicalPlan phyPlan = translatePlan(newLogicalPlan);
       
        assertEquals(1, ls.getField(0).uid);
        assertEquals(2, ls.getField(1).uid);
       
        LogicalRelationalOperator fil = (LogicalRelationalOperator)
        newLogicalPlan.getSuccessors( newLogicalPlan.getSources().get(0) ).get(0);
        assertEquals( LOFilter.class,
                fil.getClass() );
        LOFilter filter = (LOFilter)fil;
       
        LogicalExpressionPlan filPlan = filter.getFilterPlan();
       
        assertEquals( 1, filPlan.getSources().size() );
        assertEquals( 2, filPlan.size() );
        assertEquals( 1, filPlan.getSinks().size() );
        assertEquals( IsNullExpression.class, filPlan.getSources().get(0).getClass() );
        IsNullExpression isNull = (IsNullExpression)filPlan.getSources().get(0);
        assertTrue( ls.getField(0).uid != isNull.getUid() );
        assertTrue( ls.getField(1).uid != isNull.getUid() );
       
        assertEquals( ProjectExpression.class, isNull.getExpression().getClass() );
        ProjectExpression prj = (ProjectExpression) isNull.getExpression();
        assertEquals( ls.getField(0).uid, prj.getUid() );
    }
View Full Code Here

       
        org.apache.pig.experimental.logical.relational.LogicalPlan newLogicalPlan = migratePlan(plan);
        LogicalRelationalOperator ld =  (LogicalRelationalOperator)newLogicalPlan.getSources().get(0);
        assertEquals( LOLoad.class, ld.getClass() );
        LOLoad load = (LOLoad)ld;
        LogicalSchema ls = load.getSchema();
       
        PhysicalPlan phyPlan = translatePlan(newLogicalPlan);
       
        assertEquals(1, ls.getField(0).uid);
        assertEquals(2, ls.getField(1).uid);
       
        LogicalRelationalOperator fil = (LogicalRelationalOperator)
        newLogicalPlan.getSuccessors( newLogicalPlan.getSources().get(0) ).get(0);
        assertEquals( LOFilter.class,
                fil.getClass() );
        LOFilter filter = (LOFilter)fil;
       
        LogicalExpressionPlan filPlan = filter.getFilterPlan();
       
        assertEquals( 1, filPlan.getSources().size() );
        assertEquals( 3, filPlan.size() );
        assertEquals( 1, filPlan.getSinks().size() );
        assertEquals( NotExpression.class, filPlan.getSources().get(0).getClass() );
        NotExpression notExp = (NotExpression)filPlan.getSources().get(0);
        assertTrue( ls.getField(0).uid != notExp.getUid() );
        assertTrue( ls.getField(1).uid != notExp.getUid() );
        assertEquals( IsNullExpression.class, notExp.getExpression().getClass() );
        IsNullExpression isNull = (IsNullExpression)notExp.getExpression();
        assertTrue( ls.getField(0).uid != isNull.getUid() );
        assertTrue( ls.getField(1).uid != isNull.getUid() );
       
        assertEquals( ProjectExpression.class, isNull.getExpression().getClass() );
        ProjectExpression prj = (ProjectExpression) isNull.getExpression();
        assertEquals( ls.getField(0).uid, prj.getUid() );
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.experimental.logical.relational.LogicalSchema

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.