gpt4 book ai didi

java - 错误包 org.apache.pig.FilterFunc 不存在

转载 作者:可可西里 更新时间:2023-11-01 16:07:50 26 4
gpt4 key购买 nike

我可以问一个问题吗,我安装并配置了 Pig,但是当我尝试编译一个非常简单的 java 时它显示“error package org.apache.pig.FilterFunc not exist”使用 javac 命令获取源文件。

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不存在”,请哪位 friend 帮助我,非常感谢!

最佳答案

这个问题我已经解决了,除了pig的编译问题,还和pig和hadoop的兼容性有关

关于java - 错误包 org.apache.pig.FilterFunc 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34284186/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com