Package org.apache.pig.newplan

Examples of org.apache.pig.newplan.OperatorPlan


    }
   
    @Override
    public void visit(LOForEach foreach) throws FrontendException {
        foreach.resetUid();
        OperatorPlan innerPlan = foreach.getInnerPlan();
        PlanWalker newWalker = currentWalker.spawnChildWalker(innerPlan);
        pushWalker(newWalker);
        currentWalker.walk(this);
        popWalker();
    }
View Full Code Here


    @Override
    public void visit(LOForEach foreach) throws FrontendException {
        currentOp = foreach;
        // We have an Inner OperatorPlan in ForEach, so we go ahead
        // and work on that plan
        OperatorPlan innerPlan = foreach.getInnerPlan();
        PlanWalker newWalker = currentWalker.spawnChildWalker(innerPlan);
        pushWalker(newWalker);
        currentWalker.walk(this);
        popWalker();
    }
View Full Code Here

        plan.connect(l3, f5);

         plan.connect(f5, join);


         OperatorPlan pattern = new SillyPlan();
         Operator op1 = new OP_Load("mmm1", pattern);
         Operator op2 = new OP_Filter("mmm2", pattern);
         Operator op3 = new OP_Join("mmm3", pattern);
         pattern.add(op1);
         pattern.add(op2);
         pattern.add(op3);
         pattern.connect(op1, op3);
         pattern.connect(op2, op3);

         Rule r = new SillyRule("basic", pattern);
         List<OperatorPlan> l = r.match(plan);
         assertEquals(1, l.size());
         OperatorPlan match = l.get(0);
         assertEquals(3, match.size());
         assertEquals(1, match.getSinks().size());
         assertEquals(join, match.getSinks().get(0));

         assertEquals(2, match.getSources().size());
         assertTrue(match.getSources().get(0).getClass().equals(OP_Load.class) || match.getSources().get(0).equals(f5) );
         assertTrue(match.getSources().get(1).getClass().equals(OP_Load.class) || match.getSources().get(1).equals(f5) );
         assertNotSame(match.getSources().get(0), match.getSources().get(1));
    }
