Package org.apache.pig.newplan

Examples of org.apache.pig.newplan.Operator


        // it matches.
        currentPlan = plan;
        List<OperatorPlan> ll = new ArrayList<OperatorPlan>();
        Iterator<Operator> ops = plan.getOperators();
        while (ops.hasNext()) {
            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();
View Full Code Here


        //      \       /
        //        Split
        //          |
        //          op
       
        Operator op = matched.getSources().get(0);
        List<Operator> succs = currentPlan.getSuccessors(op);
        if (succs == null || succs.size() < 2)
          throw new FrontendException("Invalid match in ImplicitSplitInserter rule.", 2243);
        LOSplit splitOp = new LOSplit(currentPlan);
        splitOp.setAlias(((LogicalRelationalOperator) op).getAlias());
View Full Code Here

        Iterator<Operator> iter = plan.getOperators();
        List<OperatorPlan> matchedList = new ArrayList<OperatorPlan>();      
        matchedNodes.clear();
      
        while(iter.hasNext()) {
            Operator op = iter.next();
          
            // find a node that matches the first leaf of the pattern
            if (match(op, leaves.get(0))) {
                List<Operator> planOps = new ArrayList<Operator>();
                planOps.add(op);
                               
                // if there is more than 1 leaves in the pattern, we check
                // if other leaves match the siblings of this node
                if (leaves.size()>1) {
                    boolean matched = true;
                   
                   
                    List<Operator> preds = null;
                    preds = plan.getPredecessors(op);
                   
                    // if this node has no predecessor, it must be a root
                    if (preds == null) {
                        preds = new ArrayList<Operator>();
                        preds.add(null);
                    }
                   
                    for(Operator s: preds) {
                        matched = true;
                        List<Operator> siblings = null;
                        if (s != null) {
                            siblings = plan.getSuccessors(s);
                        }else{
                            // for a root, we get its siblings by getting all roots
                            siblings = plan.getSources();
                        }

                        int index = siblings.indexOf(op);
                        if (siblings.size()-index < leaves.size()) {
                            continue;
                        }
                   
                       
                        for(int j=1; j<leaves.size(); j++) {
                            if (!match(siblings.get(index+j), leaves.get(j))) {
                                matched = false;
                                break;
                            }
                        }    
                       
                        if (matched) {
                            for(int j=1; j<leaves.size(); j++) {
                                planOps.add(siblings.get(index+j));
                                break;
                            }
                        }
                   
                    }
                  
                    // we have move on to next operator as this one doesn't have siblings to
                    // match all the leaves
                    if (!matched) {
                        continue;
                    }
                }
               
             
                PatternMatchOperatorPlan match = new PatternMatchOperatorPlan(plan);
                if (match.check(planOps)) {
                    // we find a matched pattern,
                    // add the operators into matchedNodes
                    Iterator<Operator> iter2 = match.getOperators();                     
                    while(iter2.hasNext()) {
                        Operator opt = iter2.next();
                        matchedNodes.add(opt);                       
                    }
                   
                    // add pattern
                    matchedList.add(match);                                               
View Full Code Here

       
        @Override
        public boolean check(OperatorPlan matched) throws FrontendException {
            Iterator<Operator> iter = matched.getOperators();
            while( iter.hasNext() ) {
                Operator op = iter.next();
                if( op instanceof LOForEach ) {
                    foreach = (LOForEach)op;
                    break;
                }
            }
           
            // This would be a strange case
            if( foreach == null ) return false;
           
            iter = matched.getOperators();
            while( iter.hasNext() ) {
                Operator op = iter.next();
                if( ( op instanceof LOFilter ) ) {
                    filter = (LOFilter)op;
                    break;
                }
            }
View Full Code Here

            List<Long> uids = new ArrayList<Long>();
            List<Byte> types = new ArrayList<Byte>();
            if( filter != null ) {
                LogicalExpressionPlan filterPlan = filter.getFilterPlan();
                Iterator<Operator> iter = filterPlan.getOperators();           
                Operator op = null;
                while( iter.hasNext() ) {
                    op = iter.next();
                    if( op instanceof ProjectExpression ) {
                        ProjectExpression proj = (ProjectExpression)op;
                        if( proj.isProjectStar() ) {
View Full Code Here

           
            List<Operator> opSet = currentPlan.getPredecessors(filter);
            if( ! ( opSet != null && opSet.size() > 0 ) ) {
                return;
            }
            Operator filterPred = opSet.get(0);
           
            opSet = currentPlan.getSuccessors(filter);
            if( ! ( opSet != null && opSet.size() > 0 ) ) {
                return;
            }
            Operator filterSuc = opSet.get(0);
           
            subPlan = new OperatorSubPlan(currentPlan);
           
            // Steps below do the following
            /*
 
View Full Code Here

        @Override
        public void transform(OperatorPlan plan) throws FrontendException {
            Iterator<Operator> iter = plan.getOperators();
            while (iter.hasNext()) {
                Operator op = iter.next();
                if (op instanceof LOFilter) {
                    LOFilter filter = (LOFilter) op;
                    LogicalExpressionPlan filterPlan = filter.getFilterPlan();
                    this.plan = ((OperatorSubPlan) plan).getBasePlan();
                    try {
View Full Code Here

                        throws FrontendException {
            List<Operator> roots = dnfPlan.getSources();
            if (roots == null || roots.size() != 1)
                throw new FrontendException(
                                "DNF root size is expected to be one");
            Operator dnf = roots.get(0);
            if (dnf instanceof AndExpression || (dnf instanceof DNFExpression && ((DNFExpression) dnf).type == DNFExpression.DNFExpressionType.AND)) {
                handleDNFAnd(dnfPlan, dnf);
            }
            else if (dnf instanceof OrExpression || (dnf instanceof DNFExpression && ((DNFExpression) dnf).type == DNFExpression.DNFExpressionType.OR)) {
                handleDNFOr(dnfPlan, dnf);
View Full Code Here

            if (plan.getSuccessors(op) == null) return;

            Object[] children = plan.getSuccessors(op).toArray();
            if (children != null) {
                for (Object c : children) {
                    Operator child = (Operator) c;
                    removeDescendants(plan, child);
                    plan.disconnect(op, child);
                    if (child instanceof LogicalExpressionProxy) ((LogicalExpressionProxy) child).decrSrcDNFSplitCounter();
                    else decrDNFSplitCount((LogicalExpression) child);
                    plan.remove(child);
View Full Code Here

                        ((LogicalExpressionProxy) child).decrSrcDNFSplitCounter();
                    plan.remove(child);
                }
            }
            if (plan.getSuccessors(root) != null && plan.getSuccessors(root).size() == 1) {
                Operator child = plan.getSuccessors(root).get(0);
                plan.disconnect(root, child);
                if (plan.getPredecessors(root) != null) {
                    Operator[] preds = plan.getPredecessors(root).toArray(
                                    new Operator[0]);
                    for (Operator pred : preds) {
View Full Code Here

TOP

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

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.