Pig latin

pig的两种运行模式,local模式,mapreduce模式

local模式下,pig只能访问本地一台;在mapreduce模式下,pig可以访问一个hadoop集群和hdfs的安装位置。这时,pig将自动对这个集群进行分配和回收。因为pig系统可以自动对mapreduce程序进行优化,所以当用户使用pig latin编程时,不必关系程序的运行效率,pig系统会自动对程序进行优化。

pig的local模式以及mapreduce模式都是有三种运行模式:Grunt shell方式,脚本文件方式,嵌入式程序方式

mapreduce模式下:

1 .grunt shell 方式

[root@host pig-0.17.0]# pig -x mapreduce
18/06/15 09:40:34 INFO pig.ExecTypeProvider: Trying ExecType : LOCAL
18/06/15 09:40:34 INFO pig.ExecTypeProvider: Trying ExecType : MAPREDUCE
18/06/15 09:40:34 INFO pig.ExecTypeProvider: Picked MAPREDUCE as the ExecType
2018-06-15 09:40:34,951 [main] INFO  org.apache.pig.Main - Apache Pig version 0.17.0 (r1797386) compiled Jun 02 2017, 15:41:58
2018-06-15 09:40:34,951 [main] INFO  org.apache.pig.Main - Logging error messages to: /root/pig/pig-0.17.0/pig_1529026834950.log
2018-06-15 09:40:34,971 [main] INFO  org.apache.pig.impl.util.Utils - Default bootup file /root/.pigbootup not found
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/root/hadoop/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/hbase-1.4.4/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/hive/apache-hive-2.1.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
2018-06-15 09:40:35,586 [main] INFO  org.apache.hadoop.conf.Configuration.deprecation - mapred.job.tracker is deprecated. Instead, use mapreduce.jobtracker.address
2018-06-15 09:40:35,586 [main] INFO  org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to hadoop file system at: hdfs://localhost:9000
2018-06-15 09:40:36,347 [main] INFO  org.apache.pig.PigServer - Pig Script ID for the session: PIG-default-cb6cead5-f22f-4960-bce7-5f44cdb722ec
2018-06-15 09:40:36,347 [main] WARN  org.apache.pig.PigServer - ATS is disabled since yarn.timeline-service.enabled set to false
grunt>

2 .脚本文件方式

 pig -x mapreduce script.pig

pig latin语言

与数据库操作语言类似,但更侧重于对数据的分析查询,而不是对数据进行修改删除等操作,运行在hadoop分布式平台上,能够在短时间内处理海量数据,如处理日志文件,处理大型数据库文件, 处理WEB数据等。

pigLatin的操作:通过对关系进行处理产生另外一组关系(适用于除load ,store以外的所有操作,load和store分别执行从文件系统的读取和写入操作)。

pig latin语句一条语句可以跨越多行,但是必须以半角的分号结束。

通常按照下面的流程编写语句:

1.通过load语句从文件系统读取数据

2.通过一系列的转换语句对数据进行处理

3通过store语句把处理结果输出到文件系统,或者使用一条dump语句把处理结果输出到屏幕上。

猜你喜欢

转载自www.cnblogs.com/playforever/p/9186005.html
pig
今日推荐