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

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


        Util.checkQueryOutputs(it, expectedRes);
    }
   
    private LOSort checkNumExpressionPlansForSort(LogicalPlan lp, int numPlans, boolean[] isAsc) {
        Class<?> sortClass = org.apache.pig.newplan.logical.relational.LOSort.class;
        LOSort sort = (LOSort) NewLogicalPlanUtil.getRelOpFromPlan(lp, sortClass);
        assertEquals("number of sort col plans", numPlans, sort.getSortColPlans().size());
       
        List<Boolean> ascCols = sort.getAscendingCols();
        for(int i = 0; i < ascCols.size(); i++){
            assertEquals("ascending order", isAsc[i], ascCols.get(i));
        }
       
        return sort;
View Full Code Here


        LOCross op = new LOCross( plan );
        return buildOp ( loc, op, alias, inputAliases, partitioner );
    }
   
    LOSort createSortOp() {
        return new LOSort( plan );
    }
View Full Code Here

        plan.add( op );
        plan.connect( inputOp, op );
    }

    static LOSort createNestedSortOp(LogicalPlan plan) {
        return new LOSort( plan );
    }
View Full Code Here

        LogicalPlan lp = buildPlan( query );
        Operator store = lp.getSinks().get(0);
        LOForEach foreach = (LOForEach) lp.getPredecessors(store).get(0);
        LogicalPlan nestedPlan = foreach.getInnerPlan();
        LOGenerate gen = (LOGenerate) nestedPlan.getSinks().get(0);
        LOSort nestedSort = (LOSort)nestedPlan.getPredecessors(gen).get(0);
        LogicalExpressionPlan sortPlan = nestedSort.getSortColPlans().get(0);
        Assert.assertTrue(sortPlan.getSinks().size() == 1);
    }
View Full Code Here

                       "b = group a by $0;" +
                       "c = order b by $1 ;" +
                       "store c into 'output';";
        LogicalPlan lp = buildPlan( query );
        Operator store = lp.getSinks().get(0);
        LOSort sort = (LOSort) lp.getPredecessors(store).get(0);
        //        LOProject project1 = (LOProject) sort.getSortColPlans().get(0).getSinks().get(0) ;
        //        LOCogroup cogroup = (LOCogroup) lp.getPredecessors(sort).get(0) ;
        //        assertEquals(project1.getExpression(), cogroup) ;
    }
View Full Code Here

        String query = "a = load 'one' as (name, age, gpa);" +
        "b = order a by *;" + "store b into 'y';";

        LogicalPlan lp = buildPlan(query);
        Operator store = lp.getSinks().get(0);
        LOSort sort = (LOSort)lp.getPredecessors(store).get(0);

        for(LogicalExpressionPlan sortPlan: sort.getSortColPlans() ) {
            Assert.assertTrue(checkPlanForProjectStar(sortPlan) == false);
        }
    }
View Full Code Here

        for(LogicalExpressionPlan foreachPlan: gen.getOutputPlans()) {
            Assert.assertTrue(checkPlanForProjectStar(foreachPlan) == true);
        }

        LogicalPlan foreachPlan = foreach.getInnerPlan();
        LOSort sort = (LOSort)foreachPlan.getPredecessors(gen).get(0);

        // project (*) operator here is translated to a list of projection
        // operators
        for(LogicalExpressionPlan sortPlan: sort.getSortColPlans()) {
            Assert.assertTrue(checkPlanForProjectStar(sortPlan) == false);
        }
    }
