Package org.apache.pig

Examples of org.apache.pig.SortInfo


        List<LogicalOperator> op = loStore.getPlan().getPredecessors(loStore);
        PhysicalOperator from;
       
        if(op != null) {
            from = logToPhyMap.get(op.get(0));
            SortInfo sortInfo = null;
            // if store's predecessor is limit,
            // check limit's predecessor
            if(op.get(0) instanceof LOLimit) {
                op = loStore.getPlan().getPredecessors(op.get(0));
            }
View Full Code Here


            //create SortColInfo from the project
            if(project.isProjectStar()){
                //there is no input schema, that is why project-star is still here
                // we don't know how many columns are represented by this
                //so don't add further columns to sort list
                return new SortInfo(sortColInfoList);
            }
            if(project.isRangeProject()){
                if(project.getEndCol() < 0){
                    //stop here for
                    // same reason as project-star condition above
                    //(unkown number of columns this represents)
                    return new SortInfo(sortColInfoList);
                }
                //expand the project-range into multiple SortColInfos
                for(int cnum = project.getStartCol(); cnum < project.getEndCol(); cnum++){
                    sortColInfoList.add(
                            new SortColInfo(null, cnum, getOrder(mAscCols,i))
                    );
                }
            }
            else{
                int sortColIndex = project.getColNum();
                String sortColName = (schema == null) ? null :
                    schema.getField(sortColIndex).alias;

                sortColInfoList.add(
                        new SortColInfo(sortColName, sortColIndex, getOrder(mAscCols,i))
                );
            }
        }
        return new SortInfo(sortColInfoList);
    }
View Full Code Here

        List<SortColInfo> colList = new ArrayList<SortColInfo>();
        SortColInfo col1 = new SortColInfo("f1", 0, SortColInfo.Order.ASCENDING);
        SortColInfo col2 = new SortColInfo("f1", 1, SortColInfo.Order.DESCENDING);
        colList.add(col1);
        colList.add(col2);
        SortInfo sortInfo = new SortInfo(colList);
                       
        ResourceSchema rsSchema = new ResourceSchema(origSchema, sortInfo);

        Schema genSchema = Schema.getPigSchema(rsSchema);
        assertTrue("generated schema equals original",
View Full Code Here

            int errCode = 2051;
            String msg = "Did not find a predecessor for Store." ;
            throw new VisitorException(store, msg, errCode, PigException.BUG);   
        }
       
        SortInfo sortInfo = null;
        if(storePred instanceof LOLimit) {
            storePred = store.getPlan().getPredecessors(storePred).get(0);
        } else if (storePred instanceof LOSplitOutput) {
            LOSplitOutput splitOutput = (LOSplitOutput)storePred;
            // We assume this is the LOSplitOutput we injected for this case:
View Full Code Here

    public void testSortInfoAsc() throws Exception {
        String query = "a = load 'bla' as (i:int, n:chararray, d:double);" +
                       "b = order a by i, d;" +
                       "store b into 'foo';";
        PhysicalPlan pp = Util.buildPp( pigServer, query );
        SortInfo si = ((POStore)(pp.getLeaves().get(0))).getSortInfo();
        SortInfo expected = getSortInfo(
                Arrays.asList(new String[] {"i", "d"}),
                Arrays.asList(new Integer[] {0, 2}),
                Arrays.asList(new SortColInfo.Order[] {
                        SortColInfo.Order.ASCENDING,
                        SortColInfo.Order.ASCENDING}));
View Full Code Here

        String query = "a = load 'bla' as (i:int, n:chararray, d:double);" +
                       "b = filter a by i > 10;" +
                       "c = order b by i desc, d;" +
                       "store c into 'foo';";
        PhysicalPlan pp = Util.buildPp( pigServer, query );
        SortInfo si = ((POStore)(pp.getLeaves().get(0))).getSortInfo();
        SortInfo expected = getSortInfo(
                Arrays.asList(new String[] {"i", "d"}),
                Arrays.asList(new Integer[] {0, 2}),
                Arrays.asList(new SortColInfo.Order[] {
                        SortColInfo.Order.DESCENDING,
                        SortColInfo.Order.ASCENDING}));
View Full Code Here

    public void testSortInfoNoOrderBy1() throws Exception {
        String query = "a = load 'bla' as (i:int, n:chararray, d:double);" +
                       "b = filter a by i > 10;" +
                       "store b into 'foo';";
        PhysicalPlan pp = Util.buildPp( pigServer, query );
        SortInfo si = ((POStore)(pp.getLeaves().get(0))).getSortInfo();
        assertEquals(null, si);
    }
View Full Code Here

        String query = "a = load 'bla' as (i:int, n:chararray, d:double);" +
                       "b = order a by i, d;" +
                       "c = distinct b;" +
                       "store c into 'foo';";
        PhysicalPlan pp = Util.buildPp( pigServer, query );
        SortInfo si = ((POStore)(pp.getLeaves().get(0))).getSortInfo();
        assertEquals(null, si);
    }
View Full Code Here

        String query = "a = load 'bla' as (i:int, n:chararray, d:double);" +
                       "b = order a by i, d desc;" +
                       "c = limit b 10;" +
                       "store c into 'foo';";
        PhysicalPlan pp = Util.buildPp( pigServer, query );
        SortInfo si = ((POStore)(pp.getLeaves().get(0))).getSortInfo();
        SortInfo expected = getSortInfo(
                Arrays.asList(new String[] {"i", "d"}),
                Arrays.asList(new Integer[] {0, 2}),
                Arrays.asList(new SortColInfo.Order[] {
                        SortColInfo.Order.ASCENDING,
                        SortColInfo.Order.DESCENDING}));
View Full Code Here

                       "b = order a by i, d desc;" +
                       "store b into '1';" +
                       "store b into '2';";
       
        PhysicalPlan pp = Util.buildPp(pigServer, query);
        SortInfo si0 = ((POStore)(pp.getLeaves().get(0))).getSortInfo();
        SortInfo si1 = ((POStore)(pp.getLeaves().get(1))).getSortInfo();
        SortInfo expected = getSortInfo(
                Arrays.asList(new String[] {"i", "d"}),
                Arrays.asList(new Integer[] {0, 2}),
                Arrays.asList(new SortColInfo.Order[] {
                        SortColInfo.Order.ASCENDING,
                        SortColInfo.Order.DESCENDING}));
View Full Code Here

TOP

Related Classes of org.apache.pig.SortInfo

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.