Apache Pig,程序运行问题

发布于 2024-12-23 08:57:09 字数 1624 浏览 1 评论 0原文

REGISTER /home/hadoop/pigg/trunk/contrib/piggybank/java/piggybank.jar;

-- Use the PigStorage function to load the excite log file into the raw bag as an array of records.
-- Input: (user,time,query) 
A = LOAD 'hadoop-test-data.csv' USING PigStorage(',') AS (user: chararray, site: chararray, view: int, click: int);

B = FOREACH A GENERATE org.apache.pig.piggybank.evaluation.string.UPPER(user);
-- Use the PigStorage function to store the results. 
STORE B INTO 'test-pig-result' USING PigStorage();

这是我的代码,我只是将我的用户名转换为大写。我已将此代码存储在 pig 根文件夹中的 test.pig 中。

我正在运行此代码,

java -cp $PIGGDIR/trunk/contrib/piggybank/java/piggybank.jar:$HADOOP_HOME/conf org.apache.pig.piggybank test.pig

但它不断抛出以下错误,

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/pig/piggybank/Main
    Caused by: java.lang.ClassNotFoundException: org.apache.pig.piggybank.Main
            at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    Could not find the main class: org.apache.pig.piggybank.Main.  Program will exit.

但如果我运行grunt 上的相同程序然后它给我正确的输出。 我已经尝试了 java -cp 的倒数第二个参数的所有可能的参数。

我还需要一个示例,其中使用 CSVLoader 类。

REGISTER /home/hadoop/pigg/trunk/contrib/piggybank/java/piggybank.jar;

-- Use the PigStorage function to load the excite log file into the raw bag as an array of records.
-- Input: (user,time,query) 
A = LOAD 'hadoop-test-data.csv' USING PigStorage(',') AS (user: chararray, site: chararray, view: int, click: int);

B = FOREACH A GENERATE org.apache.pig.piggybank.evaluation.string.UPPER(user);
-- Use the PigStorage function to store the results. 
STORE B INTO 'test-pig-result' USING PigStorage();

This is my code , i am just converting my username fielded in uppercase.I have stored this code in test.pig in pig root folder.

I am running this code with ,

java -cp $PIGGDIR/trunk/contrib/piggybank/java/piggybank.jar:$HADOOP_HOME/conf org.apache.pig.piggybank test.pig

But its keep throwing following error,

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/pig/piggybank/Main
    Caused by: java.lang.ClassNotFoundException: org.apache.pig.piggybank.Main
            at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    Could not find the main class: org.apache.pig.piggybank.Main.  Program will exit.

But if I run same program on grunt then it gives me proper output.
I have tried every possible param of java -cp's second last param.

And i also need an example , in which CSVLoader class is used.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尘世孤行 2024-12-30 08:57:09

如果你想在本地运行pig,你应该运行pig.jar而不是piggybank.jar
Piggybank.jar 将通过脚本中的 REGISTER 命令包含在脚本中

If you want to run pig locally you should run pig.jar not piggybank.jar
the piggybank.jar will be included in the script by the REGISTER command in the script

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文