我在下面提到一个简单的mapR程序的驱动程序代码
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.JobClient;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
@SuppressWarnings("deprecation")
public class CsvParserDriver {
@SuppressWarnings("deprecation")
public static void main(String[] args) throws Exception
{
if(args.length != 2)
{
System.out.println("usage: [input] [output]");
System.exit(-1);
}
JobConf conf = new JobConf(CsvParserDriver.class);
Job job = new Job(conf);
conf.setJobName("CsvParserDriver");
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
conf.setMapperClass(CsvParserMapper.class);
conf.setMapOutputKeyClass(IntWritable.class);
conf.setMapOutputValueClass(Text.class);
conf.setReducerClass(CsvParserReducer.class);
conf.setOutputKeyClass(Text.class);
conf.setOutputValueClass(Text.class);
conf.set("splitNode","NUM_AE");
JobClient.runJob(conf);
}
}
我正在使用以下命令运行我的代码
hadoop jar CsvParser.jar CsvParserDriver /user/sritamd/TestData /user/sritamd/output
(上面命令中的所有相应的jar和目录都创建好了)
我得到错误
Exception in thread "main" org.apache.hadoop.mapred.InvalidJobConfException: Output directory not set in JobConf.