1
請問一個問題,我得到豬的安裝和配置,但它說「error package org.apache.pig.FilterFunc not exist
」,而我試圖通過使用javac命令編譯一個非常簡單的java源文件。錯誤包org.apache.pig.FilterFunc不存在
CLASSPATH變量被設置爲如下:
/usr/local/hadoop/share/hadoop/common/hadoop-common-2.7.0.jar:/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.7.0.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-cli-1.2.jar:/usr/local/hadoop/etc/hadoop/:/usr/local/pig/lib/:.:/usr/java/jdk1.8.0_45/jre/lib/rt.jar:/usr/java/jdk1.8.0_45/lib/dt.jar:/usr/java/jdk1.8.0_45/lib/tools.jar:/usr/share/ant/lib/ant-launcher.jar
並如下設置這兩個環境變量:
export PIG_INSTALL=/usr/local/pig
export PIG_CLASSPATH=$HADOOP_INSTALL/etc/hadoop
文件IsUseragentBot.java的源代碼被列爲如下:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import org.apache.pig.FilterFunc;
import org.apache.pig.data.Tuple;
public class IsUseragentBot extends FilterFunc {
private Set<String> blacklist = null;
private void loadBlacklist() throws IOException {
blacklist = new HashSet<String>();
BufferedReader in = new BufferedReader(new FileReader("blacklist"));
String userAgent = null;
while ((userAgent = in.readLine()) != null) {
blacklist.add(userAgent);
}
}
@Override
public Boolean exec(Tuple tuple) throws IOException {
if (blacklist == null) {
loadBlacklist();
}
if (tuple == null || tuple.size() == 0) {
return null;
}
String ua = (String)tuple.get(0);
if (blacklist.contains(ua)) {
return true;
}
return false;
}
}
雖然我要通過執行javac IsUseragentBot來編譯源文件。 java,它總是失敗,並說「錯誤包org.apache.pig不存在」,請任何朋友幫助我,謝謝!