You are currently viewing How to run Pig in different modes

How to run Pig in different modes

Loading

Apache Pig is a part of the Hadoop ecosystem. It is used to process and analyze big data. It is a script used to perform map-reduce operations in the background and run SQL-like queries in the script. Pig Latin script is being used when you don’t know any programming language and still, you want to perform any map-reduce job then pig script is the right choice for you. It is an SQL-like scripting language. So, If you don’t have knowledge of any programming language. But, you know SQL or any other query language well. It will be easy for you to adapt the pig latin script and perform big data analysis.

Prerequisite

We are planning to show you how to run pig in a different mode. To do so, first of all, we need to set up Apache Pig in our system. So, setup apache pig is the prerequisite for running pigs in different modes.                 

Apache Pig Modes

Apache Pig can be run in two different modes.

  • Local Mode
  • Map-Reduce Mode

Let’s discuss each mode one by one.

Local Mode

This mode is used for testing purposes. It is being used in a single JVM. It is used to do experiments for the implementation.

We can run pig in local mode using the below command:

  • pig -x local

Output

Map-Reduce Mode

This mode is used for production purposes. It is also known as hadoop mode or default mode. It can be executed in fully distributed mode or semi-distributed mode.

Here input and output data are present on HDFS.

We can run pig in map-reduce mode using the below command:

  • pig

or

  • pig -x mapreduce

Output

Ways to execute Pig Program

We can execute the pig program locally and mapreduce mode using the following execution methods.

  • Grunt shell: This is the interactive Pig shell where you may perform individual Pig commands. The shell offers a prompt where you can enter statements written in Pig Latin and view the outcomes right away.
  • Pig Latin script file: You can create a script in Pig Latin and execute it by using the command: pig [-x mapreduce] script_file.pig
  • A pig may be integrated with Java programs, enabling you to create Pig Latin scripts and execute them directly from Java code.
  • PigServer: The PigServer is a programmatic interface to Pig that enables Java applications to execute Pig Latin scripts.
  • Pig Latin in MapReduce: Using Hadoop MapReduce, you can write Pig Latin statements and have them executed.
  • PigUnit is a testing framework that enables you to create test cases for your Pig Latin scripts.

Conclusion

Here, we have seen we can run pig in two different modes. Local and mapreduce mode. Hope this will help you guys to understand how we can run pig in different modes and have different execution modes.

If you like the article and would like to support me, make sure to: