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();
これは私のコードです。大文字でフィールドされたユーザー名を変換しています。このコードは、豚のルートフォルダ内のtest.pigに保存されています。
Apache Pig、programe run issue
、
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.
をしかし、私は面倒で同じプログラムを実行する場合、それは私に適切な出力を提供します。 java -cpの2番目に最後のパラメータをすべて試しました。
また、CSVLoaderクラスが使用される例が必要です。
それともbin' 'で' pig'実行可能ファイルを使用して
REGISTER
コマンドによってスクリプトに含まれるpig.jar
を実行する必要があります。 –