View Full Code Here

    }

    @Test
    public void testSingleNodeMatch() throws FrontendException {
        // search for Load
        OperatorPlan pattern = new SillyPlan();
        pattern.add(new OP_Load("mmm", pattern));

        Rule r = new SillyRule("basic", pattern);
        List<OperatorPlan> l = r.match(plan);
        assertEquals(2, l.size());

        Operator m1 = l.get(0).getSources().get(0);
        assertTrue(m1.getName().equals("p1") || m1.getName().equals("p2"));
        assertEquals(1, l.get(0).size());

        Operator m2 = l.get(1).getSources().get(0);
        assertTrue(m2.getName().equals("p1") || m2.getName().equals("p2"));
        assertEquals(1, l.get(1).size());
        assertNotSame(m1.getName(), m2.getName());

        // search for filter
        pattern = new SillyPlan();
        pattern.add(new OP_Filter("mmm",pattern));
        r = new SillyRule("basic", pattern);
        l = r.match(plan);
        assertEquals(4, l.size());

        m1 = l.get(0).getSources().get(0);
        assertTrue(m1.getName().equals("f1") || m1.getName().equals("f2")
                || m1.getName().equals("f3") || m1.getName().equals("f4"));
        assertEquals(1, l.get(0).size());

        m2 = l.get(1).getSources().get(0);
        assertTrue(m1.getName().equals("f1") || m1.getName().equals("f2")
                || m1.getName().equals("f3") || m1.getName().equals("f4"));
        assertEquals(1, l.get(1).size());
        assertNotSame(m1.getName(), m2.getName());

        // search for store
        pattern = new SillyPlan();
        pattern.add(new OP_Store("mmm",pattern));
        r = new SillyRule("basic", pattern);
        l = r.match(plan);
        assertEquals(l.size(), 2);

        m1 = l.get(0).getSources().get(0);
        assertTrue(m1.getName().equals("s1") || m1.getName().equals("s2"));
        assertEquals(l.get(0).size(), 1);

        m2 = l.get(1).getSources().get(0);
        assertTrue(m2.getName().equals("s1") || m2.getName().equals("s2"));
        assertEquals(l.get(1).size(), 1);
        assertNotSame(m1.getName(), m2.getName());

        // search for split
        pattern = new SillyPlan();
        pattern.add(new OP_Split("mmm",pattern));
        r = new SillyRule("basic", pattern);
        l = r.match(plan);
        assertEquals(l.size(), 1);

        m1 = l.get(0).getSources().get(0);
        assertTrue(m1.getName().equals("t1"));
        assertEquals(l.get(0).size(), 1);

        // search for join
        pattern = new SillyPlan();
        pattern.add(new OP_Join("mmm",pattern));
        r = new SillyRule("basic", pattern);
        l = r.match(plan);
        assertEquals(l.size(), 1);

        m1 = l.get(0).getSources().get(0);
View Full Code Here

    }

    @Test
    public void testTwoNodeMatch() throws FrontendException {
        // search for 2 Loads at the same time
        OperatorPlan pattern = new SillyPlan();
        pattern.add(new OP_Load("mmm1", pattern));
        pattern.add(new OP_Load("mmm2", pattern));

        Rule r = new SillyRule("basic", pattern);
        List<OperatorPlan> l = r.match(plan);
        assertEquals(l.size(), 1);

        assertEquals(l.get(0).getSources().size(), 2);
        assertEquals(l.get(0).getSinks().size(), 2);
        assertEquals(l.get(0).size(), 2);

        Operator m1 = l.get(0).getSources().get(0);
        assertTrue(m1.getName().equals("p1") || m1.getName().equals("p2"));
        Operator m2 = l.get(0).getSources().get(1);
        assertTrue(m2.getName().equals("p1") || m2.getName().equals("p2"));
        assertNotSame(m1.getName(), m2.getName());


        // search for join then filter
        pattern = new SillyPlan();
        Operator s1 = new OP_Join("mmm1", pattern);
        Operator s2 = new OP_Filter("mmm2", pattern);
        pattern.add(s1);
        pattern.add(s2);
        pattern.connect(s1, s2);

        r = new SillyRule("basic", pattern);
        l = r.match(plan);
        assertEquals(1, l.size());

        assertEquals(1, l.get(0).getSources().size());
        assertEquals(1, l.get(0).getSinks().size());
        assertEquals(2, l.get(0).size());

        m1 = l.get(0).getSources().get(0);
        assertTrue(m1.getName().equals("j1"));
        m2 = l.get(0).getSinks().get(0);
        assertTrue(m2.getName().equals("f1"));


        // search for filter, then store
        pattern = new SillyPlan();
        s1 = new OP_Filter("mmm1", pattern);
        s2 = new OP_Store("mmm2", pattern);
        pattern.add(s1);
        pattern.add(s2);
        pattern.connect(s1, s2);

        r = new SillyRule("basic", pattern);
        l = r.match(plan);
        assertEquals(2, l.size());

        assertEquals(1, l.get(0).getSources().size());
        assertEquals(1, l.get(0).getSinks().size());

        // search for 2 loads, then join
        pattern = new SillyPlan();
        s1 = new OP_Load("mmm1", pattern);
        s2 = new OP_Load("mmm2", pattern);
        Operator s3 = new OP_Join("jjj", pattern);
        pattern.add(s1);
        pattern.add(s2);
        pattern.add(s3);
        pattern.connect(s1, s3);
        pattern.connect(s2, s3);

        r = new SillyRule("basic", pattern);
        l = r.match(plan);
        assertEquals(l.size(), 1);

        // search for split then 2 filters
        pattern = new SillyPlan();
        s1 = new OP_Split("mmm1", pattern);
        s2 = new OP_Filter("mmm2", pattern);
        s3 = new OP_Filter("mmm3", pattern);
        pattern.add(s1);
        pattern.add(s2);
        pattern.add(s3);
        pattern.connect(s1, s2);
        pattern.connect(s1, s3);

        r = new SillyRule("basic", pattern);
        l = r.match(plan);
        assertEquals(1, l.size());
View Full Code Here

        plan.connect(f5, s5);
        plan.connect(f6, s6);
        plan.connect(join, f5);
        plan.connect(join, f6);

        OperatorPlan pattern = new SillyPlan();
        Operator s1 = new OP_Join("mmm1", pattern);
        Operator s2 = new OP_Filter("mmm2", pattern);
        Operator s3 = new OP_Filter("mmm3", pattern);
        Operator s4 = new OP_Filter("mmm4", pattern);
        pattern.add(s1);
        pattern.add(s2);
        pattern.add(s3);
        pattern.add(s4);
        pattern.connect(s1, s2);
        pattern.connect(s1, s3);
        pattern.connect(s1, s4);

        Rule r = new SillyRule("basic", pattern);
        List<OperatorPlan> l = r.match(plan);
        assertEquals(1, l.size());
View Full Code Here

        next = plan.getSuccessors(next).get(0);
        Assert.assertEquals(next.getClass(), LOFilter.class);
        next = plan.getSuccessors(next).get(0);
        Assert.assertEquals(LOStore.class, next.getClass());
       
        OperatorPlan transformed = listener.getTransformed();
        Assert.assertEquals(transformed.size(), 3);
       
        // run push up filter rule
        r = new PushUpFilter("PushUpFilter");
        s = new HashSet<Rule>();
        s.add(r);
        ls = new ArrayList<Set<Rule>>();
        ls.add(s);
        optimizer = new MyPlanOptimizer(plan, ls, 3);
        listener = new MyPlanTransformListener();
        optimizer.addPlanTransformListener(listener);
        optimizer.optimize();
       
        // 2 filters should be moved up to be after each load, and one filter should remain
        next = plan.getSuccessors(load1).get(0);
        Assert.assertEquals(next.getClass(), LOFilter.class);
        Assert.assertEquals(plan.getSuccessors(next).get(0), join);
       
        next = plan.getSuccessors(load2).get(0);
        Assert.assertEquals(next.getClass(), LOFilter.class);
        Assert.assertEquals(plan.getSuccessors(next).get(0), join);
       
        next = plan.getSuccessors(join).get(0);
        Assert.assertEquals(next.getClass(), LOFilter.class);
       
        next = plan.getSuccessors(next).get(0);
        Assert.assertEquals(next.getClass(), LOStore.class);
       
        transformed = listener.getTransformed();
        Assert.assertEquals(transformed.size(), 7);
       
        // run merge filter rule
        r = new MergeFilter("MergeFilter");
        s = new HashSet<Rule>();
        s.add(r);
View Full Code Here

        Assert.assertEquals(next.getClass(), LOFilter.class);
       
        next = plan.getSuccessors(next).get(0);
        Assert.assertEquals(next.getClass(), LOStore.class);
       
        OperatorPlan transformed = listener.getTransformed();
        Assert.assertEquals(transformed.size(), 2);
    }  
View Full Code Here


    @Override
    public void visit(LOSplitOutput op) throws FrontendException {
        op.resetSchema();
        OperatorPlan lp = op.getPlan();
        // LOSplitOutput can only have 1 input
        List<Operator> list = lp.getPredecessors(op) ;
        if (list.size() != 1) {
            int errCode = 2008;
            String msg = "LOSplitOutput cannot have more than one input. Found: " + list.size() + " input(s).";
            throwTypeCheckerException(op, msg, errCode, PigException.BUG, null) ;
        }
View Full Code Here

    /***
     * The schema of split output will be the same as split input
     */

    public void visit(LOSplit split) throws VisitorException {
        OperatorPlan lp = split.getPlan();
        List<Operator> inputList = lp.getPredecessors(split);

        if (inputList.size() != 1) {           
            int errCode = 2008;
            String msg = "LOSplit cannot have more than one input. Found: " + inputList.size() + " input(s).";
            throwTypeCheckerException(split, msg, errCode, PigException.BUG, null) ;
View Full Code Here

TOP

Related Classes of org.apache.pig.newplan.OperatorPlan

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.