0

我在跑猪

example$ pig --version
Apache Pig version 0.8.1-cdh3u1 (rexported) 
compiled Jul 18 2011, 08:29:40

在非常简单的数据集上

example$ hadoop fs -cat /user/pavel/trivial.log
1   one
2   two
3   three

我正在尝试使用以下脚本将包格式保存为 json:

REGISTER ./pig.jar;
A = LOAD 'trivial.log' USING PigStorage('\t') AS (mynum: int, mynumstr: chararray);
B = GROUP A BY mynum;
DUMP B;
STORE B into 'trivial_json.out' USING JsonStorage();

我收到一个错误:后端错误消息

---------------------
java.lang.NullPointerException
    at org.apache.pig.ResourceSchema.<init>(ResourceSchema.java:239)
    at org.apache.pig.builtin.JsonStorage.prepareToWrite(JsonStorage.java:129)
    at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigOutputFormat$PigRecordWriter.<init>(PigOutputFormat.java:124)
    at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigOutputFormat.getRecordWriter(PigOutputFormat.java:85)
    at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:559)
    at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:414)
    at org.apache.hadoop.mapred.Child$4.run(Child.java:270)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:396)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1127)
    at org.apache.hadoop.mapred.Child.main(Child.java:264)

Pig Stack Trace
---------------
ERROR 2997: Unable to recreate exception from backed error: java.lang.NullPointerException

org.apache.pig.backend.executionengine.ExecException: ERROR 2997: Unable to recreate exception from backed error: java.lang.NullPointerException
    at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.Launcher.getErrorMessages(Launcher.java:221)
    at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.Launcher.getStats(Launcher.java:154)
    at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MapReduceLauncher.launchPig(MapReduceLauncher.java:337)
    at org.apache.pig.backend.hadoop.executionengine.HExecutionEngine.execute(HExecutionEngine.java:382)
    at org.apache.pig.PigServer.executeCompiledLogicalPlan(PigServer.java:1209)
    at org.apache.pig.PigServer.execute(PigServer.java:1201)
    at org.apache.pig.PigServer.access$100(PigServer.java:129)
    at org.apache.pig.PigServer$Graph.execute(PigServer.java:1528)
    at org.apache.pig.PigServer.executeBatchEx(PigServer.java:373)
    at org.apache.pig.PigServer.executeBatch(PigServer.java:340)
    at org.apache.pig.tools.grunt.GruntParser.executeBatch(GruntParser.java:115)
    at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:172)
    at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:144)
    at org.apache.pig.tools.grunt.Grunt.exec(Grunt.java:90)
    at org.apache.pig.Main.run(Main.java:396)
    at org.apache.pig.Main.main(Main.java:107)
================================================================================

我在 Java 方面不够强大,无法在几分钟内进行调试,有人可以建议可能发生什么吗?

非常感谢!-帕维尔

4

1 回答 1

2

通过电子邮件收到一些关于此的问题,认为这可能对其他人有用:

事实证明,我的 Pig 安装中没有包含 JsonStorage 类。事实上,它甚至还没有出现在一个稳定的分支中,你不会在 0.9.2 中找到它。但是如果你得到最新的后备箱

http://svn.apache.org/repos/asf/pig/trunk/

然后 trunk/test/org/apache/pig/test/TestJsonLoaderStorage.java 展示了它是如何工作的。如果您不反对未发布的版本,那么您可以尝试一下。如果你这样做,你还应该看看 Avro(带有 json 元数据的二进制格式)。也没有正式出。

我试图运行流式 python 作业,并试图避免手动指定架构。我最终传递了猪包并手动解析它们。

希望这可以帮助。-帕维尔

于 2012-03-06T23:18:36.997 回答