Package org.apache.pig.impl.logicalLayer

Examples of org.apache.pig.impl.logicalLayer.LOSort


    @Test
    public void testQueryOrderByNoSchema() {
        planTester.buildPlan("a = load 'a';");
        LogicalPlan lp = planTester.buildPlan("b = order a by $1;");
       
        LOSort sort = (LOSort)lp.getSuccessors(lp.getRoots().get(0)).get(0);
        RequiredFields sortRelevantFields0 = sort.getRelevantInputs(0, 0).get(0);
        assertTrue(sortRelevantFields0.getNeedAllFields() == false);
        assertTrue(sortRelevantFields0.getNeedNoFields() == false);
        assertTrue(sortRelevantFields0.getFields().size() == 1);
        assertTrue(sortRelevantFields0.getFields().contains(new Pair<Integer, Integer>(0, 0)));
       
        RequiredFields sortRelevantFields1 = sort.getRelevantInputs(0, 1).get(0);
        assertTrue(sortRelevantFields1.getNeedAllFields() == false);
        assertTrue(sortRelevantFields1.getNeedNoFields() == false);
        assertTrue(sortRelevantFields1.getFields().size() == 1);
        assertTrue(sortRelevantFields1.getFields().contains(new Pair<Integer, Integer>(0, 1)));
    }
View Full Code Here


    @Test
    public void testQueryOrderByWithSchema() {
        planTester.buildPlan("a = load 'a' as (url,hitCount);");
        LogicalPlan lp = planTester.buildPlan("b = order a by $1;");
       
        LOSort sort = (LOSort)lp.getSuccessors(lp.getRoots().get(0)).get(0);
        RequiredFields sortRelevantFields0 = sort.getRelevantInputs(0, 0).get(0);
        assertTrue(sortRelevantFields0.getNeedAllFields() == false);
        assertTrue(sortRelevantFields0.getNeedNoFields() == false);
        assertTrue(sortRelevantFields0.getFields().size() == 1);
        assertTrue(sortRelevantFields0.getFields().contains(new Pair<Integer, Integer>(0, 0)));
       
        RequiredFields sortRelevantFields1 = sort.getRelevantInputs(0, 1).get(0);
        assertTrue(sortRelevantFields1.getNeedAllFields() == false);
        assertTrue(sortRelevantFields1.getNeedNoFields() == false);
        assertTrue(sortRelevantFields1.getFields().size() == 1);
        assertTrue(sortRelevantFields1.getFields().contains(new Pair<Integer, Integer>(0, 1)));
    }
