Package org.apache.pig.newplan.optimizer

Examples of org.apache.pig.newplan.optimizer.Rule


       protected List<Set<Rule>> buildRuleSets() {           
            List<Set<Rule>> ls = new ArrayList<Set<Rule>>();
           
            Set<Rule> s = new HashSet<Rule>();
            // add split filter rule
            Rule r = new LoadTypeCastInserter( "TypeCastInserter" );
            s.add(r);
            ls.add(s);
            
            s = new HashSet<Rule>();
            r = new FilterAboveForeach( "FilterAboveForeach" );
View Full Code Here


        }
       
        protected List<Set<Rule>> buildRuleSets() {           
            List<Set<Rule>> ls = new ArrayList<Set<Rule>>();
           
            Rule r = new ColumnMapKeyPrune("ColumnMapKeyPrune");
            Set<Rule> s = new HashSet<Rule>();
            s.add(r);           
            ls.add(s);
           
            r = new AddForEach("AddForEach");
View Full Code Here

        protected List<Set<Rule>> buildRuleSets() {           
            List<Set<Rule>> ls = new ArrayList<Set<Rule>>();
           
            Set<Rule> s = new HashSet<Rule>();
            // add split filter rule
            Rule r = new PartitionFilterOptimizer("PartitionFilterPushDown");
            s = new HashSet<Rule>();
            s.add(r);           
            ls.add(s);
           
            r = new LoadTypeCastInserter( "LoadTypeCastInserter" );
View Full Code Here

       
        // DuplicateForEachColumnRewrite set
        // This insert Identity UDF in the case foreach duplicate field.
        // This is because we need unique uid through out the plan
        Set<Rule> s = new HashSet<Rule>();
        Rule r = new DuplicateForEachColumnRewrite("DuplicateForEachColumnRewrite");
        checkAndAddRule(s, r);
        if (!s.isEmpty())
            ls.add(s);
       
        // ImplicitSplitInserter set
View Full Code Here

       protected List<Set<Rule>> buildRuleSets() {           
            List<Set<Rule>> ls = new ArrayList<Set<Rule>>();
           
            Set<Rule> s = new HashSet<Rule>();
            // add split filter rule
            Rule r = new LoadTypeCastInserter( "TypeCastInserter" );
            s.add(r);
            ls.add(s);
            
            s = new HashSet<Rule>();
            r = new FilterAboveForeach( "FilterAboveForeach" );
View Full Code Here

       
        protected List<Set<Rule>> buildRuleSets() {           
            List<Set<Rule>> ls = new ArrayList<Set<Rule>>();
           
            Set<Rule> s = null;
            Rule r = null;
           
            s = new HashSet<Rule>();
            r = new LoadTypeCastInserter( "TypeCastInserter");
            s.add(r);
            ls.add(s);
View Full Code Here

        }

        protected List<Set<Rule>> buildRuleSets() {
            List<Set<Rule>> ls = new ArrayList<Set<Rule>>();

            Rule r = new LogicalExpressionSimplifier("LogicalPlanSimplifier");
            Set<Rule> s = new HashSet<Rule>();
            s.add(r);
            ls.add(s);

            return ls;
View Full Code Here

         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(match.size(), 3);
         assertEquals(match.getSinks().size(), 1);
         assertEquals(match.getSinks().get(0), join);
View Full Code Here

    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(l.size(), 2);
       
        Operator m1 = l.get(0).getSources().get(0);
        assertTrue(m1.getName().equals("p1") || m1.getName().equals("p2"));
        assertEquals(l.get(0).size(), 1);
       
        Operator m2 = l.get(1).getSources().get(0);
        assertTrue(m2.getName().equals("p1") || m2.getName().equals("p2"));
        assertEquals(l.get(1).size(), 1);
        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(l.size(), 4);
       
        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(l.get(0).size(), 1);
       
        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(l.get(1).size(), 1);
        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);
        assertTrue(m1.getName().equals("j1"));
        assertEquals(l.get(0).size(), 1);
View Full Code Here

        // 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(l.size(), 1);
       
        assertEquals(l.get(0).getSources().size(), 1);
        assertEquals(l.get(0).getSinks().size(), 1);
        assertEquals(l.get(0).size(), 2);
       
        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(l.get(0).getSources().size(), 1);
        assertEquals(l.get(0).getSinks().size(), 1);                    
       
        // 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());
       
        assertEquals(l.get(0).getSources().size(), 1);
        assertEquals(l.get(0).getSinks().size(), 2);
        assertEquals(l.get(0).size(), 3);
View Full Code Here

TOP

Related Classes of org.apache.pig.newplan.optimizer.Rule

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.