开发手册 欢迎您!
软件开发者资料库

Apache Pig - 诊断操作员

Apache Pig诊断操作员 - 从概述,架构,安装,执行,Grunt Shell,猪拉丁语基础知识,读取数据,存储数据,诊断操作员,描述操作员,解释操作员,说明操作员,组操作员,Cogroup操作员,加入,学习Apache Pig操作员,跨操作员,联合操作员,拆分操作员,过滤操作员,不同操作员,Foreach操作员,订单依据,限制操作员,评估函数,加载和存储函数,包和元组函数,字符串函数,日期时间函数,数学函数,用户定义的函数,运行脚本。

load 语句只是将数据加载到Apache Pig中的指定关系中.要验证 Load 语句的执行,您必须使用诊断运算符. Pig Latin提供四种不同类型的诊断算子 :

  • 转储运算符

  • 描述运算符

  • 解释运算符

  • 插图运算符

在本章中,我们将讨论Pig Latin的转储运算符.

转储运算符

转储运算符用于运行Pig Latin语句并在屏幕上显示结果.它通常用于调试目的.

语法

以下是转储运算符的语法.

grunt> Dump Relation_Name

示例

假设我们在HDFS中有一个文件 student_data.txt 以下内容.

001,Rajiv,Reddy,9848022337,Hyderabad002,siddarth,Battacharya,9848022338,Kolkata003,Rajesh,Khanna,9848022339,Delhi004,Preethi,Agarwal,9848022330,Pune005,Trupthi,Mohanthy,9848022336,Bhuwaneshwar006,Archana,Mishra,9848022335,Chennai.

我们已经使用LOAD运算符将其读入关系 student ,如下所示.

grunt> student = LOAD 'hdfs://localhost:9000/pig_data/student_data.txt'    USING PigStorage(',')   as ( id:int, firstname:chararray, lastname:chararray, phone:chararray,    city:chararray );

现在,让我们使用转储运算符打印关系的内容,如下所示.

grunt> Dump student

执行上述 Pig Latin 语句后,它将启动MapReduce作业以从HDFS读取数据.它将产生以下输出.

2015-10-01 15:05:27,642 [main]INFO  org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MapReduceLauncher - 100% complete2015-10-01 15:05:27,652 [main]INFO  org.apache.pig.tools.pigstats.mapreduce.SimplePigStats - Script Statistics:   HadoopVersion  PigVersion  UserId    StartedAt             FinishedAt       Features             2.6.0          0.15.0      Hadoop  2015-10-01 15:03:11  2015-10-01 05:27     UNKNOWN                                                Success!  Job Stats (time in seconds):  JobId           job_14459_0004Maps                 1  Reduces              0  MaxMapTime          n/a    MinMapTime          n/aAvgMapTime          n/a MedianMapTime       n/aMaxReduceTime        0MinReduceTime        0  AvgReduceTime        0MedianReducetime     0Alias             student Feature           MAP_ONLY        Outputs           hdfs://localhost:9000/tmp/temp580182027/tmp757878456,Input(s): Successfully read 0 records from: "hdfs://localhost:9000/pig_data/student_data.txt"  Output(s): Successfully stored 0 records in: "hdfs://localhost:9000/tmp/temp580182027/tmp757878456"  Counters: Total records written : 0 Total bytes written : 0 Spillable Memory Manager spill count : 0Total bags proactively spilled: 0 Total records proactively spilled: 0  Job DAG: job_1443519499159_0004  2015-10-01 15:06:28,403 [main]INFO  org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MapReduceLau ncher - Success!2015-10-01 15:06:28,441 [main] INFO  org.apache.pig.data.SchemaTupleBackend - Key [pig.schematuple] was not set... will not generate code.2015-10-01 15:06:28,485 [main]INFO  org.apache.hadoop.mapreduce.lib.input.FileInputFormat - Total input paths to process : 12015-10-01 15:06:28,485 [main]INFO  org.apache.pig.backend.hadoop.executionengine.util.MapRedUtil - Total input pathsto process : 1(1,Rajiv,Reddy,9848022337,Hyderabad)(2,siddarth,Battacharya,9848022338,Kolkata)(3,Rajesh,Khanna,9848022339,Delhi)(4,Preethi,Agarwal,9848022330,Pune)(5,Trupthi,Mohanthy,9848022336,Bhuwaneshwar)(6,Archana,Mishra,9848022335,Chennai)