View Full Code Here

    @Test
    public void testQueryOrderByStarNoSchema() {
        planTester.buildPlan("a = load 'a';");
        LogicalPlan lp = planTester.buildPlan("b = order a by *;");
       
        LOSort sort = (LOSort)lp.getLeaves().get(0);
        RequiredFields sortRelevantFields0 = sort.getRelevantInputs(0, 0).get(0);
        assertTrue(sortRelevantFields0.getNeedAllFields() == false);
        assertTrue(sortRelevantFields0.getNeedNoFields() == false);
        assertTrue(sortRelevantFields0.getFields().size() == 1);
        assertTrue(sortRelevantFields0.getFields().get(0).first == 0);
        assertTrue(sortRelevantFields0.getFields().get(0).second == 0);
       
        RequiredFields sortRelevantFields1 = sort.getRelevantInputs(0, 1).get(0);
        assertTrue(sortRelevantFields1.getNeedAllFields() == false);
        assertTrue(sortRelevantFields1.getNeedNoFields() == false);
        assertTrue(sortRelevantFields1.getFields().size() == 1);
        assertTrue(sortRelevantFields1.getFields().get(0).first == 0);
        assertTrue(sortRelevantFields1.getFields().get(0).second == 1);
View Full Code Here

    @Test
    public void testQueryOrderByStarWithSchema() {
        planTester.buildPlan("a = load 'a' as (url,hitCount);");
        LogicalPlan lp = planTester.buildPlan("b = order a by *;");
       
        LOSort sort = (LOSort)lp.getLeaves().get(0);
        RequiredFields sortRelevantFields0 = sort.getRelevantInputs(0, 0).get(0);
        assertTrue(sortRelevantFields0.getNeedAllFields() == false);
        assertTrue(sortRelevantFields0.getNeedNoFields() == false);
        assertTrue(sortRelevantFields0.getFields().size() == 1);
        assertTrue(sortRelevantFields0.getFields().contains(new Pair<Integer, Integer>(0, 0)));
       
        RequiredFields sortRelevantFields1 = sort.getRelevantInputs(0, 1).get(0);
        assertTrue(sortRelevantFields1.getNeedAllFields() == false);
        assertTrue(sortRelevantFields1.getNeedNoFields() == false);
        assertTrue(sortRelevantFields1.getFields().size() == 1);
        assertTrue(sortRelevantFields1.getFields().contains(new Pair<Integer, Integer>(0, 1)));
    }
View Full Code Here

            {
                if(mode == ExecType.LOCAL) {
                    //We don't need this optimisation to happen in the local mode.
                    //so we do nothing here.
                } else {
                    LOSort sort = (LOSort)predecessor;
                    if (sort.getLimit()==-1)
                        sort.setLimit(limit.getLimit());
                    else
                        sort.setLimit(sort.getLimit()<limit.getLimit()?sort.getLimit():limit.getLimit());
                    try {
                        mPlan.removeAndReconnect(limit);
                    } catch (Exception e) {
                        int errCode = 2012;
                        String msg = "Can not remove LOLimit after LOSort";
View Full Code Here

            // distinct(flatten({(1), (1)})) is (1). However,
            // flatten(distinct({(1), (1)})) is (1), (1)
           
            // in both cases correctness is not affected
            if(successor instanceof LOSort) {
                LOSort sort = (LOSort) successor;
                RequiredFields sortRequiredField = sort.getRequiredFields().get(0);
               
                if(sortRequiredField.getNeedAllFields()) {
                    return false;
                }
               
View Full Code Here

    @Test
    public void testQueryOrderByNoSchema() throws FrontendException {
        planTester.buildPlan("a = load 'a';");
        LogicalPlan lp = planTester.buildPlan("b = order a by $1;");
       
        LOSort sort = (LOSort)lp.getSuccessors(lp.getRoots().get(0)).get(0);
        RequiredFields sortRelevantFields0 = sort.getRelevantInputs(0, 0).get(0);
        assertTrue(sortRelevantFields0.getNeedAllFields() == false);
        assertTrue(sortRelevantFields0.getNeedNoFields() == false);
        assertTrue(sortRelevantFields0.getFields().size() == 1);
        assertTrue(sortRelevantFields0.getFields().contains(new Pair<Integer, Integer>(0, 0)));
       
        RequiredFields sortRelevantFields1 = sort.getRelevantInputs(0, 1).get(0);
        assertTrue(sortRelevantFields1.getNeedAllFields() == false);
        assertTrue(sortRelevantFields1.getNeedNoFields() == false);
        assertTrue(sortRelevantFields1.getFields().size() == 1);
        assertTrue(sortRelevantFields1.getFields().contains(new Pair<Integer, Integer>(0, 1)));
    }
View Full Code Here

    @Test
    public void testQueryOrderByWithSchema() throws FrontendException {
        planTester.buildPlan("a = load 'a' as (url,hitCount);");
        LogicalPlan lp = planTester.buildPlan("b = order a by $1;");
       
        LOSort sort = (LOSort)lp.getSuccessors(lp.getRoots().get(0)).get(0);
        RequiredFields sortRelevantFields0 = sort.getRelevantInputs(0, 0).get(0);
        assertTrue(sortRelevantFields0.getNeedAllFields() == false);
        assertTrue(sortRelevantFields0.getNeedNoFields() == false);
        assertTrue(sortRelevantFields0.getFields().size() == 1);
        assertTrue(sortRelevantFields0.getFields().contains(new Pair<Integer, Integer>(0, 0)));
       
        RequiredFields sortRelevantFields1 = sort.getRelevantInputs(0, 1).get(0);
        assertTrue(sortRelevantFields1.getNeedAllFields() == false);
        assertTrue(sortRelevantFields1.getNeedNoFields() == false);
        assertTrue(sortRelevantFields1.getFields().size() == 1);
        assertTrue(sortRelevantFields1.getFields().contains(new Pair<Integer, Integer>(0, 1)));
    }
View Full Code Here

    @Test
    public void testQueryOrderByStarNoSchema() throws FrontendException {
        planTester.buildPlan("a = load 'a';");
        LogicalPlan lp = planTester.buildPlan("b = order a by *;");
       
        LOSort sort = (LOSort)lp.getLeaves().get(0);
        RequiredFields sortRelevantFields0 = sort.getRelevantInputs(0, 0).get(0);
        assertTrue(sortRelevantFields0.getNeedAllFields() == false);
        assertTrue(sortRelevantFields0.getNeedNoFields() == false);
        assertTrue(sortRelevantFields0.getFields().size() == 1);
        assertTrue(sortRelevantFields0.getFields().get(0).first == 0);
        assertTrue(sortRelevantFields0.getFields().get(0).second == 0);
       
        RequiredFields sortRelevantFields1 = sort.getRelevantInputs(0, 1).get(0);
        assertTrue(sortRelevantFields1.getNeedAllFields() == false);
        assertTrue(sortRelevantFields1.getNeedNoFields() == false);
        assertTrue(sortRelevantFields1.getFields().size() == 1);
        assertTrue(sortRelevantFields1.getFields().get(0).first == 0);
        assertTrue(sortRelevantFields1.getFields().get(0).second == 1);
View Full Code Here

    @Test
    public void testQueryOrderByStarWithSchema() throws FrontendException {
        planTester.buildPlan("a = load 'a' as (url,hitCount);");
        LogicalPlan lp = planTester.buildPlan("b = order a by *;");
       
        LOSort sort = (LOSort)lp.getLeaves().get(0);
        RequiredFields sortRelevantFields0 = sort.getRelevantInputs(0, 0).get(0);
        assertTrue(sortRelevantFields0.getNeedAllFields() == false);
        assertTrue(sortRelevantFields0.getNeedNoFields() == false);
        assertTrue(sortRelevantFields0.getFields().size() == 1);
        assertTrue(sortRelevantFields0.getFields().contains(new Pair<Integer, Integer>(0, 0)));
       
        RequiredFields sortRelevantFields1 = sort.getRelevantInputs(0, 1).get(0);
        assertTrue(sortRelevantFields1.getNeedAllFields() == false);
        assertTrue(sortRelevantFields1.getNeedNoFields() == false);
        assertTrue(sortRelevantFields1.getFields().size() == 1);
        assertTrue(sortRelevantFields1.getFields().contains(new Pair<Integer, Integer>(0, 1)));
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.logicalLayer.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.