Pig System Analysis (5) from logical plan to physical plan

Source: Internet
Author: User
Tags execution

Physical plan generation process

The optimized logical execution plan is logtophytranslationvisitor processed to generate a physical execution plan.

This is a classic Vistor design pattern application scenario.

Where the Logtophytranslationvisitor visit () is the entry method, through Dependencyorderwalker traversal handles each logicalrelationaloperator in the logical execution plan. Dependencyorderwalker traverses the nodes in the DAG in a dependent order, ensuring that it is accessed only if all the predecessors of the node are accessed. The core logic is as follows, doallpredecessors recursively calls itself, adding nodes that meet no precursors to the FIFO queue, and the resulting effect is equivalent to sequentially accessing the graph topology.

public void Walk (planvisitorvisitor) throws Frontendexception {     
        list<operator> FIFO = new arraylist< Operator> ();     
        Set<operator> seen = new hashset<operator> ();     
        List<operator> leaves = plan.getsinks ();     
        if (leaves = null) return;     
        for (Operator op:leaves) {     
            doallpredecessors (OP, seen, FIFO);     
        }     
        for (Operator Op:fifo) {     
            op.accept (visitor);     
        }     
}

Next, each logicalrelationaloperator in turn calls the Logtophytranslationvisitor corresponding visit method to process itself, translates into physicaloperator. Finally, the complete logical execution plan is generated. The following figure is the visit operator method in Logtophytranslationvisitor.

Physical plan Structure

Analyze the execution plan for code generation in Pig System Analysis (3) before parsing, as shown in the figure:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.