Pig and Python (pig and Python)

Source: Internet
Author: User
Tags float number

Python is really everywhere in the country.

Pig 0.9 after python as an embedded voice, using the Jython interpreter to use the python2.5 feature, this interface is the topmost org.apache.pig.scripting.Pig
First the Python script translates some pig latin. Then pass the variable defined in Python to it and run it last.

1) Pig.compile or compilefromfile to pre-compile the code
2) The Bind method binds a variable in the control flow to a variable in the Pig Latin script and returns a Boundscript object
3) for the Boundscript object, the ability to call the Runsingle method to run him, return a Pigstat object, assuming that during the binding process the Pig object is bound to a set of map including the number of parameters, it is called the Run method, the same return a Pigstats object.

A separate instance of a user-written UDF is built and runs in each map or reduce task, and the constructor parameter is a way of passing information to the user UDF.


Python corresponds to the type of pig

int number
Long number
Float number
Double number
Chararray string
ByteArray string
Map Dictionary
Tuple tuple
Bag List Oftuples




Pig's load function is created from Hadoop-based InputFormat, and the base class is Loadfunc,loadfunc's default implementation is for HDFs, and Pig provides a way for the load function to initialize itself by providing the Preparetoread method. Once the user's load function implements the GetSchema method, the LOAD statement no longer needs to define their schema.



Similarly. The storage function is built on Hadoop-based Outoutformat. A tuple of pig is accepted, then a healthy-value pair is created based on the output of a good thing, and the base class is Storefunc,pig will call the stored function Preparetowrite method on each map or reduce task. Putnext It is the core method of storage functionality.

Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.

Pig and Python (pig and Python)

Related Article

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.