我是Hadoop的新手。我有三个独立的文件,分别包含map、reduce和mapreduce代码。mapper和reducer文件已编译,但主类throws在setmapperclass和setreducerclass方法中找不到符号错误。这是主要的代码:
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
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.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.Mapper;
public class MaxTemperature {
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("Usage: MaxTemperature <input path> <output path>");
System.exit(-1);
}
Job job = new Job();
job.setJarByClass(MaxTemperature.class);
job.setJobName("Max temperature");
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.setMapperClass(MaxTemperatureMapper.class); //error cannot find symbol
job.setReducerClass(MaxTemperatureReducer.class); //error cannot find symbol
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
}}
hadoop的使用版本是2.5.1,我使用编译它
hdfs com.sun.tools.javac.Main /usr/local/hadoop/share/hadoop/mapreduce/MaxTemperature.java
我使用了相同的命令来编译mapper和reducer程序。
您可以将这三个文件编译在一起,如下所示:
javac-cp hadoop-common-0.21.0.jar:hadoop-core-1.1.2.jar:commons-cli-1.3.1.jar:com.google.guava_1.6.0.jar:hadoop-mapred-0.21.0.jar FacebookCount.java FacebookMapper.java Facebook Reducer.java-d/usr/local/com/subu/