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

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


            }

            // 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(DataType.BYTEARRAY, endResultSchema.getField(0).type);
            assertEquals(DataType.INTEGER, endResultSchema.getField(1).type);
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

                "store B into '111';";

        LogicalPlan lp = Util.parseAndPreprocess(query, pc);
        Util.optimizeNewLP(lp);
        LOStore loStore = (LOStore)lp.getSinks().get(0);
        LOSort loSort = (LOSort)lp.getPredecessors(loStore).get(0);
        Operator sortPlanLeaf = loSort.getSortColPlans().get(0).getSources().get(0);
        LogicalFieldSchema sortPlanFS = ((LogicalExpression)sortPlanLeaf).getFieldSchema();
        assertNull(sortPlanFS);

        PhysicalPlan pp = Util.buildPhysicalPlanFromNewLP(lp, pc);
        POStore poStore = (POStore)pp.getLeaves().get(0);
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.connect( inputOp, op );
        }
    }

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

                    if( !isPureProjection( expr ) )
                        return false;
                }

                // Check if flatten fields are required by the successor.
                LOSort sort = (LOSort)succ;
                List<LogicalExpressionPlan> exps = sort.getSortColPlans();
                for( int i = 0; i < exps.size(); i++ ) {
                    LogicalExpressionPlan exp = exps.get( i );
                    ProjectExpression proj = (ProjectExpression)exp.getOperators().next();
                    if( !uids.contains( proj.getFieldSchema().uid ) )
                        return 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

        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

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.