我是hadoop的新手。我正在使用Pig 0.14.0和hadoop 1.2.1。我已经在本地和map reduce模式下从grunt shell和pig batch脚本成功运行了Pig。现在,我试图从Java中的嵌入式Pig运行Pig。
当我在eclipse中编译代码时,出现以下错误:
import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
public class test {
public static void main(String[] args) {
try {
PigServer pigServer = new PigServer(ExecType.MAPREDUCE);
runQuery(pigServer);
}catch(Exception e) {
e.printStackTrace();
}
}
public static void runQuery(PigServer pigServer) {
try {
pigServer.registerQuery("input1 = LOAD '/mydata/wct.txt' as (line:chararray);");
pigServer.registerQuery("words = foreach input1 generate FLATTEN(TOKENIZE(line)) as word;");
pigServer.registerQuery("word_groups = group words by word;");
pigServer.registerQuery("word_count = foreach word_groups generate group, COUNT(words);");
pigServer.registerQuery("ordered_word_count = order word_count by group desc;");
pigServer.registerQuery("store ordered_word_count into '/mydata/wct';");
} catch(Exception e) {
e.printStackTrace();
}
}
}
请帮我。提前致谢。
最佳答案
请添加公共(public)依赖项:
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
关于java - 如何在Eclipse中使用Java运行嵌入式Pig程序?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29418989/