Package org.apache.pig.impl.logicalLayer

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


            this.batchMode = batchMode;
            this.processedStores = 0;
            this.ignoreNumStores = 0;
            this.jobName = pigContext.getProperties().getProperty(PigContext.JOB_NAME,
                                                                  PigContext.JOB_NAME_PREFIX+":DefaultJobName");
            this.lp = new LogicalPlan();
        };
View Full Code Here


        public void setJobPriority(String priority){
            jobPriority = priority;
        }

        LogicalPlan getPlan(String alias) throws IOException {
            LogicalPlan plan = lp;
               
            if (alias != null) {
                LogicalOperator op = aliasOp.get(alias);
                if(op == null) {
                    int errCode = 1003;
View Full Code Here

            return plan;
        }

        void registerQuery(String query, int startLine) throws IOException {
           
            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) {
                            storeOpTable.put((LOStore)op, tmpLp);
                            lp.mergeSharedPlan(tmpLp);
                            List<LogicalOperator> roots = tmpLp.getRoots();
                            for (LogicalOperator root : roots) {
                                if (root instanceof LOLoad) {
                                    loadOps.add((LOLoad)root);
                                }
                            }
View Full Code Here

     * @return Schema of alias dumped
     * @throws IOException
     */
    public Schema dumpSchema(String alias) throws IOException{
        try {
            LogicalPlan lp = getPlanFromAlias(alias, "describe");
            lp = compileLp(alias, false);
            Schema schema = null;
            for(LogicalOperator lo : lp.getLeaves()){
                if(lo.getAlias().equals(alias)){
                    schema = lo.getSchema();
                    break;
                }
            }
View Full Code Here

     * @param nestedAlias Alias whose schema will be written out
     * @return Schema of alias dumped
     * @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

            throw new IOException("Invalid alias: " + id);
        }

        try {
            Graph g = getClonedGraph();
            LogicalPlan lp = g.getPlan(id);

            // 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(
                    scope, lp, filename, func, leaf, leaf.getAlias(),
                    pigContext);
            LogicalPlan storePlan = compileLp(unCompiledstorePlan, g, true);
           
            return executeCompiledLogicalPlan(storePlan);
        } catch (PigException e) {
            int errCode = 1002;
            String msg = "Unable to store alias " + id;
View Full Code Here

                        PrintStream lps,
                        PrintStream pps,
                        PrintStream eps) throws IOException {
        try {
            pigContext.inExplain = true;
            LogicalPlan lp = getStorePlan(alias);
            if (lp.size() == 0) {
                lps.println("Logical plan is empty.");
                pps.println("Physical plan is empty.");
                eps.println("Execution plan is empty.");
                return;
            }
            PhysicalPlan pp = compilePp(lp);
            lp.explain(lps, format, verbose);
            if( pigContext.getProperties().getProperty("pig.usenewlogicalplan", "true").equals("true") ) {
                LogicalPlanMigrationVistor migrator = new LogicalPlanMigrationVistor(lp);
                migrator.visit();
                org.apache.pig.newplan.logical.relational.LogicalPlan newPlan = migrator.getNewLogicalPlan();
               
View Full Code Here

    public Set<String> getAliasKeySet() {
        return currDAG.getAliasOp().keySet();
    }

    public Map<LogicalOperator, DataBag> getExamples(String alias) {
        LogicalPlan plan = null;

        try {       
            if (currDAG.isBatchOn()) {
                currDAG.execute();
            }
View Full Code Here

        return exgen.getExamples();
    }

    private LogicalPlan getStorePlan(String alias) throws IOException {
        Graph g = getClonedGraph();
        LogicalPlan lp = g.getPlan(alias);
       
        if (!isBatchOn() || alias != null) {
            // 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();) {
View Full Code Here

       
        return lp;
    }
   
    private PigStats execute(String alias) throws FrontendException, ExecException {
        LogicalPlan typeCheckedLp = compileLp(alias);

        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

TOP

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

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.