View Full Code Here

            load1.setScriptSchema(org.apache.pig.newplan.logical.Util.translateSchema((inputSchema1))) ; ;
   
            // Create project inner plan #1
            LogicalExpressionPlan innerPlan1 = new LogicalExpressionPlan() ;
            // Sort
            LOSort sort1 = new LOSort(plan);
            ProjectExpression project1 = new ProjectExpression(innerPlan1, 0, 1, sort1) ;
           
            innerPlan1.add(project1) ;
   
            // Create project inner plan #2
            LogicalExpressionPlan innerPlan2 = new LogicalExpressionPlan() ;
            ProjectExpression project2 = new ProjectExpression(innerPlan2, 0, 0, sort1) ;
           
            innerPlan2.add(project2) ;
   
            // List of innerplans
            List<LogicalExpressionPlan> innerPlans = new ArrayList<LogicalExpressionPlan>() ;
            innerPlans.add(innerPlan1) ;
            innerPlans.add(innerPlan2) ;
   
            // List of ASC flags
            List<Boolean> ascList = new ArrayList<Boolean>() ;
            ascList.add(true);
            ascList.add(true);
           
            sort1.setAscendingCols(ascList);
            sort1.setSortColPlans(innerPlans);
   
            plan.add(load1);
            plan.add(sort1);
            plan.connect(load1, sort1) ;
   
            CompilationMessageCollector collector = new CompilationMessageCollector() ;
            TypeCheckingRelVisitor typeChecker = new TypeCheckingRelVisitor(plan, collector);
            typeChecker.visit()
            printMessageCollector(collector) ;
            //printTypeGraph(plan) ;
   
            if (collector.hasError()) {
                throw new AssertionError("Expect no error") ;
            }
   
            LogicalSchema endResultSchema = sort1.getSchema() ;
   
            // outer
            assertEquals(endResultSchema.getField(0).type, DataType.LONG) ;
            assertEquals(endResultSchema.getField(1).type, DataType.INTEGER) ;
   
View Full Code Here

            }
   
            // set schemas
            load1.setScriptSchema(org.apache.pig.newplan.logical.Util.translateSchema((inputSchema1))) ; ;
   
            LOSort sort1 = new LOSort(plan) ;

           
            // 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) ;

            ConstantExpression const21 = new ConstantExpression(innerPlan2, 26L) ;
            ModExpression mod21 = new ModExpression(innerPlan2, project21, const21) ;
   
            // List of innerplans
            List<LogicalExpressionPlan> innerPlans = new ArrayList<LogicalExpressionPlan>() ;
            innerPlans.add(innerPlan1) ;
            innerPlans.add(innerPlan2) ;
   
            // List of ASC flags
            List<Boolean> ascList = new ArrayList<Boolean>() ;
            ascList.add(true);
            ascList.add(true);
   
            // Sort
            sort1.setAscendingCols(ascList);
            sort1.setSortColPlans(innerPlans);
   
            plan.add(load1);
            plan.add(sort1);
            plan.connect(load1, sort1) ;
   
            CompilationMessageCollector collector = new CompilationMessageCollector() ;
            TypeCheckingRelVisitor typeChecker = new TypeCheckingRelVisitor(plan, collector);
            typeChecker.visit()
            printMessageCollector(collector) ;
            //printTypeGraph(plan) ;
   
            if (collector.hasError()) {
                throw new AssertionError("Expect no error") ;
            }
   
            LogicalSchema endResultSchema = sort1.getSchema() ;
   
            // outer
            assertEquals(endResultSchema.getField(0).type, DataType.BYTEARRAY) ;
            assertEquals(endResultSchema.getField(1).type, DataType.INTEGER) ;
   
View Full Code Here

            // set schemas
            load1.setScriptSchema(org.apache.pig.newplan.logical.Util.translateSchema((inputSchema1))) ; ;
   
           
            // Sort
            LOSort sort1 = new LOSort(plan) ;
           
            // 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) ;
            ConstantExpression const21 = new ConstantExpression(innerPlan2, "26") ;
            ModExpression mod21 = new ModExpression(innerPlan2, project21, const21) ;
   
            // List of innerplans
            List<LogicalExpressionPlan> innerPlans = new ArrayList<LogicalExpressionPlan>() ;
            innerPlans.add(innerPlan1) ;
            innerPlans.add(innerPlan2) ;
   
            // List of ASC flags
            List<Boolean> ascList = new ArrayList<Boolean>() ;
            ascList.add(true);
            ascList.add(true);

            // Sort
            sort1.setAscendingCols(ascList);
            sort1.setSortColPlans(innerPlans);
   
            plan.add(load1);
            plan.add(sort1);
            plan.connect(load1, sort1) ;
   
View Full Code Here

TOP

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

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.