Package org.apache.pig.newplan

Examples of org.apache.pig.newplan.OperatorPlan


     
    }
   
    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(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());
       
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

    }

    Operator buildNestedOperatorInput(SourceLocation loc, LogicalPlan innerPlan, LOForEach foreach,
            Map<String, Operator> operators, LogicalExpression expr)
    throws NonProjectExpressionException, ParserValidationException {
        OperatorPlan plan = expr.getPlan();
        Iterator<Operator> it = plan.getOperators();
        if( !( it.next() instanceof ProjectExpression ) || it.hasNext() ) {
            throw new NonProjectExpressionException( intStream, loc, expr );
        }
        Operator op = null;
        ProjectExpression projExpr = (ProjectExpression)expr;
View Full Code Here

     * @param relOp
     * @throws FrontendException
     */
    private void mapToPredLoadFunc(LogicalRelationalOperator relOp)
    throws FrontendException {
        OperatorPlan lp = relOp.getPlan();
        List<Operator> preds = lp.getPredecessors(relOp);
        if(lp.getPredecessors(relOp) == null ||
                lp.getPredecessors(relOp).size() == 0){
            // no predecessors , nothing to do
            return;
        }

        FuncSpec loadFuncSpec = getAssociatedLoadFunc((LogicalRelationalOperator) preds.get(0));
View Full Code Here

            Operator op = ops.next();
            if (op instanceof LOSplit || op instanceof LOStore)
                continue;
            List<Operator> succs = plan.getSuccessors(op);
            if (succs != null && succs.size() >= 2) {
                OperatorPlan match = new LogicalPlan();
                match.add(op);
                ll.add(match);
            }
        }
        return ll;
    }
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

    @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

    }
   
    @Override
    public void visit(LOForEach foreach) throws FrontendException {
        foreach.resetSchema();
        OperatorPlan innerPlan = foreach.getInnerPlan();
        PlanWalker newWalker = currentWalker.spawnChildWalker(innerPlan);
        pushWalker(newWalker);
        currentWalker.walk(this);
        popWalker();
        foreach.getSchema();
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.