Package org.apache.pig.newplan.logical.relational

Examples of org.apache.pig.newplan.logical.relational.LogicalPlan


      planTester.buildPlan("A = load 'myfile';");
      planTester.buildPlan("B = limit A 50;");
      planTester.buildPlan("C = limit B 20;");
      planTester.buildPlan("D = limit C 100;");
        org.apache.pig.impl.logicalLayer.LogicalPlan plan = planTester.buildPlan( "store D into 'empty';" );
      LogicalPlan newLogicalPlan = migrateAndOptimizePlan(plan);
      compareWithGoldenFile(newLogicalPlan, FILE_BASE_LOCATION + "new-optlimitplan6.dot");
  }
View Full Code Here


    // Limit stay the same for ForEach with a flatten
    public void testOPLimit7Optimizer() throws Exception {
        planTester.buildPlan("A = load 'myfile1';");
        planTester.buildPlan("B = foreach A generate flatten($0);");
        org.apache.pig.impl.logicalLayer.LogicalPlan plan = planTester.buildPlan("C = limit B 100;");
      LogicalPlan newLogicalPlan = migrateAndOptimizePlan(plan);
        compareWithGoldenFile(newLogicalPlan, FILE_BASE_LOCATION + "new-optlimitplan7.dot");
    }
View Full Code Here

    public void testOPLimit8Optimizer() throws Exception {
        planTester.buildPlan("A = load 'myfile';");
        planTester.buildPlan("B = order A by $0;");
        planTester.buildPlan("C = limit B 10;");
        org.apache.pig.impl.logicalLayer.LogicalPlan plan = planTester.buildPlan( "store C into 'empty';" );
      LogicalPlan newLogicalPlan = migrateAndOptimizePlan(plan);
        compareWithGoldenFile(newLogicalPlan, FILE_BASE_LOCATION + "new-optlimitplan8.dot");
       
    }
View Full Code Here

    public void testOPLimit9Optimizer() throws Exception {
        planTester.buildPlan("A = load 'myfile';");
        planTester.buildPlan("B = order A by $0;");
        planTester.buildPlan("C = limit B 10;");
        org.apache.pig.impl.logicalLayer.LogicalPlan plan = planTester.buildPlan( "store C into 'empty';" );
      LogicalPlan newLogicalPlan = migrateAndOptimizePlan(plan);
        compareWithGoldenFile(newLogicalPlan, FILE_BASE_LOCATION + "new-optlimitplan9.dot");
       
    }
View Full Code Here

    //See bug PIG-913
    public void testOPLimit10Optimizer() throws Exception {
        planTester.buildPlan("A = load 'myfile' AS (s:chararray);");
        planTester.buildPlan("B = limit A 100;");
        org.apache.pig.impl.logicalLayer.LogicalPlan plan = planTester.buildPlan("C = GROUP B by $0;");
      LogicalPlan newLogicalPlan = migrateAndOptimizePlan(plan);
        compareWithGoldenFile(newLogicalPlan, FILE_BASE_LOCATION + "new-optlimitplan10.dot");
    }
View Full Code Here

            return ls;
        }
    }   

    private LogicalPlan migrateAndOptimizePlan(org.apache.pig.impl.logicalLayer.LogicalPlan plan) throws IOException {
        LogicalPlan newLogicalPlan = migratePlan( plan );
        PlanOptimizer optimizer = new MyPlanOptimizer( newLogicalPlan, 3 );
        optimizer.optimize();
        return newLogicalPlan;
    }
View Full Code Here

        planTester.buildPlan("B = foreach A generate $0, $1, flatten($2);");
        planTester.buildPlan("C = load 'anotherfile' as (name, age, preference);");
        planTester.buildPlan("D = cross B, C;");
        org.apache.pig.impl.logicalLayer.LogicalPlan lp = planTester.buildPlan("E = limit D 10;");
       
        LogicalPlan newLogicalPlan = migrateAndOptimizePlan( lp );
       
        List<Operator> loads = newLogicalPlan.getSources();
        Assert.assertTrue( loads.size() == 2 );
        Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
        Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
        Operator op = null;
        if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) )
            op = loads.get( 0 );
        else
            op = loads.get( 1 );

        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOForEach );
        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOForEach );
        Assert.assertTrue( !OptimizerUtils.hasFlatten( (LOForEach)op ) );
        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOCross );
        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOForEach );
        Assert.assertTrue( OptimizerUtils.hasFlatten( (LOForEach)op ) );
        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOLimit );
    }
View Full Code Here

        planTester.buildPlan("B = load 'anotherfile' as (name, age, preference:(course_name, instructor));");
        planTester.buildPlan("C = foreach B generate $0, $1, flatten($2);");
        planTester.buildPlan("D = cross A, C;");
        org.apache.pig.impl.logicalLayer.LogicalPlan lp = planTester.buildPlan("E = limit D 10;");
       
        LogicalPlan newLogicalPlan = migrateAndOptimizePlan( lp );

        List<Operator> loads = newLogicalPlan.getSources();
        Assert.assertTrue( loads.size() == 2 );
        Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
        Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
        Operator op = null;
        if( ((LOLoad)loads.get( 0 )).getAlias().equals( "B" ) )
            op = loads.get( 0 );
        else
            op = loads.get( 1 );

        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOForEach );
        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOForEach );
        Assert.assertTrue( !OptimizerUtils.hasFlatten( (LOForEach)op ) );
        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOCross );
        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOForEach );
        Assert.assertTrue( OptimizerUtils.hasFlatten( (LOForEach)op ) );
        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOLimit );
    }
View Full Code Here

        planTester.buildPlan("C = load 'anotherfile' as (name, age, preference:(course_name, instructor));");
        planTester.buildPlan("D = foreach C generate $0, $1, flatten($2);");
        planTester.buildPlan("E = cross B, D;");
        org.apache.pig.impl.logicalLayer.LogicalPlan lp = planTester.buildPlan("F = limit E 10;");
       
        LogicalPlan newLogicalPlan = migrateAndOptimizePlan( lp );
       
        // No optimization about foreach flatten.
        Assert.assertTrue( newLogicalPlan.getPredecessors( newLogicalPlan.getSinks().get( 0 ) ).get( 0 ) instanceof LOCross );
    }
View Full Code Here

        planTester.buildPlan("B = foreach A generate $0, $1, flatten(1);");
        planTester.buildPlan("C = load 'anotherfile' as (name, age, preference:(course_name, instructor));");
        planTester.buildPlan("D = cross B, C;");
        org.apache.pig.impl.logicalLayer.LogicalPlan lp = planTester.buildPlan("E = limit D 10;");
       
        LogicalPlan newLogicalPlan = migrateAndOptimizePlan( lp );
       
        List<Operator> loads = newLogicalPlan.getSources();
        Assert.assertTrue( loads.size() == 2 );
        Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
        Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
        Operator op = null;
        if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) )
            op = loads.get( 0 );
        else
            op = loads.get( 1 );

        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOForEach );
        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOForEach );
        Assert.assertTrue( !OptimizerUtils.hasFlatten( (LOForEach)op ) );
        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOCross );
        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOForEach );
        Assert.assertTrue( OptimizerUtils.hasFlatten( (LOForEach)op ) );
        op = newLogicalPlan.getSuccessors( op ).get( 0 );
        Assert.assertTrue( op instanceof LOLimit );
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.newplan.logical.relational.LogicalPlan

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.