Package org.apache.pig.impl.logicalLayer

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


                List<LogicalOperator> listOp = lp.getSuccessors(op);
               
                if(null != listOp) {
                    Iterator<LogicalOperator> iter = listOp.iterator();
                    while(iter.hasNext()) {
                        LogicalOperator lop = iter.next();
                        System.err.println("Successor: " + lop.getClass().getName() + " object " + lop);
                    }
                }
            }
           
            assertTrue(lp != null);
View Full Code Here


        }

        @Override
        protected void visit(LOStore store) throws VisitorException {
           
            LogicalOperator storePred = store.getPlan().getPredecessors(store).get(0);
            if(storePred == null){
                int errCode = 2051;
                String msg = "Did not find a predecessor for Store." ;
                throw new VisitorException(msg, errCode, PigException.BUG);   
            }
           
            SortInfo sortInfo = null;
            if(storePred instanceof LOLimit) {
                storePred = store.getPlan().getPredecessors(storePred).get(0);
            } else if (storePred instanceof LOSplitOutput) {
                LOSplitOutput splitOutput = (LOSplitOutput)storePred;
                // We assume this is the LOSplitOutput we injected for this case:
                // b = order a by $0; store b into '1'; store b into '2';
                // In this case, we should mark both '1' and '2' as sorted
                LogicalPlan conditionPlan = splitOutput.getConditionPlan();
                if (conditionPlan.getRoots().size()==1) {
                    LogicalOperator root = conditionPlan.getRoots().get(0);
                    if (root instanceof LOConst) {
                        Object value = ((LOConst)root).getValue();
                        if (value instanceof Boolean && (Boolean)value==true) {
                            LogicalOperator split = splitOutput.getPlan().getPredecessors(splitOutput).get(0);
                            if (split instanceof LOSplit)
                                storePred = store.getPlan().getPredecessors(split).get(0);
                        }
                    }
                }
View Full Code Here

        LogicalPlan getPlan(String alias) throws IOException {
            LogicalPlan plan = lp;
               
            if (alias != null) {
                LogicalOperator op = aliasOp.get(alias);
                if(op == null) {
                    int errCode = 1003;
                    String msg = "Unable to find an operator for alias " + alias;
                    throw new FrontendException(msg, errCode, PigException.INPUT);
                }
View Full Code Here

            LogicalPlan tmpLp = parseQuery(query, startLine);
           
            // store away the query for use in cloning later
            scriptCache.add(query);
            if (tmpLp.getLeaves().size() == 1) {
                LogicalOperator op = tmpLp.getSingleLeafPlanOutputOp();
               
                // Check if we just processed a LOStore i.e. STORE
                if (op instanceof LOStore) {

                    if (!batchMode) {
                        lp = tmpLp;
                        try {
                            execute();
                        } catch (Exception e) {
                            int errCode = 1002;
                            String msg = "Unable to store alias "
                                    + op.getOperatorKey().getId();
                            throw new FrontendException(msg, errCode,
                                    PigException.INPUT, e);
                        }
                    } else {
                        if (0 == ignoreNumStores) {
View Full Code Here

     * @throws IOException
     */
    public Schema dumpSchemaNested(String alias, String nestedAlias) throws IOException{
        LogicalPlan lp = getPlanFromAlias(alias, "describe");
        lp = compileLp(alias, false);
        LogicalOperator op = lp.getLeaves().get(0);
        if(op instanceof LOForEach) {
            return ((LOForEach)op).dumpNestedSchema(alias, nestedAlias);
        }
        else {
            int errCode = 1001;
View Full Code Here

     * @return iterator of tuples returned from the script
     * @throws IOException
     */
    public Iterator<Tuple> openIterator(String id) throws IOException {
        try {
            LogicalOperator op = currDAG.getAliasOp().get(id);
            if(null == op) {
                int errCode = 1003;
                String msg = "Unable to find an operator for alias " + id;
                throw new FrontendException(msg, errCode, PigException.INPUT);
            }
View Full Code Here

            // MRCompiler needs a store to be the leaf - hence
            // add a store to the plan to explain
           
            // figure out the leaf to which the store needs to be added
            List<LogicalOperator> leaves = lp.getLeaves();
            LogicalOperator leaf = null;
            if(leaves.size() == 1) {
                leaf = leaves.get(0);
            } else {
                for (Iterator<LogicalOperator> it = leaves.iterator(); it.hasNext();) {
                    LogicalOperator leafOp = it.next();
                    if(leafOp.getAlias().equals(id))
                        leaf = leafOp;
                }
            }
           
            LogicalPlan unCompiledstorePlan = QueryParser.generateStorePlan(
View Full Code Here

            // MRCompiler needs a store to be the leaf - hence
            // add a store to the plan to explain
           
            // figure out the leaves to which stores need to be added
            List<LogicalOperator> leaves = lp.getLeaves();
            LogicalOperator leaf = null;
            if(leaves.size() == 1) {
                leaf = leaves.get(0);
            } else {
                for (Iterator<LogicalOperator> it = leaves.iterator(); it.hasNext();) {
                    LogicalOperator leafOp = it.next();
                    if(leafOp.getAlias().equals(alias))
                        leaf = leafOp;
                }
            }
           
            lp = QueryParser.generateStorePlan(scope, lp, "fakefile",
View Full Code Here

        if (typeCheckedLp.size() == 0) {
            return PigStatsUtil.getEmptyPigStats();
        }

        LogicalOperator op = typeCheckedLp.getLeaves().get(0);
        if (op instanceof LODefine) {
            log.info("Skip execution of DEFINE only logical plan.");
            return PigStatsUtil.getEmptyPigStats();
        }
View Full Code Here

        try {
            for(Map.Entry<LOUserFunc, Pair<LogicalPlan, LogicalOperator>> scalarEntry: scalarMap.entrySet()) {
                FileSpec fileSpec;
                String alias = scalarEntry.getKey().getImplicitReferencedOperator().getAlias();
                LogicalOperator store;

                LogicalPlan referredPlan = g.getAliases().get(g.getAliasOp().get(alias));

                // If referredPlan already has a store,
                // we just use it instead of adding one from our pocket
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.logicalLayer.LogicalOperator

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.