我收到错误
尝试调用对于Job
类型,未定义addCacheFile(URI)方法
addCacheFile(URI uri)
方法时,使用CDH4.0 ,如下所示:
import java.net.URI;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
public class DistributedCacheDriver {
public static void main(String[] args) throws Exception {
String inputPath = args[0];
String outputPath = args[1];
String fileName = args[2];
Configuration conf = new Configuration();
Job job = Job.getInstance(conf, "TestingDistributedCache");
job.setJarByClass(DistributedCache.class);
job.addCacheFile(new URI(fileName)); //Getting error here -The method addCacheFile(URI) is undefined for the type Job
boolean result = job.waitForCompletion(true);
System.exit(result ? 0 : 1);
}
}
有任何建议/提示要摆脱这个错误吗?
答案 0 :(得分:1)
如果您已选择安装MapReduce版本1,则应将job.addCacheFile()
命令替换为DistributeddCache.addCacheFile();
,并相应地更改setup()
方法(称之为configure()
)。
查找一些官方文档和示例here。